Professional Documents
Culture Documents
Appendix
Appendix
Appendix
Listing 1
/****** Object: Table [dbo].[Accounts] Script Date: 5/5/99 3:46:19 PM ******/
if exists (select * from sysobjects where id = object_id(N'[dbo].[Accounts]') and OBJECTPROPERTY(id, N'IsUserTable') =
1)
drop table [dbo].[Accounts]
GO
Listing 2
/****** Object: Table [dbo].[Inventory] Script Date: 5/5/99 3:46:20 PM ******/
if exists (select * from sysobjects where id = object_id(N'[dbo].[Inventory]') and OBJECTPROPERTY(id, N'IsUserTable') =
1)
drop table [dbo].[Inventory]
GO
Listing 3
/****** Object: Table [dbo].[PurchaseOrders] Script Date: 5/5/99 3:46:20 PM ******/
if exists (select * from sysobjects where id = object_id(N'[dbo].[PurchaseOrders]') and OBJECTPROPERTY(id,
N'IsUserTable') = 1)
drop table [dbo].[PurchaseOrders]
GO
Listing 4
/****** Object: Table [dbo].[LineItems] Script Date: 5/5/99 3:46:20 PM ******/
if exists (select * from sysobjects where id = object_id(N'[dbo].[LineItems]') and OBJECTPROPERTY(id, N'IsUserTable') =
1)
drop table [dbo].[LineItems]
GO
Listing 5
/****** Object: Table [dbo].[UniqueIDs] Script Date: 5/5/99 3:46:20 PM ******/
if exists (select * from sysobjects where id = object_id(N'[dbo].[UniqueIDs]') and OBJECTPROPERTY(id, N'IsUserTable')
= 1)
drop table [dbo].[UniqueIDs]
GO
Listing 6
' IAccount
Option Explicit
Public ID As Long
Public FirstName As String
Public LastName As String
Public AddressLine1 As String
Public AddressLine2 As String
Public City As String
Public State As String
Public Zip As String
Public Phone As String
Public Email As String
Public Balance As Currency
Public Limit As Currency
End Function
End Property
Listing 7
' IAccountExec
Option Explicit
End Function
Public Function Create(rIAccount As IAccount, Optional ByVal blnByVal As Boolean = True) As Boolean
End Function
End Function
Public Function Modify(rIAccount As IAccount, Optional ByVal blnByVal As Boolean = True) As Boolean
End Function
End Function
End Function
Listing 8
' IInventory
Option Explicit
Public ID As Long
Public Description As String
Public Price As Currency
Public QOH As Long
End Function
End Property
Listing 9
' IInventoryExec
Option Explicit
End Function
Public Function Create(rIInventory As IInventory, Optional ByVal blnByVal As Boolean = True) As Boolean
End Function
End Function
End Function
End Function
Public Function Modify(rIInventory As IInventory, Optional ByVal blnByVal As Boolean = True) As Boolean
End Function
Listing 10
' ILineItem
Option Explicit
Public ID As Long
Public PurchaseOrderID As Long
Public Item As IInventory
Public Price As Currency
Public Quantity As Long
End Function
End Property
Listing 11
' ILineItemExec
Option Explicit
End Function
Public Function Create(rILineItem As ILineItem, Optional ByVal blnByVal As Boolean = True) As Boolean
End Function
End Function
End Function
Public Function Modify(rILineItem As ILineItem, Optional ByVal blnByVal As Boolean = True) As Boolean
End Function
Listing 12
' ILineItems
Option Explicit
End Function
Public Property Get Count() As Long
End Property
End Function
End Function
Listing 13
' IPurchaseOrder
Option Explicit
Public ID As Long
Public AccountID As Long
Public OrderDate As Date
Public SubTotal As Currency
Public ShippingHandling As Currency
Public TaxRate As Double
Public Tax As Currency
Public Total As Currency
Public ShipToFirstName As String
Public ShipToLastName As String
Public ShipToAddressLine1 As String
Public ShipToAddressLine2 As String
Public ShipToCity As String
Public ShipToState As String
Public ShipToZip As String
Public ShipToPhone As String
Public ShipToEmail As String
End Property
End Function
End Property
Listing 14
' IPurchaseOrderExec
Option Explicit
End Function
Public Function Create(rIPurchaseOrder As IPurchaseOrder, Optional ByVal blnByVal As Boolean = True) As Boolean
End Function
End Function
Public Function Modify(rIPurchaseOrder As IPurchaseOrder, Optional ByVal blnByVal As Boolean = True) As Boolean
End Function
End Function
Listing 15
/****** Object: Stored Procedure dbo.sp_AllocBatchOfUniqueIDs_UniqueIDs Script Date: 5/5/99 3:46:20 PM ******/
if exists (select * from sysobjects where id = object_id(N'[dbo].[sp_AllocBatchOfUniqueIDs_UniqueIDs]') and
OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[sp_AllocBatchOfUniqueIDs_UniqueIDs]
GO
UPDATE [DNADesign].[dbo].[UniqueIDs]
SET [StartingIDofCurrentBatch] = [StartingIDofCurrentBatch] + 100
RETURN (SELECT [StartingIDofCurrentBatch] FROM [DNADesign].[dbo].[UniqueIDs])
GO
Listing 16
/****** Object: Stored Procedure dbo.sp_decrementBalance_Accounts Script Date: 5/5/99 3:46:20 PM ******/
if exists (select * from sysobjects where id = object_id(N'[dbo].[sp_decrementBalance_Accounts]') and
OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[sp_decrementBalance_Accounts]
GO
GO
Listing 17
/****** Object: Stored Procedure dbo.sp_decrementQOH_Inventory Script Date: 5/5/99 3:46:20 PM ******/
if exists (select * from sysobjects where id = object_id(N'[dbo].[sp_decrementQOH_Inventory]') and
OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[sp_decrementQOH_Inventory]
GO
GO
Listing 18
/****** Object: Stored Procedure dbo.sp_delete_Accounts Script Date: 5/5/99 3:46:20 PM ******/
if exists (select * from sysobjects where id = object_id(N'[dbo].[sp_delete_Accounts]') and OBJECTPROPERTY(id,
N'IsProcedure') = 1)
drop procedure [dbo].[sp_delete_Accounts]
GO
WHERE
( [IDPK] = @IDPK)
GO
Listing 19
/****** Object: Stored Procedure dbo.sp_delete_Inventory Script Date: 5/5/99 3:46:20 PM ******/
if exists (select * from sysobjects where id = object_id(N'[dbo].[sp_delete_Inventory]') and OBJECTPROPERTY(id,
N'IsProcedure') = 1)
drop procedure [dbo].[sp_delete_Inventory]
GO
AS DELETE [DNADesign].[dbo].[Inventory]
WHERE
( [IDPK] = @IDPK)
GO
Listing 20
/****** Object: Stored Procedure dbo.sp_delete_LineItems Script Date: 5/5/99 3:46:21 PM ******/
if exists (select * from sysobjects where id = object_id(N'[dbo].[sp_delete_LineItems]') and OBJECTPROPERTY(id,
N'IsProcedure') = 1)
drop procedure [dbo].[sp_delete_LineItems]
GO
AS DELETE [DNADesign].[dbo].[LineItems]
WHERE
( [IDPK] = @IDPK)
GO
Listing 21
/****** Object: Stored Procedure dbo.sp_deleteByPurchaseOrder_LineItems Script Date: 5/5/99 3:46:21 PM ******/
if exists (select * from sysobjects where id = object_id(N'[dbo].[sp_deleteByPurchaseOrder_LineItems]') and
OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[sp_deleteByPurchaseOrder_LineItems]
GO
AS
DELETE [DNADesign].[dbo].[LineItems] WHERE ([PurchaseOrderIDFK] = @PurchaseOrderIDFK)
GO
Listing 22
/****** Object: Stored Procedure dbo.sp_delete_PurchaseOrders Script Date: 5/5/99 3:46:21 PM ******/
if exists (select * from sysobjects where id = object_id(N'[dbo].[sp_delete_PurchaseOrders]') and OBJECTPROPERTY(id,
N'IsProcedure') = 1)
drop procedure [dbo].[sp_delete_PurchaseOrders]
GO
Listing 23
/****** Object: Stored Procedure dbo.sp_incrementBalance_Accounts Script Date: 5/5/99 3:46:20 PM ******/
if exists (select * from sysobjects where id = object_id(N'[dbo].[sp_incrementBalance_Accounts]') and
OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[sp_incrementBalance_Accounts]
GO
GO
Listing 24
/****** Object: Stored Procedure dbo.sp_incrementQOH_Inventory Script Date: 5/5/99 3:46:20 PM ******/
if exists (select * from sysobjects where id = object_id(N'[dbo].[sp_incrementQOH_Inventory]') and
OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[sp_incrementQOH_Inventory]
GO
GO
Listing 25
/****** Object: Stored Procedure dbo.sp_insert_Accounts Script Date: 5/5/99 3:46:20 PM ******/
if exists (select * from sysobjects where id = object_id(N'[dbo].[sp_insert_Accounts]') and OBJECTPROPERTY(id,
N'IsProcedure') = 1)
drop procedure [dbo].[sp_insert_Accounts]
GO
VALUES
( @IDPK,
@FirstName,
@LastName,
@AddressLine1,
@AddressLine2,
@City,
@State,
@Zip,
@Phone,
@Email,
@Balance,
@Limit)
GO
Listing 26
/****** Object: Stored Procedure dbo.sp_insert_Inventory Script Date: 5/5/99 3:46:20 PM ******/
if exists (select * from sysobjects where id = object_id(N'[dbo].[sp_insert_Inventory]') and OBJECTPROPERTY(id,
N'IsProcedure') = 1)
drop procedure [dbo].[sp_insert_Inventory]
GO
VALUES
( @IDPK,
@Description,
@Price,
@QOH)
GO
Listing 27
/****** Object: Stored Procedure dbo.sp_insert_LineItems Script Date: 5/5/99 3:46:21 PM ******/
if exists (select * from sysobjects where id = object_id(N'[dbo].[sp_insert_LineItems]') and OBJECTPROPERTY(id,
N'IsProcedure') = 1)
drop procedure [dbo].[sp_insert_LineItems]
GO
VALUES
( @IDPK,
@PurchaseOrderIDFK,
@InventoryIDFK,
@Price,
@Quantity)
GO
Listing 28
/****** Object: Stored Procedure dbo.sp_insert_PurchaseOrders Script Date: 5/5/99 3:46:20 PM ******/
if exists (select * from sysobjects where id = object_id(N'[dbo].[sp_insert_PurchaseOrders]') and OBJECTPROPERTY(id,
N'IsProcedure') = 1)
drop procedure [dbo].[sp_insert_PurchaseOrders]
GO
VALUES
( @IDPK,
@AccountIDFK,
@ShippingHandling,
@TaxRate,
@Total,
@ShipToFirstName,
@ShipToLastName,
@ShipToAddressLine1,
@ShipToAddressLine2,
@ShipToCity,
@ShipToState,
@ShipToZip,
@ShipToPhone,
@ShipToEmail)
GO
Listing 29
/****** Object: Stored Procedure dbo.sp_update_Accounts Script Date: 5/5/99 3:46:20 PM ******/
if exists (select * from sysobjects where id = object_id(N'[dbo].[sp_update_Accounts]') and OBJECTPROPERTY(id,
N'IsProcedure') = 1)
drop procedure [dbo].[sp_update_Accounts]
GO
AS UPDATE [DNADesign].[dbo].[Accounts]
WHERE
( [IDPK] = @IDPK)
GO
Listing 30
/****** Object: Stored Procedure dbo.sp_update_Inventory Script Date: 5/5/99 3:46:20 PM ******/
if exists (select * from sysobjects where id = object_id(N'[dbo].[sp_update_Inventory]') and OBJECTPROPERTY(id,
N'IsProcedure') = 1)
drop procedure [dbo].[sp_update_Inventory]
GO
AS UPDATE [DNADesign].[dbo].[Inventory]
WHERE
( [IDPK] = @IDPK)
GO
Listing 31
/****** Object: Stored Procedure dbo.sp_update_LineItems Script Date: 5/5/99 3:46:21 PM ******/
if exists (select * from sysobjects where id = object_id(N'[dbo].[sp_update_LineItems]') and OBJECTPROPERTY(id,
N'IsProcedure') = 1)
drop procedure [dbo].[sp_update_LineItems]
GO
AS UPDATE [DNADesign].[dbo].[LineItems]
WHERE
( [IDPK] = @IDPK)
GO
Listing 32
/****** Object: Stored Procedure dbo.sp_update_PurchaseOrders Script Date: 5/5/99 3:46:21 PM ******/
if exists (select * from sysobjects where id = object_id(N'[dbo].[sp_update_PurchaseOrders]') and
OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[sp_update_PurchaseOrders]
GO
AS UPDATE [DNADesign].[dbo].[PurchaseOrders]
WHERE
( [IDPK] = @IDPK)
GO
Listing 33
' AccountExec
Option Explicit
Implements IAccountExec
If blnByVal Then
' Create a local copy of the object
objPropertyBag.Contents = rIAccount.MarshalToPropertyBag(strKey)
Set rIAccountLocal = objPropertyBag.ReadProperty(strKey, Nothing)
Else
' Use the object ByRef
Set rIAccountLocal = rIAccount
End If
' Make sure that the information is valid
If Not rIAccountLocal.Valid Then GoTo ErrorHandler
objCommand.ActiveConnection = gstrCONNECT
objCommand.CommandText = "sp_insert_Accounts"
objCommand.CommandType = adCmdStoredProc
' Create each parameter and supply it's data
objCommand.Parameters.Append _
objCommand.CreateParameter("IDPK", adInteger, _
adParamInput, , rIAccountLocal.ID)
objCommand.Parameters.Append _
objCommand.CreateParameter("FirstName", adVarChar, _
adParamInput, 20, rIAccountLocal.FirstName)
objCommand.Parameters.Append _
objCommand.CreateParameter("LastName", adVarChar, _
adParamInput, 40, rIAccountLocal.LastName)
objCommand.Parameters.Append _
objCommand.CreateParameter("AddressLine1", adVarChar, _
adParamInput, 20, rIAccountLocal.AddressLine1)
objCommand.Parameters.Append _
objCommand.CreateParameter("AddressLine2", adVarChar, _
adParamInput, 20, rIAccountLocal.AddressLine2)
objCommand.Parameters.Append _
objCommand.CreateParameter("City", adVarChar, _
adParamInput, 20, rIAccountLocal.City)
objCommand.Parameters.Append _
objCommand.CreateParameter("State", adVarChar, _
adParamInput, 2, rIAccountLocal.State)
objCommand.Parameters.Append _
objCommand.CreateParameter("Zip", adVarChar, _
adParamInput, 5, rIAccountLocal.Zip)
objCommand.Parameters.Append _
objCommand.CreateParameter("Phone", adVarChar, _
adParamInput, 12, rIAccountLocal.Phone)
objCommand.Parameters.Append _
objCommand.CreateParameter("Email", adVarChar, _
adParamInput, 20, rIAccountLocal.Email)
objCommand.Parameters.Append _
objCommand.CreateParameter("Balance", adCurrency, _
adParamInput, , rIAccountLocal.Balance)
objCommand.Parameters.Append _
objCommand.CreateParameter("Limit", adCurrency, _
adParamInput, , rIAccountLocal.Limit)
' Execute the call
objCommand.Execute lngRecordsAffected
objCommand.ActiveConnection = gstrCONNECT
objCommand.CommandText = "sp_decrementBalance_Accounts"
objCommand.CommandType = adCmdStoredProc
' Create each parameter and supply it's data
objCommand.Parameters.Append _
objCommand.CreateParameter("IDPK", adInteger, _
adParamInput, , lngAccountID)
objCommand.Parameters.Append _
objCommand.CreateParameter("Amount", adCurrency, _
adParamInput, , curAmount)
objCommand.Parameters.Append _
objCommand.CreateParameter("Balance", adCurrency, _
adParamOutput)
objCommand.Parameters.Append _
objCommand.CreateParameter("Limit", adCurrency, _
adParamOutput)
' Execute the call
objCommand.Execute lngRecordsAffected
' Get the Account Balance
curBalance = objCommand.Parameters(2)
' Get the Account Limit
curLimit = objCommand.Parameters(3)
objCommand.ActiveConnection = gstrCONNECT
objCommand.CommandText = "sp_delete_Accounts"
objCommand.CommandType = adCmdStoredProc
' Create each parameter and supply it's data
objCommand.Parameters.Append _
objCommand.CreateParameter("IDPK", adInteger, _
adParamInput, , lngAccountID)
' Execute the call
objCommand.Execute lngRecordsAffected
objCommand.ActiveConnection = gstrCONNECT
objCommand.CommandText = "sp_incrementBalance_Accounts"
objCommand.CommandType = adCmdStoredProc
' Create each parameter and supply it's data
objCommand.Parameters.Append _
objCommand.CreateParameter("IDPK", adInteger, _
adParamInput, , lngAccountID)
objCommand.Parameters.Append _
objCommand.CreateParameter("Amount", adCurrency, _
adParamInput, , curAmount)
objCommand.Parameters.Append _
objCommand.CreateParameter("Balance", adCurrency, _
adParamOutput)
objCommand.Parameters.Append _
objCommand.CreateParameter("Limit", adCurrency, _
adParamOutput)
' Execute the call
objCommand.Execute lngRecordsAffected
' Get the Account Balance
curBalance = objCommand.Parameters(2)
' Get the Account Limit
curLimit = objCommand.Parameters(3)
If blnByVal Then
' Create a local copy of the object
objPropertyBag.Contents = rIAccount.MarshalToPropertyBag(strKey)
Set rIAccountLocal = objPropertyBag.ReadProperty(strKey, Nothing)
Else
' Use the object ByRef
Set rIAccountLocal = rIAccount
End If
' Make sure that the information is valid
If Not rIAccountLocal.Valid Then GoTo ErrorHandler
objCommand.ActiveConnection = gstrCONNECT
objCommand.CommandText = "sp_update_Accounts"
objCommand.CommandType = adCmdStoredProc
' Create each parameter and supply it's data
objCommand.Parameters.Append _
objCommand.CreateParameter("IDPK", adInteger, _
adParamInput, , rIAccount.ID)
objCommand.Parameters.Append _
objCommand.CreateParameter("FirstName", adVarChar, _
adParamInput, 20, rIAccountLocal.FirstName)
objCommand.Parameters.Append _
objCommand.CreateParameter("LastName", adVarChar, _
adParamInput, 40, rIAccountLocal.LastName)
objCommand.Parameters.Append _
objCommand.CreateParameter("AddressLine1", adVarChar, _
adParamInput, 20, rIAccountLocal.AddressLine1)
objCommand.Parameters.Append _
objCommand.CreateParameter("AddressLine2", adVarChar, _
adParamInput, 20, rIAccountLocal.AddressLine2)
objCommand.Parameters.Append _
objCommand.CreateParameter("City", adVarChar, _
adParamInput, 20, rIAccountLocal.City)
objCommand.Parameters.Append _
objCommand.CreateParameter("State", adVarChar, _
adParamInput, 2, rIAccountLocal.State)
objCommand.Parameters.Append _
objCommand.CreateParameter("Zip", adVarChar, _
adParamInput, 5, rIAccountLocal.Zip)
objCommand.Parameters.Append _
objCommand.CreateParameter("Phone", adVarChar, _
adParamInput, 12, rIAccountLocal.Phone)
objCommand.Parameters.Append _
objCommand.CreateParameter("Email", adVarChar, _
adParamInput, 20, rIAccountLocal.Email)
objCommand.Parameters.Append _
objCommand.CreateParameter("Balance", adCurrency, _
adParamInput, , rIAccountLocal.Balance)
objCommand.Parameters.Append _
objCommand.CreateParameter("Limit", adCurrency, _
adParamInput, , rIAccountLocal.Limit)
' Execute the call
objCommand.Execute lngRecordsAffected
Listing 34
' InventoryExec
Option Explicit
Implements IInventoryExec
If blnByVal Then
' Create a local copy of the object
objPropertyBag.Contents = rIInventory.MarshalToPropertyBag(strKey)
Set rIInventoryLocal = objPropertyBag.ReadProperty(strKey, Nothing)
Else
' Use the object ByRef
Set rIInventoryLocal = rIInventory
End If
' Make sure that the information is valid
If Not rIInventoryLocal.Valid Then GoTo ErrorHandler
objCommand.ActiveConnection = gstrCONNECT
objCommand.CommandText = "sp_insert_Inventory"
objCommand.CommandType = adCmdStoredProc
' Create each parameter and supply it's data
objCommand.Parameters.Append _
objCommand.CreateParameter("IDPK", adInteger, _
adParamInput, , rIInventoryLocal.ID)
objCommand.Parameters.Append _
objCommand.CreateParameter("Description", adVarChar, _
adParamInput, 50, rIInventoryLocal.Description)
objCommand.Parameters.Append _
objCommand.CreateParameter("Price", adCurrency, _
adParamInput, , rIInventoryLocal.Price)
objCommand.Parameters.Append _
objCommand.CreateParameter("QOH", adInteger, _
adParamInput, , rIInventoryLocal.QOH)
' Execute the call
objCommand.Execute lngRecordsAffected
objCommand.ActiveConnection = gstrCONNECT
objCommand.CommandText = "sp_decrementQOH_Inventory"
objCommand.CommandType = adCmdStoredProc
' Create each parameter and supply it's data
objCommand.Parameters.Append _
objCommand.CreateParameter("Return", adInteger, _
adParamReturnValue)
objCommand.Parameters.Append _
objCommand.CreateParameter("IDPK", adInteger, _
adParamInput, , lngInventoryID)
objCommand.Parameters.Append _
objCommand.CreateParameter("Quantity", adInteger, _
adParamInput, , lngQuantity)
' Execute the call
objCommand.Execute lngRecordsAffected
' Get the return value
lngQOH = objCommand(0)
objCommand.ActiveConnection = gstrCONNECT
objCommand.CommandText = "sp_delete_Inventory"
objCommand.CommandType = adCmdStoredProc
' Create each parameter and supply it's data
objCommand.Parameters.Append _
objCommand.CreateParameter("IDPK", adInteger, _
adParamInput, , lngInventoryID)
' Execute the call
objCommand.Execute lngRecordsAffected
objCommand.ActiveConnection = gstrCONNECT
objCommand.CommandText = "sp_incrementQOH_Inventory"
objCommand.CommandType = adCmdStoredProc
' Create each parameter and supply it's data
objCommand.Parameters.Append _
objCommand.CreateParameter("Return", adInteger, _
adParamReturnValue)
objCommand.Parameters.Append _
objCommand.CreateParameter("IDPK", adInteger, _
adParamInput, , lngInventoryID)
objCommand.Parameters.Append _
objCommand.CreateParameter("Quantity", adInteger, _
adParamInput, , lngQuantity)
' Execute the call
objCommand.Execute lngRecordsAffected
' Get the return value
lngQOH = objCommand(0)
If blnByVal Then
' Create a local copy of the object
objPropertyBag.Contents = rIInventory.MarshalToPropertyBag(strKey)
Set rIInventoryLocal = objPropertyBag.ReadProperty(strKey, Nothing)
Else
' Use the object ByRef
Set rIInventoryLocal = rIInventory
End If
' Make sure that the information is valid
If Not rIInventoryLocal.Valid Then GoTo ErrorHandler
objCommand.ActiveConnection = gstrCONNECT
objCommand.CommandText = "sp_update_Inventory"
objCommand.CommandType = adCmdStoredProc
' Create each parameter and supply it's data
objCommand.Parameters.Append _
objCommand.CreateParameter("IDPK", adInteger, _
adParamInput, , rIInventoryLocal.ID)
objCommand.Parameters.Append _
objCommand.CreateParameter("Description", adVarChar, _
adParamInput, 50, rIInventoryLocal.Description)
objCommand.Parameters.Append _
objCommand.CreateParameter("Price", adCurrency, _
adParamInput, , rIInventoryLocal.Price)
objCommand.Parameters.Append _
objCommand.CreateParameter("QOH", adInteger, _
adParamInput, , rIInventoryLocal.QOH)
' Execute the call
objCommand.Execute lngRecordsAffected
Listing 35
' LineItemExec
Option Explicit
Implements ILineItemExec
If blnByVal Then
' Create a local copy of the object
objPropertyBag.Contents = rILineItem.MarshalToPropertyBag(strKey)
Set rILineItemLocal = objPropertyBag.ReadProperty(strKey, Nothing)
Else
' Use the object ByRef
Set rILineItemLocal = rILineItem
End If
' Make sure that the information is valid
If Not rILineItemLocal.Valid Then GoTo ErrorHandler
objCommand.ActiveConnection = gstrCONNECT
objCommand.CommandText = "sp_insert_LineItems"
objCommand.CommandType = adCmdStoredProc
' Create each parameter and supply it's data
objCommand.Parameters.Append _
objCommand.CreateParameter("IDPK", adInteger, _
adParamInput, , rILineItemLocal.ID)
objCommand.Parameters.Append _
objCommand.CreateParameter("PurchaseOrderIDFK", adInteger, _
adParamInput, , rILineItemLocal.PurchaseOrderID)
objCommand.Parameters.Append _
objCommand.CreateParameter("InventoryIDFK", adInteger, _
adParamInput, , rILineItemLocal.Item.ID)
objCommand.Parameters.Append _
objCommand.CreateParameter("Price", adCurrency, _
adParamInput, , rILineItemLocal.Price)
objCommand.Parameters.Append _
objCommand.CreateParameter("Quantity", adInteger, _
adParamInput, , rILineItemLocal.Quantity)
' Execute the call
objCommand.Execute lngRecordsAffected
objCommand.ActiveConnection = gstrCONNECT
objCommand.CommandText = "sp_delete_LineItems"
objCommand.CommandType = adCmdStoredProc
' Create each parameter and supply it's data
objCommand.Parameters.Append _
objCommand.CreateParameter("IDPK", adInteger, _
adParamInput, , lngLineItemID)
' Execute the call
objCommand.Execute lngRecordsAffected
objCommand.ActiveConnection = gstrCONNECT
objCommand.CommandText = "sp_deleteByPurchaseOrder_LineItems"
objCommand.CommandType = adCmdStoredProc
' Create each parameter and supply it's data
objCommand.Parameters.Append _
objCommand.CreateParameter("PurchaseOrderIDFK", adInteger, _
adParamInput, , lngPurchaseOrderID)
' Execute the call
objCommand.Execute lngRecordsAffected
If blnByVal Then
' Create a local copy of the object
objPropertyBag.Contents = rILineItem.MarshalToPropertyBag(strKey)
Set rILineItemLocal = objPropertyBag.ReadProperty(strKey, Nothing)
Else
' Use the object ByRef
Set rILineItemLocal = rILineItem
End If
' Make sure that the information is valid
If Not rILineItemLocal.Valid Then GoTo ErrorHandler
objCommand.ActiveConnection = gstrCONNECT
objCommand.CommandText = "sp_insert_LineItems"
objCommand.CommandType = adCmdStoredProc
' Create each parameter and supply it's data
objCommand.Parameters.Append _
objCommand.CreateParameter("IDPK", adInteger, _
adParamInput, , rILineItemLocal.ID)
objCommand.Parameters.Append _
objCommand.CreateParameter("PurchaseOrderIDFK", adInteger, _
adParamInput, , rILineItemLocal.PurchaseOrderID)
objCommand.Parameters.Append _
objCommand.CreateParameter("InventoryIDFK", adInteger, _
adParamInput, , rILineItemLocal.Item.ID)
objCommand.Parameters.Append _
objCommand.CreateParameter("Price", adCurrency, _
adParamInput, , rILineItemLocal.Price)
objCommand.Parameters.Append _
objCommand.CreateParameter("Quantity", adInteger, _
adParamInput, , rILineItemLocal.Quantity)
' Execute the call
objCommand.Execute lngRecordsAffected
Listing 36
' PurchaseOrderExec
Option Explicit
Implements IPurchaseOrderExec
GetObjectContext.SetComplete
IPurchaseOrderExec_Cancel = True
CleanUp:
Set rIAccountExec = Nothing
Set rIInventoryExec = Nothing
Set objRecordset = Nothing
Set objConnection = Nothing
Exit Function
ErrorHandler:
GetObjectContext.SetAbort
GoTo CleanUp
End Function
If blnByVal Then
' Create a local copy of the object
objPropertyBag.Contents = rIPurchaseOrder.MarshalToPropertyBag(strKey)
Set rIPurchaseOrderLocal = objPropertyBag.ReadProperty(strKey, Nothing)
Else
' Use the object ByRef
Set rIPurchaseOrderLocal = rIPurchaseOrder
End If
' Make sure that the information is valid
If Not rIPurchaseOrderLocal.Valid Then GoTo ErrorHandler
objCommand.ActiveConnection = gstrCONNECT
objCommand.CommandText = "sp_insert_PurchaseOrders"
objCommand.CommandType = adCmdStoredProc
' Create each parameter and supply it's data
objCommand.Parameters.Append _
objCommand.CreateParameter("IDPK", adInteger, _
adParamInput, , rIPurchaseOrderLocal.ID)
objCommand.Parameters.Append _
objCommand.CreateParameter("AccountIDFK", adInteger, _
adParamInput, , rIPurchaseOrderLocal.AccountID)
objCommand.Parameters.Append _
objCommand.CreateParameter("ShippingHandling", adCurrency, _
adParamInput, , rIPurchaseOrderLocal.ShippingHandling)
objCommand.Parameters.Append _
objCommand.CreateParameter("TaxRate", adDouble, _
adParamInput, , rIPurchaseOrderLocal.TaxRate)
objCommand.Parameters.Append _
objCommand.CreateParameter("Total", adCurrency, _
adParamInput, , rIPurchaseOrderLocal.Total)
objCommand.Parameters.Append _
objCommand.CreateParameter("ShipToFirstName", adVarChar, _
adParamInput, 20, rIPurchaseOrderLocal.ShipToFirstName)
objCommand.Parameters.Append _
objCommand.CreateParameter("ShipToLastName", adVarChar, _
adParamInput, 40, rIPurchaseOrderLocal.ShipToLastName)
objCommand.Parameters.Append _
objCommand.CreateParameter("ShipToAddressLine1", adVarChar, _
adParamInput, 20, rIPurchaseOrderLocal.ShipToAddressLine1)
objCommand.Parameters.Append _
objCommand.CreateParameter("ShipToAddressLine2", adVarChar, _
adParamInput, 20, rIPurchaseOrderLocal.ShipToAddressLine2)
objCommand.Parameters.Append _
objCommand.CreateParameter("ShipToCity", adVarChar, _
adParamInput, 20, rIPurchaseOrderLocal.ShipToCity)
objCommand.Parameters.Append _
objCommand.CreateParameter("ShipToState", adVarChar, _
adParamInput, 2, rIPurchaseOrderLocal.ShipToState)
objCommand.Parameters.Append _
objCommand.CreateParameter("ShipToZip", adVarChar, _
adParamInput, 5, rIPurchaseOrderLocal.ShipToZip)
objCommand.Parameters.Append _
objCommand.CreateParameter("ShipToPhone", adVarChar, _
adParamInput, 12, rIPurchaseOrderLocal.ShipToPhone)
objCommand.Parameters.Append _
objCommand.CreateParameter("ShipToEmail", adVarChar, _
adParamInput, 20, rIPurchaseOrderLocal.ShipToEmail)
' Execute the call
objCommand.Execute lngRecordsAffected
objCommand.ActiveConnection = gstrCONNECT
objCommand.CommandText = "sp_delete_PurchaseOrders"
objCommand.CommandType = adCmdStoredProc
' Create each parameter and supply it's data
objCommand.Parameters.Append _
objCommand.CreateParameter("IDPK", adInteger, _
adParamInput, , lngPurchaseOrderID)
' Execute the call
objCommand.Execute lngRecordsAffected
If blnByVal Then
' Create a local copy of the object
objPropertyBag.Contents = rIPurchaseOrder.MarshalToPropertyBag(strKey)
Set rIPurchaseOrderLocal = objPropertyBag.ReadProperty(strKey, Nothing)
Else
' Use the object ByRef
Set rIPurchaseOrderLocal = rIPurchaseOrder
End If
' Make sure that the information is valid
If Not rIPurchaseOrderLocal.Valid Then GoTo ErrorHandler
objCommand.ActiveConnection = gstrCONNECT
objCommand.CommandText = "sp_insert_PurchaseOrders"
objCommand.CommandType = adCmdStoredProc
' Create each parameter and supply it's data
objCommand.Parameters.Append _
objCommand.CreateParameter("IDPK", adInteger, _
adParamInput, , rIPurchaseOrderLocal.ID)
objCommand.Parameters.Append _
objCommand.CreateParameter("AccountIDFK", adInteger, _
adParamInput, , rIPurchaseOrderLocal.AccountID)
objCommand.Parameters.Append _
objCommand.CreateParameter("ShippingHandling", adCurrency, _
adParamInput, , rIPurchaseOrderLocal.ShippingHandling)
objCommand.Parameters.Append _
objCommand.CreateParameter("TaxRate", adDouble, _
adParamInput, , rIPurchaseOrderLocal.TaxRate)
objCommand.Parameters.Append _
objCommand.CreateParameter("Total", adCurrency, _
adParamInput, , rIPurchaseOrderLocal.Total)
objCommand.Parameters.Append _
objCommand.CreateParameter("ShipToFirstName", adVarChar, _
adParamInput, 20, rIPurchaseOrderLocal.ShipToFirstName)
objCommand.Parameters.Append _
objCommand.CreateParameter("ShipToLastName", adVarChar, _
adParamInput, 40, rIPurchaseOrderLocal.ShipToLastName)
objCommand.Parameters.Append _
objCommand.CreateParameter("ShipToAddressLine1", adVarChar, _
adParamInput, 20, rIPurchaseOrderLocal.ShipToAddressLine1)
objCommand.Parameters.Append _
objCommand.CreateParameter("ShipToAddressLine2", adVarChar, _
adParamInput, 20, rIPurchaseOrderLocal.ShipToAddressLine2)
objCommand.Parameters.Append _
objCommand.CreateParameter("ShipToCity", adVarChar, _
adParamInput, 20, rIPurchaseOrderLocal.ShipToCity)
objCommand.Parameters.Append _
objCommand.CreateParameter("ShipToState", adVarChar, _
adParamInput, 2, rIPurchaseOrderLocal.ShipToState)
objCommand.Parameters.Append _
objCommand.CreateParameter("ShipToZip", adVarChar, _
adParamInput, 5, rIPurchaseOrderLocal.ShipToZip)
objCommand.Parameters.Append _
objCommand.CreateParameter("ShipToPhone", adVarChar, _
adParamInput, 12, rIPurchaseOrderLocal.ShipToPhone)
objCommand.Parameters.Append _
objCommand.CreateParameter("ShipToEmail", adVarChar, _
adParamInput, 20, rIPurchaseOrderLocal.ShipToEmail)
' Execute the call
objCommand.Execute lngRecordsAffected
If lngRecordsAffected > 0 Then
Set rILineItemExec = GetObjectContext.CreateInstance("POExecutants.LineItemExec")
Set rIInventoryExec = GetObjectContext.CreateInstance("POExecutants.InventoryExec")
Set rIAccountExec = GetObjectContext.CreateInstance("POExecutants.AccountExec")
' Save the related LineItems
For lngLineItem = 1 To rIPurchaseOrderLocal.LineItems.Count
Set rILineItem = rIPurchaseOrderLocal.LineItems.Item(lngLineItem)
If Not rILineItem Is Nothing Then
rILineItem.PurchaseOrderID = rIPurchaseOrderLocal.ID
' Pass each LineItem ByRef since both
' components are in the same package
If rILineItemExec.Create(rILineItem, False) Then
' Decrement the QOH for each Inventory item
If Not rIInventoryExec.DecrementQOH(rILineItem.Item.ID, rILineItem.Quantity) Then
GoTo ErrorHandler
End If
Else
GoTo ErrorHandler
End If
End If
Next lngLineItem
' Increment the Account balance
If Not rIAccountExec.IncrementBalance(rIPurchaseOrderLocal.AccountID, rIPurchaseOrderLocal.Total) Then
GoTo ErrorHandler
End If
Else
GoTo ErrorHandler
End If
'
GetObjectContext.SetComplete
IPurchaseOrderExec_Modify = True
CleanUp:
Set rILineItem = Nothing
Set rIAccountExec = Nothing
Set rIInventoryExec = Nothing
Set rILineItemExec = Nothing
Set rIPurchaseOrderLocal = Nothing
Set objPropertyBag = Nothing
Set objCommand = Nothing
Exit Function
ErrorHandler:
GetObjectContext.SetAbort
GoTo CleanUp
End Function
Listing 37
Public Function Create(vntAccount As Variant, Optional ByVal blnByVal As Boolean = True) As Boolean
Dim rIAccount As IAccount
Public Function Modify(vntAccount As Variant, Optional ByVal blnByVal As Boolean = True) As Boolean
Dim rIAccount As IAccount
Listing 38
Public Function Create(vntInventory As Variant, Optional ByVal blnByVal As Boolean = True) As Boolean
Dim rIInventory As IInventory
Public Function Modify(vntInventory As Variant, Optional ByVal blnByVal As Boolean = True) As Boolean
Dim rIInventory As IInventory
' Cast the generic object reference
' into a specific object type
If VarType(vntInventory) = vbObject Then
Set rIInventory = vntInventory
' Delegate the default interface implementation
' to the appropriate interface implementation
Modify = IInventoryExec_Modify(rIInventory, blnByVal)
End If
Set rIInventory = Nothing
End Function
Listing 39
Public Function CreateRecordset(Optional ByVal strFilter As String = "") As ADODB.Recordset
' Delegate the default interface implementation
' to the appropriate interface implementation
Set CreateRecordset = ILineItemExec_CreateRecordset(strFilter)
End Function
Public Function Create(vntLineItem As Variant, Optional ByVal blnByVal As Boolean = True) As Boolean
Dim rILineItem As ILineItem
Public Function Modify(vntLineItem As Variant, Optional ByVal blnByVal As Boolean = True) As Boolean
Dim rILineItem As ILineItem
Listing 40
Public Function CreateRecordset(Optional ByVal strFilter As String = "") As ADODB.Recordset
' Delegate the default interface implementation
' to the appropriate interface implementation
Set CreateRecordset = IPurchaseOrderExec_CreateRecordset(strFilter)
End Function
Public Function Create(vntPurchaseOrder As Variant, Optional ByVal blnByVal As Boolean = True) As Boolean
Dim rIPurchaseOrder As IPurchaseOrder
Public Function Modify(vntPurchaseOrder As Variant, Optional ByVal blnByVal As Boolean = True) As Boolean
Dim rIPurchaseOrder As IPurchaseOrder
Listing 41
' UniqueIDAllocBatch
Option Explicit
objCommand.ActiveConnection = gstrCONNECT
objCommand.CommandText = "sp_AllocBatchOfUniqueIDs_UniqueIDs"
objCommand.CommandType = adCmdStoredProc
' Create each parameter and supply it's data
objCommand.Parameters.Append _
objCommand.CreateParameter("Return", adInteger, _
adParamReturnValue)
' Execute the call
objCommand.Execute
' Get the return value
lngNextReceipt = objCommand(0)
GetObjectContext.SetComplete
AllocBatchOfUniqueIDs = lngNextReceipt
CleanUp:
Set objCommand = Nothing
Exit Function
ErrorHandler:
GetObjectContext.SetAbort
AllocBatchOfUniqueIDs = -1
GoTo CleanUp
End Function
Listing 42
' UniqueIDGen
Option Explicit
GetObjectContext.SetComplete
GetNextUniqueID = objSPMPropNextUniqueID.Value
CleanUp:
Set objSPMMgr = Nothing
Set objSPMGroup = Nothing
Set objSPMPropNextUniqueID = Nothing
Set objSPMPropMaxIDOfCurrentBatch = Nothing
Set objUniqueIDAllocBatch = Nothing
Exit Function
ErrorHandler:
GetObjectContext.SetAbort
GetNextUniqueID = -1
GoTo CleanUp
End Function
Listing 43
' AccountIterator
Option Explicit
' Clean Up
Set objAccountExec = Nothing
End Function
' Clean up
Set objAccount = Nothing
End Property
Listing 44
' InventoryIterator
Option Explicit
' Clean Up
Set objInventoryExec = Nothing
End Function
' Clean up
Set objInventory = Nothing
End Property
Listing 45
' LineItemIterator
Option Explicit
' Clean Up
Set objLineItemExec = Nothing
End Function
' Clean up
Set objInventory = Nothing
Set objLineItem = Nothing
End Property
Listing 46
' PurchaseOrderIterator
Option Explicit
' Clean Up
Set objPurchaseOrderExec = Nothing
End Function
' Clean up
Set objInventory = Nothing
Set objLineItem = Nothing
Set rsLineItems = Nothing
Set objPurchaseOrder = Nothing
End Property
Listing 47
' InvalidProperties
Option Explicit
If blnInvalid Then
' Add the invalid property to the collection
' if it doesn't already exist
mcolInvalidProperties.Add lngRuleNumber, "Key=" & CStr(lngRuleNumber)
Else
' Remove the invalid property from the
' collection if it exists
mcolInvalidProperties.Remove "Key=" & CStr(lngRuleNumber)
End If
ErrorHandler:
End Sub
Listing 48
' Account
Option Explicit
Implements IAccount
Private mobjInvalidProperties As New InvalidProperties
mcurBalance = RHS
End Property
' Clean Up
Set rIAccountExec = Nothing
End Function
' Clean Up
Set rIAccountExec = Nothing
End Function
mcurLimit = RHS
End Property
Listing 49
' Inventory
Option Explicit
Implements IInventory
Private mobjInvalidProperties As New InvalidProperties
' Clean Up
Set rIInventoryExec = Nothing
End Function
' Clean Up
Set rIInventoryExec = Nothing
End Function
' Clean Up
Set rIInventoryExec = Nothing
End Function
Listing 50
' LineItem
Option Explicit
Implements ILineItem
Private mobjInvalidProperties As New InvalidProperties
' Clean Up
Set rILineItemExec = Nothing
End Function
Listing 51
' LineItems
Option Explicit
Implements ILineItems
Listing 52
' PurchaseOrder
Option Explicit
Implements IPurchaseOrder
Private mobjInvalidProperties As New InvalidProperties
' Clean Up
Set rIPurchaseOrderExec = Nothing
End Function
' Clean Up
Set rIPurchaseOrderExec = Nothing
End Function
Listing 53
' Constants
Option Explicit
Listing 54
' Global
Option Explicit
Listing 55
'frmPurchaseOrderManagement
Option Explicit
Private mobjPurchaseOrderIterator As PurchaseOrderIterator
' Clean Up
Set objListViewItemAdded = Nothing
Set objPurchaseOrder = Nothing
End Sub
CleanUp:
Set objPurchaseOrder = Nothing
Set objListViewItemSelected = Nothing
Exit Sub
ErrorHandler:
' Inform the user of the invalid operation
MsgBox Err.Description, vbExclamation
GoTo CleanUp
End Sub
CleanUp:
Set objPurchaseOrder = Nothing
Set objListViewItemSelected = Nothing
Exit Sub
ErrorHandler:
' Inform the user of the invalid operation
MsgBox Err.Description, vbExclamation
GoTo CleanUp
End Sub
Listing 56
' frmPurchaseOrderDetailed
Option Explicit
If mobjPurchaseOrder.Save() Then
mblnCanceled = False
Me.Hide
End If
Exit Sub
ErrorHandler:
' Inform the user of the invalid operation
MsgBox Err.Description, vbExclamation
End Sub
Listing 57
' frmInventorySelection
Option Explicit
' Clean Up
Set objListViewItemAdded = Nothing
Set objInventory = Nothing
End Sub
Load Me
' Display the Inventory information
DisplayInventory
' Enable the Done button if necessary
cmdDone.Enabled = (lvInventory.ListItems.Count > 0)
Me.Show 1
If Not mblnCanceled Then
' Get the selected item
Set objListViewItemSelected = lvInventory.SelectedItem
mobjInventoryIterator.Filter = "ID = " & Mid$(objListViewItemSelected.Key, 5)
Set SelectItem = mobjInventoryIterator.Item
End If
Unload Me
Set objListViewItemSelected = Nothing
End Function
Listing 58
' frmInventoryManagement
Option Explicit
' Clean Up
Set objListViewItemAdded = Nothing
Set objInventory = Nothing
End Sub
Listing 59
' frmInventoryDetailed
Option Explicit
If mobjInventory.Save() Then
mblnCanceled = False
Me.Hide
End If
Exit Sub
ErrorHandler:
' Inform the user of the invalid operation
MsgBox Err.Description, vbExclamation
End Sub
Listing 60
' frmAccountManagement
Option Explicit
' Clean Up
Set objListViewItemAdded = Nothing
Set objAccount = Nothing
End Sub
CleanUp:
Set objAccount = Nothing
Set objListViewItemSelected = Nothing
Exit Sub
ErrorHandler:
' Inform the user of the invalid operation
MsgBox Err.Description, vbExclamation
GoTo CleanUp
End Sub
Listing 61
' frmAccountDetailed
Option Explicit
If mobjAccount.Save() Then
mblnCanceled = False
Me.Hide
End If
Exit Sub
ErrorHandler:
' Inform the user of the invalid operation
MsgBox Err.Description, vbExclamation
End Sub