home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / DBServ / SAMPLES / SAMPLES.ZIP / ORDERS / OrderFormAppJDBC.java < prev    next >
Encoding:
Java Source  |  1997-02-21  |  94.2 KB  |  2,215 lines

  1. /**************************************************************************************************
  2. *                                                                                                 *
  3. *  Class name:  OrderFormAppJDBC                                                                  *
  4. *     Purpose:  This applet accesses the Sales Order, Sales Order Items, Product, Employee,       *
  5. *               Customer, and Department tables.  OrderFormAppJDBC simulates a real order form    *
  6. *               allowing users to add new orders to the tables mentioned above.  Additionally,    *
  7. *               this applet allows you to search for orders from any field, edit an existing      *
  8. *               order, and provides basic database functionality (e.g., First, Next, Delete)      *
  9. *                                                                                                 *
  10. *     Imports:  import java.applet.Applet;                                                        *
  11. *               import java.awt.*;                                                                *
  12. *               import java.lang.Thread;                                                          *
  13. *               import java.lang.String;                                                          *
  14. *               import symjava.sql.*;                                                             *
  15. *               import java.util.Properties;                                                      *
  16. *                                                                                                 *
  17. *  Methods Include:  final void clear_record()                                                    *
  18. *                    final void close_server()                                                    *
  19. *                    final void connect_server()                                                  *
  20. *                    final ResultSet generate_ResultSet()                                         *
  21. *                    final boolean move()                                                         *
  22. *                    final void save_info()                                                       *
  23. *                    final void show_information()                                                *
  24. *                    final void update_delete()                                                   *
  25. *                    public boolean handleEvent()                                                 *
  26. *                                                                                                 *
  27. * Additional Notes:                                                                               *
  28. * THIS SOFTWARE HAS BEEN COMPILED AND EXECUTED SUCCESSFULLY IN SPECIFIC SYMANTEC                  *
  29. * ENVIRONMENTS, AND IS BEING PROVIDED ONLY AS SAMPLE CODE.                                        *
  30. *                                                                                                 *
  31. * SYMANTEC MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE SOFTWARE,          *
  32. * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF               *
  33. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.  SYMANTEC SHALL NOT     *
  34. * BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING, OR DISTRIBUTING *
  35. * THIS SOFTWARE OR ITS DERIVATIVES.                                                               *
  36. *                                                                                                 *
  37. *  Please see the Sample Code Configuration  item in the Read Me file for additional              *
  38. *  information about the sample database  used in this applet.
  39. *
  40. * Copyright (c) 1996 Symantec.  All Rights Reserved.
  41. *
  42. *                                                                                                 *
  43. ***************************************************************************************************/
  44.  
  45. import java.applet.Applet;
  46. import java.awt.*;
  47. import java.lang.Thread;
  48. import java.lang.String;
  49. import symjava.sql.*;
  50. import symjava.math.BigDecimal;
  51. import java.util.Properties;
  52.  
  53. public class OrderFormAppJDBC extends Applet {
  54.  
  55.     public void init() {
  56.         // Initialize Properties
  57.         props.put("user","dba");
  58.         props.put("password","sql");
  59.  
  60.         // Set the font for everything but output
  61.         this.setFont(hel_reg_font);
  62.  
  63.         // Initialize Background and Text Color
  64.         this.setBackground(Color.white);
  65.         this.setForeground(Color.black);
  66.  
  67.         super.init();
  68.  
  69.         // Initialize Buttons
  70.         browse_button = new Button("Go to Browse Mode");
  71.         add_button = new Button("Go to Add/Edit Mode");
  72.         save_button = new Button("Save");
  73.         delete_button = new Button("Delete");
  74.         edit_button = new Button("Edit");
  75.         clear_button = new Button("Clear Record");
  76.         first_button = new Button("<<");
  77.         next_button = new Button(">");
  78.         search_button = new Button("Search");
  79.  
  80.         add_item_button = new Button("Add Item");
  81.         edit_item_button = new Button("Update Item");
  82.         delete_item_button = new Button("Delete Item");
  83.         clear_item_button = new Button("Clear Item");
  84.         quit_button = new Button("Quit");
  85.         confirm_button = new Button("Confirm Action");
  86.  
  87.         // Initialize Choices
  88.         empl_dept = new Choice();
  89.         empl_dept.addItem("");
  90.         empl_dept.addItem("Finance");
  91.         empl_dept.addItem("Marketing");
  92.         empl_dept.addItem("R & D");
  93.         empl_dept.addItem("Sales");
  94.         empl_dept.addItem("Shipping");
  95.         empl_dept.select(0);
  96.  
  97.         req_region = new Choice();
  98.         req_region.addItem("");
  99.         req_region.addItem("Canada");
  100.         req_region.addItem("Central");
  101.         req_region.addItem("Eastern");
  102.         req_region.addItem("South");
  103.         req_region.addItem("Western");
  104.         req_region.select(0);
  105.  
  106.         // Initialize Labels
  107.         record_label = new Label("of");
  108.         record_label.setFont(hel_reg_14_font);
  109.  
  110.         req_date_label = new Label("Purchase Date:");
  111.         req_date_label.setFont(hel_reg_11_font);
  112.  
  113.         req_fin_label = new Label("Finance Code:");
  114.         req_fin_label.setFont(hel_reg_11_font);
  115.  
  116.         req_region_label = new Label("Region:");
  117.         req_region_label.setFont(hel_reg_11_font);
  118.  
  119.         cust_first_label = new Label("First Name:");
  120.         cust_first_label.setFont(hel_reg_11_font);
  121.  
  122.         cust_last_label = new Label("Last Name:");
  123.         cust_last_label.setFont(hel_reg_11_font);
  124.  
  125.         cust_company_label = new Label("Company:");
  126.         cust_company_label.setFont(hel_reg_11_font);
  127.  
  128.         cust_addr_label = new Label("Address:");
  129.         cust_addr_label.setFont(hel_reg_11_font);
  130.  
  131.         cust_phone_label = new Label("Phone:");
  132.         cust_phone_label.setFont(hel_reg_11_font);
  133.  
  134.         cust_city_label = new Label("City:");
  135.         cust_city_label.setFont(hel_reg_11_font);
  136.  
  137.         cust_state_label = new Label("State:");
  138.         cust_state_label.setFont(hel_reg_11_font);
  139.  
  140.         cust_zip_label = new Label("Zip Code:");
  141.         cust_zip_label.setFont(hel_reg_11_font);
  142.  
  143.         empl_first_label = new Label("First Name:");
  144.         empl_first_label.setFont(hel_reg_11_font);
  145.  
  146.         empl_last_label = new Label("Last Name:");
  147.         empl_last_label.setFont(hel_reg_11_font);
  148.  
  149.         empl_dept_label = new Label("Department:");
  150.         empl_dept_label.setFont(hel_reg_11_font);
  151.  
  152.         prod_line_label = new Label("Number:");
  153.         prod_line_label.setFont(hel_reg_11_font);
  154.  
  155.         prod_id_label = new Label("ID #:");
  156.         prod_id_label.setFont(hel_reg_11_font);
  157.  
  158.         prod_quan_label = new Label("Quantity:");
  159.         prod_quan_label.setFont(hel_reg_11_font);
  160.  
  161.         prod_ship_label = new Label("Ship Date:");
  162.         prod_ship_label.setFont(hel_reg_11_font);
  163.  
  164.         // Initialize Strings
  165.         current_status_bar = new String();
  166.  
  167.         // Initialize Textfields
  168.         status_bar = new TextField("Ready. System messages go here.", 40);
  169.         status_bar.setFont(hel_reg_14_font);
  170.         status_bar.setBackground(Color.black);
  171.         status_bar.setForeground(Color.orange);
  172.         status_bar.setEditable(false);
  173.  
  174.         req_total = new TextField();
  175.         req_total.setFont(hel_reg_14_font);
  176.         req_total.setBackground(Color.black);
  177.         req_total.setForeground(Color.orange);
  178.         req_total.setEditable(false);
  179.  
  180.         req_current = new TextField();
  181.         req_current.setFont(hel_reg_14_font);
  182.         req_current.setBackground(Color.black);
  183.         req_current.setForeground(Color.orange);
  184.         req_current.setEditable(false);
  185.  
  186.         req_num = new TextField();
  187.         req_num.setBackground(Color.black);
  188.         req_num.setForeground(Color.orange);
  189.         req_date = new TextField();
  190.         req_fin = new TextField("r1", 2);
  191.         req_fin.setEditable(false);
  192.         req_fin.setBackground(Color.lightGray);
  193.  
  194.         cust_num = new TextField();
  195.         cust_first = new TextField();
  196.         cust_last = new TextField();
  197.         cust_company = new TextField();
  198.         cust_addr = new TextField();
  199.         cust_phone = new TextField();
  200.         cust_city = new TextField();
  201.         cust_state = new TextField();
  202.         cust_zip = new TextField();
  203.  
  204.         empl_num = new TextField(15);
  205.         empl_first = new TextField(20);
  206.         empl_last = new TextField(35);
  207.  
  208.         prod_header = new TextField("#      UnitPrice  Quantity    Shipping      Product Information");
  209.         prod_header.setFont(cour_reg_font);
  210.         prod_header.setEditable(false);
  211.  
  212.         prod_line = new TextField();
  213.         prod_id = new TextField();
  214.         prod_quan = new TextField();
  215.         prod_ship = new TextField();
  216.  
  217.         prod_mask = new TextField();
  218.         prod_mask.disable();
  219.         prod_mask.setBackground(Color.black);
  220.         prod_mask.setEditable(false);
  221.  
  222.         // Initialize TextArea
  223.         order_list = new TextArea();
  224.         order_list.setFont(cour_reg_font);
  225.         order_list.setEditable(false);
  226.  
  227.         this.setLayout(null);
  228.         addNotify();
  229.         resize(insets().left + insets().right + 540, insets().top + insets().bottom + 540);
  230.  
  231.         // Add header stuff
  232.         add(req_current);
  233.         req_current.reshape(insets().left+150, insets().top+50, 51, 24);
  234.  
  235.         add(record_label);
  236.         record_label.reshape(insets().left+192, insets().top+50, 25, 24);
  237.  
  238.         add(req_total);
  239.         req_total.reshape(insets().left+219, insets().top+50, 51, 24);
  240.  
  241.         add(browse_button);
  242.         browse_button.reshape(insets().left, insets().top+75, 125, 20);
  243.  
  244.         add(add_button);
  245.         add_button.reshape(insets().left, insets().top+75, 125, 20);
  246.  
  247.         add(save_button);
  248.         save_button.reshape(insets().left + 127, insets().top+75, 55, 20);
  249.  
  250.         add(delete_button);
  251.         delete_button.reshape(insets().left + 127, insets().top+75, 55, 20);
  252.  
  253.         add(edit_button);
  254.         edit_button.reshape(insets().left+184, insets().top+75, 62, 20);
  255.  
  256.         add(first_button);
  257.         first_button.reshape(insets().left+184, insets().top+75, 30, 20);
  258.  
  259.         add(next_button);
  260.         next_button.reshape(insets().left+216, insets().top+75, 30, 20);
  261.  
  262.         add(search_button);
  263.         search_button.reshape(insets().left+248, insets().top+75, 96, 20);
  264.  
  265.         add(clear_button);
  266.         clear_button.reshape(insets().left+346, insets().top+75, 96, 20);
  267.  
  268.         add(quit_button);
  269.         quit_button.reshape(insets().left+444, insets().top+75, 96, 20);
  270.  
  271.         add(status_bar);
  272.         status_bar.reshape(insets().left+2, insets().top+96, 537, 23);
  273.  
  274.         // Add Requisition stuff
  275.         add(req_num);
  276.         req_num.reshape(insets().left+475,insets().top+121, 60, 19);
  277.  
  278.         add(req_date_label);
  279.         req_date_label.reshape(insets().left, insets().top+145, 85, 15);
  280.         add(req_date);
  281.         req_date.reshape(insets().left+87, insets().top+144, 90, 19);
  282.  
  283.         add(req_fin_label);
  284.         req_fin_label.reshape(insets().left+190, insets().top+145, 80, 15);
  285.         add(req_fin);
  286.         req_fin.reshape(insets().left+272, insets().top+144, 60, 19);
  287.  
  288.         add(req_region_label);
  289.         req_region_label.reshape(insets().left+390, insets().top+145, 50, 15);
  290.         add(req_region);
  291.         req_region.reshape(insets().left+440, insets().top+142, 70, 16);
  292.  
  293.         // Add Customer stuff
  294.         add(cust_num);
  295.         cust_num.reshape(insets().left+475, insets().top+166, 60, 19);
  296.  
  297.         add(cust_first_label);
  298.         cust_first_label.reshape(insets().left, insets().top+190, 66, 15);
  299.         add(cust_first);
  300.         cust_first.reshape(insets().left+68, insets().top+189, 85, 19);
  301.  
  302.         add(cust_last_label);
  303.         cust_last_label.reshape(insets().left+150, insets().top+190, 64, 15);
  304.         add(cust_last);
  305.         cust_last.reshape(insets().left+216, insets().top+189, 90, 19);
  306.  
  307.         add(cust_company_label);
  308.         cust_company_label.reshape(insets().left+323, insets().top+190, 64, 15);
  309.         add(cust_company);
  310.         cust_company.reshape(insets().left+387, insets().top+189, 150, 19);
  311.  
  312.         add(cust_addr_label);
  313.         cust_addr_label.reshape(insets().left, insets().top+212, 66, 15);
  314.         add(cust_addr);
  315.         cust_addr.reshape(insets().left+68, insets().top+211, 200, 19);
  316.  
  317.         add(cust_phone_label);
  318.         cust_phone_label.reshape(insets().left+394, insets().top+212, 45, 15);
  319.         add(cust_phone);
  320.         cust_phone.reshape(insets().left+442, insets().top+211, 95, 19);
  321.  
  322.         add(cust_city_label);
  323.         cust_city_label.reshape(insets().left, insets().top+234, 66, 15);
  324.         add(cust_city);
  325.         cust_city.reshape(insets().left+68, insets().top+233, 90, 19);
  326.  
  327.         add(cust_state_label);
  328.         cust_state_label.reshape(insets().left+155, insets().top+234, 40, 15);
  329.         add(cust_state);
  330.         cust_state.reshape(insets().left+197, insets().top+233, 40, 19);
  331.  
  332.         add(cust_zip_label);
  333.         cust_zip_label.reshape(insets().left+235, insets().top+234, 58, 15);
  334.         add(cust_zip);
  335.         cust_zip.reshape(insets().left+295, insets().top+233, 60, 19);
  336.  
  337.         // Add Employee stuff
  338.         add(empl_num);
  339.         empl_num.reshape(insets().left+475, insets().top+255, 60, 19);
  340.  
  341.         add(empl_first_label);
  342.         empl_first_label.reshape(insets().left, insets().top+279, 66, 15);
  343.         add(empl_first);
  344.         empl_first.reshape(insets().left+68, insets().top+278, 85, 19);
  345.  
  346.         add(empl_last_label);
  347.         empl_last_label.reshape(insets().left+150, insets().top+279, 64, 15);
  348.         add(empl_last);
  349.         empl_last.reshape(insets().left+216, insets().top+278, 90, 19);
  350.  
  351.         add(empl_dept_label);
  352.         empl_dept_label.reshape(insets().left+323, insets().top+279, 68, 15);
  353.         add(empl_dept);
  354.         empl_dept.reshape(insets().left+395, insets().top+278, 142, 19);
  355.  
  356.         // Add Product stuff
  357.         add(prod_header);
  358.         prod_header.reshape(insets().left+2, insets().top+323, 536, 22);
  359.  
  360.         add(order_list);
  361.         order_list.reshape(insets().left+2, insets().top+347, 536, 146);
  362.  
  363.         add(prod_mask);
  364.         prod_mask.reshape(insets().left, insets().top+495, 538, 47);
  365.  
  366.         add(prod_line_label);
  367.         prod_line_label.reshape(insets().left, insets().top+496, 50, 15);
  368.         add(prod_line);
  369.         prod_line.reshape(insets().left+68, insets().top+495, 50, 19);
  370.  
  371.         add(prod_id_label);
  372.         prod_id_label.reshape(insets().left+134, insets().top+496, 33, 15);
  373.         add(prod_id);
  374.         prod_id.reshape(insets().left+169, insets().top+495, 50, 19);
  375.  
  376.         add(prod_quan_label);
  377.         prod_quan_label.reshape(insets().left+230, insets().top+496, 55, 15);
  378.         add(prod_quan);
  379.         prod_quan.reshape(insets().left+287, insets().top+495, 50, 19);
  380.  
  381.         add(prod_ship_label);
  382.         prod_ship_label.reshape(insets().left+348, insets().top+496, 60, 15);
  383.         add(prod_ship );
  384.         prod_ship.reshape(insets().left+410, insets().top+495, 90, 19);
  385.  
  386.         add(add_item_button);
  387.         add_item_button.reshape(insets().left, insets().top+516, 80, 20);
  388.  
  389.         add(edit_item_button);
  390.         edit_item_button.reshape(insets().left+88, insets().top+516, 98, 20);
  391.  
  392.         add(delete_item_button);
  393.         delete_item_button.reshape(insets().left+196, insets().top+516, 107, 20);
  394.  
  395.         add(confirm_button);
  396.         confirm_button.reshape(insets().left+313, insets().top+516, 120, 20);
  397.  
  398.         add(clear_item_button);
  399.         clear_item_button.reshape(insets().left+443, insets().top+516, 97, 20);
  400.  
  401.         // Display UI to the screen
  402.         show();
  403.         disable_buttons();
  404.  
  405.         // Try to connect to the server.  The connection will be keep up for the whole
  406.         // duration of the session that the applet is used.
  407.         connect_server();
  408.         if (good_connection) {
  409.             try {
  410.                 message("Establishing connection...");
  411.                 // create a statement to be executed from the connection
  412.                 stmt = server.createStatement();
  413.             }
  414.             catch (SQLException create_error) {
  415.                 message("Exception caught!  Could not create multiple statements!");
  416.                 sleep();
  417.             }
  418.         }
  419.         else {
  420.             message("Could not open server!");
  421.             sleep();
  422.         }
  423.  
  424.         // set up initial state
  425.         set_browse_mode();
  426.         order_list.setText("OrderFormAppJDBC v0.23\n");
  427.         order_list.appendText("Please note that there is no error checking for input.");
  428.     }
  429.  
  430.     // already_exist()
  431.     final boolean already_exist(String from_clause, String table_clause, String identifier_clause) {
  432.         String prod_SQL = "SELECT count(*) FROM "+from_clause+" WHERE "+table_clause+" = '" + identifier_clause + "'";
  433.         int total = 0;
  434.  
  435.         try {
  436.             message("Checking if record already exists...");
  437.             rs = generate_ResultSet(prod_SQL, rs, stmt, true);
  438.             total = rs.getInt(1);
  439.             rs.close();
  440.         }
  441.         catch (SQLException create_error) {
  442.             message("Exception caught!  Could not check if record exists!");
  443.             sleep();
  444.         }
  445.  
  446.         if (total == 1) { return true; }
  447.         else if (total == 0) { return false; }
  448.         else {
  449.             message("Data integrity volation has been detected!");
  450.             sleep();
  451.         }
  452.         return false;
  453.     }
  454.  
  455.     // clear_item()
  456.     final void clear_item() {
  457.         prod_id.setText("");
  458.         prod_quan.setText("");
  459.         prod_ship.setText("");
  460.     }
  461.  
  462.     // clear_record()
  463.     final void clear_record() {
  464.         if (mode != 1) { req_num.setText(""); req_date.setText(""); }
  465.         if (mode == 2) { set_browse_mode(); }
  466.  
  467.         req_region.select(0);
  468.         cust_num.setText("");
  469.         cust_first.setText("");
  470.         cust_last.setText("");
  471.         cust_addr.setText("");
  472.         cust_company.setText("");
  473.         cust_city.setText("");
  474.         cust_state.setText("");
  475.         cust_zip.setText("");
  476.         cust_phone.setText("");
  477.         empl_num.setText("");
  478.         empl_first.setText("");
  479.         empl_last.setText("");
  480.         empl_dept.select(0);
  481.         order_list.setText("");
  482.  
  483.         clear_item();
  484.     }
  485.  
  486.     // close_server()
  487.     final void close_server() {
  488.         message("Attempting to close server "+server_url+"...");
  489.         try {
  490.             server.close();
  491.             good_connection = false;
  492.             message("Server closed successfully!");
  493.         }
  494.         catch (Exception close_error) {
  495.             message("Exception caught! Could not close server!");
  496.             sleep();
  497.         }
  498.     }
  499.  
  500.     // connect_server()
  501.     final void connect_server() {
  502.         message("Attempting to open server "+server_url+"...");
  503.         try {
  504.             // create a specific driver for use with JDBC
  505.             dbaw_driver = (Driver)Class.forName(dbaw_driver_name).newInstance();
  506.  
  507.             // connect to server given by server_url and props
  508.             server = dbaw_driver.connect(server_url, props);
  509.             //server.setAutoClose(false);
  510.             good_connection = true;
  511.             message("Server opened successfully!");
  512.         }
  513.         catch (InstantiationException instantiation_error) { }
  514.         catch (ClassNotFoundException classnotfound_error) { }
  515.         catch (IllegalAccessException illegalaccess_error) { }
  516.         catch (SQLException open_error) {
  517.             message("Exception caught! Could not open server!");
  518.             sleep();
  519.         }
  520.     }
  521.  
  522.     // disable_buttons()
  523.     final void disable_buttons() {
  524.         browse_button.disable();
  525.         add_button.disable();
  526.         delete_button.disable();
  527.         edit_button.disable();
  528.         save_button.disable();
  529.         clear_button.disable();
  530.         first_button.disable();
  531.         next_button.disable();
  532.         search_button.disable();
  533.         add_item_button.disable();
  534.         edit_item_button.disable();
  535.         delete_item_button.disable();
  536.         clear_item_button.disable();
  537.         confirm_button.disable();
  538.     }
  539.  
  540.     // generate_ResultSet()
  541.     final ResultSet generate_ResultSet(String target_SQL, ResultSet target_RS, Statement target_Stmt, boolean get_record) {
  542.  
  543.         try {
  544.             message("Grabbing results...");
  545.             target_RS = target_Stmt.executeQuery(target_SQL);
  546.             message("Ready.");
  547.         }
  548.         catch (Exception search_error) {
  549.             message("Could not find any hits!");
  550.         }
  551.  
  552.         if (get_record) {
  553.             try { target_RS.next(); }
  554.             catch (SQLException next_error) {
  555.                 message("Exception caught!  Could not grab next record!");
  556.                 sleep();
  557.             }
  558.         }
  559.  
  560.         return (target_RS);
  561.     }
  562.  
  563.     // generate_SQL()
  564.     final String generate_SQL(int current_mode, boolean is_count) {
  565.         String select = "SELECT sales_order.id, cust_id, order_date, region, sales_rep,"
  566.             + " fname, lname, customer.address, customer.city, customer.state, zip,"
  567.             + " customer.phone, company_name, emp_fname, emp_lname, employee.dept_id,"
  568.             + " dept_name, sales_order_items.id, line_id, prod_id, sales_order_items.quantity,"
  569.             + " ship_date, name, description, size, color, unit_price";
  570.         String select_count = "SELECT count(*)";
  571.         String from = " FROM sales_order, customer, employee, department, sales_order_items, product";
  572.         String from_count = " FROM sales_order";
  573.         String where = " WHERE customer.id = cust_id AND emp_id = sales_rep AND department.dept_id = employee.dept_id AND product.id = prod_id";
  574.         String where_count = "";
  575.  
  576.         boolean req_num_exist = false, req_date_exist = false;
  577.         boolean first_req = true, first_cust = true, first_empl = true, first_dept = true;
  578.         boolean req_region_exist = false, cust_num_exist = false, empl_num_exist = false;
  579.         boolean cust_first_exist = false, cust_last_exist = false, cust_company_exist = false;
  580.         boolean cust_addr_exist = false, cust_city_exist = false, cust_state_exist = false;
  581.         boolean cust_zip_exist = false, cust_phone_exist = false, empl_dept_exist = false;
  582.         boolean empl_first_exist = false, empl_last_exist = false;
  583.  
  584.         boolean req_num_wild = has_wildcard(req_num);
  585.         boolean req_date_wild = has_wildcard(req_date);
  586.         boolean cust_num_wild = has_wildcard(cust_num);
  587.         boolean empl_num_wild = has_wildcard(empl_num);
  588.         boolean cust_first_wild = has_wildcard(cust_first);
  589.         boolean cust_last_wild = has_wildcard(cust_last);
  590.         boolean cust_company_wild = has_wildcard(cust_company);
  591.         boolean cust_addr_wild = has_wildcard(cust_addr);
  592.         boolean cust_city_wild = has_wildcard(cust_city);
  593.         boolean cust_state_wild = has_wildcard(cust_state);
  594.         boolean cust_zip_wild = has_wildcard(cust_zip);
  595.         boolean cust_phone_wild = has_wildcard(cust_phone);
  596.         boolean empl_first_wild = has_wildcard(empl_first);
  597.         boolean empl_last_wild = has_wildcard(empl_last);
  598.  
  599.         if (req_num.getText().length() != 0) req_num_exist = true;
  600.         if (req_date.getText().length() != 0) req_date_exist = true;
  601.         if (req_region.getSelectedIndex() != 0) req_region_exist = true;
  602.         if (cust_num.getText().length() != 0) cust_num_exist = true;
  603.         if (empl_num.getText().length() != 0) empl_num_exist = true;
  604.  
  605.         if (cust_first.getText().length() != 0) cust_first_exist = true;
  606.         if (cust_last.getText().length() != 0) cust_last_exist = true;
  607.         if (cust_company.getText().length() != 0) cust_company_exist = true;
  608.         if (cust_addr.getText().length() != 0) cust_addr_exist = true;
  609.         if (cust_city.getText().length() != 0) cust_city_exist = true;
  610.         if (cust_state.getText().length() != 0) cust_state_exist = true;
  611.         if (cust_zip.getText().length() != 0) cust_zip_exist = true;
  612.         if (empl_first.getText().length() != 0) empl_first_exist = true;
  613.         if (empl_last.getText().length() != 0) empl_last_exist = true;
  614.         if (empl_dept.getSelectedIndex() != 0) empl_dept_exist = true;
  615.  
  616.         message("Dynamically generating SQL statement...");
  617.  
  618.         if (req_num_exist || req_date_exist || req_region_exist || cust_num_exist || empl_num_exist) {
  619.             if ( (req_num_exist) && (!req_num_wild) ) {
  620.                 if (first_req) {
  621.                     where_count = where_count.concat(" WHERE sales_order.id = '" + req_num.getText() + "'");
  622.                     first_req = false;
  623.                 }
  624.                 else {
  625.                     where_count = where_count.concat(" AND sales_order.id = '" + req_num.getText() + "'");
  626.                 }
  627.                 where = where.concat(" AND sales_order.id = '" + req_num.getText() + "'");
  628.             }
  629.             else if ( (req_num_exist) && (req_num_wild) ) {
  630.                 if (first_req) {
  631.                     where_count = where_count.concat(" WHERE sales_order.id LIKE '" + req_num.getText() + "'");
  632.                     first_req = false;
  633.                 }
  634.                 else {
  635.                     where_count = where_count.concat(" AND sales_order.id LIKE '" + req_num.getText() + "'");
  636.                 }
  637.                 where = where.concat(" AND sales_order.id LIKE '" + req_num.getText() + "'");
  638.             }
  639.  
  640.             if ( (cust_num_exist) && (!cust_num_wild) ) {
  641.                 if (first_req) {
  642.                     where_count = where_count.concat(" WHERE cust_id = '" + cust_num.getText() + "'");
  643.                     first_req = false;
  644.                 }
  645.                 else {
  646.                     where_count = where_count.concat(" AND cust_id = '" + cust_num.getText() + "'");
  647.                 }
  648.                 where = where.concat(" AND cust_id = '" + cust_num.getText() + "'");
  649.             }
  650.             else if ( (cust_num_exist) && (cust_num_wild) ) {
  651.                 if (first_req) {
  652.                     where_count = where_count.concat(" WHERE cust_id LIKE '" + cust_num.getText() + "'");
  653.                     first_req = false;
  654.                 }
  655.                 else {
  656.                     where_count = where_count.concat(" AND cust_id LIKE '" + cust_num.getText() + "'");
  657.                 }
  658.                 where = where.concat(" AND cust_id LIKE '" + cust_num.getText() + "'");
  659.             }
  660.  
  661.             if ( (req_date_exist) && (!req_date_wild) ) {
  662.                 if (first_req) {
  663.                     where_count = where_count.concat(" WHERE order_date = '" + req_date.getText() + "'");
  664.                     first_req = false;
  665.                 }
  666.                 else {
  667.                     where_count = where_count.concat(" AND order_date = '" + req_date.getText() + "'");
  668.                 }
  669.                 where = where.concat(" AND order_date = '" + req_date.getText() + "'");
  670.             }
  671.             else if ( (req_date_exist) && (req_date_wild) ) {
  672.                 if (first_req) {
  673.                     where_count = where_count.concat(" WHERE order_date LIKE '" + req_date.getText() + "'");
  674.                     first_req = false;
  675.                 }
  676.                 else {
  677.                     where_count = where_count.concat(" AND order_date LIKE '" + req_date.getText() + "'");
  678.                 }
  679.                 where = where.concat(" AND order_date LIKE '" + req_date.getText() + "'");
  680.             }
  681.  
  682.             if (req_region_exist) {
  683.                 if (first_req) {
  684.                     where_count = where_count.concat(" WHERE region = '" + req_region.getSelectedItem() + "'");
  685.                     first_req = false;
  686.                 }
  687.                 else {
  688.                     where_count = where_count.concat(" AND region = '" + req_region.getSelectedItem() + "'");
  689.                 }
  690.                 where = where.concat(" AND region = '" + req_region.getSelectedItem() + "'");
  691.             }
  692.  
  693.             if ( (empl_num_exist) && (!empl_num_wild) ) {
  694.                 if (first_req) {
  695.                     where_count = where_count.concat(" WHERE sales_rep = '" + empl_num.getText() + "'");
  696.                     first_req = false;
  697.                 }
  698.                 else {
  699.                     where_count = where_count.concat(" AND sales_rep= '" + empl_num.getText() + "'");
  700.                 }
  701.                 where = where.concat(" AND sales_rep = '" + empl_num.getText() + "'");
  702.             }
  703.             else if ( (empl_num_exist) && (empl_num_wild) ) {
  704.                 if (first_req) {
  705.                     where_count = where_count.concat(" WHERE sales_rep LIKE '" + empl_num.getText() + "'");
  706.                     first_req = false;
  707.                 }
  708.                 else {
  709.                     where_count = where_count.concat(" AND sales_rep LIKE '" + empl_num.getText() + "'");
  710.                 }
  711.                 where = where.concat(" AND sales_rep LIKE '" + empl_num.getText() + "'");
  712.             }
  713.         }
  714.  
  715.             if (cust_first_exist || cust_last_exist || cust_company_exist || cust_addr_exist
  716.             || cust_city_exist || cust_state_exist || cust_zip_exist || empl_first_exist
  717.             || empl_last_exist || empl_dept_exist) {
  718.                 if (cust_first_exist) {
  719.                     if (!from_count.endsWith(", customer")) {
  720.                         from_count = from_count.concat(", customer");
  721.                     }
  722.                     if ((first_req) && (first_cust)) {
  723.                         where_count = where_count.concat(" WHERE customer.id = cust_id");
  724.                         first_cust = false;
  725.                     }
  726.                     else if ((!first_req) && (first_cust)) {
  727.                         StringBuffer string_buffer = new StringBuffer(where_count);
  728.                         string_buffer.insert(7, "customer.id = cust_id AND ");
  729.                         where_count = string_buffer.toString();
  730.                         first_cust = false;
  731.                     }
  732.  
  733.                     if (!cust_first_wild) {
  734.                         where_count = where_count.concat(" AND fname = '" + cust_first.getText() + "'");
  735.                         where = where.concat(" AND fname = '" + cust_first.getText() + "'");
  736.                     }
  737.                     else {
  738.                         where_count = where_count.concat(" AND fname LIKE '" + cust_first.getText() + "'");
  739.                         where = where.concat(" AND fname LIKE '" + cust_first.getText() + "'");
  740.                     }
  741.                 }
  742.  
  743.                 if (cust_last_exist) {
  744.                     if (!from_count.endsWith(", customer")) {
  745.                         from_count = from_count.concat(", customer");
  746.                     }
  747.                     if ((first_req) && (first_cust)) {
  748.                         where_count = where_count.concat(" WHERE customer.id = cust_id");
  749.                         first_cust = false;
  750.                     }
  751.                     else if ((!first_req) && (first_cust)) {
  752.                         StringBuffer string_buffer = new StringBuffer(where_count);
  753.                         string_buffer.insert(7, "customer.id = cust_id AND ");
  754.                         where_count = string_buffer.toString();
  755.                         first_cust = false;
  756.                     }
  757.  
  758.                     if (!cust_last_wild) {
  759.                         where_count = where_count.concat(" AND lname = '" + cust_last.getText() + "'");
  760.                         where = where.concat(" AND lname = '" + cust_last.getText() + "'");
  761.                     }
  762.                     else {
  763.                         where_count = where_count.concat(" AND lname LIKE '" + cust_last.getText() + "'");
  764.                         where = where.concat(" AND lname LIKE '" + cust_last.getText() + "'");
  765.                     }
  766.                 }
  767.  
  768.                 if (cust_company_exist) {
  769.                     if (!from_count.endsWith(", customer")) {
  770.                         from_count = from_count.concat(", customer");
  771.                     }
  772.                     if ((first_req) && (first_cust)) {
  773.                         where_count = where_count.concat(" WHERE customer.id = cust_id");
  774.                         first_cust = false;
  775.                     }
  776.                     else if ((!first_req) && (first_cust)) {
  777.                         StringBuffer string_buffer = new StringBuffer(where_count);
  778.                         string_buffer.insert(7, "customer.id = cust_id AND ");
  779.                         where_count = string_buffer.toString();
  780.                         first_cust = false;
  781.                     }
  782.  
  783.                     if (!cust_company_wild) {
  784.                         where_count = where_count.concat(" AND company_name = '" + cust_company.getText() + "'");
  785.                         where = where.concat(" AND company_name = '" + cust_company.getText() + "'");
  786.                     }
  787.                     else {
  788.                         where_count = where_count.concat(" AND company_name LIKE '" + cust_company.getText() + "'");
  789.                         where = where.concat(" AND company_name LIKE '" + cust_company.getText() + "'");
  790.                     }
  791.                 }
  792.  
  793.                 if (cust_addr_exist) {
  794.                     if (!from_count.endsWith(", customer")) {
  795.                         from_count = from_count.concat(", customer");
  796.                     }
  797.                     if ((first_req) && (first_cust)) {
  798.                         where_count = where_count.concat(" WHERE customer.id = cust_id");
  799.                         first_cust = false;
  800.                     }
  801.                     else if ((!first_req) && (first_cust)) {
  802.                         StringBuffer string_buffer = new StringBuffer(where_count);
  803.                         string_buffer.insert(7, "customer.id = cust_id AND ");
  804.                         where_count = string_buffer.toString();
  805.                         first_cust = false;
  806.                     }
  807.  
  808.                     if (!cust_addr_wild) {
  809.                         where_count = where_count.concat(" AND customer.address = '" + cust_addr.getText() + "'");
  810.                         where = where.concat(" AND customer.address = '" + cust_addr.getText() + "'");
  811.                     }
  812.                     else {
  813.                         where_count = where_count.concat(" AND customer.address LIKE '" + cust_addr.getText() + "'");
  814.                         where = where.concat(" AND customer.address LIKE '" + cust_addr.getText() + "'");
  815.                     }
  816.                 }
  817.  
  818.                 if (cust_city_exist) {
  819.                     if (!(from_count.endsWith(", customer"))) {
  820.                         from_count = from_count.concat(", customer");
  821.                     }
  822.                     if ((first_req) && (first_cust)) {
  823.                         where_count = where_count.concat(" WHERE customer.id = cust_id");
  824.                         first_cust = false;
  825.                     }
  826.                     else if ((!first_req) && (first_cust)) {
  827.                         StringBuffer string_buffer = new StringBuffer(where_count);
  828.                         string_buffer.insert(7, "customer.id = cust_id AND ");
  829.                         where_count = string_buffer.toString();
  830.                         first_cust = false;
  831.                     }
  832.  
  833.                     if (!cust_city_wild) {
  834.                         where_count = where_count.concat(" AND customer.city = '" + cust_city.getText() + "'");
  835.                         where = where.concat(" AND customer.city = '" + cust_city.getText() + "'");
  836.                     }
  837.                     else {
  838.                         where_count = where_count.concat(" AND customer.city LIKE '" + cust_city.getText() + "'");
  839.                         where = where.concat(" AND customer.city LIKE '" + cust_city.getText() + "'");
  840.                     }
  841.                 }
  842.  
  843.                 if (cust_state_exist) {
  844.                     if (!(from_count.endsWith(", customer"))) {
  845.                         from_count = from_count.concat(", customer");
  846.                     }
  847.                     if ((first_req) && (first_cust)) {
  848.                         where_count = where_count.concat(" WHERE customer.id = cust_id");
  849.                         first_cust = false;
  850.                     }
  851.                     else if ((!first_req) && (first_cust)) {
  852.                         StringBuffer string_buffer = new StringBuffer(where_count);
  853.                         string_buffer.insert(7, "customer.id = cust_id AND ");
  854.                         where_count = string_buffer.toString();
  855.                         first_cust = false;
  856.                     }
  857.  
  858.                     if (!cust_state_wild) {
  859.                         where_count = where_count.concat(" AND customer.state = '" + cust_state.getText() + "'");
  860.                         where = where.concat(" AND customer.state = '" + cust_state.getText() + "'");
  861.                     }
  862.                     else {
  863.                         where_count = where_count.concat(" AND customer.state LIKE '" + cust_state.getText() + "'");
  864.                         where = where.concat(" AND customer.state LIKE '" + cust_state.getText() + "'");
  865.                     }
  866.                 }
  867.  
  868.                 if (cust_zip_exist) {
  869.                     if (!from_count.endsWith(", customer")) {
  870.                         from_count = from_count.concat(", customer");
  871.                     }
  872.                     if ((first_req) && (first_cust)) {
  873.                         where_count = where_count.concat(" WHERE customer.id = cust_id");
  874.                         first_cust = false;
  875.                     }
  876.                     else if ((!first_req) && (first_cust)) {
  877.                         StringBuffer string_buffer = new StringBuffer(where_count);
  878.                         string_buffer.insert(7, "customer.id = cust_id AND ");
  879.                         where_count = string_buffer.toString();
  880.                         first_cust = false;
  881.                     }
  882.  
  883.                     if (!cust_zip_wild) {
  884.                         where_count = where_count.concat(" AND zip = '" + cust_zip.getText() + "'");
  885.                         where = where.concat(" AND zip = '" + cust_zip.getText() + "'");
  886.                     }
  887.                     else {
  888.                         where_count = where_count.concat(" AND zip LIKE '" + cust_zip.getText() + "'");
  889.                         where = where.concat(" AND zip LIKE '" + cust_zip.getText() + "'");
  890.                     }
  891.                 }
  892.  
  893.                 if (cust_phone_exist) {
  894.                     if (!from_count.endsWith(", customer")) {
  895.                         from_count = from_count.concat(", customer");
  896.                     }
  897.                     if ((first_req) && (first_cust)) {
  898.                         where_count = where_count.concat(" WHERE customer.id = cust_id");
  899.                         first_cust = false;
  900.                     }
  901.                     else if ((!first_req) && (first_cust)) {
  902.                         StringBuffer string_buffer = new StringBuffer(where_count);
  903.                         string_buffer.insert(7, "customer.id = cust_id AND ");
  904.                         where_count = string_buffer.toString();
  905.                         first_cust = false;
  906.                     }
  907.  
  908.                     if (!cust_phone_wild) {
  909.                         where_count = where_count.concat(" AND customer.phone = '" + cust_phone.getText() + "'");
  910.                         where = where.concat(" AND customer.phone = '" + cust_phone.getText() + "'");
  911.                     }
  912.                     else {
  913.                         where_count = where_count.concat(" AND customer.phone LIKE '" + cust_phone.getText() + "'");
  914.                         where = where.concat(" AND customer.phone LIKE '" + cust_phone.getText() + "'");
  915.                     }
  916.                 }
  917.  
  918.                 if (empl_first_exist) {
  919.                     if (!from_count.endsWith(", employee")) {
  920.                         from_count = from_count.concat(", employee");
  921.                     }
  922.                     if ((first_req) && (first_cust) && (first_empl)) {
  923.                         where_count = where_count.concat(" WHERE emp_id = sales_rep");
  924.                         first_empl = false;
  925.                     }
  926.                     else if (((!first_req) || (!first_cust)) && (first_empl)) {
  927.                         StringBuffer string_buffer = new StringBuffer(where_count);
  928.                         string_buffer.insert(7, "emp_id = sales_rep AND ");
  929.                         where_count = string_buffer.toString();
  930.                         first_empl = false;
  931.                     }
  932.  
  933.                     if (!empl_first_wild) {
  934.                         where_count = where_count.concat(" AND emp_fname = '" + empl_first.getText() + "'");
  935.                         where = where.concat(" AND emp_fname = '" + empl_first.getText() + "'");
  936.                     }
  937.                     else {
  938.                         where_count = where_count.concat(" AND emp_fname LIKE '" + empl_first.getText() + "'");
  939.                         where = where.concat(" AND emp_fname LIKE '" + empl_first.getText() + "'");
  940.                     }
  941.                 }
  942.  
  943.                 if (empl_last_exist) {
  944.                     if (!from_count.endsWith(", employee")) {
  945.                         from_count = from_count.concat(", employee");
  946.                     }
  947.                     if ((first_req) && (first_cust) && (first_empl)) {
  948.                         where_count = where_count.concat(" WHERE emp_id = sales_rep");
  949.                         first_empl = false;
  950.                     }
  951.                     else if (((!first_req) || (!first_cust)) && (first_empl)) {
  952.                         StringBuffer string_buffer = new StringBuffer(where_count);
  953.                         string_buffer.insert(7, "emp_id = sales_rep AND ");
  954.                         where_count = string_buffer.toString();
  955.                         first_empl = false;
  956.                     }
  957.  
  958.                     if (!empl_last_wild) {
  959.                         where_count = where_count.concat(" AND emp_lname = '" + empl_last.getText() + "'");
  960.                         where = where.concat(" AND emp_lname = '" + empl_last.getText() + "'");
  961.                     }
  962.                     else {
  963.                         where_count = where_count.concat(" AND emp_lname LIKE '" + empl_last.getText() + "'");
  964.                         where = where.concat(" AND emp_lname LIKE '" + empl_last.getText() + "'");
  965.                     }
  966.                 }
  967.  
  968.                 if (empl_dept_exist) {
  969.                     String dept_SQL = "SELECT dept_id FROM department WHERE dept_name = '" + empl_dept.getSelectedItem() + "'";
  970.                     int dept_id = 0;
  971.                     boolean dept_found = false;
  972.  
  973.                     try {
  974.                         message("Grabbing department ID number...");
  975.                         rs = generate_ResultSet(dept_SQL, rs, stmt, true);
  976.                         dept_id = rs.getInt(1);
  977.                         message("Searching department ID...");
  978.                         dept_found = true;
  979.                         rs.close();
  980.                     }
  981.                     catch (SQLException dept_error) {
  982.                         empl_dept.select(0);
  983.                     }
  984.  
  985.                     if (dept_found) {
  986.                         if (!from_count.endsWith(", employee")) {
  987.                             from_count = from_count.concat(", employee");
  988.                         }
  989.                         if ((first_req) && (first_cust) && (first_empl) && (first_dept)) {
  990.                             where_count = where_count.concat(" WHERE emp_id = sales_rep");
  991.                             first_dept = false;
  992.                         }
  993.                         else if (((!first_req) || (!first_cust) || (!first_empl)) && (first_empl)) {
  994.                             StringBuffer string_buffer = new StringBuffer(where_count);
  995.                             string_buffer.insert(7, "emp_id = sales_rep AND ");
  996.                             where_count = string_buffer.toString();
  997.                             first_dept = false;
  998.                         }
  999.  
  1000.                         where_count = where_count.concat(" AND employee.dept_id = " + String.valueOf(dept_id));
  1001.                         where = where.concat(" AND employee.dept_id = " + String.valueOf(dept_id));
  1002.                     }
  1003.                 }
  1004.         }
  1005.         // assemble and return the SQL statement
  1006.         where = where.concat(" AND sales_order_items.id = sales_order.id");
  1007.  
  1008.         if (is_count) { return(select_count + from_count + where_count); }
  1009.         return (select + from + where + " ORDER BY 1, 18, 19 ASC");
  1010.     }
  1011.  
  1012.     // get_cust_info()
  1013.     final void get_cust_info() {
  1014.         String cust_SQL = "SELECT fname, lname, address, city, state, zip, phone, company_name FROM customer WHERE id = '"+cust_num.getText().trim()+"'";
  1015.  
  1016.         try {
  1017.             message("Opening customer records...");
  1018.             rs = generate_ResultSet(cust_SQL, rs, stmt, true);
  1019.             message("Displaying results...");
  1020.  
  1021.             if (rs.getString(1) != null) cust_first.setText(rs.getString(1));
  1022.             else cust_first.setText("");
  1023.             if (rs.getString(2) != null) cust_last.setText(rs.getString(2));
  1024.             else cust_last.setText("");
  1025.             if (rs.getString(3) != null) cust_addr.setText(rs.getString(3));
  1026.             else cust_addr.setText("");
  1027.             if (rs.getString(4) != null) cust_city.setText(rs.getString(4));
  1028.             else cust_city.setText("");
  1029.             if (rs.getString(5) != null) cust_state.setText(rs.getString(5));
  1030.             else cust_state.setText("");
  1031.             if (rs.getString(6) != null) cust_zip.setText(rs.getString(6));
  1032.             else cust_zip.setText("");
  1033.             if (rs.getString(7) != null) cust_phone.setText(rs.getString(7));
  1034.             else cust_phone.setText("");
  1035.             if (rs.getString(8) != null) cust_company.setText(rs.getString(8));
  1036.             else cust_company.setText("");
  1037.  
  1038.             message("Ready. [Add Mode]");
  1039.             highlight(empl_num);
  1040.             rs.close();
  1041.         }
  1042.         catch (SQLException validity_error) {
  1043.             message("The customer ID you entered was not valid.  Try again.");
  1044.             highlight(cust_num);
  1045.         }
  1046.     }
  1047.  
  1048.     // get_edit_info()
  1049.     final void get_edit_info() {
  1050.         boolean worked = false;
  1051.         String select = "SELECT sales_order.id, cust_id, order_date, region, sales_rep,"
  1052.             + " fname, lname, customer.address, customer.city, customer.state, zip,"
  1053.             + " customer.phone, company_name, emp_fname, emp_lname, employee.dept_id,"
  1054.             + " dept_name, sales_order_items.id, line_id, prod_id, sales_order_items.quantity,"
  1055.             + " ship_date, name, description, size, color, unit_price";
  1056.         String from = " FROM sales_order, customer, employee, department, sales_order_items, product";
  1057.         String where = " WHERE customer.id = cust_id AND emp_id = sales_rep AND"
  1058.             + " department.dept_id = employee.dept_id AND product.id = prod_id AND"
  1059.             + " sales_order_items.id = sales_order.id AND sales_order.id = " + req_num.getText().trim();
  1060.  
  1061.         req_num.setEditable(false);
  1062.  
  1063.         message("Grabbing record from database...");
  1064.         rs = generate_ResultSet(select+from+where, rs, stmt, true);
  1065.         message("Displaying results...");
  1066.  
  1067.         worked = move(3);
  1068.         if (worked) {
  1069.             req_num.setBackground(Color.black);
  1070.             req_num.setForeground(Color.orange);
  1071.             highlight(prod_line);
  1072.             set_edit_item(3);
  1073.             message("Ready. [Edit Mode]");
  1074.             try { rs.close(); }
  1075.             catch (SQLException close_error) { message("Exception caught! Could not close record!"); }
  1076.             record_saved = true;
  1077.             update_prod_line(true);
  1078.         }
  1079.         else {
  1080.             message("The record number you entered was not valid.  Try again.");
  1081.             req_num.setEditable(true);
  1082.             highlight(req_num);
  1083.         }
  1084.     }
  1085.  
  1086.     // get_empl_info()
  1087.     final void get_empl_info() {
  1088.         String empl_SQL = "SELECT emp_fname, emp_lname, employee.dept_id, dept_name FROM employee, department WHERE department.dept_id = employee.dept_id AND emp_id = '"+empl_num.getText().trim()+"'";
  1089.  
  1090.         try {
  1091.             message("Opening employee records...");
  1092.             rs = generate_ResultSet(empl_SQL, rs, stmt, true);
  1093.             message("Displaying results...");
  1094.  
  1095.             if (rs.getString(1) != null) empl_first.setText(rs.getString(1));
  1096.             else empl_first.setText("");
  1097.             if (rs.getString(2) != null) empl_last.setText(rs.getString(2));
  1098.             else empl_last.setText("");
  1099.             if (rs.getString(4) != null) empl_dept.select(rs.getString(4));
  1100.             else empl_dept.select(0);
  1101.  
  1102.             message("Ready. [Add Mode]");
  1103.             highlight(prod_id);
  1104.             rs.close();
  1105.         }
  1106.         catch (SQLException validity_error) {
  1107.             message("The employee ID you entered was not valid.  Try again.");
  1108.             highlight(empl_num);
  1109.         }
  1110.     }
  1111.  
  1112.     // get_last_req_num()
  1113.     final void get_last_req_num() {
  1114.         String last_SQL = "SELECT MAX(sales_order.id) FROM sales_order";
  1115.  
  1116.         current_item_pos = 0;
  1117.  
  1118.         try {
  1119.             message("Getting last record of database...");
  1120.             rs = generate_ResultSet(last_SQL, rs, stmt, true);
  1121.             req_num.setText(String.valueOf(rs.getInt(1)+1));
  1122.             rs.close();
  1123.         }
  1124.         catch (SQLException get_int_error) {
  1125.             message("Exception caught!  Could not grab integer for Number!");
  1126.             sleep();
  1127.         }
  1128.  
  1129.         message("Getting today's date...");
  1130.         java.util.Date todays_date = new java.util.Date();
  1131.         Date sql_date = new Date(todays_date.getYear(), todays_date.getMonth(), todays_date.getDate());
  1132.         req_date.setText(sql_date.toString());
  1133.         req_date.setEditable(false);
  1134.  
  1135.         current_item_pos++;
  1136.         prod_line.setText(String.valueOf(current_item_pos));
  1137.  
  1138.         req_region.requestFocus();
  1139.         message("Ready. [Add Mode]");
  1140.     }
  1141.  
  1142.     // get_prod_info()
  1143.     final void get_prod_info() {
  1144.         String prod_SQL = "SELECT count(*) FROM product WHERE id = '" + prod_id.getText().trim() + "'";
  1145.         int total;
  1146.  
  1147.         try {
  1148.             message("Executing temporary statement...");
  1149.             rs = generate_ResultSet(prod_SQL, rs, stmt, true);
  1150.             total = rs.getInt(1);
  1151.  
  1152.             if (total == 1) {
  1153.                 message("Ready. [Add Mode]");
  1154.                 if (mode == 1) { highlight(prod_quan); }
  1155.                 else if (mode == 4) {
  1156.                     prod_quan.requestFocus();
  1157.                     prod_quan.selectAll();
  1158.                 }
  1159.             }
  1160.             else {
  1161.                 message("The product ID you entered was not valid.  Try again.");
  1162.                 highlight(prod_id);
  1163.             }
  1164.  
  1165.             rs.close();
  1166.         }
  1167.         catch (SQLException create_error) {
  1168.             message("Exception caught!  Could not create temporary statement!");
  1169.             sleep();
  1170.         }
  1171.     }
  1172.  
  1173.     // get_prod_item()
  1174.     final void get_prod_item() {
  1175.         String prod_item_SQL = "SELECT line_id, prod_id, quantity, ship_date FROM sales_order_items WHERE id = '" + req_num.getText().trim() + "' AND line_id = '" + prod_line.getText().trim() + "'";
  1176.  
  1177.         message("Grabbing product information...");
  1178.         rs = generate_ResultSet(prod_item_SQL, rs, stmt, false);
  1179.  
  1180.         try {
  1181.             rs.next();
  1182.  
  1183.             prod_id.setText("                        ");
  1184.             prod_quan.setText("                        ");
  1185.             prod_ship.setText("                        ");
  1186.  
  1187.             prod_line.setText(String.valueOf(rs.getString(1)));
  1188.             prod_id.setText(String.valueOf(rs.getString(2)));
  1189.             prod_quan.setText(String.valueOf(rs.getString(3)));
  1190.             prod_ship.setText(String.valueOf(rs.getString(4)));
  1191.             if (mode == 2) {
  1192.                 message("Please confirm requested action...");
  1193.                 confirm_button.enable();
  1194.                 confirm_button.requestFocus();
  1195.             }
  1196.             if (mode == 3) set_editing();
  1197.         }
  1198.         catch (SQLException next_error) {
  1199.             message("Order not found!");
  1200.             if (mode == 2) { highlight(prod_line); }
  1201.             else if (mode == 3) {
  1202.                 current_item_pos = Integer.valueOf(prod_line.getText()).intValue();
  1203.                 update_prod_line(false);
  1204.             }
  1205.             else highlight(prod_line);
  1206.         }
  1207.  
  1208.         try { rs.close(); }
  1209.         catch (SQLException close_error) { message("Exception caught! Could not close record!"); }
  1210.     }
  1211.  
  1212.     // has_wildcard()
  1213.     final boolean has_wildcard(TextField target) {
  1214.         boolean return_value = false;
  1215.  
  1216.         target.setText(target.getText().trim().replace('\u0027', '_'));
  1217.         target.setText(target.getText().replace('*', '%').replace('?', '_'));
  1218.  
  1219.         if ((target.getText().indexOf("%", 0)) != -1) { return_value = true; }
  1220.         else if ((target.getText().indexOf("_", 0)) != -1) { return_value =  true; }
  1221.         else return_value = false;
  1222.  
  1223.         return return_value;
  1224.     }
  1225.  
  1226.     // highlight()
  1227.     final void highlight(TextField target) {
  1228.         target.setText("                        ");
  1229.         target.requestFocus();
  1230.         target.selectAll();
  1231.     }
  1232.  
  1233.     // message()
  1234.     final void message(String text) {
  1235.         current_status_bar = text;
  1236.         status_bar.setText(current_status_bar);
  1237.     }
  1238.  
  1239.     // move()
  1240.     final boolean move(int first_rec) {
  1241.         int current_record;
  1242.  
  1243.         try {
  1244.             if (first_rec == 1) { message("Grabbing first record..."); }
  1245.             else if (first_rec == 2) { message("Grabbing next record..."); }
  1246.             else if (first_rec == 3) { message("Grabbing data..."); }
  1247.  
  1248.             if (first_rec == 1) rs.next();
  1249.             current_record = rs.getInt(1);
  1250.  
  1251.             req_current.setText(String.valueOf(current_pos+1));
  1252.  
  1253.             message("Displaying record...");
  1254.  
  1255.             if (rs.getString(1) != null) req_num.setText(rs.getString(1));
  1256.             else req_num.setText("");
  1257.             if (rs.getString(2) != null) cust_num.setText(rs.getString(2));
  1258.             else cust_num.setText("");
  1259.             if (rs.getString(3) != null) req_date.setText(rs.getString(3));
  1260.             else req_date.setText("");
  1261.             if (rs.getString(4) != null) req_region.select(rs.getString(4));
  1262.             else req_region.select(0);
  1263.             if (rs.getString(5) != null) empl_num.setText(rs.getString(5));
  1264.             else empl_num.setText("");
  1265.  
  1266.             if (rs.getString(6) != null) cust_first.setText(rs.getString(6));
  1267.             else cust_first.setText("");
  1268.             if (rs.getString(7) != null) cust_last.setText(rs.getString(7));
  1269.             else cust_last.setText("");
  1270.             if (rs.getString(8) != null) cust_addr.setText(rs.getString(8));
  1271.             else cust_addr.setText("");
  1272.             if (rs.getString(9) != null) cust_city.setText(rs.getString(9));
  1273.             else cust_city.setText("");
  1274.             if (rs.getString(10) != null) cust_state.setText(rs.getString(10));
  1275.             else cust_state.setText("");
  1276.             if (rs.getString(11) != null) cust_zip.setText(rs.getString(11));
  1277.             else cust_zip.setText("");
  1278.             if (rs.getString(12) != null) cust_phone.setText(rs.getString(12));
  1279.             else cust_phone.setText("");
  1280.             if (rs.getString(13) != null) cust_company.setText(rs.getString(13));
  1281.             else cust_company.setText("");
  1282.  
  1283.             if (rs.getString(14) != null) empl_first.setText(rs.getString(14));
  1284.             else empl_first.setText("");
  1285.             if (rs.getString(15) != null) empl_last.setText(rs.getString(15));
  1286.             else empl_last.setText("");
  1287.  
  1288.             if (rs.getString(17) != null) empl_dept.select(rs.getString(17));
  1289.             else empl_dept.select(0);
  1290.  
  1291.             String padding = new String("                                                   ");
  1292.             String temp_string;
  1293.             BigDecimal subtotal = new BigDecimal ("0");
  1294.             BigDecimal sub_temp = new BigDecimal ("0");
  1295.  
  1296.             order_list.setText("");
  1297.             try {
  1298.                 for (; rs.getInt(18) == current_record; rs.next()) {
  1299.                     message("Displaying ordered items");
  1300.  
  1301.                     temp_string = new String(rs.getString(19).concat(padding));
  1302.                     temp_string = temp_string.substring(0, 4);
  1303.  
  1304.                     BigDecimal price_temp = new BigDecimal(rs.getBigDecimal(27, 2).doubleValue());
  1305.                     BigDecimal quantity_temp = new BigDecimal(rs.getString(21));
  1306.  
  1307.                     order_list.appendText(temp_string+"   $"+price_temp.toString()+"\t     "
  1308.                         +rs.getString(21)+"\t     "+rs.getString(22)+"\t"
  1309.                         +rs.getString(23)+" - "+rs.getString(24)+"\n");
  1310.                     order_list.appendText("\t\t\t\t\tSize: "+rs.getString(25)+" - Color: "
  1311.                         +rs.getString(26)+"\n");
  1312.                     message("Calculating subtotal...");
  1313.  
  1314.                     sub_temp = price_temp.multiply(quantity_temp);
  1315.                     subtotal = subtotal.add(sub_temp);
  1316.                 }
  1317.             }
  1318.             catch (SQLException order_list_error) { message("End of results reached."); }
  1319.  
  1320.             order_list.appendText("--------------------------------------------------------------------------\n");
  1321.             order_list.appendText("\t\t\t\t\tSubtotal: $"+subtotal+"\n");
  1322.  
  1323.             message("Ready.");
  1324.  
  1325.             if ((current_pos == (counter - 1)) && (current_pos == 0)) { nav_buttons(false, false); }
  1326.             else if (current_pos == (counter - counter)) { nav_buttons(false, true); }
  1327.             else if (current_pos == (counter - 1)) { nav_buttons(true, false); }
  1328.             else if (current_pos < (counter - 1)) { nav_buttons(true, true); }
  1329.             else {
  1330.                 message("Problem with current_pos!  Exceeds counter!");
  1331.                 return false;
  1332.             }
  1333.         }
  1334.         catch (SQLException next_error) {
  1335.             message("Exception caught!  Record grab unsuccessful!");
  1336.             return false;
  1337.         }
  1338.         return true;
  1339.     }
  1340.  
  1341.     // nav_buttons()
  1342.     final void nav_buttons(boolean one, boolean two) {
  1343.         if (one) {first_button.enable();}
  1344.         else {first_button.disable();}
  1345.  
  1346.         if (two) {next_button.enable();}
  1347.         else {next_button.disable();}
  1348.     }
  1349.  
  1350.     // paint()
  1351.     public void paint(Graphics g) {
  1352.         super.paint(g);
  1353.  
  1354.         // Company info
  1355.         g.setColor(Color.black);
  1356.         g.setFont(company_font);
  1357.         g.drawString("ADGGIL Systems.", 4, 25);
  1358.  
  1359.         g.setFont(hel_reg_font);
  1360.         g.drawString("123 Anywhere Street", 4, 40);
  1361.         g.drawString("AnyCity, State Zip", 4, 54);
  1362.         g.drawString("(xxx) 555 - 1234", 4, 68);
  1363.  
  1364.         // OrderForm info
  1365.         g.setFont(hel_bold_16_font);
  1366.         g.drawString("Purchase Requisition", 364, 18);
  1367.  
  1368.         g.setFont(hel_reg_font);
  1369.         g.drawString("Complete all ungrayed portions of this form.", 290, 33);
  1370.         g.drawString("Click on the form to refresh.", 379, 46);
  1371.  
  1372.         // Requisition info
  1373.         g.setColor(Color.black);
  1374.         g.fillRect(2, 120, 537, 22);
  1375.  
  1376.         g.setFont(hel_reg_14_font);
  1377.         g.setColor(Color.white);
  1378.         g.drawString("Requisition Information", 4, 135);
  1379.         g.drawString("Number:", 420, 135);
  1380.  
  1381.         // Customer info
  1382.         g.setColor(Color.black);
  1383.         g.fillRect(2, 165, 537, 22);
  1384.  
  1385.         g.setFont(hel_reg_14_font);
  1386.         g.setColor(Color.white);
  1387.         g.drawString("Customer Information", 4, 180);
  1388.         g.drawString("ID:", 456, 180);
  1389.  
  1390.         // Employee info
  1391.         g.setColor(Color.black);
  1392.         g.fillRect(2, 254, 537, 22);
  1393.  
  1394.         g.setFont(hel_reg_14_font);
  1395.         g.setColor(Color.white);
  1396.         g.drawString("Employee Information", 4, 269);
  1397.         g.drawString("ID:", 456, 269);
  1398.  
  1399.         // Product info
  1400.         g.setColor(Color.black);
  1401.         g.fillRect(2, 299, 537, 22);
  1402.  
  1403.         g.setFont(hel_reg_14_font);
  1404.         g.setColor(Color.white);
  1405.         g.drawString("Product Information", 4, 314);
  1406.     }
  1407.  
  1408.     // save_info()
  1409.     final void save_info() {
  1410.         String save_SQL = "";
  1411.         boolean is_missing = true;
  1412.  
  1413.         if ((req_num.getText().trim().length() != 0) && (req_date.getText().trim().length() != 0) && (req_region.getSelectedIndex() != 0)
  1414.             && (cust_num.getText().trim().length() != 0) && (empl_num.getText().trim().length() != 0)) { is_missing = false; }
  1415.         else { message("Cannot save!  Empty fields were detected in record!"); }
  1416.  
  1417.         if (!is_missing) {
  1418.             if (!already_exist("sales_order", "id", req_num.getText().trim())) {
  1419.                 save_SQL = "INSERT INTO sales_order (id, cust_id, order_date, fin_code_id, region, sales_rep) VALUES ("+req_num.getText().trim()+", "+cust_num.getText().trim()+", '"+req_date.getText().trim()+"', '"
  1420.                     +req_fin.getText().trim()+"', '"+req_region.getSelectedItem()+"', "+empl_num.getText().trim()+")";
  1421.  
  1422.                 message("Saving record information...");
  1423.  
  1424.                 try {
  1425.                     stmt.executeUpdate(save_SQL);
  1426.                     record_saved = true;
  1427.                     message("Record saved... press return or click on the Add Item button to same item.");
  1428.                 }
  1429.                 catch (SQLException save_error) { message("Problem with SQL Statement!  No records were inserted!"); }
  1430.             }
  1431.             else {
  1432.                 message("This record already exists!");
  1433.                 sleep();
  1434.             }
  1435.         }
  1436.     }
  1437.  
  1438.     // save_item_info()
  1439.     final void save_item_info() {
  1440.         String save_SQL = "";
  1441.         boolean is_missing = true;
  1442.  
  1443.         if ((req_num.getText().trim().length() != 0) && (prod_line.getText().trim().length() != 0)
  1444.             && (prod_id.getText().trim().length() != 0) && (prod_quan.getText().trim().length() != 0)
  1445.             && (prod_ship.getText().trim().length() != 0)) { is_missing = false; }
  1446.         else { message("Cannot save!  Empty fields were detected in item!"); }
  1447.  
  1448.         if (!is_missing) {
  1449.             if ( already_exist("sales_order", "id", req_num.getText().trim()) ) {
  1450.                 save_SQL = "INSERT INTO sales_order_items (id, line_id, prod_id, quantity, ship_date) VALUES ("
  1451.                     +req_num.getText().trim()+", "+prod_line.getText().trim()+", "
  1452.                     +prod_id.getText().trim()+", "+prod_quan.getText().trim()+", '"
  1453.                     +prod_ship.getText().trim()+"')";
  1454.  
  1455.                 message("Saving items...");
  1456.  
  1457.                 try {
  1458.                     stmt.executeUpdate(save_SQL);
  1459.                     message("Item saved.");
  1460.                     clear_item();
  1461.                     current_item_pos++;
  1462.                     update_prod_line(true);
  1463.                     prod_line.setText(String.valueOf(current_item_pos));
  1464.                     if (current_item_pos > 1) {
  1465.                         edit_item_button.enable();
  1466.                         delete_item_button.enable();
  1467.                     }
  1468.                 }
  1469.                 catch (SQLException save_error) { message("Problem with SQL Statement!  No records were inserted!"); }
  1470.                 show_order_list();
  1471.             }
  1472.             else {
  1473.                 message("Record does not exist yet.  Please save the record first.");
  1474.                 edit_item_button.requestFocus();
  1475.             }
  1476.         }
  1477.     }
  1478.  
  1479.     // set_add_mode()
  1480.     final void set_add_mode() {
  1481.         mode = 1;
  1482.         clear_record();
  1483.         set_modify_mode(true);
  1484.         get_last_req_num();
  1485.         confirm_button.setLabel("Confirm Action.");
  1486.     }
  1487.  
  1488.     // set_browse_mode()
  1489.     final void set_browse_mode() {
  1490.         mode = 0;
  1491.         record_saved = false;
  1492.  
  1493.         req_total.setText("");
  1494.         req_current.setText("");
  1495.  
  1496.         browse_button.disable();
  1497.         browse_button.hide();
  1498.         add_button.enable();
  1499.         add_button.show();
  1500.         save_button.disable();
  1501.         save_button.hide();
  1502.         edit_button.disable();
  1503.         edit_button.hide();
  1504.         delete_button.enable();
  1505.         delete_button.show();
  1506.         search_button.enable();
  1507.         clear_button.enable();
  1508.         clear_button.setLabel("Clear Record");
  1509.         first_button.disable();
  1510.         next_button.disable();
  1511.  
  1512.         req_total.show();
  1513.         record_label.show();
  1514.         req_current.show();
  1515.  
  1516.         req_num.setEditable(true);
  1517.         req_num.setBackground(Color.black);
  1518.         req_num.setForeground(Color.orange);
  1519.         req_date.setEditable(true);
  1520.         req_region.select(0);
  1521.         cust_first.setEditable(true);
  1522.         cust_last.setEditable(true);
  1523.         cust_addr.setEditable(true);
  1524.         cust_company.setEditable(true);
  1525.         cust_city.setEditable(true);
  1526.         cust_state.setEditable(true);
  1527.         cust_zip.setEditable(true);
  1528.         cust_phone.setEditable(true);
  1529.         empl_first.setEditable(true);
  1530.         empl_last.setEditable(true);
  1531.         empl_dept.select(0);
  1532.         empl_dept.enable();
  1533.  
  1534.         req_date.setBackground(Color.white);
  1535.         cust_first.setBackground(Color.white);
  1536.         cust_last.setBackground(Color.white);
  1537.         cust_addr.setBackground(Color.white);
  1538.         cust_company.setBackground(Color.white);
  1539.         cust_city.setBackground(Color.white);
  1540.         cust_state.setBackground(Color.white);
  1541.         cust_zip.setBackground(Color.white);
  1542.         cust_phone.setBackground(Color.white);
  1543.         empl_first.setBackground(Color.white);
  1544.         empl_last.setBackground(Color.white);
  1545.         empl_dept.setBackground(Color.white);
  1546.  
  1547.         req_num.setText("");
  1548.         req_date.setText("");
  1549.         cust_first.setText("");
  1550.         cust_last.setText("");
  1551.         cust_addr.setText("");
  1552.         cust_company.setText("");
  1553.         cust_city.setText("");
  1554.         cust_state.setText("");
  1555.         cust_zip.setText("");
  1556.         cust_phone.setText("");
  1557.         empl_first.setText("");
  1558.         empl_last.setText("");
  1559.  
  1560.         add_item_button.hide();
  1561.         edit_item_button.hide();
  1562.         delete_item_button.hide();
  1563.         clear_item_button.hide();
  1564.         prod_line_label.hide();
  1565.         prod_line.hide();
  1566.         prod_id_label.hide();
  1567.         prod_id.hide();
  1568.         prod_quan_label.hide();
  1569.         prod_quan.hide();
  1570.         prod_ship_label.hide();
  1571.         prod_ship.hide();
  1572.         prod_mask.show();
  1573.  
  1574.         highlight(req_num);
  1575.         message("Ready. [Browse Mode]");
  1576.         mode = 0;
  1577.     }
  1578.  
  1579.     // set_edit()
  1580.     final void set_edit(int mode_setting) {
  1581.         mode = mode_setting;
  1582.  
  1583.         edit_button.disable();
  1584.         if (mode_setting != 2) clear_record();
  1585.         if (mode_setting == 2) set_modify_mode(false);
  1586.         else if ((mode_setting == 3) || (mode_setting == 4)) set_modify_mode(true);
  1587.  
  1588.         req_num.setEditable(true);
  1589.         req_num.setBackground(Color.black);
  1590.         req_num.setForeground(Color.orange);
  1591.         req_region.select(0);
  1592.         req_region.disable();
  1593.  
  1594.         cust_num.setEditable(false);
  1595.         cust_num.setBackground(Color.lightGray);
  1596.         cust_num.setText("                        ");
  1597.  
  1598.         empl_num.setEditable(false);
  1599.         empl_num.setBackground(Color.lightGray);
  1600.         empl_num.setText("                        ");
  1601.  
  1602.         edit_button.setLabel("Add");
  1603.  
  1604.         highlight(req_num);
  1605.         if (mode == 2) message("Enter record to delete and press return.");
  1606.         else if (mode == 4) {
  1607.             message("Enter record to edit, or click Add to add a new record.");
  1608.             clear_button.disable();
  1609.         }
  1610.         edit_button.enable();
  1611.     }
  1612.  
  1613.     // set_edit_item()
  1614.     final void set_edit_item(int mode_setting) {
  1615.         if (mode_setting == 3) {
  1616.             mode = 3;
  1617.             edit_item_button.disable();
  1618.             confirm_button.setLabel("Confirm Update");
  1619.         }
  1620.         else if (mode_setting == 2) {
  1621.             mode = 2;
  1622.             delete_item_button.disable();
  1623.             confirm_button.setLabel("Confirm Delete");
  1624.         }
  1625.         clear_item();
  1626.  
  1627.         add_item_button.enable();
  1628.         edit_item_button.disable();
  1629.         delete_button.enable();
  1630.         confirm_button.enable();
  1631.  
  1632.         prod_id.setEditable(false);
  1633.         prod_quan.setEditable(false);
  1634.         prod_ship.setEditable(false);
  1635.  
  1636.         prod_id.setBackground(Color.lightGray);
  1637.         prod_quan.setBackground(Color.lightGray);
  1638.         prod_ship.setBackground(Color.lightGray);
  1639.  
  1640.         prod_id.setText("                        ");
  1641.         prod_quan.setText("                        ");
  1642.         prod_ship.setText("                        ");
  1643.  
  1644.         prod_line.setEditable(true);
  1645.         highlight(prod_line);
  1646.     }
  1647.  
  1648.     // set_editing()
  1649.     final void set_editing() {
  1650.         mode = 4;
  1651.         delete_item_button.disable();
  1652.  
  1653.         message("Click on Add Item to continue adding items.");
  1654.  
  1655.         prod_line.setEditable(false);
  1656.         prod_line.setBackground(Color.lightGray);
  1657.  
  1658.         prod_id.setEditable(true);
  1659.         prod_quan.setEditable(true);
  1660.         prod_ship.setEditable(true);
  1661.  
  1662.         prod_id.setBackground(Color.white);
  1663.         prod_quan.setBackground(Color.white);
  1664.         prod_ship.setBackground(Color.white);
  1665.  
  1666.         prod_id.requestFocus();
  1667.         prod_id.selectAll();
  1668.     }
  1669.  
  1670.     // set_modify_mode()
  1671.     final void set_modify_mode(boolean modify_state) {
  1672.         record_saved = false;
  1673.  
  1674.         if (modify_state) {
  1675.             disable_buttons();
  1676.             delete_button.hide();
  1677.             save_button.show();
  1678.             edit_button.enable();
  1679.             edit_button.show();
  1680.             edit_button.setLabel("Edit");
  1681.             browse_button.enable();
  1682.             browse_button.show();
  1683.             add_button.hide();
  1684.             clear_button.enable();
  1685.  
  1686.             add_item_button.show();
  1687.             edit_item_button.show();
  1688.             delete_item_button.show();
  1689.             clear_item_button.show();
  1690.             clear_item_button.enable();
  1691.             prod_line_label.show();
  1692.             prod_line.show();
  1693.             prod_line.setEditable(false);
  1694.             prod_line.setBackground(Color.lightGray);
  1695.             prod_id_label.show();
  1696.             prod_id.show();
  1697.             prod_quan_label.show();
  1698.             prod_quan.show();
  1699.             prod_ship_label.show();
  1700.             prod_ship.show();
  1701.             prod_mask.hide();
  1702.         }
  1703.         first_button.disable();
  1704.         next_button.disable();
  1705.  
  1706.         if (mode == 2) clear_button.setLabel("Cancel Delete");
  1707.         else clear_button.setLabel("Clear Record");
  1708.         req_total.hide();
  1709.         record_label.hide();
  1710.         req_current.hide();
  1711.  
  1712.         req_num.setEditable(false);
  1713.         req_date.setEditable(false);
  1714.         req_region.select(0);
  1715.         req_region.enable();
  1716.         cust_num.setEditable(true);
  1717.         cust_first.setEditable(false);
  1718.         cust_last.setEditable(false);
  1719.         cust_addr.setEditable(false);
  1720.         cust_company.setEditable(false);
  1721.         cust_city.setEditable(false);
  1722.         cust_state.setEditable(false);
  1723.         cust_zip.setEditable(false);
  1724.         cust_phone.setEditable(false);
  1725.         empl_num.setEditable(true);
  1726.         empl_first.setEditable(false);
  1727.         empl_last.setEditable(false);
  1728.         empl_dept.select(0);
  1729.         empl_dept.disable();
  1730.  
  1731.         req_num.setBackground(Color.lightGray);
  1732.         req_num.setForeground(Color.red);
  1733.         req_date.setBackground(Color.lightGray);
  1734.         cust_num.setBackground(Color.white);
  1735.         cust_first.setBackground(Color.lightGray);
  1736.         cust_last.setBackground(Color.lightGray);
  1737.         cust_addr.setBackground(Color.lightGray);
  1738.         cust_company.setBackground(Color.lightGray);
  1739.         cust_city.setBackground(Color.lightGray);
  1740.         cust_state.setBackground(Color.lightGray);
  1741.         cust_zip.setBackground(Color.lightGray);
  1742.         cust_phone.setBackground(Color.lightGray);
  1743.         empl_num.setBackground(Color.white);
  1744.         empl_first.setBackground(Color.lightGray);
  1745.         empl_last.setBackground(Color.lightGray);
  1746.         empl_dept.setBackground(Color.lightGray);
  1747.  
  1748.         req_num.setText("                        ");
  1749.         req_date.setText("                        ");
  1750.         cust_num.setText("                        ");
  1751.         cust_first.setText("                        ");
  1752.         cust_last.setText("                        ");
  1753.         cust_addr.setText("                        ");
  1754.         cust_company.setText("                        ");
  1755.         cust_city.setText("                        ");
  1756.         cust_state.setText("                        ");
  1757.         cust_zip.setText("                        ");
  1758.         cust_phone.setText("                        ");
  1759.         empl_num.setText("                        ");
  1760.         empl_first.setText("                        ");
  1761.         empl_last.setText("                        ");
  1762.  
  1763.         if (mode != 2) { message("Ready. [Add Mode]"); req_region.requestFocus(); }
  1764.     }
  1765.  
  1766.     // show_information()
  1767.     final void show_information() {
  1768.         SQL_string_asc = generate_SQL(mode, false);
  1769.  
  1770.         counter = 0;
  1771.         current_pos = 0;
  1772.  
  1773.         try {
  1774.             message("Counting records...");
  1775.             rs = generate_ResultSet(generate_SQL(mode, true), rs, stmt, true);
  1776.         }
  1777.         catch (Exception filter_error) {
  1778.             message("Exception caught!  Could not create counter!");
  1779.             sleep();
  1780.         }
  1781.  
  1782.         try { counter = rs.getInt(1); rs.close(); }
  1783.         catch (SQLException get_error) {
  1784.             message("Exception caught!  Could not get grab int for max record!");
  1785.             sleep();
  1786.         }
  1787.  
  1788.         req_total.setText(String.valueOf(counter));
  1789.  
  1790.         if (counter != 0) {
  1791.             message("Number of records found in result set...  "+String.valueOf(counter)+".");
  1792.             rs = generate_ResultSet(SQL_string_asc, rs, stmt, false);
  1793.             move(1);
  1794.             message("Ready. [Browse mode]");
  1795.  
  1796.             if (mode == 2) {
  1797.                 message("Click on delete if you are sure you want to delete this record.");
  1798.                 delete_button.enable();
  1799.                 delete_button.requestFocus();
  1800.             }
  1801.         }
  1802.         else {
  1803.             req_current.setText(String.valueOf(current_pos));
  1804.             message("No hits found.");
  1805.             clear_record();
  1806.         }
  1807.  
  1808.     }
  1809.  
  1810.  
  1811.     // show_order_list()
  1812.     final void show_order_list() {
  1813.         String padding = new String("                                                   ");
  1814.         String temp_string;
  1815.         BigDecimal subtotal = new BigDecimal ("0");
  1816.         BigDecimal sub_temp = new BigDecimal ("0");
  1817.  
  1818.         try {
  1819.             String select = "SELECT sales_order_items.id, line_id, prod_id, sales_order_items.quantity, ship_date, name, description, size, color, unit_price";
  1820.             String from = " FROM sales_order_items, product";
  1821.             String where = " WHERE product.id = prod_id AND sales_order_items.id = '"+Integer.valueOf(req_num.getText().trim()).intValue()+"'";
  1822.  
  1823.             message("Grabbing ordered items");
  1824.             rs = generate_ResultSet(select + from + where, rs, stmt, false);
  1825.             message("Displaying ordered items");
  1826.  
  1827.             order_list.setText("");
  1828.             while (rs.next()) {
  1829.                 message("Displaying ordered items");
  1830.  
  1831.                 temp_string = new String(rs.getString(2).concat(padding));
  1832.                 temp_string = temp_string.substring(0, 4);
  1833.  
  1834.                 BigDecimal price_temp = new BigDecimal(rs.getBigDecimal(10, 2).doubleValue());
  1835.                 BigDecimal quantity_temp = new BigDecimal(rs.getString(4));
  1836.  
  1837.                 order_list.appendText(temp_string+"   $"+price_temp.toString()+"\t     "
  1838.                     +rs.getString(4)+"\t     "+rs.getString(5)+"\t"
  1839.                     +rs.getString(6)+" - "+rs.getString(7)+"\n");
  1840.                 order_list.appendText("\t\t\t\t\tSize: "+rs.getString(8)+" - Color: "
  1841.                     +rs.getString(9)+"\n");
  1842.                 message("Calculating subtotal...");
  1843.  
  1844.                 sub_temp = price_temp.multiply(quantity_temp);
  1845.                 subtotal = subtotal.add(sub_temp);
  1846.             }
  1847.  
  1848.             order_list.appendText("--------------------------------------------------------------------------\n");
  1849.             order_list.appendText("\t\t\t\t\tSubtotal: $"+subtotal+"\n");
  1850.  
  1851.             message("Ready.");
  1852.  
  1853.             rs.close();
  1854.         }
  1855.         catch (SQLException order_list_error) {
  1856.             message("Exception caught!  Could not continue with order listing!");
  1857.         }
  1858.     }
  1859.  
  1860.     // sleep();
  1861.     final void sleep() {
  1862.         try { server.close(); }
  1863.         catch (SQLException close_server_error) { message("Exception caught!  Could not close server!!!"); }
  1864.         disable_buttons();
  1865.         for (int i = 0; i < 3; i++) i = 1;
  1866.     }
  1867. /*
  1868.     // start()
  1869.     public void start() {
  1870.         if (kicker == null) {
  1871.             kicker = new Thread(this);
  1872.             kicker.setPriority(kicker.MIN_PRIORITY);
  1873.             kicker.start();
  1874.         }
  1875.     }
  1876.  
  1877.     // stop()
  1878.     public void stop() {
  1879.         close_server();
  1880.         kicker = null;
  1881.     }
  1882.  
  1883.     // run()
  1884.     public void run() {
  1885.         int cntr = 0;
  1886.  
  1887.         while (kicker != null) {
  1888.             cntr++;
  1889.             if ((cntr%1000) == 0) first = true;
  1890.             try {kicker.sleep(100);} catch (InterruptedException e) {}
  1891.         }
  1892.     }
  1893. */
  1894.     // update()
  1895.     public void update(Graphics g) {
  1896.         g.clearRect(0, 0, 540, 540);
  1897.         paint(g);
  1898.     }
  1899.  
  1900.     // update_delete()
  1901.     final void update_delete(boolean delete_item, boolean delete_record) {
  1902.         boolean is_missing = true;
  1903.  
  1904.  
  1905.         if ((req_num.getText().trim().length() != 0) && (prod_line.getText().trim().length() != 0)
  1906.             && (prod_id.getText().trim().length() != 0) && (prod_quan.getText().trim().length() != 0)
  1907.             && (prod_ship.getText().trim().length() != 0)) { is_missing = false; }
  1908.         else { message("Cannot save!  Empty fields were detected in item!"); }
  1909.  
  1910.         if (delete_item) {
  1911.             String delete_item_SQL = "DELETE FROM sales_order_items WHERE id = " + req_num.getText().trim() + " AND line_id = " + prod_line.getText().trim();
  1912.  
  1913.             if (!is_missing) {
  1914.                 message("Deleting item...");
  1915.  
  1916.                 try {
  1917.                     stmt.executeUpdate(delete_item_SQL);
  1918.                     message("Deleting item... done.");
  1919.                     update_prod_line(true);
  1920.                 }
  1921.                 catch (SQLException delete_error) { message("Caution! Could not delete item!"); }
  1922.                 show_order_list();
  1923.             }
  1924.         }
  1925.         else if ((req_num.getText().trim().length() != 0) && delete_record) {
  1926.             String delete_item_SQL2 = "DELETE FROM sales_order_items WHERE id = " + req_num.getText().trim();
  1927.             String delete_record_SQL = "DELETE FROM sales_order WHERE id = " + req_num.getText().trim();
  1928.  
  1929.             message("Deleting items in record...");
  1930.  
  1931.             try { stmt.executeUpdate(delete_item_SQL2); }
  1932.             catch (SQLException delete_item_error) { message("Caution! Could not delete all the items in the record!"); }
  1933.  
  1934.             try { stmt.executeUpdate(delete_record_SQL); }
  1935.             catch (SQLException delete_record_error) {message("Caution! Could not delete record!"); }
  1936.  
  1937.             clear_record();
  1938.             set_browse_mode();
  1939.         }
  1940.         else {
  1941.             String update_SQL = "UPDATE sales_order_items SET prod_id = " + prod_id.getText().trim() + ", quantity = " + prod_quan.getText().trim() + ", ship_date = '" + prod_ship.getText().trim() + "' WHERE id = " + req_num.getText().trim() + " AND line_id = " + prod_line.getText().trim();
  1942.  
  1943.             if (!is_missing) {
  1944.                 message("Updating item...");
  1945.  
  1946.                 try {
  1947.                     stmt.executeUpdate(update_SQL);
  1948.                     message("Item updated.");
  1949.                     update_prod_line(true);
  1950.                 }
  1951.                 catch (SQLException save_error) { message("Problem with SQL Statement!  No records were inserted!"); }
  1952.                 show_order_list();
  1953.             }
  1954.         }
  1955.     }
  1956.  
  1957.     // update_prod_line()
  1958.     final void update_prod_line(boolean get_last) {
  1959.         String count_SQL = "SELECT max(line_id) FROM sales_order_items WHERE id = " + req_num.getText().trim();
  1960.  
  1961.         mode = 1;
  1962.  
  1963.         if (get_last) {
  1964.             rs = generate_ResultSet(count_SQL, rs, stmt, true);
  1965.             try { current_item_pos = rs.getInt(1) + 1; rs.close(); }
  1966.             catch (SQLException get_error) { message("Exception caught!  Could not grab last item!"); }
  1967.             clear_item();
  1968.         }
  1969.  
  1970.         add_item_button.disable();
  1971.         edit_item_button.enable();
  1972.         delete_item_button.enable();
  1973.         confirm_button.disable();
  1974.         prod_line.setEditable(false);
  1975.         prod_line.setBackground(Color.lightGray);
  1976.         prod_line.setText(String.valueOf(current_item_pos));
  1977.         prod_id.setEditable(true);
  1978.         prod_id.setBackground(Color.white);
  1979.         prod_quan.setEditable(true);
  1980.         prod_quan.setBackground(Color.white);
  1981.         prod_ship.setEditable(true);
  1982.         prod_ship.setBackground(Color.white);
  1983.         highlight(prod_id);
  1984.     }
  1985.  
  1986.     // handleEvent()
  1987.     public boolean handleEvent(Event event) {
  1988.         Object evt = event.target;
  1989.         int evtx = event.x, evty = event.y;
  1990.  
  1991.         showStatus("Symantec Corp., 1996");
  1992.         if ((mode == 1) || (mode == 3) || (mode == 4)) {
  1993.             if ((evtx > 0 && evtx < 125) && (evty > 75 && evty < 95)) status_bar.setText("Switch to Browse Mode to look up record(s).");
  1994.             else if ((evtx > 127 && evtx < 182) && (evty > 75 && evty < 95)) status_bar.setText("Delete/Save this record.");
  1995.             else if ((evtx > 184 && evtx < 246) && (evty > 75 && evty < 95)) status_bar.setText("Switch between [Add new record]/[Edit existing record].");
  1996.             else if ((evtx > 0 && evtx < 80) && (evty > 516 && evty < 536)) status_bar.setText("Add current item to order list.");
  1997.             else if ((evtx > 88 && evtx < 186) && (evty > 516 && evty < 536)) status_bar.setText("Choose item in order list to update.");
  1998.             else if ((evtx > 196 && evtx < 303) && (evty > 516 && evty < 536)) status_bar.setText("Choose item to delete off of order list.");
  1999.             else if ((evtx > 313 && evtx < 433) && (evty > 516 && evty < 536)) status_bar.setText("Concur that you want to save item to order list.");
  2000.             else if ((evtx > 443 && evtx < 540) && (evty > 516 && evty < 536)) status_bar.setText("Clear current item entry.");
  2001.             else status_bar.setText(current_status_bar);
  2002.         }
  2003.         else if ((mode == 0) || (mode == 2)) {
  2004.             if ((evtx > 0 && evtx < 125) && (evty > 75 && evty <95)) status_bar.setText("Switch to Add/Edit Mode to modify record(s).");
  2005.             else if ((evtx > 127 && evtx < 182) && (evty > 75 && evty < 95)) status_bar.setText("Choose record to delete.");
  2006.             else if ((evtx > 184 && evtx < 214) && (evty > 75 && evty < 95)) status_bar.setText("Go to the first record in this set.");
  2007.             else if ((evtx > 216 && evtx < 246) && (evty > 75 && evty < 95)) status_bar.setText("Go to the next record in this set.");
  2008.             else if ((evtx > 248 && evtx < 344) && (evty > 75 && evty < 95)) status_bar.setText("Search the database given the information that you have entered.");
  2009.             else status_bar.setText(current_status_bar);
  2010.         }
  2011.         if ((evtx > 346 && evtx < 442) && (evty > 75 && evty < 95) && (mode != 2)) status_bar.setText("Clear current record entry.");
  2012.         else if ((evtx > 346 && evtx < 442) && (evty > 75 && evty < 95) && (mode == 2)) status_bar.setText("Continue with browsing.");
  2013.         if ((evtx > 444 && evtx < 540) && (evty > 75 && evty < 95)) status_bar.setText("Quit this program.");
  2014.  
  2015.  
  2016.         if ((event.id == Event.ACTION_EVENT) && (evt instanceof Button)) {
  2017.             if (evt == add_button) { set_add_mode(); }
  2018.             else if (evt == add_item_button) {
  2019.                 if (mode == 1) {
  2020.                     save_item_info();
  2021.                     add_item_button.disable();
  2022.                     highlight(prod_id);
  2023.                 }
  2024.                 else if ((mode >= 2) || (mode <= 4)) { update_prod_line(true); }
  2025.             }
  2026.             else if (evt == browse_button) { clear_record(); set_browse_mode(); }
  2027.             else if (evt == clear_button) {
  2028.                 clear_record();
  2029.                 if (mode == 1) req_region.requestFocus();
  2030.                 else highlight(req_num);
  2031.             }
  2032.             else if (evt == clear_item_button) { clear_item(); }
  2033.             else if (evt == confirm_button) {
  2034.                 if ((mode == 4) || (mode == 1)) { update_delete(false, false); }
  2035.                 else if (mode == 2) { update_delete(true, false); }
  2036.             }
  2037.             else if (evt == delete_button) {
  2038.                 if (mode == 2) { update_delete(false, true); }
  2039.                 else { set_edit(2); delete_button.disable(); }
  2040.             }
  2041.             else if (evt == delete_item_button) {
  2042.                 message("Click on Add Item to continue adding items.");
  2043.                 set_edit_item(2);
  2044.             }
  2045.             else if (evt == edit_button) {
  2046.                 if ((mode == 4) || (mode == 3)){ set_add_mode(); }
  2047.                 else if (mode == 1) { set_edit(4); }
  2048.             }
  2049.             else if (evt == edit_item_button) {
  2050.                 message("Click on Add Item to continue adding items.");
  2051.                 set_edit_item(3);
  2052.             }
  2053.             else if (evt == first_button) {
  2054.                 current_pos = (counter - counter);
  2055.                 nav_buttons(false, false);
  2056.                 rs= generate_ResultSet(SQL_string_asc, rs, stmt, false);
  2057.                 move(1);
  2058.             }
  2059.             else if (evt == next_button) {
  2060.                 current_pos++;
  2061.                 nav_buttons(false, false);
  2062.                 move(2);
  2063.             }
  2064.             else if (evt == save_button) {
  2065.                 save_info();
  2066.                 save_button.disable();
  2067.                 add_item_button.enable();
  2068.                 add_item_button.requestFocus();
  2069.             }
  2070.             else if (evt == search_button) { show_information(); }
  2071.             else { InterruptedException e; return false; }
  2072.             return true;
  2073.         }
  2074.         else if ((event.id == Event.KEY_PRESS) && ((event.key == 9) || (event.key == 10))) {
  2075.             if ((mode == 4) && (event.key == 9)) {
  2076.                 if (evt == prod_id) { get_prod_info(); }
  2077.                 else if (evt == prod_quan) { prod_ship.requestFocus(); prod_ship.selectAll(); }
  2078.                 else if (evt == prod_ship) { prod_id.requestFocus(); prod_id.selectAll(); }
  2079.             }
  2080.             else if ((mode == 4) && (event.key == 10)) {
  2081.                 if (evt == req_num) { get_edit_info(); }
  2082.                 else if (evt == prod_id) { get_prod_info(); }
  2083.                 else if (evt == prod_quan) { prod_ship.requestFocus(); prod_ship.selectAll(); }
  2084.                 else if (evt == prod_ship) {
  2085.                     message("Please confirm requested action...");
  2086.                     confirm_button.enable();
  2087.                     confirm_button.requestFocus();
  2088.                 }
  2089.                 else if (evt == confirm_button) { update_delete(false, false); }
  2090.             }
  2091.             else if ((mode == 3) && (event.key == 10)) { get_prod_item(); }
  2092.             else if ((mode == 2) && (event.key == 10)) {
  2093.                 if (evt == prod_line) { get_prod_item(); }
  2094.                 else if (evt == req_num) { show_information(); }
  2095.                 else if (evt == confirm_button) {  update_delete(true, false); }
  2096.             }
  2097.             else if ((mode == 1) && (event.key == 10)) {
  2098.                 if (evt == req_region) { highlight(cust_num); }
  2099.                 else if (evt == cust_num) { get_cust_info(); }
  2100.                 else if (evt == empl_num) { get_empl_info(); }
  2101.                 else if (evt == prod_line) { get_prod_item(); set_editing(); }
  2102.                 else if (evt == prod_id) { get_prod_info(); }
  2103.                 else if (evt == prod_quan) { highlight(prod_ship); }
  2104.                 else if (evt == prod_ship) {
  2105.                     if (record_saved) {
  2106.                         message("Press return or click on the Add Item button to save item.");
  2107.                         add_item_button.enable();
  2108.                         add_item_button.requestFocus();
  2109.                     }
  2110.                     else {
  2111.                         message("Press return or click on the Save button to save.");
  2112.                         save_button.enable();
  2113.                         save_button.requestFocus();
  2114.                     }
  2115.                 }
  2116.                 else if (evt == add_item_button) {
  2117.                     save_item_info();
  2118.                     add_item_button.disable();
  2119.                     highlight(prod_id);
  2120.                 }
  2121.                 else if (evt == edit_item_button) {
  2122.                     message("Click on Add Item to continue adding items.");
  2123.                     set_edit_item(3);
  2124.                 }
  2125.                 else if (evt == save_button) {
  2126.                     save_info();
  2127.                     save_button.disable();
  2128.                     add_item_button.enable();
  2129.                     add_item_button.requestFocus();
  2130.                 }
  2131.             }
  2132.             else if ((mode == 1) && (event.key == 9)) {
  2133.                 if (evt == req_region) { highlight(cust_num); }
  2134.                 else if (evt == cust_num) { get_cust_info(); }
  2135.                 else if (evt == empl_num) { get_empl_info(); }
  2136.                 else if (evt == prod_line) { get_prod_item(); set_editing(); }
  2137.                 else if (evt == prod_id) { get_prod_info(); }
  2138.                 else if (evt == prod_quan) { highlight(prod_ship); }
  2139.                 else if (evt == prod_ship) { req_region.requestFocus(); }
  2140.             }
  2141.             else if ((mode == 0) && ((event.key == 9) || (event.key == 10))) {
  2142.                 if (evt == req_num) { req_date.requestFocus(); }
  2143.                 else if (evt == req_date) { req_region.requestFocus(); }
  2144.                 else if (evt == req_region) { cust_num.requestFocus(); }
  2145.                 else if (evt == cust_num) { cust_first.requestFocus(); }
  2146.                 else if (evt == cust_first) { cust_last.requestFocus(); }
  2147.                 else if (evt == cust_last) { cust_addr.requestFocus(); }
  2148.                 else if (evt == cust_addr) { cust_city.requestFocus(); }
  2149.                 else if (evt == cust_city) { cust_state.requestFocus(); }
  2150.                 else if (evt == cust_state) { cust_zip.requestFocus(); }
  2151.                 else if (evt == cust_zip) { cust_company.requestFocus(); }
  2152.                 else if (evt == cust_company) { cust_phone.requestFocus(); }
  2153.                 else if (evt == cust_phone) { empl_num.requestFocus(); }
  2154.                 else if (evt == empl_num) { empl_first.requestFocus(); }
  2155.                 else if (evt == empl_first) { empl_last.requestFocus(); }
  2156.                 else if (evt == empl_last) { empl_dept.requestFocus(); }
  2157.                 else if (evt == empl_dept) { req_num.requestFocus(); }
  2158.             }
  2159.             return true;
  2160.         }
  2161.         else if ((event.id == Event.MOUSE_DOWN) && (evt == this)) { update(this.getGraphics()); return true; }
  2162.         else if (event.id == Event.WINDOW_DESTROY) { close_server(); System.exit(0); return true; }
  2163.         else if (event.id == Event.WINDOW_MOVED) { update(this.getGraphics()); return true; }
  2164.         else return super.handleEvent(event);
  2165.     }
  2166.  
  2167.     // Global Objects
  2168.     private boolean first = false, good_connection = false, record_saved = false;
  2169.     private int counter = 0, current_pos = 0, current_item_pos = 0, mode = 0;
  2170.     // mode: 0 = browse, 1 = add, 2 = delete item, 3 = update item, 4 = editing items
  2171.     private Color current_color = Color.white;
  2172.     private Font cour_reg_font = new Font("Courier", Font.PLAIN, 12);
  2173.     private Font hel_reg_font = new Font("Helvetica", Font.PLAIN, 12);
  2174.     private Font hel_reg_11_font = new Font("Helvetica", Font.PLAIN, 11);
  2175.     private Font hel_reg_14_font = new Font("Helvetica", Font.PLAIN, 14);
  2176.     private Font hel_bold_16_font = new Font("Helvetica", Font.BOLD, 16);
  2177.     private Font company_font = new Font("Helvetica", Font.BOLD, 26);
  2178.     private String current_status_bar;
  2179.  
  2180.     // Instantiate UI and Thread Objects
  2181.     Button browse_button, add_button, delete_button, edit_button, save_button, clear_button;
  2182.     Button first_button, next_button, search_button, quit_button;
  2183.     Button add_item_button, edit_item_button, delete_item_button, clear_item_button, confirm_button;
  2184.  
  2185.     Choice empl_dept, req_region;
  2186.  
  2187.     Label record_label;
  2188.     Label req_date_label, req_fin_label, req_region_label;
  2189.     Label cust_first_label, cust_last_label, cust_addr_label, cust_city_label;
  2190.     Label cust_state_label, cust_zip_label, cust_phone_label, cust_company_label;
  2191.     Label empl_first_label, empl_last_label, empl_dept_label;
  2192.     Label prod_line_label, prod_id_label, prod_quan_label, prod_ship_label;
  2193.  
  2194.     TextArea order_list;
  2195.  
  2196.     TextField prod_header, req_total, req_current;
  2197.     TextField req_num, req_date, req_fin, status_bar;
  2198.     TextField cust_num, cust_first, cust_last, cust_addr, cust_city;
  2199.     TextField cust_state, cust_zip, cust_phone, cust_company;
  2200.     TextField empl_num, empl_first, empl_last;
  2201.     TextField prod_line, prod_id, prod_quan, prod_ship, prod_mask;
  2202.  
  2203.     Thread kicker = null;
  2204.  
  2205.     // JDBC Objects
  2206.     Connection server;
  2207.     DriverManager dmanager;
  2208.     Driver dbaw_driver;
  2209.     ResultSet rs;
  2210.     Statement stmt;
  2211.     Properties props = new Properties();
  2212.     private String SQL_string_asc;
  2213.     private String dbaw_driver_name = "symantec.itools.db.jdbc.Driver";
  2214.     private String server_url = "jdbc:dbaw://localhost:8889/Watcom/SQL Anywhere 5.0 Sample/SQL Anywhere";
  2215. }