Visual Basic

Functional Specification

Create a prototype ActiveX DLL component (SERVERDATA.DLL) that encapsulates the StockList table of the SERVERDATA.MDB database. The table is defined as shown on the following page.

Field name Data Type Description
ID AutoNumber ID number for each record
StockCode Text (length = 8) Stock code to identify item
Name Text (length = 50) Name of stock item
StockLevel Number (Long Integer) Number of units currently held
UnitPrice Currency Price of each unit

General requirements

The following characteristics should be defined for the DLL component:

  1. The DLL component does not explicitly need any startup code.
  2. The DLL component should have two classes defined.
    • CStockList, which provides a logical wrapper around the StockList table. Its Instancing property should be set to MultiUse.
    • CStockItem, which acts as a single record representation of the StockList table. Its Instancing property should be set to PublicNotCreatable.
  3. Database access should be performed via ActiveX Data Objects (ADO).
  4. The database should be opened during the first call upon it, and should be closed during the Terminate event of the CStockList class. For the purposes of this prototype it can be assumed that the client application will not generate any database activity from the CStockItem class once the CStockList class has been destroyed.

CStockList

Implement the following interface:

Add method Input parameters:

       StockCode As String
       Name As String
       StockLevel As Long
       UnitPrice As Currency

This method should create a new record in the StockList table and populate that record with the parameter data. It should check that the StockCode value has not already been used and that all numeric values are at least zero. (If there is an error, a negative value is returned.)

Count property (read-only) This property should return the number of records in the StockList table.

Item method function Input parameters:

       StockCode As String

This function should create, instantiate, and return an object of type CStockItem for the record identified by the StockCode parameter. This function should raise an error in the event of the record not being found.

ItemList function Input parameters:

       None

This function should return a collection of all StockCode values that exist within the StockList table.

StockValue property (read-only)This property should return the sum of each record's StockLevel field multiplied by its UnitPrice field.

Remove method Input parameters:

       StockCode As String

This method should delete the record that matches the supplied StockCode value.

CStockItem

Implement the following interface:

Name property (read/write) Let/Get for the Name field.

StockCode property (read/write) Let/Get for the StockCode field.

StockLevel property (read/write) Let/Get for the StockLevel field.

UnitPrice property (read/write) Let/Get for the UnitPrice field.

StockValue property (read-only) Get property only. Calculated dynamically and is the product of the UnitPrice field and the StockLevel field.

Update method This method should apply any changes that are made to any of the read/write properties.

by BrainBellupdated
Advertisement: