home *** CD-ROM | disk | FTP | other *** search
/ Java 1.2 How-To / JavaHowTo.iso / 3rdParty / jbuilder / TRIAL / JBUILDER / JREFRNCE.Z / DataModule1.java < prev    next >
Encoding:
Java Source  |  1998-05-08  |  86.3 KB  |  2,112 lines

  1. /*
  2.  * Copyright (c) 1997-1998 Borland International, Inc. All Rights Reserved.
  3.  * 
  4.  * This SOURCE CODE FILE, which has been provided by Borland as part
  5.  * of a Borland product for use ONLY by licensed users of the product,
  6.  * includes CONFIDENTIAL and PROPRIETARY information of Borland.  
  7.  *
  8.  * USE OF THIS SOFTWARE IS GOVERNED BY THE TERMS AND CONDITIONS 
  9.  * OF THE LICENSE STATEMENT AND LIMITED WARRANTY FURNISHED WITH
  10.  * THE PRODUCT.
  11.  *
  12.  * IN PARTICULAR, YOU WILL INDEMNIFY AND HOLD BORLAND, ITS RELATED
  13.  * COMPANIES AND ITS SUPPLIERS, HARMLESS FROM AND AGAINST ANY CLAIMS
  14.  * OR LIABILITIES ARISING OUT OF THE USE, REPRODUCTION, OR DISTRIBUTION
  15.  * OF YOUR PROGRAMS, INCLUDING ANY CLAIMS OR LIABILITIES ARISING OUT OF
  16.  * OR RESULTING FROM THE USE, MODIFICATION, OR DISTRIBUTION OF PROGRAMS
  17.  * OR FILES CREATED FROM, BASED ON, AND/OR DERIVED FROM THIS SOURCE
  18.  * CODE FILE.
  19.  */
  20.  
  21. //Title:        Cliffhanger Adventure Gear
  22. //Version:      
  23. //Copyright:    Copyright (c) 1997 Borland International, Inc.
  24. //Author:       Application Methods, Inc.
  25. //Description:  Cliffhanger Adventure Gear order entry system
  26.  
  27. package borland.reference.cliffhanger;
  28.  
  29. import java.awt.*;
  30. import java.util.*;
  31. import borland.sql.dataset.*;
  32. import borland.jbcl.dataset.*;
  33. import borland.jbcl.util.*;
  34. import borland.jbcl.control.*;
  35. import java.sql.Date;
  36.  
  37. /**
  38.  * DataModule1 is an implementation of the DataModule interface.
  39.  * The DataModule is a non visual container for components, especially
  40.  * DataBroker components (i.e. Database and DataSet components). This
  41.  * centralizes related database components into one module, allowing a
  42.  * separation of business rule logic and application logic. A big advantage
  43.  * DataModules allow for easier reuse or sharing of components between
  44.  * multiple Frames in an application, or between multiple applets.
  45.  *
  46.  * <P>
  47.  * This class employs the Singleton pattern to ensure that the class has only
  48.  * one instance. You can access the singleton instance by calling the
  49.  * static method getDataModule. This method instantiates the DataModule for
  50.  * the first caller and returns this same instance to any successive callers:
  51.  *
  52.  * <P>
  53.  * <CODE><PRE>
  54.  *   DataModule1 dm = DataModule1.getDataModule();
  55.  * <PRE></CODE>
  56.  *
  57.  * <P>
  58.  * The DataSets that are used throughout the Cliffhanger application are
  59.  * contained and initialized here in this DataModule. Any master-detail
  60.  * relationships between datasets are defined here too. All persistent
  61.  * columns for the various datasets are defined and initialized here also.
  62.  * Client-side business logic is implemented in the data module to centralize
  63.  * a common response by datasets to validation checks and database exceptions.
  64.  * To access a dataset contained in the data module, use the getter methods
  65.  * for the various DataSets in the data module. These methods instantiate the
  66.  * DataSets for the first caller and returns the same instances to any
  67.  * successive callers, allowing mulitple frames to share the same dataset
  68.  * cursor:
  69.  *
  70.  * <P>
  71.  * <CODE><PRE>
  72.  *   DataModule1 dm = DataModule1.getDataModule();
  73.  *   QueryDataSet customerDataSet = dm.getCustomerDataSet();
  74.  * </PRE></CODE>
  75.  *
  76.  */
  77. public class DataModule1 implements DataModule{
  78.   private static DataModule1 myDM;
  79.   static final double TAXPERCENT = 0.09086;
  80.   static final double SHIPPERCENT = 0.04;
  81.  
  82.   Database database1 = new Database();
  83.   QueryDataSet productDataSet = new QueryDataSet();
  84.   QueryDataSet categoryDataSet = new QueryDataSet();
  85.  
  86.   // customerDataSet and custOrderDataSet are linked
  87.   // in a master-detail relationship
  88.   QueryDataSet customerDataSet = new QueryDataSet();
  89.   QueryDataSet custOrderDataSet = new QueryDataSet();
  90.  
  91.   // orderDataSet and orderItemDataSet are linked
  92.   // in a master-detail relationship
  93.   QueryDataSet orderDataSet = new QueryDataSet();
  94.   QueryDataSet orderItemDataSet = new QueryDataSet();
  95.  
  96.   // Lookup datasets
  97.   QueryDataSet payMethodDataSet = new QueryDataSet();
  98.   QueryDataSet shipMethodDataSet = new QueryDataSet();
  99.   QueryDataSet statusDataSet = new QueryDataSet();
  100.  
  101.   // Other datasets
  102.   QueryDataSet nextOrderIDDataSet = new QueryDataSet();
  103.   QueryDataSet nextCustomerIDDataSet = new QueryDataSet();
  104.   QueryDataSet accountDataSet = new QueryDataSet();
  105.  
  106.   // Query Resolvers
  107.   QueryResolver resOrder = new QueryResolver();
  108.   QueryResolver resOrderItem = new QueryResolver();
  109.   QueryResolver resCustomer = new QueryResolver();
  110.   QueryResolver resProduct = new QueryResolver();
  111.  
  112.   // Persistent columns
  113.   // Orders
  114.   Column colOrdersID = new Column();
  115.   Column colOrdersCustomerID = new Column();
  116.   Column colOrdersOrderDate = new Column();
  117.   Column colOrdersStatus = new Column();
  118.   Column colOrdersShipDate = new Column();
  119.   Column colOrdersOrderTrackNum = new Column();
  120.   Column colOrdersCustomerPONum = new Column();
  121.   Column colOrdersPayMethod = new Column();
  122.   Column colOrdersCreditCardNum = new Column();
  123.   Column colOrdersWirePaymentInstr = new Column();
  124.   Column colOrdersShipMethod = new Column();
  125.   Column colOrdersAmtPaid = new Column();
  126.   Column colOrdersShipName = new Column();
  127.   Column colOrdersShipAddr1 = new Column();
  128.   Column colOrdersShipAddr2 = new Column();
  129.   Column colOrdersShipCity = new Column();
  130.   Column colOrdersShipState = new Column();
  131.   Column colOrdersShipPostalCode = new Column();
  132.   Column colOrdersShipCountry = new Column();
  133.   Column colOrdersBillAddr1 = new Column();
  134.   Column colOrdersBillAddr2 = new Column();
  135.   Column colOrdersBillCity = new Column();
  136.   Column colOrdersBillState = new Column();
  137.   Column colOrdersBillPostalCode = new Column();
  138.   Column colOrdersBillCountry = new Column();
  139.   Column colOrdersCustomerName = new Column();
  140.   // OrderItem
  141.   Column colOrderItemQty = new Column();
  142.   Column colOrderItemProductID = new Column();
  143.   Column colOrderItemProductName = new Column();
  144.   Column colOrderItemSalePrice = new Column();
  145.   Column colOrderItemExtendedPrice = new Column();
  146.   Column colOrderItemSubtotal = new Column();
  147.   Column colOrderItemOrderID = new Column();
  148.   Column colOrderItemTax = new Column();
  149.   Column colOrderItemShipping = new Column();
  150.   Column colOrderItemAmtDue = new Column();
  151.   // Customer
  152.   Column colCustomerID = new Column();
  153.   Column colCustomerFirstName = new Column();
  154.   Column colCustomerMI = new Column();
  155.   Column colCustomerLastName = new Column();
  156.   Column colCustomerPhone = new Column();
  157.   Column colCustomerFax = new Column();
  158.   Column colCustomerEmail = new Column();
  159.   Column colCustomerAddr1 = new Column();
  160.   Column colCustomerAddr2 = new Column();
  161.   Column colCustomerCity = new Column();
  162.   Column colCustomerState = new Column();
  163.   Column colCustomerPostalCode = new Column();
  164.   Column colCustomerCountry = new Column();
  165.   Column colCustomerShipName = new Column();
  166.   Column colCustomerShipAddr1 = new Column();
  167.   Column colCustomerShipAddr2 = new Column();
  168.   Column colCustomerShipCity = new Column();
  169.   Column colCustomerShipState = new Column();
  170.   Column colCustomerShipPostalCode = new Column();
  171.   Column colCustomerShipCountry = new Column();
  172.   // Customer Order
  173.   Column colCustOrderID = new Column();
  174.   Column colCustOrderCustomerID = new Column();
  175.   Column colCustOrderOrderDate = new Column();
  176.   Column colCustOrderStatus = new Column();
  177.   Column colCustOrderShipDate = new Column();
  178.   // Product
  179.   Column colProductID = new Column();
  180.   Column colProductIsActive = new Column();
  181.   Column colProductName = new Column();
  182.   Column colProductCategory = new Column();
  183.   Column colProductBasePrice = new Column();
  184.   Column colProductDiscountPct = new Column();
  185.   Column colProductStockQty = new Column();
  186.   Column colProductMinReorderQty = new Column();
  187.   ResourceBundle res = Res.getBundle("borland.reference.cliffhanger.Res");
  188.   Column categoryColumn = new Column();
  189.   PopupPickListItemEditor edtOrderItemProductID = new PopupPickListItemEditor();
  190.  
  191.   public DataModule1() {
  192.     try {
  193.       jbInit();
  194.     }
  195.     catch (Exception e) {
  196.       e.printStackTrace();
  197.     }
  198.   }
  199.  
  200.   private void jbInit() throws Exception {
  201.     database1.setConnection(new borland.sql.dataset.ConnectionDescriptor("jdbc:odbc:Cliffhanger", "SYSDBA", "masterkey", true, "sun.jdbc.odbc.JdbcOdbcDriver"));
  202.     database1.setTransactionIsolation(java.sql.Connection.TRANSACTION_READ_COMMITTED);
  203.     productDataSet.setQuery(new borland.sql.dataset.QueryDescriptor(database1, "SELECT * FROM Product", null, true, Load.ALL));
  204.     categoryDataSet.setQuery(new borland.sql.dataset.QueryDescriptor(database1, "SELECT * FROM L_ProductCategory", null, true, Load.ALL));
  205.     categoryDataSet.addEditListener(new DataModule1_categoryDataSet_editAdapter(this));
  206.     customerDataSet.setQuery(new borland.sql.dataset.QueryDescriptor(database1, "SELECT * FROM Customer", null, true, Load.ALL));
  207.     custOrderDataSet.setMasterLink(new borland.jbcl.dataset.MasterLinkDescriptor(customerDataSet, new String[] {"ID"}, new String[] {"CUSTOMERID"}, true));
  208.     custOrderDataSet.setReadOnly(true);
  209.     custOrderDataSet.setQuery(new borland.sql.dataset.QueryDescriptor(database1, "SELECT ID, CUSTOMERID, ORDERDATE, STATUS, SHIPDATE FROM ORDERS WHERE CUSTOMERID = :ID", null, true, Load.ALL));
  210.     orderDataSet.setQuery(new borland.sql.dataset.QueryDescriptor(database1, "SELECT * FROM ORDERS", null, true, Load.ALL));
  211.     orderDataSet.addCalcFieldsListener(new DataModule1_orderDataSet_calcFieldsAdapter(this));
  212.     orderItemDataSet.setMasterLink(new borland.jbcl.dataset.MasterLinkDescriptor(orderDataSet, new String[] {"ID"}, new String[] {"ORDERID"}, true));
  213.     orderItemDataSet.setQuery(new borland.sql.dataset.QueryDescriptor(database1, "SELECT ORDERID, PRODUCTID, QTY, SALEPRICE FROM ORDERITEM WHERE ORDERID = :ID", null, true, Load.ALL));
  214.     orderItemDataSet.addCalcFieldsListener(new DataModule1_orderItemDataSet_calcFieldsAdapter(this));
  215.     orderItemDataSet.addCalcAggFieldsListener(new DataModule1_orderItemDataSet_calcAggFieldsAdapter(this));
  216.     payMethodDataSet.setQuery(new borland.sql.dataset.QueryDescriptor(database1, "SELECT * FROM L_PAYMETHOD", null, true, Load.ALL));
  217.     shipMethodDataSet.setQuery(new borland.sql.dataset.QueryDescriptor(database1, "SELECT * FROM L_SHIPMETHOD", null, true, Load.ALL));
  218.     statusDataSet.setQuery(new borland.sql.dataset.QueryDescriptor(database1, "SELECT * FROM L_STATUS", null, true, Load.ALL));
  219.     nextOrderIDDataSet.setQuery(new borland.sql.dataset.QueryDescriptor(database1, "SELECT NEXTID FROM spNextOrderID", null, true, Load.ALL));
  220.     nextCustomerIDDataSet.setQuery(new borland.sql.dataset.QueryDescriptor(database1, "SELECT NEXTID FROM spNextCustomerID", null, true, Load.ALL));
  221.     accountDataSet.setQuery(new borland.sql.dataset.QueryDescriptor(database1, "SELECT ID, CREDITCARDNUMBER FROM ACCOUNT", null, true, Load.ALL));
  222.  
  223.     // Initialize QueryResolvers
  224.     orderDataSet.setResolver(resOrder);
  225.     orderDataSet.addEditListener(new DataModule1_orderDataSet_editAdapter(this));
  226.     orderItemDataSet.setResolver(resOrderItem);
  227.     orderItemDataSet.addEditListener(new DataModule1_orderItemDataSet_editAdapter(this));
  228.     customerDataSet.setResolver(resCustomer);
  229.     customerDataSet.addEditListener(new DataModule1_customerDataSet_editAdapter(this));
  230.     productDataSet.setResolver(resProduct);
  231.     productDataSet.addEditListener(new DataModule1_productDataSet_editAdapter(this));
  232.     resOrder.setDatabase(database1);
  233.     resOrder.setUpdateMode(borland.jbcl.dataset.UpdateMode.CHANGED_COLUMNS);
  234.     resOrderItem.setDatabase(database1);
  235.     resOrderItem.setUpdateMode(borland.jbcl.dataset.UpdateMode.CHANGED_COLUMNS);
  236.     resCustomer.setDatabase(database1);
  237.     resCustomer.setUpdateMode(borland.jbcl.dataset.UpdateMode.CHANGED_COLUMNS);
  238.     resProduct.setDatabase(database1);
  239.     resProduct.setUpdateMode(borland.jbcl.dataset.UpdateMode.CHANGED_COLUMNS);
  240.     resProduct.addResolverListener(new DataModule1_resProduct_resolverAdapter(this));
  241.  
  242.     // Initialize Persistent Columns
  243.     // Orders
  244.     colOrdersID.setCaption(res.getString("DM_OrderDS_ID"));
  245.     colOrdersID.setColumnName("ID");
  246.     colOrdersID.setDataType(borland.jbcl.util.Variant.INT);
  247.     colOrdersCustomerID.setCaption(res.getString("DM_OrderDS_CUSTOMERID"));
  248.     colOrdersCustomerID.setColumnName("CUSTOMERID");
  249.     colOrdersCustomerID.setDataType(borland.jbcl.util.Variant.INT);
  250.     colOrdersCustomerID.addColumnChangeListener(new DataModule1_colOrdersCustomerID_columnChangeAdapter(this));
  251.     colOrdersOrderDate.setCaption(res.getString("DM_OrderDS_ORDERDATE"));
  252.     colOrdersOrderDate.setColumnName("ORDERDATE");
  253.     colOrdersOrderDate.setDisplayMask(res.getString("DM_DateDisplayMask"));
  254.     colOrdersOrderDate.setDataType(borland.jbcl.util.Variant.TIMESTAMP);
  255.     colOrdersOrderDate.setEditMask(res.getString("DM_DateEditMask"));
  256.     colOrdersOrderDate.setDefault("NOW");
  257.     colOrdersStatus.setCaption(res.getString("DM_OrderDS_STATUS"));
  258.     colOrdersStatus.setColumnName("STATUS");
  259.     colOrdersStatus.setDataType(borland.jbcl.util.Variant.STRING);
  260.     colOrdersStatus.setDefault(res.getString("DM_Open"));
  261.     colOrdersStatus.addColumnChangeListener(new DataModule1_colOrdersStatus_columnChangeAdapter(this));
  262.     colOrdersShipDate.setCaption(res.getString("DM_OrderDS_SHIPDATE"));
  263.     colOrdersShipDate.setColumnName("SHIPDATE");
  264.     colOrdersShipDate.setDisplayMask(res.getString("DM_DateDisplayMask"));
  265.     colOrdersShipDate.setDataType(borland.jbcl.util.Variant.TIMESTAMP);
  266.     colOrdersShipDate.setEditMask(res.getString("DM_DateEditMask"));
  267.     colOrdersOrderTrackNum.setCaption(res.getString("DM_OrderDS_ORDERTRACKNUM"));
  268.     colOrdersOrderTrackNum.setColumnName("ORDERTRACKNUM");
  269.     colOrdersOrderTrackNum.setDataType(borland.jbcl.util.Variant.STRING);
  270.     colOrdersCustomerPONum.setCaption(res.getString("DM_OrderDS_CUSTOMERPONUM"));
  271.     colOrdersCustomerPONum.setColumnName("CUSTOMERPONUM");
  272.     colOrdersCustomerPONum.setDataType(borland.jbcl.util.Variant.STRING);
  273.     colOrdersPayMethod.setColumnName("PAYMETHOD");
  274.     colOrdersPayMethod.setDataType(borland.jbcl.util.Variant.STRING);
  275.     colOrdersPayMethod.setDefault(res.getString("DM_VISA"));
  276.     colOrdersPayMethod.setVisible(borland.jbcl.util.TriState.NO);
  277.     colOrdersPayMethod.addColumnChangeListener(new DataModule1_colOrdersPayMethod_columnChangeAdapter(this));
  278.     colOrdersCreditCardNum.setColumnName("CREDITCARDNUM");
  279.     colOrdersCreditCardNum.setDisplayMask("####\\-####\\-####\\-####;0; ; ");
  280.     colOrdersCreditCardNum.setDataType(borland.jbcl.util.Variant.STRING);
  281.     colOrdersCreditCardNum.setEditMask("####\\-####\\-####\\-####;0; ; ");
  282.     colOrdersCreditCardNum.setVisible(borland.jbcl.util.TriState.NO);
  283.     colOrdersWirePaymentInstr.setColumnName("WIREPAYMENTINSTR");
  284.     colOrdersWirePaymentInstr.setDataType(borland.jbcl.util.Variant.STRING);
  285.     colOrdersWirePaymentInstr.setVisible(borland.jbcl.util.TriState.NO);
  286.     colOrdersShipMethod.setColumnName("SHIPMETHOD");
  287.     colOrdersShipMethod.setDataType(borland.jbcl.util.Variant.STRING);
  288.     colOrdersShipMethod.setDefault(res.getString("DM_UPS"));
  289.     colOrdersShipMethod.setVisible(borland.jbcl.util.TriState.NO);
  290.     colOrdersAmtPaid.setCurrency(true);
  291.     colOrdersAmtPaid.setColumnName("AMTPAID");
  292.     colOrdersAmtPaid.setDataType(borland.jbcl.util.Variant.DOUBLE);
  293.     colOrdersAmtPaid.setLocale(new java.util.Locale("en", "US", ""));
  294.     colOrdersAmtPaid.setDefault("0");
  295.     colOrdersAmtPaid.setVisible(borland.jbcl.util.TriState.NO);
  296.     colOrdersAmtPaid.addColumnChangeListener(new DataModule1_colOrdersAmtPaid_columnChangeAdapter(this));
  297.     colOrdersShipName.setColumnName("SHIPNAME");
  298.     colOrdersShipName.setDataType(borland.jbcl.util.Variant.STRING);
  299.     colOrdersShipName.setVisible(borland.jbcl.util.TriState.NO);
  300.     colOrdersShipAddr1.setColumnName("SHIPADDR1");
  301.     colOrdersShipAddr1.setDataType(borland.jbcl.util.Variant.STRING);
  302.     colOrdersShipAddr1.setVisible(borland.jbcl.util.TriState.NO);
  303.     colOrdersShipAddr2.setColumnName("SHIPADDR2");
  304.     colOrdersShipAddr2.setDataType(borland.jbcl.util.Variant.STRING);
  305.     colOrdersShipAddr2.setVisible(borland.jbcl.util.TriState.NO);
  306.     colOrdersShipCity.setColumnName("SHIPCITY");
  307.     colOrdersShipCity.setDataType(borland.jbcl.util.Variant.STRING);
  308.     colOrdersShipCity.setVisible(borland.jbcl.util.TriState.NO);
  309.     colOrdersShipState.setColumnName("SHIPSTATE");
  310.     colOrdersShipState.setDataType(borland.jbcl.util.Variant.STRING);
  311.     colOrdersShipState.setVisible(borland.jbcl.util.TriState.NO);
  312.     colOrdersShipPostalCode.setColumnName("SHIPPOSTALCODE");
  313.     colOrdersShipPostalCode.setDataType(borland.jbcl.util.Variant.STRING);
  314.     colOrdersShipPostalCode.setVisible(borland.jbcl.util.TriState.NO);
  315.     colOrdersShipCountry.setColumnName("SHIPCOUNTRY");
  316.     colOrdersShipCountry.setDataType(borland.jbcl.util.Variant.STRING);
  317.     colOrdersShipCountry.setVisible(borland.jbcl.util.TriState.NO);
  318.     colOrdersBillAddr1.setColumnName("BILLADDR1");
  319.     colOrdersBillAddr1.setDataType(borland.jbcl.util.Variant.STRING);
  320.     colOrdersBillAddr1.setVisible(borland.jbcl.util.TriState.NO);
  321.     colOrdersBillAddr2.setColumnName("BILLADDR2");
  322.     colOrdersBillAddr2.setDataType(borland.jbcl.util.Variant.STRING);
  323.     colOrdersBillAddr2.setVisible(borland.jbcl.util.TriState.NO);
  324.     colOrdersBillCity.setColumnName("BILLCITY");
  325.     colOrdersBillCity.setDataType(borland.jbcl.util.Variant.STRING);
  326.     colOrdersBillCity.setVisible(borland.jbcl.util.TriState.NO);
  327.     colOrdersBillState.setColumnName("BILLSTATE");
  328.     colOrdersBillState.setDataType(borland.jbcl.util.Variant.STRING);
  329.     colOrdersBillState.setVisible(borland.jbcl.util.TriState.NO);
  330.     colOrdersBillPostalCode.setColumnName("BILLPOSTALCODE");
  331.     colOrdersBillPostalCode.setDataType(borland.jbcl.util.Variant.STRING);
  332.     colOrdersBillPostalCode.setVisible(borland.jbcl.util.TriState.NO);
  333.     colOrdersBillCountry.setColumnName("BILLCOUNTRY");
  334.     colOrdersBillCountry.setDataType(borland.jbcl.util.Variant.STRING);
  335.     colOrdersBillCountry.setVisible(borland.jbcl.util.TriState.NO);
  336.     colOrdersCustomerName.setCalcType(borland.jbcl.dataset.CalcType.CALC);
  337.     colOrdersCustomerName.setColumnName("CUSTOMERNAME");
  338.     colOrdersCustomerName.setDataType(borland.jbcl.util.Variant.STRING);
  339.     colOrdersCustomerName.setResolvable(false);
  340.     colOrdersCustomerName.setVisible(borland.jbcl.util.TriState.NO);
  341.     orderDataSet.setColumns(new Column[] {
  342.       colOrdersID,
  343.       colOrdersCustomerID,
  344.       colOrdersOrderDate,
  345.       colOrdersStatus,
  346.       colOrdersShipDate,
  347.       colOrdersOrderTrackNum,
  348.       colOrdersCustomerPONum,
  349.       colOrdersPayMethod,
  350.       colOrdersCreditCardNum,
  351.       colOrdersWirePaymentInstr,
  352.       colOrdersShipMethod,
  353.       colOrdersAmtPaid,
  354.       colOrdersShipName,
  355.       colOrdersShipAddr1,
  356.       colOrdersShipAddr2,
  357.       colOrdersShipCity,
  358.       colOrdersShipState,
  359.       colOrdersShipPostalCode,
  360.       colOrdersShipCountry,
  361.       colOrdersBillAddr1,
  362.       colOrdersBillAddr2,
  363.       colOrdersBillCity,
  364.       colOrdersBillState,
  365.       colOrdersBillPostalCode,
  366.       colOrdersBillCountry,
  367.       colOrdersCustomerName
  368.     });
  369.     // OrderItem
  370.     colOrderItemQty.setCaption(res.getString("DM_Qty"));
  371.     colOrderItemQty.setColumnName("QTY");
  372.     colOrderItemQty.setDataType(borland.jbcl.util.Variant.INT);
  373.     colOrderItemQty.setDefault("1");
  374.     colOrderItemProductID.setCaption(res.getString("DM_Product_ID"));
  375.     colOrderItemProductID.setColumnName("PRODUCTID");
  376.     colOrderItemProductID.setDataType(borland.jbcl.util.Variant.INT);
  377.     colOrderItemProductID.addColumnChangeListener(new DataModule1_colOrderItemProductID_columnChangeAdapter(this));
  378.  
  379.     // Create a pickList for the ProductID column of the OrderItem dataset
  380.     colOrderItemProductID.setPickList(new borland.jbcl.dataset.PickListDescriptor(productDataSet, new String[] {"ID", "BASEPRICE"}, new String[] {"ID", "NAME", "BASEPRICE"}, new String[] {"PRODUCTID", "SALEPRICE"}, false));
  381.     colOrderItemProductID.setItemEditor(edtOrderItemProductID);
  382.     edtOrderItemProductID.setAllowSearch(false);
  383.     edtOrderItemProductID.setDisplayOKCancel(true);
  384.     colOrderItemProductName.setCaption(res.getString("DM_Name"));
  385.     colOrderItemProductName.setColumnName("PRODUCTNAME");
  386.     colOrderItemProductName.setDataType(borland.jbcl.util.Variant.STRING);
  387.     colOrderItemProductName.setCalcType(borland.jbcl.dataset.CalcType.CALC);
  388.     colOrderItemProductName.setEditable(false);
  389.     colOrderItemProductName.setResolvable(false);
  390.  
  391.     colOrderItemSalePrice.setCaption(res.getString("DM_Sale_Price"));
  392.     colOrderItemSalePrice.setCurrency(true);
  393.     colOrderItemSalePrice.setColumnName("SALEPRICE");
  394.     colOrderItemSalePrice.setDataType(borland.jbcl.util.Variant.DOUBLE);
  395.     colOrderItemSalePrice.setLocale(new java.util.Locale("en", "US", ""));
  396.     colOrderItemSalePrice.setDefault("0");
  397.     colOrderItemExtendedPrice.setCalcType(borland.jbcl.dataset.CalcType.CALC);
  398.     colOrderItemExtendedPrice.setCaption(res.getString("DM_Ext_Price"));
  399.     colOrderItemExtendedPrice.setCurrency(true);
  400.     colOrderItemExtendedPrice.setColumnName("EXTENDEDPRICE");
  401.     colOrderItemExtendedPrice.setDataType(borland.jbcl.util.Variant.DOUBLE);
  402.     colOrderItemExtendedPrice.setLocale(new java.util.Locale("en", "US", ""));
  403.     colOrderItemExtendedPrice.setDefault("0");
  404.     colOrderItemExtendedPrice.setReadOnly(true);
  405.     colOrderItemExtendedPrice.setResolvable(false);
  406.     colOrderItemSubtotal.setCalcType(borland.jbcl.dataset.CalcType.AGGREGATE);
  407.     colOrderItemSubtotal.setCaption(res.getString("DM_SubTotal"));
  408.     colOrderItemSubtotal.setCurrency(true);
  409.     colOrderItemSubtotal.setColumnName("SUBTOTAL");
  410.     colOrderItemSubtotal.setDataType(borland.jbcl.util.Variant.DOUBLE);
  411.     colOrderItemSubtotal.setLocale(new java.util.Locale("en", "US", ""));
  412.     colOrderItemSubtotal.setDefault("0");
  413.     colOrderItemSubtotal.setReadOnly(true);
  414.     colOrderItemSubtotal.setResolvable(false);
  415.     // Set AggregationDescriptor for calculated column
  416.     colOrderItemSubtotal.setAgg(new AggDescriptor( new String[] { "ORDERID" },
  417.                                       "EXTENDEDPRICE",
  418.                                       new SumAggOperator() ));
  419.     colOrderItemOrderID.setCaption(res.getString("DM_Order_ID"));
  420.     colOrderItemOrderID.setColumnName("ORDERID");
  421.     colOrderItemOrderID.setDataType(borland.jbcl.util.Variant.INT);
  422.     colOrderItemOrderID.setVisible(borland.jbcl.util.TriState.NO);
  423.     colOrderItemTax.setCaption(res.getString("DM_Tax"));
  424.     colOrderItemTax.setCurrency(true);
  425.     colOrderItemTax.setCalcType(borland.jbcl.dataset.CalcType.AGGREGATE);
  426.     colOrderItemTax.setColumnName("TAX");
  427.     colOrderItemTax.setDataType(borland.jbcl.util.Variant.DOUBLE);
  428.     colOrderItemTax.setLocale(new java.util.Locale("en", "US", ""));
  429.     colOrderItemTax.setDefault("0");
  430.     colOrderItemTax.setResolvable(false);
  431.     // Set AggregationDescriptor for calculated column
  432.     colOrderItemTax.setAgg(new AggDescriptor( new String[] { "ORDERID" },
  433.                                       "EXTENDEDPRICE",
  434.                                       null ));
  435.     colOrderItemShipping.setCaption(res.getString("DM_Shipping"));
  436.     colOrderItemShipping.setCurrency(true);
  437.     colOrderItemShipping.setCalcType(borland.jbcl.dataset.CalcType.AGGREGATE);
  438.     colOrderItemShipping.setColumnName("SHIPPING");
  439.     colOrderItemShipping.setDataType(borland.jbcl.util.Variant.DOUBLE);
  440.     colOrderItemShipping.setLocale(new java.util.Locale("en", "US", ""));
  441.     colOrderItemShipping.setDefault("0");
  442.     colOrderItemShipping.setResolvable(false);
  443.     // Set AggregationDescriptor for calculated column
  444.     colOrderItemShipping.setAgg(new AggDescriptor( new String[] { "ORDERID" },
  445.                                       "EXTENDEDPRICE",
  446.                                       null ));
  447.     colOrderItemAmtDue.setCalcType(borland.jbcl.dataset.CalcType.AGGREGATE);
  448.     colOrderItemAmtDue.setCaption(res.getString("DM_Amt_Due"));
  449.     colOrderItemAmtDue.setCurrency(true);
  450.     colOrderItemAmtDue.setColumnName("AMTDUE");
  451.     colOrderItemAmtDue.setDataType(borland.jbcl.util.Variant.DOUBLE);
  452.     colOrderItemAmtDue.setLocale(new java.util.Locale("en", "US", ""));
  453.     colOrderItemAmtDue.setDefault("0");
  454.     colOrderItemAmtDue.setResolvable(false);
  455.     // Set AggregationDescriptor for calculated column
  456.     colOrderItemAmtDue.setAgg(new AggDescriptor( new String[] { "ORDERID" },
  457.                                        "EXTENDEDPRICE",
  458.                                        null ));
  459.     orderItemDataSet.setColumns(new Column[] {
  460.       colOrderItemQty,
  461.       colOrderItemProductID,
  462.       colOrderItemProductName,
  463.       colOrderItemSalePrice,
  464.       colOrderItemExtendedPrice,
  465.       colOrderItemSubtotal,
  466.       colOrderItemOrderID,
  467.       colOrderItemTax,
  468.       colOrderItemShipping,
  469.       colOrderItemAmtDue
  470.     });
  471.     // Customer
  472.     colCustomerID.setCaption(res.getString("DM_CustomerDS_ID"));
  473.     colCustomerID.setColumnName("ID");
  474.     colCustomerID.setDataType(borland.jbcl.util.Variant.INT);
  475.     colCustomerFirstName.setCaption(res.getString("DM_CustomerDS_FIRSTNAME"));
  476.     colCustomerFirstName.setColumnName("FIRSTNAME");
  477.     colCustomerFirstName.setDataType(borland.jbcl.util.Variant.STRING);
  478.     colCustomerMI.setCaption(res.getString("DM_CustomerDS_MI"));
  479.     colCustomerMI.setColumnName("MI");
  480.     colCustomerMI.setDataType(borland.jbcl.util.Variant.STRING);
  481.     colCustomerLastName.setCaption(res.getString("DM_CustomerDS_LASTNAME"));
  482.     colCustomerLastName.setColumnName("LASTNAME");
  483.     colCustomerLastName.setDataType(borland.jbcl.util.Variant.STRING);
  484.     colCustomerPhone.setCaption(res.getString("DM_CustomerDS_PHONE"));
  485.     colCustomerPhone.setColumnName("PHONE");
  486.     colCustomerPhone.setDataType(borland.jbcl.util.Variant.STRING);
  487.     colCustomerFax.setColumnName("FAX");
  488.     colCustomerFax.setDataType(borland.jbcl.util.Variant.STRING);
  489.     colCustomerFax.setVisible(borland.jbcl.util.TriState.NO);
  490.     colCustomerEmail.setColumnName("EMAIL");
  491.     colCustomerEmail.setDataType(borland.jbcl.util.Variant.STRING);
  492.     colCustomerEmail.setVisible(borland.jbcl.util.TriState.NO);
  493.     colCustomerAddr1.setColumnName("ADDR1");
  494.     colCustomerAddr1.setDataType(borland.jbcl.util.Variant.STRING);
  495.     colCustomerAddr1.setVisible(borland.jbcl.util.TriState.NO);
  496.     colCustomerAddr2.setColumnName("ADDR2");
  497.     colCustomerAddr2.setDataType(borland.jbcl.util.Variant.STRING);
  498.     colCustomerAddr2.setVisible(borland.jbcl.util.TriState.NO);
  499.     colCustomerCity.setColumnName("CITY");
  500.     colCustomerCity.setDataType(borland.jbcl.util.Variant.STRING);
  501.     colCustomerCity.setVisible(borland.jbcl.util.TriState.NO);
  502.     colCustomerState.setColumnName("STATE");
  503.     colCustomerState.setDataType(borland.jbcl.util.Variant.STRING);
  504.     colCustomerState.setVisible(borland.jbcl.util.TriState.NO);
  505.     colCustomerPostalCode.setColumnName("POSTALCODE");
  506.     colCustomerPostalCode.setDataType(borland.jbcl.util.Variant.STRING);
  507.     colCustomerPostalCode.setVisible(borland.jbcl.util.TriState.NO);
  508.     colCustomerCountry.setColumnName("COUNTRY");
  509.     colCustomerCountry.setDataType(borland.jbcl.util.Variant.STRING);
  510.     colCustomerCountry.setVisible(borland.jbcl.util.TriState.NO);
  511.     colCustomerShipName.setColumnName("SHIPNAME");
  512.     colCustomerShipName.setDataType(borland.jbcl.util.Variant.STRING);
  513.     colCustomerShipName.setVisible(borland.jbcl.util.TriState.NO);
  514.     colCustomerShipAddr1.setColumnName("SHIPADDR1");
  515.     colCustomerShipAddr1.setDataType(borland.jbcl.util.Variant.STRING);
  516.     colCustomerShipAddr1.setVisible(borland.jbcl.util.TriState.NO);
  517.     colCustomerShipAddr2.setColumnName("SHIPADDR2");
  518.     colCustomerShipAddr2.setDataType(borland.jbcl.util.Variant.STRING);
  519.     colCustomerShipAddr2.setVisible(borland.jbcl.util.TriState.NO);
  520.     colCustomerShipCity.setColumnName("SHIPCITY");
  521.     colCustomerShipCity.setDataType(borland.jbcl.util.Variant.STRING);
  522.     colCustomerShipCity.setVisible(borland.jbcl.util.TriState.NO);
  523.     colCustomerShipState.setColumnName("SHIPSTATE");
  524.     colCustomerShipState.setDataType(borland.jbcl.util.Variant.STRING);
  525.     colCustomerShipState.setVisible(borland.jbcl.util.TriState.NO);
  526.     colCustomerShipPostalCode.setColumnName("SHIPPOSTALCODE");
  527.     colCustomerShipPostalCode.setDataType(borland.jbcl.util.Variant.STRING);
  528.     colCustomerShipPostalCode.setVisible(borland.jbcl.util.TriState.NO);
  529.     colCustomerShipCountry.setColumnName("SHIPCOUNTRY");
  530.     colCustomerShipCountry.setDataType(borland.jbcl.util.Variant.STRING);
  531.     colCustomerShipCountry.setVisible(borland.jbcl.util.TriState.NO);
  532.     customerDataSet.setColumns(new Column[] {
  533.       colCustomerID,
  534.       colCustomerFirstName,
  535.       colCustomerMI,
  536.       colCustomerLastName,
  537.       colCustomerPhone,
  538.       colCustomerFax,
  539.       colCustomerEmail,
  540.       colCustomerAddr1,
  541.       colCustomerAddr2,
  542.       colCustomerCity,
  543.       colCustomerState,
  544.       colCustomerPostalCode,
  545.       colCustomerCountry,
  546.       colCustomerShipName,
  547.       colCustomerShipAddr1,
  548.       colCustomerShipAddr2,
  549.       colCustomerShipCity,
  550.       colCustomerShipState,
  551.       colCustomerShipPostalCode,
  552.       colCustomerShipCountry
  553.     });
  554.     // Customer Order
  555.     colCustOrderID.setColumnName("ID");
  556.     colCustOrderID.setDataType(borland.jbcl.util.Variant.INT);
  557.     colCustOrderID.setVisible(borland.jbcl.util.TriState.NO);
  558.     colCustOrderCustomerID.setColumnName("CUSTOMERID");
  559.     colCustOrderCustomerID.setDataType(borland.jbcl.util.Variant.INT);
  560.     colCustOrderCustomerID.setVisible(borland.jbcl.util.TriState.NO);
  561.     colCustOrderOrderDate.setCaption(res.getString("DM_CustOrderDS_ORDERDATE"));
  562.     colCustOrderOrderDate.setColumnName("ORDERDATE");
  563.     colCustOrderOrderDate.setDisplayMask(res.getString("DM_DateDisplayMask"));
  564.     colCustOrderOrderDate.setDataType(borland.jbcl.util.Variant.TIMESTAMP);
  565.     colCustOrderStatus.setCaption(res.getString("DM_CustOrderDS_STATUS"));
  566.     colCustOrderStatus.setColumnName("STATUS");
  567.     colCustOrderStatus.setDataType(borland.jbcl.util.Variant.STRING);
  568.     colCustOrderStatus.addColumnChangeListener(new DataModule1_colOrdersStatus_columnChangeAdapter(this));
  569.     colCustOrderShipDate.setCaption(res.getString("DM_CustOrderDS_SHIPDATE"));
  570.     colCustOrderShipDate.setColumnName("SHIPDATE");
  571.     colCustOrderShipDate.setDisplayMask(res.getString("DM_DateDisplayMask"));
  572.     colCustOrderShipDate.setDataType(borland.jbcl.util.Variant.TIMESTAMP);
  573.     custOrderDataSet.setColumns(new Column[] {
  574.       colCustOrderID,
  575.       colCustOrderCustomerID,
  576.       colCustOrderOrderDate,
  577.       colCustOrderStatus,
  578.       colCustOrderShipDate
  579.     });
  580.     // Product
  581.     colProductID.setCaption(res.getString("DM_ID"));
  582.     colProductID.setColumnName("ID");
  583.     colProductID.setDataType(borland.jbcl.util.Variant.INT);
  584.     colProductIsActive.setCaption(res.getString("DM_Is_Active"));
  585.     colProductIsActive.setColumnName("ISACTIVE");
  586.     colProductIsActive.setDataType(borland.jbcl.util.Variant.SHORT);
  587.     colProductIsActive.setDefault("1");
  588.     colProductName.setCaption(res.getString("DM_Name"));
  589.     colProductName.setColumnName("NAME");
  590.     colProductName.setDataType(borland.jbcl.util.Variant.STRING);
  591.     colProductCategory.setCaption(res.getString("DM_Category"));
  592.     colProductCategory.setColumnName("CATEGORY");
  593.     colProductCategory.setDataType(borland.jbcl.util.Variant.STRING);
  594.     colProductCategory.setDefault(res.getString("DM_Active_Wear"));
  595.     colProductBasePrice.setCaption(res.getString("DM_Base_Price"));
  596.     colProductBasePrice.setDisplayMask("#0.00");
  597.     colProductBasePrice.setLocale(new java.util.Locale("en", "US", ""));
  598.     colProductBasePrice.setColumnName("BASEPRICE");
  599.     colProductBasePrice.setDataType(borland.jbcl.util.Variant.DOUBLE);
  600.     colProductBasePrice.setDefault("0");
  601.     colProductBasePrice.setVisible(borland.jbcl.util.TriState.NO);
  602.     colProductDiscountPct.setCaption(res.getString("DM_Discount_%"));
  603.     colProductDiscountPct.setColumnName("DISCOUNTPCT");
  604.     colProductDiscountPct.setDisplayMask("#0.00");
  605.     colProductDiscountPct.setMax("100");
  606.     colProductDiscountPct.setDataType(borland.jbcl.util.Variant.DOUBLE);
  607.     colProductDiscountPct.setDefault("0");
  608.     colProductDiscountPct.setMin("0");
  609.     colProductDiscountPct.setVisible(borland.jbcl.util.TriState.NO);
  610.     colProductStockQty.setCaption(res.getString("DM_Stock_Qty"));
  611.     colProductStockQty.setColumnName("STOCKQTY");
  612.     colProductStockQty.setDataType(borland.jbcl.util.Variant.INT);
  613.     colProductStockQty.setDefault("0");
  614.     colProductMinReorderQty.setCaption(res.getString("DM_Min_ReOrder_Qty"));
  615.     colProductMinReorderQty.setColumnName("MINREORDERQTY");
  616.     colProductMinReorderQty.setDataType(borland.jbcl.util.Variant.INT);
  617.     colProductMinReorderQty.setDefault("0");
  618.     colProductMinReorderQty.setVisible(borland.jbcl.util.TriState.NO);
  619.     productDataSet.setColumns(new Column[] {
  620.       colProductID,
  621.       colProductIsActive,
  622.       colProductName,
  623.       colProductCategory,
  624.       colProductBasePrice,
  625.       colProductDiscountPct,
  626.       colProductStockQty,
  627.       colProductMinReorderQty
  628.     });
  629.     categoryColumn.setCaption(res.getString("DM_CategoryDS_CATEGORY"));
  630.     categoryColumn.setColumnName("CATEGORY");
  631.     categoryColumn.setDataType(borland.jbcl.util.Variant.STRING);
  632.     categoryDataSet.setColumns(new Column[] {categoryColumn});
  633.   }
  634.  
  635.  
  636.  
  637.   // Getter methods for Data Access controls
  638.  
  639.   /**
  640.    * Class method to access the singleton instance of the class.
  641.    */
  642.   static public DataModule1 getDataModule() {
  643.     if (myDM == null)
  644.       myDM = new DataModule1();
  645.     return myDM;
  646.   }
  647.  
  648.   /**
  649.    * Method to access the Product DataSet.
  650.    */
  651.   public borland.sql.dataset.QueryDataSet getProductDataSet() {
  652.     return productDataSet;
  653.   }
  654.  
  655.   /**
  656.    * Method to access the Category DataSet.
  657.    */
  658.   public borland.sql.dataset.QueryDataSet getCategoryDataSet() {
  659.     return categoryDataSet;
  660.   }
  661.  
  662.   /**
  663.    * Method to access the Customer DataSet.
  664.    */
  665.   public borland.sql.dataset.QueryDataSet getCustomerDataSet() {
  666.     return customerDataSet;
  667.   }
  668.  
  669.   /**
  670.    * Method to access the Order DataSet that is linked to the
  671.    * Customer DataSet by a MasterLink.
  672.    */
  673.   public borland.sql.dataset.QueryDataSet getCustOrderDataSet() {
  674.     return custOrderDataSet;
  675.   }
  676.  
  677.   /**
  678.    * Method to access the Order DataSet.
  679.    */
  680.   public borland.sql.dataset.QueryDataSet getOrderDataSet() {
  681.     return orderDataSet;
  682.   }
  683.  
  684.   /**
  685.    * Method to access the OrderItem DataSet. This is linked to the
  686.    * Order DataSet by a MasterLink.
  687.    */
  688.   public borland.sql.dataset.QueryDataSet getOrderItemDataSet() {
  689.     return orderItemDataSet;
  690.   }
  691.  
  692.   /**
  693.    * Method to access the PayMethod DataSet.
  694.    */
  695.   public borland.sql.dataset.QueryDataSet getPayMethodDataSet() {
  696.     return payMethodDataSet;
  697.   }
  698.  
  699.   /**
  700.    * Method to access the ShipMethod DataSet.
  701.    */
  702.   public borland.sql.dataset.QueryDataSet getShipMethodDataSet() {
  703.     return shipMethodDataSet;
  704.   }
  705.  
  706.   /**
  707.    * Method to access the Status DataSet.
  708.    */
  709.   public borland.sql.dataset.QueryDataSet getStatusDataSet() {
  710.     return statusDataSet;
  711.   }
  712.  
  713.   /**
  714.    * Method to access the Account DataSet.
  715.    */
  716.   public borland.sql.dataset.QueryDataSet getAccountDataSet() {
  717.     return accountDataSet;
  718.   }
  719.  
  720.   /**
  721.    * This method is used to open a connection to the database
  722.    * explicitly.
  723.    */
  724.   public void dbConnect() throws DataSetException {
  725.     database1.openConnection();
  726.   }
  727.  
  728.  
  729.   // Category DataSet EditEvents
  730.  
  731.   /**
  732.    * Before adding a category row, do row-level validation.
  733.    */
  734.   void categoryDataSet_adding(DataSet dataSet, ReadWriteRow readWriteRow) throws Exception{
  735.     validateCategoryRow();
  736.   }
  737.  
  738.   /**
  739.    * Before updating a category row, do row-level validation.
  740.    */
  741.   void categoryDataSet_updating(DataSet dataSet, ReadWriteRow readWriteRow, ReadRow readRow) throws Exception{
  742.     validateCategoryRow();
  743.   }
  744.  
  745.   /**
  746.    * Before deleting a Category record, prompt the user to confirm delete.
  747.    */
  748.   void categoryDataSet_deleting(DataSet dataSet) throws Exception{
  749.     confirmDelete(res.getString("DM_Delete_this_category?"));
  750.   }
  751.  
  752.   /**
  753.    * When a new record is added, resolve new record to the database.
  754.    */
  755.   void categoryDataSet_added(DataSet dataSet) throws DataSetException{
  756.     dataSet.saveChanges();
  757.   }
  758.  
  759.   /**
  760.    * When a record is updated, resolve updated record to the database.
  761.    */
  762.   void categoryDataSet_updated(DataSet dataSet) throws DataSetException{
  763.     dataSet.saveChanges();
  764.   }
  765.  
  766.   /**
  767.    * When a record is deleted, resolve to the database.
  768.    */
  769.   void categoryDataSet_deleted(DataSet dataSet) throws DataSetException{
  770.     dataSet.saveChanges();
  771.   }
  772.  
  773.   /**
  774.    * When canceling an edit or insert, clear the messages from
  775.    * all status bar controls
  776.    */
  777.   void categoryDataSet_canceling(DataSet dataSet) throws Exception{
  778.     dataSet.clearStatus();
  779.   }
  780.  
  781.   /**
  782.    * Show an error dialog if error occurs during editing.
  783.    */
  784.   void categoryDataSet_editError(DataSet dataSet, Column column, Variant variant, DataSetException dataSetException, ErrorResponse errorResponse) throws DataSetException{
  785.     CliffhangerApplication.messageDlg(
  786.       res.getString("DM_Error"),
  787.       dataSetException.getMessage(),
  788.       Message.OK);
  789.   }
  790.  
  791.   /**
  792.    * Show an error dialog if error occurs during adding.
  793.    */
  794.   void categoryDataSet_addError(DataSet dataSet, ReadWriteRow readWriteRow, DataSetException dataSetException, ErrorResponse errorResponse) throws DataSetException{
  795.     CliffhangerApplication.messageDlg(
  796.       res.getString("DM_Error"),
  797.       dataSetException.getMessage(),
  798.       Message.OK);
  799.   }
  800.  
  801.   /**
  802.    * Show an error dialog if error occurs during updating.
  803.    */
  804.   void categoryDataSet_updateError(DataSet dataSet, ReadWriteRow readWriteRow, DataSetException dataSetException, ErrorResponse errorResponse) throws DataSetException{
  805.     CliffhangerApplication.messageDlg(
  806.       res.getString("DM_Error"),
  807.       dataSetException.getMessage(),
  808.       Message.OK);
  809.   }
  810.  
  811.  
  812.  
  813.   // Product DataSet EditEvents
  814.  
  815.   /**
  816.    * Before adding a product row, do row-level validation.
  817.    */
  818.   void productDataSet_adding(DataSet dataSet, ReadWriteRow readWriteRow) throws Exception{
  819.     validateProductRow();
  820.   }
  821.  
  822.   /**
  823.    * Before updating a product row, do row-level validation.
  824.    */
  825.   void productDataSet_updating(DataSet dataSet, ReadWriteRow readWriteRow, ReadRow readRow) throws Exception{
  826.     validateProductRow();
  827.   }
  828.  
  829.   /**
  830.    * Before deleting a Product record, prompt the user to confirm delete.
  831.    */
  832.   void productDataSet_deleting(DataSet dataSet) throws Exception{
  833.     confirmDelete(res.getString("DM_Delete_this_product?"));
  834.   }
  835.  
  836.   /**
  837.    * When a new record is added, resolve new record to the database.
  838.    */
  839.   void productDataSet_added(DataSet dataSet) throws DataSetException{
  840.     dataSet.saveChanges();
  841.   }
  842.  
  843.   /**
  844.    * When a record is updated, resolve updated record to the database.
  845.    */
  846.   void productDataSet_updated(DataSet dataSet) throws DataSetException{
  847.     dataSet.saveChanges();
  848.   }
  849.  
  850.   /**
  851.    * When a record is deleted, resolve to the database.
  852.    */
  853.   void productDataSet_deleted(DataSet dataSet) throws DataSetException{
  854.     dataSet.saveChanges();
  855.   }
  856.  
  857.   /**
  858.    * When canceling an edit or insert, clear the messages from
  859.    * all status bar controls
  860.    */
  861.   void productDataSet_canceling(DataSet dataSet) throws Exception{
  862.     dataSet.clearStatus();
  863.   }
  864.  
  865.   /**
  866.    * Show an error dialog if error occurs during editing.
  867.    */
  868.   void productDataSet_editError(DataSet dataSet, Column column, Variant variant, DataSetException dataSetException, ErrorResponse errorResponse) throws DataSetException{
  869.     CliffhangerApplication.messageDlg(
  870.       res.getString("DM_Error"),
  871.       dataSetException.getMessage(),
  872.       Message.OK);
  873.   }
  874.  
  875.   /**
  876.    * Show an error dialog if error occurs during adding.
  877.    */
  878.   void productDataSet_addError(DataSet dataSet, ReadWriteRow readWriteRow, DataSetException dataSetException, ErrorResponse errorResponse) throws DataSetException{
  879.     CliffhangerApplication.messageDlg(
  880.       res.getString("DM_Error"),
  881.       dataSetException.getMessage(),
  882.       Message.OK);
  883.   }
  884.  
  885.   /**
  886.    * Show an error dialog if error occurs during updating.
  887.    */
  888.   void productDataSet_updateError(DataSet dataSet, ReadWriteRow readWriteRow, DataSetException dataSetException, ErrorResponse errorResponse) throws DataSetException{
  889.     CliffhangerApplication.messageDlg(
  890.       res.getString("DM_Error"),
  891.       dataSetException.getMessage(),
  892.       Message.OK);
  893.   }
  894.  
  895.  
  896.  
  897.   // Customer DataSet EditEvents
  898.  
  899.   /**
  900.    * Before adding a new customer record, get the Order ID from the
  901.    * Server. We want the ID upfront for the Order Item records.
  902.    * Also, copy the customer info into the ShipTo info for the
  903.    * customer if the ShipName column is NULL.
  904.    */
  905.   void customerDataSet_adding(DataSet dataSet, ReadWriteRow readWriteRow) throws Exception{
  906.      validateCustomerRow();
  907.  
  908.     // Call the stored procedure to get a new Customer ID
  909.     int customerID = getNextCustomerID();
  910.     readWriteRow.setInt("ID", customerID);
  911.  
  912.     // Copy customer info into shipto info columns
  913.     if (readWriteRow.isNull("SHIPNAME")) {
  914.       String custName = formatCustomerName( readWriteRow.getString("FIRSTNAME"),
  915.                                             readWriteRow.getString("MI"),
  916.                                             readWriteRow.getString("LASTNAME") );
  917.       readWriteRow.setString("SHIPNAME",    custName);
  918.       readWriteRow.setString("SHIPADDR1",   readWriteRow.getString("ADDR1"));
  919.       readWriteRow.setString("SHIPADDR2",   readWriteRow.getString("ADDR2"));
  920.       readWriteRow.setString("SHIPCITY",    readWriteRow.getString("CITY"));
  921.       readWriteRow.setString("SHIPSTATE",   readWriteRow.getString("STATE"));
  922.       readWriteRow.setString("SHIPPOSTALCODE", readWriteRow.getString("POSTALCODE"));
  923.       readWriteRow.setString("SHIPCOUNTRY", readWriteRow.getString("COUNTRY"));
  924.     }
  925.   }
  926.  
  927.   /**
  928.    * Method to get the next customer ID.
  929.    * This calls a stored procedure on the database server spNextCustomerID
  930.    * that returns a single row with the next Customer ID generated by the server.
  931.    */
  932.   private int getNextCustomerID() throws Exception {
  933.     int result = 0;
  934.     try {
  935.       nextCustomerIDDataSet.open();
  936.       nextCustomerIDDataSet.refresh();
  937.       result = nextCustomerIDDataSet.getInt("NEXTID");
  938.       nextCustomerIDDataSet.close();
  939.     }
  940.     catch (Exception ex) {
  941.       ex.printStackTrace();
  942.       throw ex;
  943.     }
  944.     return result;
  945.   }
  946.  
  947.   /**
  948.    * Before updating a customer row, do row-level validation.
  949.    */
  950.   void customerDataSet_updating(DataSet dataSet, ReadWriteRow readWriteRow, ReadRow readRow) throws Exception{
  951.     validateCustomerRow();
  952.   }
  953.  
  954.   /**
  955.    * Before deleting a Customer record, prompt the user to confirm delete.
  956.    */
  957.   void customerDataSet_deleting(DataSet dataSet) throws Exception{
  958.     confirmDelete(res.getString("DM_Delete_this_customer?"));
  959.   }
  960.  
  961.   /**
  962.    * When a new record is added, resolve new record to the database.
  963.    */
  964.   void customerDataSet_added(DataSet dataSet) throws DataSetException{
  965.     dataSet.saveChanges();
  966.   }
  967.  
  968.   /**
  969.    * When a record is updated, resolve updated record to the database.
  970.    */
  971.   void customerDataSet_updated(DataSet dataSet) throws DataSetException{
  972.     dataSet.saveChanges();
  973.   }
  974.  
  975.   /**
  976.    * When a record is deleted, resolve to the database.
  977.    */
  978.   void customerDataSet_deleted(DataSet dataSet) throws DataSetException{
  979.     dataSet.saveChanges();
  980.   }
  981.  
  982.   /**
  983.    * When canceling an edit or insert, clear the messages from
  984.    * all status bar controls
  985.    */
  986.   void customerDataSet_canceling(DataSet dataSet) throws Exception{
  987.     dataSet.clearStatus();
  988.   }
  989.  
  990.   /**
  991.    * Show an error dialog if error occurs during editing.
  992.    */
  993.   void customerDataSet_editError(DataSet dataSet, Column column, Variant variant, DataSetException dataSetException, ErrorResponse errorResponse) throws DataSetException{
  994.     CliffhangerApplication.messageDlg(
  995.       res.getString("DM_Error"),
  996.       dataSetException.getMessage(),
  997.       Message.OK);
  998.   }
  999.  
  1000.   /**
  1001.    * Show an error dialog if error occurs during adding.
  1002.    */
  1003.   void customerDataSet_addError(DataSet dataSet, ReadWriteRow readWriteRow, DataSetException dataSetException, ErrorResponse errorResponse) throws DataSetException{
  1004.     CliffhangerApplication.messageDlg(
  1005.       res.getString("DM_Error"),
  1006.       dataSetException.getMessage(),
  1007.       Message.OK);
  1008.   }
  1009.  
  1010.   /**
  1011.    * Show an error dialog if error occurs during updating.
  1012.    */
  1013.   void customerDataSet_updateError(DataSet dataSet, ReadWriteRow readWriteRow, DataSetException dataSetException, ErrorResponse errorResponse) throws DataSetException{
  1014.     CliffhangerApplication.messageDlg(
  1015.       res.getString("DM_Error"),
  1016.       dataSetException.getMessage(),
  1017.       Message.OK);
  1018.   }
  1019.  
  1020.  
  1021.  
  1022.  
  1023.   // Order DataSet EditEvents
  1024.  
  1025.   /**
  1026.    * When adding a new order record, get the Order ID from the
  1027.    * Server. We want the ID upfront for the Order Item records.
  1028.    */
  1029.   void orderDataSet_adding(DataSet dataSet, ReadWriteRow readWriteRow) throws Exception{
  1030.     validateOrderRow();
  1031.  
  1032.     // call the stored procedure to get a new Order ID
  1033.     int orderID = getNextOrderID();
  1034.     readWriteRow.setInt("ID", orderID);
  1035.   }
  1036.  
  1037.   /**
  1038.    * Method to get the next order ID.
  1039.    * This calls a stored procedure on the database server spNextOrderID
  1040.    * that returns a single row with the next Order ID generated by the server.
  1041.    */
  1042.   private int getNextOrderID() throws Exception {
  1043.     int result = 0;
  1044.     try {
  1045.       nextOrderIDDataSet.open();
  1046.       nextOrderIDDataSet.refresh();
  1047.       result = nextOrderIDDataSet.getInt("NEXTID");
  1048.       nextOrderIDDataSet.close();
  1049.     }
  1050.     catch (Exception ex) {
  1051.       ex.printStackTrace();
  1052.       throw ex;
  1053.     }
  1054.     return result;
  1055.   }
  1056.  
  1057.   /**
  1058.    * Before updating an order row, do row-level validation.
  1059.    */
  1060.   void orderDataSet_updating(DataSet dataSet, ReadWriteRow readWriteRow, ReadRow readRow) throws Exception{
  1061.     validateOrderRow();
  1062.   }
  1063.  
  1064.   /**
  1065.    * When canceling an edit or insert, clear the messages from
  1066.    * all status bar controls
  1067.    */
  1068.   void orderDataSet_canceling(DataSet dataSet) throws Exception{
  1069.     dataSet.clearStatus();
  1070.   }
  1071.  
  1072.   /**
  1073.    * Before deleting an Order record, prompt the user to confirm delete.
  1074.    */
  1075.   void orderDataSet_deleting(DataSet dataSet) throws Exception{
  1076.     confirmDelete(res.getString("DM_Delete_this_order?"));
  1077.   }
  1078.  
  1079.   /**
  1080.    * Show an error dialog if error occurs during editing.
  1081.    */
  1082.   void orderDataSet_editError(DataSet dataSet, Column column, Variant variant, DataSetException dataSetException, ErrorResponse errorResponse) throws DataSetException{
  1083.     CliffhangerApplication.messageDlg(
  1084.       res.getString("DM_Error"),
  1085.       dataSetException.getMessage(),
  1086.       Message.OK);
  1087.   }
  1088.  
  1089.   /**
  1090.    * Show an error dialog if error occurs during adding.
  1091.    */
  1092.   void orderDataSet_addError(DataSet dataSet, ReadWriteRow readWriteRow, DataSetException dataSetException, ErrorResponse errorResponse) throws DataSetException{
  1093.     CliffhangerApplication.messageDlg(
  1094.       res.getString("DM_Error"),
  1095.       dataSetException.getMessage(),
  1096.       Message.OK);
  1097.   }
  1098.  
  1099.   /**
  1100.    * Show an error dialog if error occurs during updating.
  1101.    */
  1102.   void orderDataSet_updateError(DataSet dataSet, ReadWriteRow readWriteRow, DataSetException dataSetException, ErrorResponse errorResponse) throws DataSetException{
  1103.     CliffhangerApplication.messageDlg(
  1104.       res.getString("DM_Error"),
  1105.       dataSetException.getMessage(),
  1106.       Message.OK);
  1107.   }
  1108.  
  1109.  
  1110.  
  1111.  
  1112.   // OrderItem DataSet EditEvents
  1113.  
  1114.   /**
  1115.    * Before inserting a new OrderItem record, post the Order dataset
  1116.    * if a new record is being inserted.
  1117.    */
  1118.   void orderItemDataSet_inserting(DataSet dataSet) throws Exception{
  1119.     // Do not allow inserts if the corresponding Order record
  1120.     // STATUS value is Fullfilled.
  1121.     String status = orderDataSet.getString("STATUS");
  1122.     if (status.compareTo(res.getString("DM_Fulfilled")) == 0) {
  1123.       // Show the message dialog here because there is
  1124.       // no error event handler for inserting event errors.
  1125.       CliffhangerApplication.messageDlg(
  1126.         res.getString("DM_Error"),
  1127.         res.getString("DM_Cannot_modify_order"),
  1128.         Message.OK);
  1129.       throw new VetoException(res.getString("DM_Cannot_modify_order"));
  1130.     }
  1131.  
  1132.     // Post order dataset first
  1133.     if (orderDataSet.isEditingNewRow()) {
  1134.       orderDataSet.post();
  1135.     }
  1136.   }
  1137.  
  1138.   /**
  1139.    * The adding event occurs after the inserted record is posted.
  1140.    * Before an orderItem is added, check the quantity on hand in the
  1141.    * Product dataset and subtract the quantity for this order item.
  1142.    */
  1143.   void orderItemDataSet_adding(DataSet dataSet, ReadWriteRow readWriteRow) throws Exception{
  1144.     validateOrderItemRow();
  1145.  
  1146.     int productID  = readWriteRow.getInt("PRODUCTID");
  1147.     int orderedQty = readWriteRow.getInt("QTY");
  1148.  
  1149.     // Update the product StockQty by the amount ordered
  1150.     subtractProductStockQty(productID, orderedQty);
  1151.   }
  1152.  
  1153.   /**
  1154.    * The updating event occurs after the modified record is posted.
  1155.    * When an orderItem is being updated, do the following:
  1156.    * <UL>
  1157.    * <LI>1. Determine if the productID has changed
  1158.    *    <P>
  1159.    *    - subtract qty from new product
  1160.    *    <P>
  1161.    *    - replace qty of old product
  1162.    * <LI>2. Determine if the quantity has changed
  1163.    *    <P>
  1164.    *    - replace or subtract from product
  1165.    * </UL>
  1166.    */
  1167.   void orderItemDataSet_updating(DataSet dataSet, ReadWriteRow readWriteRow, ReadRow readRow) throws Exception{
  1168.     validateOrderItemRow();
  1169.  
  1170.     int oldProductID  = readRow.getInt("PRODUCTID");
  1171.     int oldOrderedQty = readRow.getInt("QTY");
  1172.     int newProductID  = readWriteRow.getInt("PRODUCTID");
  1173.     int newOrderedQty = readWriteRow.getInt("QTY");
  1174.  
  1175.     if (oldProductID != newProductID) {
  1176.       subtractProductStockQty(newProductID, newOrderedQty);
  1177.       subtractProductStockQty(oldProductID, -oldOrderedQty);
  1178.     }
  1179.     else {
  1180.       if (newOrderedQty != oldOrderedQty)
  1181.         subtractProductStockQty(newProductID, newOrderedQty - oldOrderedQty);
  1182.     }
  1183.   }
  1184.  
  1185.   /**
  1186.    * The deleting event occurs before a record is deleted.
  1187.    * Confirm delete with the user, and update stock quantity.
  1188.    */
  1189.   void orderItemDataSet_deleting(DataSet dataSet) throws Exception{
  1190.     // Prompt the user to confirm delete.
  1191.     confirmDelete(res.getString("DM_Delete_this_order"));
  1192.  
  1193.     // Do not allow edits if the corresponding Order record
  1194.     // STATUS value is Fulfilled.
  1195.     String status = orderDataSet.getString("STATUS");
  1196.     if (status.compareTo(res.getString("DM_Fulfilled")) == 0) {
  1197.       // Show the message dialog here because there is
  1198.       // no error event handler for modifying event errors.
  1199.       CliffhangerApplication.messageDlg(
  1200.         res.getString("DM_Error"),
  1201.         res.getString("DM_Cannot_modify_order"),
  1202.         Message.OK);
  1203.       throw new VetoException(res.getString("DM_Cannot_modify_order"));
  1204.     } else {
  1205.       // When an orderItem is being deleted, replace the qty of the product.
  1206.       int productID  = dataSet.getInt("PRODUCTID");
  1207.       int orderedQty = dataSet.getInt("QTY");
  1208.       subtractProductStockQty(productID, -orderedQty);
  1209.     }
  1210.   }
  1211.  
  1212.   /**
  1213.    * Method to prompt the user to confirm before deleting a record.
  1214.    * This raises an exception if the user cancels.
  1215.    * Call this method from the deleting event handler.
  1216.    */
  1217.   private void confirmDelete(String message) throws Exception {
  1218.     // Prompt the user to confirm delete.
  1219.     int answer = CliffhangerApplication.messageDlg(
  1220.                    res.getString("DM_Confirm"),
  1221.                    message,
  1222.                    Message.YES_NO);
  1223.  
  1224.     if (answer == Message.NO) {
  1225.       throw new VetoException(res.getString("DM_Delete_canceled"));
  1226.     }
  1227.   }
  1228.  
  1229.   /**
  1230.    * Event handler for modifying event. Make sure that the orderDataSet's
  1231.    * Stutus column is not "Fulfilled" before allowing the orderItemDataSet
  1232.    * to be modified.
  1233.    */
  1234.   void orderItemDataSet_modifying(DataSet dataSet) throws Exception{
  1235.     // Do not allow edits if the corresponding Order record
  1236.     // STATUS value is Fulfilled.
  1237.     String status = orderDataSet.getString("STATUS");
  1238.     if (status.compareTo(res.getString("DM_Fulfilled")) == 0) {
  1239.       // Show the message dialog here because there is
  1240.       // no error event handler for modifying event errors.
  1241.       CliffhangerApplication.messageDlg(
  1242.         res.getString("DM_Error"),
  1243.         res.getString("DM_Cannot_modify_order"),
  1244.         Message.OK);
  1245.       throw new VetoException(res.getString("DM_Cannot_modify_order"));
  1246.     }
  1247.   }
  1248.  
  1249.   /**
  1250.    * When canceling an edit or insert, clear the messages from
  1251.    * all status bar controls
  1252.    */
  1253.   void orderItemDataSet_canceling(DataSet dataSet) throws Exception{
  1254.     dataSet.clearStatus();
  1255.   }
  1256.  
  1257.   /**
  1258.    * Event handler to calculate the values for all the calculated columns
  1259.    * for the OrderItem dataset.
  1260.    */
  1261.   void orderItemDataSet_calcFields(ReadRow readRow, DataRow dataRow, boolean boolean1) throws DataSetException{
  1262.     // Calculate the Extended Qty for OrderItems
  1263.     double extPrice = readRow.getInt("QTY") * readRow.getDouble("SALEPRICE");
  1264.     dataRow.setDouble("EXTENDEDPRICE", extPrice);
  1265.  
  1266.     // Lookup the product Name for the OrderItem
  1267.     String productName = lookupProductName(readRow.getInt("PRODUCTID"));
  1268.     dataRow.setString("PRODUCTNAME", productName);
  1269.   }
  1270.  
  1271.   /**
  1272.    * Method to lookup the Product Name given the ProductID.
  1273.    */
  1274.   private String lookupProductName(int productID) {
  1275.     String productName = new String("");
  1276.     try {
  1277.       // Define a DataRow to hold the productID to look for
  1278.       // the Product Dataset, and another to hold the row
  1279.       // of product data that we find.
  1280.       productDataSet.open();
  1281.       DataRow lookupRow = new DataRow(productDataSet, "ID");
  1282.       DataRow productRow = new DataRow(productDataSet, new String[] {"NAME"} );
  1283.  
  1284.       lookupRow.setInt("ID", productID);
  1285.  
  1286.       if (productDataSet.lookup(lookupRow, productRow, Locate.FIRST)) {
  1287.         productName = productRow.getString("NAME");
  1288.       }
  1289.     }
  1290.     catch (Exception e) {
  1291.       e.printStackTrace();
  1292.     };
  1293.     return productName;
  1294.   }
  1295.  
  1296.   /**
  1297.    * Event handler to calculate the aggregate columns for the
  1298.    * orderItem DataSet when an row is added.
  1299.    */
  1300.   void orderItemDataSet_calcAggAdd(ReadRow readRow, ReadWriteRow readWriteRow) throws DataSetException{
  1301.     calcAggregate(readRow, readWriteRow);
  1302.   }
  1303.  
  1304.   /**
  1305.    * Event handler to calculate the aggregate columns for the
  1306.    * orderItem DataSet when an row is deleted.
  1307.    */
  1308.   void orderItemDataSet_calcAggDelete(ReadRow readRow, ReadWriteRow readWriteRow) throws DataSetException{
  1309.     calcAggregate(readRow, readWriteRow);
  1310.   }
  1311.  
  1312.   /**
  1313.    * Method to calculate the aggregate columns
  1314.    * called by calcAggAdd and calcAggDelete.
  1315.    */
  1316.   void calcAggregate(ReadRow readRow, ReadWriteRow readWriteRow) throws DataSetException {
  1317.     double subTotal = readRow.getDouble("SUBTOTAL");
  1318.     // Calculate the Tax on the SubTotal
  1319.     double tax = subTotal * TAXPERCENT;
  1320.     readWriteRow.setDouble("TAX", tax);
  1321.     // Calculate the Shipping on the SubTotal
  1322.     double shipping = subTotal * SHIPPERCENT;
  1323.     readWriteRow.setDouble("SHIPPING", shipping);
  1324.     // Calculate the AmtDue                                      
  1325.     double amtPaid = orderDataSet.getDouble("AMTPAID");
  1326.     readWriteRow.setDouble("AMTDUE", ((subTotal + tax + shipping) - amtPaid));
  1327.   }
  1328.  
  1329.   /**
  1330.    * Event handler to calculate the values for all the calculated columns
  1331.    * for the Orders dataset.
  1332.    */
  1333.   void orderDataSet_calcFields(ReadRow readRow, DataRow dataRow, boolean boolean1) throws DataSetException{
  1334.     // Lookup the CustomerName for the current Order
  1335.     String custName = lookupCustomerName(readRow.getInt("CUSTOMERID"));
  1336.     dataRow.setString("CUSTOMERNAME", custName);
  1337.   }
  1338.  
  1339.   /**
  1340.    * Method to lookup the CustomerName given the customerID
  1341.    * This method also formats the name, taking care of the
  1342.    * middle initial.
  1343.    */
  1344.   private String lookupCustomerName(int customerID) {
  1345.     String customerName = new String("");
  1346.     try {
  1347.       // Define a DataRow to hold the customerID to look for
  1348.       // the Customer Dataset, and another to hold the row
  1349.       // of customer data that we find.
  1350.       customerDataSet.open();
  1351.       DataRow lookupRow = new DataRow(customerDataSet, "ID");
  1352.       DataRow customerRow = new DataRow(customerDataSet, new String[] {"FIRSTNAME", "MI", "LASTNAME"} );
  1353.  
  1354.       lookupRow.setInt("ID", customerID);
  1355.  
  1356.       if (customerDataSet.lookup(lookupRow, customerRow, Locate.FIRST)) {
  1357.         String firstName = customerRow.getString("FIRSTNAME");
  1358.         String mi        = customerRow.getString("MI");
  1359.         String lastName  = customerRow.getString("LASTNAME");
  1360.  
  1361.         // Format the customer name
  1362.         customerName = formatCustomerName(firstName, mi, lastName);
  1363.       }
  1364.     }
  1365.     catch (Exception e) {
  1366.       e.printStackTrace();
  1367.     };
  1368.     return customerName;
  1369.   }
  1370.  
  1371.   /**
  1372.    * Method to format a customer name given the first name, middle initial,
  1373.    * and last name.
  1374.    */
  1375.   private String formatCustomerName(String firstName, String mi, String lastName) {
  1376.     // Format the customer name
  1377.     if (mi.compareTo("") == 0)
  1378.       return (firstName + " " + lastName);
  1379.     else
  1380.       return (firstName + " " + mi + ". " + lastName);
  1381.   }
  1382.  
  1383.   /**
  1384.    * Event handler when the user changes the ProductID, update the SalePrice
  1385.    * accordingly by looking up the PRICE for the Product.
  1386.    */
  1387.   void colOrderItemProductID_changed(DataSet dataSet, Column column, Variant variant) throws DataSetException{
  1388.     double salePrice = lookupProductSalePrice(dataSet.getInt("PRODUCTID"));
  1389.     try {
  1390.       dataSet.startEdit(column);
  1391.       dataSet.setDouble("SALEPRICE", salePrice);
  1392.     }
  1393.     catch (Exception ex) {
  1394.       ex.printStackTrace();
  1395.     }
  1396.   }
  1397.  
  1398.   /**
  1399.    * Method to lookup the Product SalePrice given the ProductID.
  1400.    */
  1401.   private double lookupProductSalePrice(int productID) {
  1402.     double productSalePrice = 0.0;
  1403.     try {
  1404.       // Define a DataRow to hold the productID to look for
  1405.       // the Product Dataset, and another to hold the row
  1406.       // of product data that we find.
  1407.       productDataSet.open();
  1408.       DataRow lookupRow = new DataRow(productDataSet, "ID");
  1409.       DataRow productRow = new DataRow(productDataSet, new String[] {"BASEPRICE", "DISCOUNTPCT"} );
  1410.  
  1411.       lookupRow.setInt("ID", productID);
  1412.  
  1413.       if (productDataSet.lookup(lookupRow, productRow, Locate.FIRST)) {
  1414.         double basePrice   = productRow.getDouble("BASEPRICE");
  1415.         double discountPct = productRow.getDouble("DISCOUNTPCT");
  1416.         productSalePrice   = basePrice - (basePrice * (discountPct / 100));
  1417.       }
  1418.     }
  1419.     catch (Exception e) {
  1420.       e.printStackTrace();
  1421.     };
  1422.     return productSalePrice;
  1423.   }
  1424.  
  1425.  
  1426.   /**
  1427.    * Show an error dialog if error occurs during editing.
  1428.    */
  1429.   void orderItemDataSet_editError(DataSet dataSet, Column column, Variant variant, DataSetException dataSetException, ErrorResponse errorResponse) throws DataSetException{
  1430.     CliffhangerApplication.messageDlg(
  1431.       res.getString("DM_Error"),
  1432.       dataSetException.getMessage(),
  1433.       Message.OK);
  1434.   }
  1435.  
  1436.   /**
  1437.    * Show an error dialog if error occurs during adding.
  1438.    */
  1439.   void orderItemDataSet_addError(DataSet dataSet, ReadWriteRow readWriteRow, DataSetException dataSetException, ErrorResponse errorResponse) throws DataSetException{
  1440.     CliffhangerApplication.messageDlg(
  1441.       res.getString("DM_Error"),
  1442.       dataSetException.getMessage(),
  1443.       Message.OK);
  1444.   }
  1445.  
  1446.   /**
  1447.    * Show an error dialog if error occurs during updating.
  1448.    */
  1449.   void orderItemDataSet_updateError(DataSet dataSet, ReadWriteRow readWriteRow, DataSetException dataSetException, ErrorResponse errorResponse) throws DataSetException{
  1450.     CliffhangerApplication.messageDlg(
  1451.       res.getString("DM_Error"),
  1452.       dataSetException.getMessage(),
  1453.       Message.OK);
  1454.   }
  1455.  
  1456.  
  1457.  
  1458.   /**
  1459.    * Event handler when the CustomerID has changed get the Customer info
  1460.    * for the new customer ID.
  1461.    */
  1462.   void colOrdersCustomerID_changed(DataSet dataSet, Column column, Variant variant) throws DataSetException{
  1463.     try {
  1464.       // Define a DataRow to hold the productID to look for
  1465.       // the Product Dataset, and another to hold the row
  1466.       // of product data that we find.
  1467.       customerDataSet.open();
  1468.       DataRow lookupRow = new DataRow(customerDataSet, "ID");
  1469.       DataRow customerRow = new DataRow(
  1470.         customerDataSet,
  1471.         new String[] {
  1472.           "ADDR1",
  1473.           "ADDR2",
  1474.           "CITY",
  1475.           "STATE",
  1476.           "POSTALCODE",
  1477.           "COUNTRY",
  1478.           "SHIPNAME",
  1479.           "SHIPADDR1",
  1480.           "SHIPADDR2",
  1481.           "SHIPCITY",
  1482.           "SHIPSTATE",
  1483.           "SHIPPOSTALCODE",
  1484.           "SHIPCOUNTRY"
  1485.         }
  1486.       );
  1487.       lookupRow.setInt("ID", dataSet.getInt("CUSTOMERID"));
  1488.  
  1489.       if (customerDataSet.lookup(lookupRow, customerRow, Locate.FIRST)) {
  1490.         dataSet.startEdit(column);
  1491.         dataSet.setString("BILLADDR1",      customerRow.getString("ADDR1"));
  1492.         dataSet.setString("BILLADDR2",      customerRow.getString("ADDR2"));
  1493.         dataSet.setString("BILLCITY",       customerRow.getString("CITY"));
  1494.         dataSet.setString("BILLSTATE",      customerRow.getString("STATE"));
  1495.         dataSet.setString("BILLPOSTALCODE", customerRow.getString("POSTALCODE"));
  1496.         dataSet.setString("BILLCOUNTRY",    customerRow.getString("COUNTRY"));
  1497.         dataSet.setString("SHIPNAME",       customerRow.getString("SHIPNAME"));
  1498.         dataSet.setString("SHIPADDR1",      customerRow.getString("SHIPADDR1"));
  1499.         dataSet.setString("SHIPADDR2",      customerRow.getString("SHIPADDR2"));
  1500.         dataSet.setString("SHIPCITY",       customerRow.getString("SHIPCITY"));
  1501.         dataSet.setString("SHIPSTATE",      customerRow.getString("SHIPSTATE"));
  1502.         dataSet.setString("SHIPPOSTALCODE", customerRow.getString("SHIPPOSTALCODE"));
  1503.         dataSet.setString("SHIPCOUNTRY",    customerRow.getString("SHIPCOUNTRY"));
  1504.       }
  1505.     }
  1506.     catch (Exception e) {
  1507.       e.printStackTrace();
  1508.     };
  1509.   }
  1510.  
  1511.   /**
  1512.    * NOTE:
  1513.    * The issue of applying changes to the quantity of a product in the
  1514.    * Product table can be approached in two ways:
  1515.    * 1. Apply quantity changes to our client Product dataset and resolve
  1516.    *    the changes together when we resolve Orders and OrderItem datasets.
  1517.    * 2. Create a trigger on the database server for a BeforeInsert on the
  1518.    *    OrderItem table which could in turn call a stored procedure to
  1519.    *    make the necessary quantity changes to the Product table.
  1520.    * We have chosen to use method #1 to show case how you could do so on the
  1521.    * client, although it could be more realistic to use a stored procedure.
  1522.    */
  1523.  
  1524.  
  1525.   /**
  1526.    * This method updates the StockQty column of the Product dataset
  1527.    * checking that the resulting StockQty value does not go below 0.
  1528.    */
  1529.   private void subtractProductStockQty(int productID, int orderedQty) throws Exception {
  1530.     // Define a DataRow to hold the productID to locate in
  1531.     // the Product Dataset.
  1532.     productDataSet.open();
  1533.     DataRow locateRow = new DataRow(productDataSet, "ID");
  1534.     locateRow.setInt("ID", productID);
  1535.  
  1536.     if (productDataSet.locate(locateRow, Locate.FIRST)) {
  1537.       int stockQty = productDataSet.getInt("STOCKQTY");
  1538.       // make sure that (stockQty - orderedQty) >= 0
  1539.       int remainingQty = stockQty - orderedQty;
  1540.       if (remainingQty < 0) {
  1541.         throw new DataSetException(DataSetException.FIELD_POST_ERROR,
  1542.                                    res.getString("DM_Insufficient_stock"));
  1543.       }
  1544.       else {
  1545.         // make the changes to the product dataset
  1546.         productDataSet.editRow();
  1547.         productDataSet.setInt("STOCKQTY", remainingQty);
  1548.         productDataSet.post();
  1549.       } //else
  1550.     } //if
  1551.   }
  1552.  
  1553.   /**
  1554.    * This method is called when an exception is thrown during resolution
  1555.    * of modifications to a row in the Product DataSet.
  1556.    * Here we will try to refetch the row and retry the resolution.
  1557.    */
  1558.   void resProduct_updateError(DataSet dataSet, ReadWriteRow readWriteRow, ReadRow readRow, ReadWriteRow readWriteRow1, DataSetException dataSetException, ErrorResponse errorResponse) throws DataSetException{
  1559.     if (dataSetException.getErrorCode() == DataSetException.NO_ROWS_AFFECTED) {
  1560.       // refetch the row and make the necessary changes.
  1561.       dataSet.refetchRow(readWriteRow1);
  1562.       int updStockQty = readWriteRow1.getInt("STOCKQTY");
  1563.  
  1564.       // Determine the change in the row
  1565.       int oldStockQty = readRow.getInt("STOCKQTY");
  1566.       int newStockQty = readWriteRow.getInt("STOCKQTY");
  1567.       int qtyDifference = newStockQty - oldStockQty;
  1568.  
  1569.       // We will only attempt to make changes to the StockQty column here
  1570.       if (oldStockQty != updStockQty) {
  1571.         int updRemainingQty = updStockQty + qtyDifference;
  1572.         if (updRemainingQty >= 0) {
  1573.           readWriteRow.setInt("STOCKQTY", updRemainingQty);
  1574.           errorResponse.retry();
  1575.         }
  1576.         else
  1577.           errorResponse.abort();
  1578.       }
  1579.     }
  1580.   }
  1581.  
  1582.   /**
  1583.    * Do some row validation before adding new Order record
  1584.    * or before updating Order record.
  1585.    */
  1586.   private void validateOrderRow() throws Exception {
  1587.     // In validating an Order record check the following:
  1588.     // - must have valid CustomerId
  1589.     // - must have valid OrderDate
  1590.     // - must have valid Status
  1591.     if ( orderDataSet.isNull("CUSTOMERID") || (orderDataSet.getInt("CUSTOMERID") <= 0) )
  1592.       throw new VetoException(res.getString("DM_Invalid_customer"));
  1593.     if ( orderDataSet.isNull("ORDERDATE") )
  1594.       throw new VetoException(res.getString("DM_Invalid_order_date"));
  1595.     if ( orderDataSet.isNull("STATUS") || (orderDataSet.getString("STATUS").trim().compareTo("") == 0))
  1596.       throw new VetoException(res.getString("DM_Invalid_status"));
  1597.     if ( orderDataSet.isNull("PAYMETHOD") || (orderDataSet.getString("PAYMETHOD").trim().compareTo("") == 0))
  1598.       throw new VetoException(res.getString("DM_Invalid_paymethod"));
  1599.   }
  1600.  
  1601.   /**
  1602.    * Do some row validation before adding new OrderItem record
  1603.    * or before updating OrderItem record.
  1604.    */
  1605.   private void validateOrderItemRow() throws Exception {
  1606.     // validate only if posting from editing or inserting
  1607.     //if (!(orderItemDataSet.isEditing() || orderItemDataSet.isEditingNewRow())) return;
  1608.  
  1609.     // In validating an OrderItem record check the following:
  1610.     // - must have valid ProductId
  1611.     // - must have valid Qty
  1612.     if ( orderItemDataSet.isNull("PRODUCTID") || (orderItemDataSet.getInt("PRODUCTID") <= 0) )
  1613.       throw new VetoException(res.getString("DM_Invalid_product"));
  1614.     if ( orderItemDataSet.isNull("QTY") || (orderItemDataSet.getInt("QTY") <= 0) )
  1615.       throw new VetoException(res.getString("DM_Invalid_product_quantity"));
  1616.   }
  1617.  
  1618.   /**
  1619.    * Do some row validation before adding new product record
  1620.    * or before updating product record.
  1621.    */
  1622.   private void validateProductRow() throws Exception{
  1623.     // In validating an product record check the following:
  1624.     // - must have valid Name
  1625.     // - must have valid Category
  1626.     // - must have valid BasePrice
  1627.     // - must have valid DiscountPct, but min and max contraints take care of that
  1628.     // - must have valid StockQty
  1629.     // - must have valid MinReorderQty
  1630.     if ( productDataSet.isNull("NAME") || (productDataSet.getString("NAME").trim().compareTo("") == 0) )
  1631.       throw new VetoException(res.getString("DM_Invalid_product_name"));
  1632.     if ( productDataSet.isNull("CATEGORY") || (productDataSet.getString("CATEGORY").trim().compareTo("") == 0) )
  1633.       throw new VetoException(res.getString("DM_Invalid_product_category"));
  1634.     if ( productDataSet.isNull("BASEPRICE") || (productDataSet.getDouble("BASEPRICE") < 0.0) )
  1635.       throw new VetoException(res.getString("DM_Invalid_base_price"));
  1636.     if ( productDataSet.isNull("STOCKQTY") || (productDataSet.getInt("STOCKQTY") < 0) )
  1637.       throw new VetoException(res.getString("DM_Invalid_stock_qty"));
  1638.     if ( productDataSet.isNull("MINREORDERQTY") || (productDataSet.getInt("MINREORDERQTY") < 0) )
  1639.       throw new VetoException(res.getString("DM_Invalid_min_reorder_qty"));
  1640.     if ( productDataSet.isNull("ISACTIVE") || (productDataSet.getShort("ISACTIVE") < 0) )
  1641.       throw new VetoException(res.getString("DM_Invalid_active_value"));
  1642.   }
  1643.  
  1644.   /**
  1645.    * Do some row validation before adding new customer record
  1646.    * or before updating customer record.
  1647.    */
  1648.   private void validateCustomerRow() throws Exception {
  1649.     // In validating an customer record check the following:
  1650.     // - must have valid Name i.e. FirstName and LastName cannot both be blank
  1651.     if ( customerDataSet.isNull("FIRSTNAME") ||
  1652.         (customerDataSet.getString("FIRSTNAME").trim().compareTo("") == 0) )
  1653.       throw new VetoException(res.getString("DM_Invalid_first_name"));
  1654.     if ( customerDataSet.isNull("LASTNAME") ||
  1655.         (customerDataSet.getString("LASTNAME").trim().compareTo("") == 0) )
  1656.       throw new VetoException(res.getString("DM_Invalid_last_name"));
  1657.     if ( customerDataSet.isNull("PHONE") ||
  1658.         (customerDataSet.getString("PHONE").trim().compareTo("") == 0) )
  1659.       throw new VetoException(res.getString("DM_Invalid_phone"));
  1660.   }
  1661.  
  1662.   /**
  1663.    * Do some row validation before adding new category record
  1664.    * or before updating category record.
  1665.    */
  1666.   private void validateCategoryRow() throws Exception {
  1667.     // In validating an category record check the following:
  1668.     // - must have valid Category
  1669.     if ( categoryDataSet.isNull("CATEGORY") ||
  1670.         (categoryDataSet.getString("CATEGORY").trim().compareTo("") == 0) )
  1671.       //throw new DataSetException(DataSetException.FIELD_POST_ERROR,
  1672.       //                           res.getString("DM_Invalid_category_name"));
  1673.       throw new VetoException(res.getString("DM_Invalid_category_name"));
  1674.   }
  1675.  
  1676.  
  1677.  
  1678.   /**
  1679.    * When the STATUS column of the order is changed to "Fulfilled", then
  1680.    * set the ShipDate column to today's date.
  1681.    */
  1682.   void colOrdersStatus_changed(DataSet dataSet, Column column, Variant variant) throws DataSetException{
  1683.     if (variant.getString().compareTo(res.getString("DM_Fulfilled")) == 0) {
  1684.       // The SHIPDATE column is declared as type DATE in the Interbase
  1685.       // server as well as the persistent Column object colOrdersShipDate.
  1686.       // But we are getting the error "Unexpected type: TIMESTAMP Expected type:
  1687.       // DATE" if we use the setDate() method instead of the setTimestamp()
  1688.       // method:
  1689.       dataSet.setTimestamp("SHIPDATE", System.currentTimeMillis());
  1690.     }
  1691.   }
  1692.  
  1693.   /**
  1694.    * When the PayMethod column is changed to "CLIFFCARD", validate to make sure
  1695.    * that the customer has a valid Cliffhanger account in the accountDataSet.
  1696.    * If so, fill the CreditCard number.
  1697.    */
  1698.   void colOrdersPayMethod_validate(DataSet dataSet, Column column, Variant variant) throws Exception{
  1699.     if (variant.getString().compareTo(res.getString("DM_CLIFFCARD")) == 0) {
  1700.       // Lookup the CreditCardNumber for the current customer
  1701.       int customerID = dataSet.getInt("CUSTOMERID");
  1702.       if (customerID <= 0) {
  1703.         throw new VetoException(res.getString("DM_Invalid_customer"));
  1704.       }
  1705.  
  1706.       String creditCardNum = lookupCreditCardNumber(customerID);
  1707.       if (creditCardNum.compareTo("") == 0) {
  1708.         throw new VetoException(res.getString("DM_Non_Cliffcard_member"));
  1709.       }
  1710.       else {
  1711.         dataSet.setString("CREDITCARDNUM", creditCardNum);
  1712.       }
  1713.     }
  1714.   }
  1715.  
  1716.   /**
  1717.    * Method to lookup the CreditCardNumber given the customerID
  1718.    */
  1719.   private String lookupCreditCardNumber(int customerID) {
  1720.     String creditCardNum = new String("");
  1721.     try {
  1722.       // Define a DataRow to hold the customerID to look for
  1723.       // the Account Dataset, and another to hold the row
  1724.       // of account data that we find.
  1725.       accountDataSet.open();
  1726.       DataRow lookupRow = new DataRow(accountDataSet, "ID");
  1727.       DataRow accountRow = new DataRow(accountDataSet, new String[] {"ID", "CREDITCARDNUMBER"} );
  1728.  
  1729.       lookupRow.setInt("ID", customerID);
  1730.  
  1731.       if (accountDataSet.lookup(lookupRow, accountRow, Locate.FIRST)) {
  1732.         creditCardNum = accountRow.getString("CREDITCARDNUMBER");
  1733.       }
  1734.     }
  1735.     catch (Exception e) {
  1736.       e.printStackTrace();
  1737.     };
  1738.     return creditCardNum;
  1739.   }
  1740.  
  1741.   /**
  1742.    * When the AmtPaid column changes, recalculate the aggregate totals for
  1743.    * the order items dataset.
  1744.    */
  1745.   void colOrdersAmtPaid_changed(DataSet dataSet, Column column, Variant variant) throws DataSetException{
  1746.     // To force the orderItemDataSet to recalculate the Aggregate columns, we
  1747.     // want to trigger the calcAggAdd event of the orderItemDataSet.
  1748.     // Do a dummy edit to the current record assigning the ID of the order
  1749.     // record to the OrderID column.
  1750.     if (orderItemDataSet.getRowCount() > 0) {
  1751.       orderItemDataSet.editRow();
  1752.       orderItemDataSet.setInt("ORDERID", dataSet.getInt("ID"));
  1753.       orderItemDataSet.post();
  1754.     }
  1755.   }
  1756.  
  1757.   void orderDataSet_modifying(DataSet dataSet) throws Exception{
  1758.     // Do not allow edits if the Order record
  1759.     // STATUS value is Fulfilled.
  1760.     String status = orderDataSet.getString("STATUS");
  1761.     if (status.compareTo(res.getString("DM_Fulfilled")) == 0) {
  1762.       // Show the message dialog here because there is
  1763.       // no error event handler for modifying event errors.
  1764.       CliffhangerApplication.messageDlg(
  1765.         res.getString("DM_Error"),
  1766.         res.getString("DM_Cannot_modify_order"),
  1767.         Message.OK);
  1768.       throw new VetoException(res.getString("DM_Cannot_modify_order"));
  1769.     }
  1770.   }
  1771. }
  1772.  
  1773. class DataModule1_orderItemDataSet_calcFieldsAdapter implements borland.jbcl.dataset.CalcFieldsListener{
  1774.   DataModule1 adaptee;
  1775.  
  1776.   DataModule1_orderItemDataSet_calcFieldsAdapter(DataModule1 adaptee) {
  1777.     this.adaptee = adaptee;
  1778.   }
  1779.  
  1780.   public void calcFields(ReadRow readRow, DataRow dataRow, boolean boolean1) throws DataSetException, DataSetException{
  1781.     adaptee.orderItemDataSet_calcFields(readRow, dataRow, boolean1);
  1782.   }
  1783. }
  1784.  
  1785. class DataModule1_orderItemDataSet_calcAggFieldsAdapter extends borland.jbcl.dataset.CalcAggFieldsAdapter {
  1786.   DataModule1 adaptee;
  1787.  
  1788.   DataModule1_orderItemDataSet_calcAggFieldsAdapter(DataModule1 adaptee) {
  1789.     this.adaptee = adaptee;
  1790.   }
  1791.  
  1792.   public void calcAggAdd(ReadRow readRow, ReadWriteRow readWriteRow) throws DataSetException, DataSetException{
  1793.     adaptee.orderItemDataSet_calcAggAdd(readRow, readWriteRow);
  1794.   }
  1795.  
  1796.   public void calcAggDelete(ReadRow readRow, ReadWriteRow readWriteRow) throws DataSetException{
  1797.     adaptee.orderItemDataSet_calcAggDelete(readRow, readWriteRow);
  1798.   }
  1799. }
  1800.  
  1801. class DataModule1_orderDataSet_calcFieldsAdapter implements borland.jbcl.dataset.CalcFieldsListener{
  1802.   DataModule1 adaptee;
  1803.  
  1804.   DataModule1_orderDataSet_calcFieldsAdapter(DataModule1 adaptee) {
  1805.     this.adaptee = adaptee;
  1806.   }
  1807.  
  1808.   public void calcFields(ReadRow readRow, DataRow dataRow, boolean boolean1) throws DataSetException, DataSetException{
  1809.     adaptee.orderDataSet_calcFields(readRow, dataRow, boolean1);
  1810.   }
  1811. }
  1812.  
  1813. class DataModule1_colOrderItemProductID_columnChangeAdapter extends borland.jbcl.dataset.ColumnChangeAdapter {
  1814.   DataModule1 adaptee;
  1815.  
  1816.   DataModule1_colOrderItemProductID_columnChangeAdapter(DataModule1 adaptee) {
  1817.     this.adaptee = adaptee;
  1818.   }
  1819.  
  1820.   public void changed(DataSet dataSet, Column column, Variant variant) throws DataSetException{
  1821.     adaptee.colOrderItemProductID_changed(dataSet, column, variant);
  1822.   }
  1823. }
  1824.  
  1825. class DataModule1_colOrdersCustomerID_columnChangeAdapter extends borland.jbcl.dataset.ColumnChangeAdapter {
  1826.   DataModule1 adaptee;
  1827.  
  1828.   DataModule1_colOrdersCustomerID_columnChangeAdapter(DataModule1 adaptee) {
  1829.     this.adaptee = adaptee;
  1830.   }
  1831.  
  1832.   public void changed(DataSet dataSet, Column column, Variant variant) throws DataSetException{
  1833.     adaptee.colOrdersCustomerID_changed(dataSet, column, variant);
  1834.   }
  1835. }
  1836.  
  1837. class DataModule1_orderItemDataSet_editAdapter extends borland.jbcl.dataset.EditAdapter {
  1838.   DataModule1 adaptee;
  1839.  
  1840.   DataModule1_orderItemDataSet_editAdapter(DataModule1 adaptee) {
  1841.     this.adaptee = adaptee;
  1842.   }
  1843.  
  1844.   public void adding(DataSet dataSet, ReadWriteRow readWriteRow) throws Exception{
  1845.     adaptee.orderItemDataSet_adding(dataSet, readWriteRow);
  1846.   }
  1847.  
  1848.   public void updating(DataSet dataSet, ReadWriteRow readWriteRow, ReadRow readRow) throws Exception{
  1849.     adaptee.orderItemDataSet_updating(dataSet, readWriteRow, readRow);
  1850.   }
  1851.  
  1852.   public void deleting(DataSet dataSet) throws Exception{
  1853.     adaptee.orderItemDataSet_deleting(dataSet);
  1854.   }
  1855.  
  1856.   public void modifying(DataSet dataSet) throws Exception{
  1857.     adaptee.orderItemDataSet_modifying(dataSet);
  1858.   }
  1859.  
  1860.   public void inserting(DataSet dataSet) throws Exception{
  1861.     adaptee.orderItemDataSet_inserting(dataSet);
  1862.   }
  1863.  
  1864.   public void canceling(DataSet dataSet) throws Exception{
  1865.     adaptee.orderItemDataSet_canceling(dataSet);
  1866.   }
  1867.  
  1868.   public void editError(DataSet dataSet, Column column, Variant variant, DataSetException dataSetException, ErrorResponse errorResponse) throws DataSetException{
  1869.     adaptee.orderItemDataSet_editError(dataSet, column, variant, dataSetException, errorResponse);
  1870.   }
  1871.  
  1872.   public void addError(DataSet dataSet, ReadWriteRow readWriteRow, DataSetException dataSetException, ErrorResponse errorResponse) throws DataSetException{
  1873.     adaptee.orderItemDataSet_addError(dataSet, readWriteRow, dataSetException, errorResponse);
  1874.   }
  1875.  
  1876.   public void updateError(DataSet dataSet, ReadWriteRow readWriteRow, DataSetException dataSetException, ErrorResponse errorResponse) throws DataSetException{
  1877.     adaptee.orderItemDataSet_updateError(dataSet, readWriteRow, dataSetException, errorResponse);
  1878.   }
  1879. }
  1880.  
  1881. class DataModule1_resProduct_resolverAdapter extends borland.jbcl.dataset.ResolverAdapter {
  1882.   DataModule1 adaptee;
  1883.  
  1884.   DataModule1_resProduct_resolverAdapter(DataModule1 adaptee) {
  1885.     this.adaptee = adaptee;
  1886.   }
  1887.  
  1888.   public void updateError(DataSet dataSet, ReadWriteRow readWriteRow, ReadRow readRow, ReadWriteRow readWriteRow1, DataSetException dataSetException, ErrorResponse errorResponse) throws DataSetException{
  1889.     adaptee.resProduct_updateError(dataSet, readWriteRow, readRow, readWriteRow1, dataSetException, errorResponse);
  1890.   }
  1891. }
  1892.  
  1893. class DataModule1_customerDataSet_editAdapter extends borland.jbcl.dataset.EditAdapter {
  1894.   DataModule1 adaptee;
  1895.  
  1896.   DataModule1_customerDataSet_editAdapter(DataModule1 adaptee) {
  1897.     this.adaptee = adaptee;
  1898.   }
  1899.  
  1900.   public void adding(DataSet dataSet, ReadWriteRow readWriteRow) throws Exception{
  1901.     adaptee.customerDataSet_adding(dataSet, readWriteRow);
  1902.   }
  1903.  
  1904.   public void deleting(DataSet dataSet) throws Exception{
  1905.     adaptee.customerDataSet_deleting(dataSet);
  1906.   }
  1907.  
  1908.   public void added(DataSet dataSet) throws DataSetException{
  1909.     adaptee.customerDataSet_added(dataSet);
  1910.   }
  1911.  
  1912.   public void updated(DataSet dataSet) throws DataSetException{
  1913.     adaptee.customerDataSet_updated(dataSet);
  1914.   }
  1915.  
  1916.   public void deleted(DataSet dataSet) throws DataSetException{
  1917.     adaptee.customerDataSet_deleted(dataSet);
  1918.   }
  1919.  
  1920.   public void updating(DataSet dataSet, ReadWriteRow readWriteRow, ReadRow readRow) throws Exception{
  1921.     adaptee.customerDataSet_updating(dataSet, readWriteRow, readRow);
  1922.   }
  1923.  
  1924.   public void canceling(DataSet dataSet) throws Exception{
  1925.     adaptee.customerDataSet_canceling(dataSet);
  1926.   }
  1927.  
  1928.   public void editError(DataSet dataSet, Column column, Variant variant, DataSetException dataSetException, ErrorResponse errorResponse) throws DataSetException{
  1929.     adaptee.customerDataSet_editError(dataSet, column, variant, dataSetException, errorResponse);
  1930.   }
  1931.  
  1932.   public void addError(DataSet dataSet, ReadWriteRow readWriteRow, DataSetException dataSetException, ErrorResponse errorResponse) throws DataSetException{
  1933.     adaptee.customerDataSet_addError(dataSet, readWriteRow, dataSetException, errorResponse);
  1934.   }
  1935.  
  1936.   public void updateError(DataSet dataSet, ReadWriteRow readWriteRow, DataSetException dataSetException, ErrorResponse errorResponse) throws DataSetException{
  1937.     adaptee.customerDataSet_updateError(dataSet, readWriteRow, dataSetException, errorResponse);
  1938.   }
  1939. }
  1940.  
  1941. class DataModule1_orderDataSet_editAdapter extends borland.jbcl.dataset.EditAdapter {
  1942.   DataModule1 adaptee;
  1943.  
  1944.   DataModule1_orderDataSet_editAdapter(DataModule1 adaptee) {
  1945.     this.adaptee = adaptee;
  1946.   }
  1947.  
  1948.   public void deleting(DataSet dataSet) throws Exception{
  1949.     adaptee.orderDataSet_deleting(dataSet);
  1950.   }
  1951.  
  1952.   public void adding(DataSet dataSet, ReadWriteRow readWriteRow) throws Exception{
  1953.     adaptee.orderDataSet_adding(dataSet, readWriteRow);
  1954.   }
  1955.  
  1956.   public void updating(DataSet dataSet, ReadWriteRow readWriteRow, ReadRow readRow) throws Exception{
  1957.     adaptee.orderDataSet_updating(dataSet, readWriteRow, readRow);
  1958.   }
  1959.  
  1960.   public void canceling(DataSet dataSet) throws Exception{
  1961.     adaptee.orderDataSet_canceling(dataSet);
  1962.   }
  1963.  
  1964.   public void editError(DataSet dataSet, Column column, Variant variant, DataSetException dataSetException, ErrorResponse errorResponse) throws DataSetException{
  1965.     adaptee.orderDataSet_editError(dataSet, column, variant, dataSetException, errorResponse);
  1966.   }
  1967.  
  1968.   public void addError(DataSet dataSet, ReadWriteRow readWriteRow, DataSetException dataSetException, ErrorResponse errorResponse) throws DataSetException{
  1969.     adaptee.orderDataSet_addError(dataSet, readWriteRow, dataSetException, errorResponse);
  1970.   }
  1971.  
  1972.   public void updateError(DataSet dataSet, ReadWriteRow readWriteRow, DataSetException dataSetException, ErrorResponse errorResponse) throws DataSetException{
  1973.     adaptee.orderDataSet_updateError(dataSet, readWriteRow, dataSetException, errorResponse);
  1974.   }
  1975.  
  1976.   public void modifying(DataSet dataSet) throws Exception{
  1977.     adaptee.orderDataSet_modifying(dataSet);
  1978.   }
  1979. }
  1980.  
  1981. class DataModule1_categoryDataSet_editAdapter extends borland.jbcl.dataset.EditAdapter {
  1982.   DataModule1 adaptee;
  1983.  
  1984.   DataModule1_categoryDataSet_editAdapter(DataModule1 adaptee) {
  1985.     this.adaptee = adaptee;
  1986.   }
  1987.  
  1988.   public void deleting(DataSet dataSet) throws Exception{
  1989.     adaptee.categoryDataSet_deleting(dataSet);
  1990.   }
  1991.  
  1992.   public void deleted(DataSet dataSet) throws DataSetException{
  1993.     adaptee.categoryDataSet_deleted(dataSet);
  1994.   }
  1995.  
  1996.   public void added(DataSet dataSet) throws DataSetException{
  1997.     adaptee.categoryDataSet_added(dataSet);
  1998.   }
  1999.  
  2000.   public void updated(DataSet dataSet) throws DataSetException{
  2001.     adaptee.categoryDataSet_updated(dataSet);
  2002.   }
  2003.  
  2004.   public void adding(DataSet dataSet, ReadWriteRow readWriteRow) throws Exception{
  2005.     adaptee.categoryDataSet_adding(dataSet, readWriteRow);
  2006.   }
  2007.  
  2008.   public void canceling(DataSet dataSet) throws Exception{
  2009.     adaptee.categoryDataSet_canceling(dataSet);
  2010.   }
  2011.  
  2012.   public void updating(DataSet dataSet, ReadWriteRow readWriteRow, ReadRow readRow) throws Exception{
  2013.     adaptee.categoryDataSet_updating(dataSet, readWriteRow, readRow);
  2014.   }
  2015.  
  2016.   public void editError(DataSet dataSet, Column column, Variant variant, DataSetException dataSetException, ErrorResponse errorResponse) throws DataSetException{
  2017.     adaptee.categoryDataSet_editError(dataSet, column, variant, dataSetException, errorResponse);
  2018.   }
  2019.  
  2020.   public void addError(DataSet dataSet, ReadWriteRow readWriteRow, DataSetException dataSetException, ErrorResponse errorResponse) throws DataSetException{
  2021.     adaptee.categoryDataSet_addError(dataSet, readWriteRow, dataSetException, errorResponse);
  2022.   }
  2023.  
  2024.   public void updateError(DataSet dataSet, ReadWriteRow readWriteRow, DataSetException dataSetException, ErrorResponse errorResponse) throws DataSetException{
  2025.     adaptee.categoryDataSet_updateError(dataSet, readWriteRow, dataSetException, errorResponse);
  2026.   }
  2027. }
  2028.  
  2029. class DataModule1_colOrdersStatus_columnChangeAdapter extends borland.jbcl.dataset.ColumnChangeAdapter {
  2030.   DataModule1 adaptee;
  2031.  
  2032.   DataModule1_colOrdersStatus_columnChangeAdapter(DataModule1 adaptee) {
  2033.     this.adaptee = adaptee;
  2034.   }
  2035.  
  2036.   public void changed(DataSet dataSet, Column column, Variant variant) throws DataSetException{
  2037.     adaptee.colOrdersStatus_changed(dataSet, column, variant);
  2038.   }
  2039. }
  2040.  
  2041. class DataModule1_productDataSet_editAdapter extends borland.jbcl.dataset.EditAdapter {
  2042.   DataModule1 adaptee;
  2043.  
  2044.   DataModule1_productDataSet_editAdapter(DataModule1 adaptee) {
  2045.     this.adaptee = adaptee;
  2046.   }
  2047.  
  2048.   public void deleting(DataSet dataSet) throws Exception{
  2049.     adaptee.productDataSet_deleting(dataSet);
  2050.   }
  2051.  
  2052.   public void added(DataSet dataSet) throws DataSetException{
  2053.     adaptee.productDataSet_added(dataSet);
  2054.   }
  2055.  
  2056.   public void updated(DataSet dataSet) throws DataSetException{
  2057.     adaptee.productDataSet_updated(dataSet);
  2058.   }
  2059.  
  2060.   public void deleted(DataSet dataSet) throws DataSetException{
  2061.     adaptee.productDataSet_deleted(dataSet);
  2062.   }
  2063.  
  2064.   public void adding(DataSet dataSet, ReadWriteRow readWriteRow) throws Exception{
  2065.     adaptee.productDataSet_adding(dataSet, readWriteRow);
  2066.   }
  2067.  
  2068.   public void updating(DataSet dataSet, ReadWriteRow readWriteRow, ReadRow readRow) throws Exception{
  2069.     adaptee.productDataSet_updating(dataSet, readWriteRow, readRow);
  2070.   }
  2071.  
  2072.   public void canceling(DataSet dataSet) throws Exception{
  2073.     adaptee.productDataSet_canceling(dataSet);
  2074.   }
  2075.  
  2076.   public void editError(DataSet dataSet, Column column, Variant variant, DataSetException dataSetException, ErrorResponse errorResponse) throws DataSetException{
  2077.     adaptee.productDataSet_editError(dataSet, column, variant, dataSetException, errorResponse);
  2078.   }
  2079.  
  2080.   public void addError(DataSet dataSet, ReadWriteRow readWriteRow, DataSetException dataSetException, ErrorResponse errorResponse) throws DataSetException{
  2081.     adaptee.productDataSet_addError(dataSet, readWriteRow, dataSetException, errorResponse);
  2082.   }
  2083.  
  2084.   public void updateError(DataSet dataSet, ReadWriteRow readWriteRow, DataSetException dataSetException, ErrorResponse errorResponse) throws DataSetException{
  2085.     adaptee.productDataSet_updateError(dataSet, readWriteRow, dataSetException, errorResponse);
  2086.   }
  2087. }
  2088.  
  2089. class DataModule1_colOrdersPayMethod_columnChangeAdapter extends borland.jbcl.dataset.ColumnChangeAdapter {
  2090.   DataModule1 adaptee;
  2091.  
  2092.   DataModule1_colOrdersPayMethod_columnChangeAdapter(DataModule1 adaptee) {
  2093.     this.adaptee = adaptee;
  2094.   }
  2095.  
  2096.   public void validate(DataSet dataSet, Column column, Variant variant) throws Exception{
  2097.     adaptee.colOrdersPayMethod_validate(dataSet, column, variant);
  2098.   }
  2099. }
  2100.  
  2101. class DataModule1_colOrdersAmtPaid_columnChangeAdapter extends borland.jbcl.dataset.ColumnChangeAdapter {
  2102.   DataModule1 adaptee;
  2103.  
  2104.   DataModule1_colOrdersAmtPaid_columnChangeAdapter(DataModule1 adaptee) {
  2105.     this.adaptee = adaptee;
  2106.   }
  2107.  
  2108.   public void changed(DataSet dataSet, Column column, Variant variant) throws DataSetException{
  2109.     adaptee.colOrdersAmtPaid_changed(dataSet, column, variant);
  2110.   }
  2111. }
  2112.