home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / samples / database / stockcpp / client.cpp next >
Encoding:
C/C++ Source or Header  |  1996-02-22  |  3.3 KB  |  67 lines

  1. //******************************************************************************
  2. //                                                                             *
  3. //COPYRIGHT: Copyright (C) International Business Machines Corp., 1992,1994.   *
  4. //                                                                             *
  5. //DISCLAIMER OF WARRANTIES:                                                    *
  6. //  The following [enclosed] code is sample code created by IBM                *
  7. //  Corporation.  This sample code is not part of any standard IBM product     *
  8. //  and is provided to you solely for the purpose of assisting you in the      *
  9. //  development of your applications.  The code is provided "AS IS",           *
  10. //  without warranty of any kind.  IBM shall not be liable for any damages     *
  11. //  arising out of your use of the sample code, even if they have been         *
  12. //  advised of the possibility of such damages.                                *
  13. //                                                                             *
  14. //******************************************************************************
  15. //******************************************************************************
  16. // File Name: client.cpp                                                       *
  17. //                                                                             *
  18. // Note: This file illustrates how a store class can be used.                  *
  19. //                                                                             *
  20. //******************************************************************************
  21. #include "store.hpp"
  22.  
  23. void main(int argc, char * argv[]) {
  24.  
  25.   Store * ComputerShop;
  26.  
  27.   if (argc == 3)
  28.     ComputerShop = new Store(argv[1], argv[2]);                    // send userid and password for connection
  29.   else
  30.     ComputerShop = new Store();                                    // send userid and password for connection
  31.  
  32.   // Generate a price list report of the current stock.
  33.   cout << "The following is a price list before update:" << endl; endl;
  34.   ComputerShop->generatePriceList();
  35.  
  36.   // Add a record if there is a new item.
  37.   ComputerShop->addNewItem("HDR0025","Hard Drive 250MD IDE", 12, 200.00, 239.45);
  38.   ComputerShop->addNewItem("HDR0034","Hard Drive 340MD IDE", 40, 220.00, 270.89);
  39.   ComputerShop->addNewItem("CPU486a","486SLC-33 TI CPU,AMI", 12, 105.45, 139.99);
  40.   ComputerShop->addNewItem("CPUPTMa","Pentium 60/66 PCI256", 23, 350.85, 459.50);
  41.  
  42.   // Commit the changes to the database
  43.   ComputerShop->transaction(COMMIT);
  44.  
  45.   // Add a reocrd whenever an order has been received.
  46.   ComputerShop->addReceivedOrder(123,"HDR0025", 10, 1800.00);
  47.   ComputerShop->addReceivedOrder(124,"RAM4-72", 30, 6001.35);
  48.   ComputerShop->addReceivedOrder(125,"CPUPTMa",  5, 1904.75);
  49.   ComputerShop->addReceivedOrder(126,"MONAD14", 40, 1538.00);
  50.  
  51.   // Commit the changes to the database
  52.   ComputerShop->transaction(COMMIT);
  53.  
  54.   // The inventory has to be posted.
  55.   ComputerShop->postingInventory();
  56.  
  57.   // Commit the changes to the database
  58.   ComputerShop->transaction(COMMIT);
  59.  
  60.   cout << endl << endl;
  61.   cout << "The following is an updated price list:" << endl; endl;
  62.  
  63.   // Generate an updated report after posting.
  64.   ComputerShop->generatePriceList();
  65.  
  66. }
  67.