Steve Kirk
Microsoft Developer Network
August 1999
The Business Logic Layer (BLL) COM component used in this Phase 4 of the Duwamish Books sample application contains two code classes providing separate BLL implementations. One class (cBusLogic) provides features and a transaction model optimized for the Phase 4 Web application. The other class (cBusLogic_3) provides compatibility with legacy (Phase 3 and Phase 3.5) applications by implementing functionality that is equivalent to the Phase 3x BLL. This article documents the Phase 4 BLL API exposed by cBusLogic. For documentation of the Phase 3x BLL API, see "Duwamish Books Business Logic Layer API Reference." The cBusLogic_3 API may be accessed through migration components that are COM interface compatible with the legacy BLL components. This strategy for compatibility with legacy client applications is covered in my article "Migrating a Business Logic Component to a Web Application."
Retrieves into Authors Recordset the entire Authors domain or a single Author specified by PKId.
Public Function GetAuthors(Authors As ADODB.Recordset, _
Optional Byval PKId as Long)
The following columns are returned: PKId and AuthorName.
Boolean: Returns True if successful, False if not successful.
Retrieves into Categories Recordset the entire Categories domain, or a single Category specified by PKId.
Public Function GetCategories(Categories As ADODB.Recordset, _
Optional Byval PKId as Long)
The following columns are returned: PKId, ParentId, Description, and IsLeaf.
Boolean: Returns True if successful, False if not successful.
Retrieves into Customers Recordset the entire Customers domain or a single Customer specified by PKId, or by Alias. The Customers Recordset is expanded according to the value of ExpType.
Public Function GetCustomers(Customers As ADODB.Recordset, _
Optional ByVal PKId as Long, _
Optional ByVal Alias As String, _
Optional ByVal ExpType As EXPANSION_TYPE_4 = icPK_4)
Boolean: Returns True if successful, False if not successful.
Retrieves into Employees Recordset the entire Employees domain or a single Employee specified either by PKId or by Alias.
Public Function GetEmployees(Employees As ADODB.Recordset, _
Optional ByVal PKId as Long, _
Optional ByVal Alias As String)
The following columns are returned: PKId, Alias, EmployeeName, TaxAccount, Address, Country, PhoneNumber, Fax, CellPhone, EmergencyContact, EmergencyPhone, HireDate, Password, and Admin.
Boolean: Returns True if successful, False if not successful.
Retrieves into Inventories Recordset the entire Inventories domain or one of the following subsets:
Inventories are expanded according to the value of ExpType.
Public Function GetInventories(Inventories As ADODB.Recordset, _
Optional ByVal PKId as Long, _
Optional ByVal ItemId As Long, _
Optional ByVal StoreId As Long, _
Optional ByVal ExpType As EXPANSION_TYPE_4 = icPART_4)
Boolean: Returns True if successful, False if not successful.
Retrieves into ItemCategories Recordset the entire ItemCategories domain, or a single ItemCategory specified by PKId.
Public Function GetItemCategories(ItemCategories As ADODB.Recordset, _
Optional Byval PKId as Long)
The following columns are returned: PKId, CategoryId, and ItemId.
Boolean: Returns True if successful, False if not successful.
Retrieves into Items Recordset, in a format specified by ItemTemplateType, the entire Items domain, a single Item, or a subset of the Items domain.
Public Function GetItems(Items As ADODB.Recordset, _
Optional ByVal PKId as Long, _
Optional ByVal PKIdList As String, _
Optional ByVal ISBN As String, _
Optional ByVal Title As String, _
Optional ByVal AuthorId As String, _
Optional ByVal CategoryId As String, _
Optional ByVal AuthorKeywordList As String, _
Optional ByVal SubjectKeywordList As String, _
Optional ByVal TitleKeywordList As String, _
Optional ByVal NatLangIn As String, _
Optional NatLangOut As String, _
Optional ByVal ItemTemplateType As ITEM_TEMPLATE_TYPE_4 = icITEM_4), _
Optional ByVal TopId As Long, _
Optional ByVal MatchLevel As Long
Either of the following parameters specifies a single Item to retrieve:
Any of the following parameters, specify a subset of Items to retrieve.
The following parameters are used for natural-language search. These parameters return PKIds only. PKIds may be converted to PKIdList format to return columns specified with ItemTemplateType.
The following parameters control "chunking" of the returned subset. They may be used with subset specifying parameters as indicated above. Subset specifying parameters return Item records ordered by MatchLevel (descending count of number of matches for Item) and by PKId.
Boolean: Returns True if successful, False if not successful.
Retrieves into ItemTypes Recordset the entire ItemTypes domain or a single ItemType specified by PKId.
Public Function GetItemTypes(ItemTypes As ADODB.Recordset, _
Byval Optional PKId as Long)
The following columns are returned: PKId, Code, Description, and IsBook.
Boolean: Returns True if successful, False if not successful.
Retrieves Orders matching OrderTemplateType. From Orders matching OrderTemplateType, GetOrders will return all Orders, a single Order specified by PKId, all Orders for a store specified by StoreId, or all Orders for a customer specified by CustomerId.
Public Function GetOrders(Orders As ADODB.Recordset, _
OrderTemplateTypeAs ORDER_TEMPLATE_TYPE_4, _
Optional ByVal ExpType As EXPANSION_TYPE_4, _
Optional ByVal PKId as Long, _
Optioinal ByVal CustomerId As Long, _
Optional ByVal StoreId as Long)
Header fields: PKId, CustomerId, EmployeeId, OtherStoreId, StoreId, SupplierId, OrderType, OrderStatus, OrderDate, PickupDate, SubTotal, ShippingHandling, Tax, Total, ShipToName, ShipToAddress1, ShipToAddress2, ShipToCity, ShipToState, ShipToZipCode, ShipToPhone, and Details.
Detail fields: PKId, OrderId, ItemId, Qty_Ordered, Qty_Received, and Notes.
Header fields: PKId, CustomerId, EmployeeId, OtherStoreId, StoreId, SupplierId, OrderType, OrderStatus, OrderDate, PickupDate, SubTotal, ShippingHandling, Tax, Total, ShipToName, ShipToAddress1, ShipToAddress2, ShipToCity, ShipToState, ShipToZipCode, ShipToPhone, and Details.
Detail fields: PKId, OrderId, ItemId, UnitPrice, Quantity, Qty_Shipped, and Notes.
Header fields: PKId, EmployeeId, OtherStoreId, StoreId, SupplierId, OrderStatus, OrderDate, SubTotal, and Details.
Detail fields: PKId, OrderId, ItemId, Qty_Ordered, Qty_Received, Notes, Qty_This_Trans, and Note_This_Trans.
Header fields: PKId, CustomerId, EmployeeId, OtherStoreId, StoreId, SupplierId, OrderType, OrderStatus, OrderDate, PickupDate, SubTotal, ShippingHandling, Tax, Total, ShipToName, ShipToAddress1, ShipToAddress2, ShipToCity, ShipToState, ShipToZipCode, ShipToPhone, and Details.
Detail fields: PKId, OrderId, ItemId, UnitPrice, Qty_Ordered, Qty_Shipped, Notes, Qty_This_Trans, and Note_This_Trans.
Boolean: Returns True if successful, False if not successful.
Retrieves into OrderTypes domain into OrderTypes Recordset.
Public Function GetItemTypes(OrderTypes As ADODB.Recordset)
The following columns are returned: PKId and Code.
Boolean: Returns True if successful, False if not successful.
Retrieves into Publishers Recordset the entire Publishers domain or a single Publisher specified by PKId.
Public Function GetPublishers(Publishers As ADODB.Recordset, _
Optional ByVal PKId as Long)
The following columns are returned: PKId, Name, Address1, Address2, City, State, ZipCode, ContactPerson, and PhoneNumber.
Boolean: Returns True if successful, False if not successful.
Gets and updates data for session specified by PKId and Alias. Creates session and returns PKId if session matching PKId and Alias does not exist.
Public Function GetSession(PKId As Long, _
Alias As String, _
Session As String)
Boolean: Returns True if successful, False if not successful.
Retrieves into Settings Recordset Codes for the entire Settings domain or a single Setting specified by Description.
Public Function GetSettings(Settings As ADODB.Recordset, _
Optional ByVal Code as String)
Settings: An ADO Recordset to be filled with the appropriate data.
Boolean: Returns True if successful, False if not successful.
Retrieves into Stores Recordset the entire Stores domain or a single Store specified by PKId.
Public Function GetStores(Stores As ADODB.Recordset, _
Optional ByVal PKId as Long)
The following columns are returned: PKId, Code, Name, Address1, Address2, City, State, ZipCode, Phone, and Fax.
Boolean: Returns True if successful, False if not successful.
Retrieves into Suppliers Recordset the entire Suppliers domain or a single Supplier specified by PKId.
Public Function GetSuppliers(Suppliers As ADODB.Recordset, _
Optional ByVal PKId as Long)
The following columns are returned: PKId, Name, Address1, Address2, City, State, ZipCode, ContactPerson, and PhoneNumber.
Boolean: Returns True if successful, False if not successful.
Inserts an Author into database. Returns PKId of inserted Author if successful.
Public Function InsertAuthor(PKId As Long, ByVal AuthorName As String)
Boolean: Returns True if successful, False if not successful.
Inserts a Category into database. Returns PKId of inserted Category if successful.
Public Function InsertCategory(PKId As Long, _
ByVal Description As String, _
Optional ByVal ParentId As Long,)
Boolean: Returns True if successful, False if not successful.
Inserts a Customer into database. Returns PKId of inserted customer if successful.
Public Function InsertCustomer(PKId As Long, _
ByVal Alias As String, _
ByVal Password As String, _
ByVal CustomerName As String, _
ByVal Address As String, _
ByVal Country As String, _
ByVal PhoneNumber As String, _
ByVal Fax As String, _
ByVal Email As String)
Boolean: Returns True if successful, False if not successful.
Inserts an Employee into database. Returns PKId of inserted Employee if successful.
Public Function InsertEmployee(PKId As Long, _
ByVal Alias As String, _
ByVal Password As String, _
Optional ByVal EmployeeName As String, _
Optional ByVal TaxAccount As String, _
Optional ByVal Address As String, _
Optional ByVal Country As String, _
Optional ByVal PhoneNumber As String, _
Optional ByVal Fax As String, _
Optional ByVal CellPhone As String, _
Optional ByVal EmergencyContact As String, _
Optional ByVal HireDate As Date, _
Optional ByVal Admin As Boolean)
Boolean: Returns True if successful, False if not successful.
Inserts an Inventory into database for Item and Store. Returns PKId of inventory if successful.
Public Function InsertInventory(PKId As Long, _
ByVal ItemId As Long, _
ByVal StoreId As Long, _
ByVal InStock As Long, _
ByVal ReorderLevel As Long)
Boolean: Returns True if successful, False if not successful.
Inserts an Item into database. If insert is successful, returns PKId of inserted Item.
Public Function InsertItem(PKId As Long, _
ByVal ItemTypeId As Long, _
Optional ByVal PublisherId As Long, _
Optional ByVal SupplierId As Long, _
Optional ByVal PublicationYear As Long, _
Optional ByVal ISBN As String, _
Optional ByVal ImageFileSpec As String, _
Optaionl ByVal Title As String, _
Optional ByVal Description As String, _
Optional ByVal UnitCost As Currency, _
Optional ByVal UnitPrice As Currency, _
Optional ByVal AuthorList As String, _
Optional ByVal KeywordList As String) Ab Boolean
Boolean: Returns True if successful, False if not successful.
Inserts an ItemCategory into database for Item and Category.
Public Function InsertItemCategory(ByVal ItemId As Long, _
ByVal CategoryId As Long)
Boolean: Returns True if successful, False if not successful.
Inserts an ItemType into database. If insert is successful, returns PKId of ItemType.
Public Function InsertItemType(PKId As Long, _
ByVal Code As String, _
ByVal Description As String, _
ByVal IsBook As Boolean)
Boolean: Returns True if successful, False if not successful.
Inserts an Order into database and returns PKId of inserted order if successful.
Public Function InsertOrder(PKId As Long, _
Optional ByVal OrderType As ORDER_TYPE_4, _
Optional ByVal OrderStatus As ORDER_STATUS_4, _ Optinal ByVal CustomerId As Long, _
Optional ByVal EmployeeId As Long, _
Optional ByVal OtherStoreId As Long, _
Optional ByVal StoreId As Long, _
Optional ByVal SupplierId As Long, _
Optional ByVal OrderDate As Date, _
Optional ByVal PickupDate As Date, _
Optional ByVal SubTotal As Currency, _
Optional ByVal ShippingHandling As Currency, _
Optional ByVal ShipToName As String, _
Optional ByVal Address As String, _
Optional ByVal Country As String, _
Optional ByVal PhoneNumber As String, _
Optional ByVal Fax As String, _
Optional ByVal ItemIdList As String, _
Optional ByVal QuantityList As String, _
Optional ByVal PriceList As stirng) As Boolean
Boolean: Returns True if successful, False if not successful.
Inserts a Publisher into database. Returns PKId of inserted Publisher if successful.
Public Function InsertPublisher(PKId As Long, _
ByVal PublisherName As String, _
Optional ByVal Address As String, _
Optional ByVal Country As String, _
Optional ByVal PhoneNumber As String, _
Optional ByVal Fax As String, _
Optional ByVal ContactPerson As String)
Boolean: Returns True if successful, False if not successful.
Inserts a Sale into database and returns PKId of inserted Sale if successful.
Public Function InsertSale(PKId As Long, _
_ Optinal ByVal CustomerId As Long, _
Optional ByVal EmployeeId As Long, _
Optional ByVal StoreId As Long, _
Optional ByVal SaleDate As Date, _
Optional ByVal SubTotal As Currency, _
Optional ByVal Tax As Currency, _
Optional ByVal ShippingHandling As Currency, _
Optional ByVal ShipToName As String, _
Optional ByVal Address As String, _
Optional ByVal Country As String, _
Optional ByVal PhoneNumber As String, _
Optional ByVal Fax As String, _
Optional ByVal Ship As Boolean, _
Optional ByVal PaymentType As String, _
Optional ByVal CreditCardNumber As String, _
Optional ByVal ExpirationDate As String, _
Optional ByVal NameOnCard As String, _
Optional ByVal ItemIdList As String, _
Optional ByVal QuantityList As String, _
Optional ByVal PriceList As stirng) As Boolean
Boolean: Returns True if successful, False if not successful.
Inserts a Setting into database for supplied Code, Description, and Value. Code must be unique in Settings table.
Public Function InsertSetting (ByVal Code As String,
ByVal Description As String, _
ByVal Value As String)
Boolean: Returns True if successful, False if not successful.
Inserts a Store into database. Returns PKId of inserted Store if successful.
Public Function InsertStore(PKId As Long,
ByVal Code As String, _
ByVal StoreName As String, _
ByVal Address As String, _
ByVal Country As String, _
ByVal PhoneNumber As String, _
ByVal Fax As String)
Boolean: Returns True if successful, False if not successful.
Inserts a Supplier into database. Returns PKId of inserted Supplier if successful.
Public Function InsertSupplier (PKId As Long, _
ByVal SupplierName As String, _
ByVal Address As String, _
ByVal Country As String, _
ByVal PhoneNumber As String, _
ByVal Fax As String, _
ByVal ContactPerson As String)
Boolean: Returns True if successful, False if not successful.
Updates database for Author specified by PKId.
Public Function UpdateAuthor(ByVal As Long, _
ByVal AuthorName As String)
Boolean: Returns True if successful, False if not successful.
Updates database for Category specified by PKId.
Public Function UpdateCategory(ByVal PKId As Long, _
ByVal Description As String, _
ByVal ParentId As Long)
Boolean: Returns True if successful, False if not successful.
Updates database for Customer specified by PKId.
Public Function UpdateCustomer(PKId As Long, _
ByVal Alias As String, _
Optional ByVal Password As String, _
Optional ByVal CustomerName As String, _
Optional ByVal Address As String, _
Optional ByVal Country As String, _
Optional ByVal PhoneNumber As String, _
Optional ByVal Fax As String, _
Optional ByVal Email As String)
Boolean: Returns True if successful, False if not successful.
Updates database for Employee specified by PKId.
Public Function UpdateEmployee(PKId As Long, _
ByVal Alias As String, _
ByVal Password As String, _
ByVal EmployeeName As String, _
ByVal TaxAccount As String, _
ByVal Address As String, _
ByVal Country As String, _
ByVal PhoneNumber As String, _
ByVal Fax As String, _
ByVal CellPhone As String, _
ByVal EmergencyContacty As String, _
ByVal EmergencyPhone As String, _
ByVal HireDate As Date, _
ByVal Admin As Boolean) As Boolean
Boolean: Returns True if successful, False if not successful.
Updates database for Inventory specified by PKId.
Public Function UpdateInventory(ByVal PKId As Long, _
ByVal InventoryUpdateType As INVENTORY_UPDATE_TYPE_4, _
ByVal InStock As Long, _
ByVal ReorderLevel As Long)
Boolean: Returns True if successful, False if not successful.
Updates database for Item specified by PKId.
Public Function UpdateItem(ByVal PKId As Long, _
ItemTypeId As Long, _
Optional ByVal PublisherId As Long, _
Optional ByVal SupplierId As Long, _
Optional ByVal PublicationYear As Long, _
Optional ByVal ISBN As String, _
Optional ByVal ImageFileSpec As String, _
Optional ByVal Title As String, _
Optional ByVal Description As String, _
Optional ByVal UnitCost As Currency, _
Optional ByVal UnitPrice As Currency, _
Optional ByVal AuthorList As String, _
Optional ByVal KeywordList As String)
Boolean: Returns True if successful, False if not successful.
Updates database for ItemType specified by PKId.
Public Function UpdateItemType(ByVal PKId As Long, _
ByVal Code As String, _
ByVal Description As String, _
ByVal IsBook As Boolean)
Boolean: Returns True if successful, False if not successful.
Updates database according to UpdateType for current record in Order Recordset.
Public Function UpdateOrders(Byval OrderUpdateType As ORDER_UPDATE_TYPE_4,_
Optional Order As ADODB.Recordset, _
Optional ByVal PKId As Long, _
Optional ByVal StatusType As ORDER_STATUS_4, _
Optional ByVal ApprovalCode As String, _
Byval Optional EmployeeId As Long)
Boolean: Returns True if successful, False if not successful.
Updates database for Publisher specified by PKId.
Public Function UpdatePublisher(ByVal PKId As Long, _
ByVal PublisherName As String, _
Optional ByVal Address As String, _
Optional ByVal Country As String, _
Optional ByVal PhoneNumber As String, _
Optional ByVal Fax As String, _
Optional ByVal ContactPerson As String)
Boolean: Returns True if successful, False if not successful.
Updates database Setting record specified by Code.
Public Function UpdateSetting(ByVal Code As String, _
ByVal Description As String, _
ByVal Value As String)
Boolean: Returns True if successful, False if not successful.
Updates database for Store specified by PKId.
Public Function UpdateStore(ByVal PKId As Long, _
ByVal Code As String, _
ByVal StoreName As String, _
ByVal Address As String, _
ByVal Country As String, _
ByVal PhoneNumber As String, _
ByVal Fax As String)
Boolean: Returns True if successful, False if not successful.
Updates database for Supplier specified by PKId.
Public Function UpdateSupplier(ByVal PKId As Long, _
ByVal SupplierName As String, _
ByVal Address As String, _
ByVal Country As String, _
ByVal PhoneNumber As String, _
ByVal Fax As String, _
ByVal ContactPerson As String)
Boolean: Returns True if successful, False if not successful.
Comments? We welcome your feedback at duwamish@microsoft.com.