Rogue Wave banner
Previous fileTop of DocumentContentsIndexNext file

21.2 Overview

As customers rent videos, invoices are produced for the customers. Each video rental is entered into the database and on-hand inventory data are updated. Data are retrieved again when the final invoice is produced.

Like other tutorials, this tutorial uses the VVContact, VVVideo, and VVRentalTransaction classes. Of course, this implies that the VVContactRepository, VVVideoRepository, and VVRentalTransactionRepository classes are also used. In addition, this tutorial introduces another class to encapsulate the notion of an invoice, VVInvoice.

As a transaction occurs, the rental information is used to enter a new VVRentalTransaction into the rentals table. At the same time, the on-hand inventory for each video is decremented. To guarantee that both transactions happen together, the database's transaction controls are used, that is, the commitTransaction() function.

Finally, after all the rental information for the customer has been entered into the database, an invoice is printed for the customer. Customer information is accessed to print the header of the invoice. Rental and video information are accessed to print the details of the rental transaction.

Most of the functionality of this example is encapsulated in the classes mentioned above. These classes hide the details of the DBTools.h++ code in the same manner that the DBTools.h++ code hides the details of the underlying database API. The classes also allow the reuse of already-defined interfaces to the underlying structure of the database.


Previous fileTop of DocumentContentsIndexNext file

©Copyright 2000, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.