Technology Store – Java

My Java Technology Store was one of the most comprehensive Java applications I had to develop for university. The assignment brief was to develop a Java store/shop point of sale application that stores inventory and customer/staff details between sessions of use of the application. The information was read and written to a Microsoft Access database during operation.

For extra credit I implemented a login screen which dependant on which type of staff logging displays the appropriate screen i.e managers login shows screens for editing inventory and showing sales information such as sales figures etc while the sales assistant screen just shows options to make a sale and access certain sales figure information.

During the summer break, I modified the application slightly to read/write the data from a MYSQL database located on the university’s server so the application could access the data from any location and the inventory could be implemented into a e-commerce solution alongside the physical application.

 

Code Snippet

import java.sql.ResultSet;
import java.util.*;
import javax.swing.*;
/**
 *
 * @author Robert Jones 
 */
public class Sales extends javax.swing.JFrame {

    /**
     * Creates new form Sales
     */
    public Sales() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    //                           
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jPanel9 = new javax.swing.JPanel();
        jLabel34 = new javax.swing.JLabel();
        txtSearch = new javax.swing.JTextField();
        btnSearch = new javax.swing.JButton();
        btnClearSearch = new javax.swing.JButton();
        jLabel33 = new javax.swing.JLabel();
        cmbSearchResults = new javax.swing.JComboBox();
        jLabel49 = new javax.swing.JLabel();
        jPanel8 = new javax.swing.JPanel();
        jLabel36 = new javax.swing.JLabel();
        jLabel38 = new javax.swing.JLabel();
        jLabel40 = new javax.swing.JLabel();
        jLabel41 = new javax.swing.JLabel();
        jLabel42 = new javax.swing.JLabel();
        txtCustomerName = new javax.swing.JTextField();
        txtCustomerAddress = new javax.swing.JTextField();
        txtCustomerTel = new javax.swing.JTextField();
        txtCustomerEmail = new javax.swing.JTextField();
        jPanel6 = new javax.swing.JPanel();
        jLabel35 = new javax.swing.JLabel();
        lblItemName = new javax.swing.JLabel();
        jLabel43 = new javax.swing.JLabel();
        lblManName = new javax.swing.JLabel();
        jLabel37 = new javax.swing.JLabel();
        lblItemSp1 = new javax.swing.JLabel();
        jLabel39 = new javax.swing.JLabel();
        lblItemSp2 = new javax.swing.JLabel();
        jLabel45 = new javax.swing.JLabel();
        lblStockLvl = new javax.swing.JLabel();
        jLabel47 = new javax.swing.JLabel();
        lblPrice = new javax.swing.JLabel();
        jLabel44 = new javax.swing.JLabel();
        cmbOrderQty = new javax.swing.JComboBox();
        jPanel10 = new javax.swing.JPanel();
        lblOrderTotal = new javax.swing.JLabel();
        jLabel46 = new javax.swing.JLabel();
        jLabel48 = new javax.swing.JLabel();
        btnCancelOrder = new javax.swing.JButton();
        btnPlaceOrder = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        jPanel3 = new javax.swing.JPanel();
        jLabel19 = new javax.swing.JLabel();
        cmbListCust = new javax.swing.JComboBox();
        btnListCust = new javax.swing.JButton();
        jLabel27 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();
        jLabel22 = new javax.swing.JLabel();
        jLabel23 = new javax.swing.JLabel();
        jLabel24 = new javax.swing.JLabel();
        jLabel25 = new javax.swing.JLabel();
        jLabel26 = new javax.swing.JLabel();
        txtTotalCustomerOrder = new javax.swing.JTextField();
        txtPurQty = new javax.swing.JTextField();
        txtItemPur = new javax.swing.JTextField();
        txtCustEma = new javax.swing.JTextField();
        txtCustTel = new javax.swing.JTextField();
        txtCustAddr = new javax.swing.JTextField();
        txtCustName = new javax.swing.JTextField();
        lblOrderNum = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        jPanel7 = new javax.swing.JPanel();
        jLabel31 = new javax.swing.JLabel();
        lblTotalStockCost = new javax.swing.JLabel();
        lblTotalLowQty = new javax.swing.JLabel();
        lblTotalQty = new javax.swing.JLabel();
        lblNumCust = new javax.swing.JLabel();
        lblnumProd = new javax.swing.JLabel();
        lblNoMan = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel28 = new javax.swing.JLabel();
        jLabel29 = new javax.swing.JLabel();
        jLabel30 = new javax.swing.JLabel();
        jLabel32 = new javax.swing.JLabel();
        jLabel56 = new javax.swing.JLabel();
        jPanel11 = new javax.swing.JPanel();
        lblTotalItemsSold = new javax.swing.JLabel();
        lblTotalRev = new javax.swing.JLabel();
        lblTotalOrders = new javax.swing.JLabel();
        jLabel52 = new javax.swing.JLabel();
        jlabel = new javax.swing.JLabel();
        anothrJlabe = new javax.swing.JLabel();
        jLabel57 = new javax.swing.JLabel();
        btnGenReport = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 48)); // NOI18N
        jLabel1.setText("Electronics Store");

        jPanel9.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel34.setText("Search:");

        txtSearch.setToolTipText("Search by Brand, Name or Specification");
        txtSearch.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtSearchActionPerformed(evt);
            }
        });

        btnSearch.setText("Go");
        btnSearch.setToolTipText("Find Items");
        btnSearch.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSearchActionPerformed(evt);
            }
        });

        btnClearSearch.setText("Clear");
        btnClearSearch.setToolTipText("Reset Results");
        btnClearSearch.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnClearSearchActionPerformed(evt);
            }
        });

        jLabel33.setText("Results:");

        cmbSearchResults.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmbSearchResultsActionPerformed(evt);
            }
        });

        jLabel49.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel49.setText("Search:");

        javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
        jPanel9.setLayout(jPanel9Layout);
        jPanel9Layout.setHorizontalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel9Layout.createSequentialGroup()
                        .addComponent(jLabel34)
                        .addGap(20, 20, 20)
                        .addComponent(txtSearch, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(btnSearch)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnClearSearch))
                    .addGroup(jPanel9Layout.createSequentialGroup()
                        .addComponent(jLabel33)
                        .addGap(18, 18, 18)
                        .addComponent(cmbSearchResults, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jLabel49))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel9Layout.setVerticalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel9Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabel49)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtSearch, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel34)
                    .addComponent(btnSearch)
                    .addComponent(btnClearSearch))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel33)
                    .addComponent(cmbSearchResults, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        jPanel8.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel36.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel36.setText("Customer details:");

        jLabel38.setText("Name:");

        jLabel40.setText("Address:");

        jLabel41.setText("Tel:");

        jLabel42.setText("Email:");

        txtCustomerName.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtCustomerNameActionPerformed(evt);
            }
        });

        txtCustomerAddress.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtCustomerAddressActionPerformed(evt);
            }
        });

        txtCustomerTel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtCustomerTelActionPerformed(evt);
            }
        });

        txtCustomerEmail.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtCustomerEmailActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel40)
                    .addComponent(jLabel41)
                    .addComponent(jLabel42)
                    .addComponent(jLabel38)
                    .addComponent(jLabel36))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtCustomerName, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtCustomerAddress, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtCustomerTel, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtCustomerEmail, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(243, 243, 243))
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel36)
                .addGap(18, 18, 18)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel38)
                    .addComponent(txtCustomerName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel40)
                    .addComponent(txtCustomerAddress, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel41)
                    .addComponent(txtCustomerTel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel42)
                    .addComponent(txtCustomerEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(30, Short.MAX_VALUE))
        );

        jPanel6.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel35.setText("Item Name:");

        lblItemName.setText("Name");

        jLabel43.setText("Manufacturer:");

        lblManName.setText("Name");

        jLabel37.setText("Item Spec1:");

        lblItemSp1.setText("Name");

        jLabel39.setText("Item Spec2:");

        lblItemSp2.setText("Name");

        jLabel45.setText("In Stock:");

        lblStockLvl.setText("Name");

        jLabel47.setText("Price Per Item:");

        lblPrice.setText("Name");

        jLabel44.setText("Order Quantity:");

        cmbOrderQty.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" }));
        cmbOrderQty.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmbOrderQtyActionPerformed(evt);
            }
        });

        jPanel10.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        lblOrderTotal.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        lblOrderTotal.setText("£0.0");

        jLabel46.setText("Total Price:");

        javax.swing.GroupLayout jPanel10Layout = new javax.swing.GroupLayout(jPanel10);
        jPanel10.setLayout(jPanel10Layout);
        jPanel10Layout.setHorizontalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel10Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel46)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 41, Short.MAX_VALUE)
                .addComponent(lblOrderTotal)
                .addContainerGap())
        );
        jPanel10Layout.setVerticalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel10Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblOrderTotal)
                    .addComponent(jLabel46))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jLabel48.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel48.setText("Item details:");

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addGap(29, 29, 29)
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel37)
                            .addComponent(jLabel35)
                            .addGroup(jPanel6Layout.createSequentialGroup()
                                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel44)
                                    .addComponent(jLabel43)
                                    .addComponent(jLabel39)
                                    .addComponent(jLabel45)
                                    .addComponent(jLabel47))
                                .addGap(164, 164, 164)
                                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(cmbOrderQty, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(lblItemSp1)
                                    .addComponent(lblManName)
                                    .addComponent(lblItemSp2)
                                    .addComponent(lblStockLvl)
                                    .addComponent(lblPrice)
                                    .addComponent(lblItemName)))
                            .addComponent(jLabel48)))
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addGap(91, 91, 91)
                        .addComponent(jPanel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(89, Short.MAX_VALUE))
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel6Layout.createSequentialGroup()
                .addGap(7, 7, 7)
                .addComponent(jLabel48)
                .addGap(18, 18, 18)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel35)
                    .addComponent(lblItemName))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel43)
                    .addComponent(lblManName))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel37)
                    .addComponent(lblItemSp1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel39)
                    .addComponent(lblItemSp2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel45)
                    .addComponent(lblStockLvl))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel47)
                    .addComponent(lblPrice))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel44)
                    .addComponent(cmbOrderQty, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 11, Short.MAX_VALUE)
                .addComponent(jPanel10, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        btnCancelOrder.setText("Cancel");
        btnCancelOrder.setToolTipText("Cancel Order");
        btnCancelOrder.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelOrderActionPerformed(evt);
            }
        });

        btnPlaceOrder.setText("Order");
        btnPlaceOrder.setToolTipText("Place Order");
        btnPlaceOrder.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPlaceOrderActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(29, 29, 29)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, 320, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap())
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(76, 76, 76)
                        .addComponent(btnCancelOrder)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnPlaceOrder)
                        .addGap(0, 0, Short.MAX_VALUE))))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(19, 19, 19)
                        .addComponent(jPanel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(14, 14, 14)
                        .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(64, 64, 64)
                        .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(btnCancelOrder)
                            .addComponent(btnPlaceOrder))))
                .addContainerGap(34, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Sales", jPanel1);

        jPanel3.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel19.setText("Customer:");

        cmbListCust.setToolTipText("Customer List");
        cmbListCust.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmbListCustActionPerformed(evt);
            }
        });

        btnListCust.setText("List");
        btnListCust.setToolTipText("Show Customers");
        btnListCust.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnListCustActionPerformed(evt);
            }
        });

        jLabel27.setText("Order Number:");

        jLabel20.setText("Cust Name:");

        jLabel21.setText("Cust Address:");

        jLabel22.setText("Cust Tel:");

        jLabel23.setText("Cust Email:");

        jLabel24.setText("Item Purchased:");

        jLabel25.setText("Item Qty");

        jLabel26.setText("Order Price:");

        lblOrderNum.setText("0");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel21)
                            .addComponent(jLabel20))
                        .addGap(21, 21, 21)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtCustName, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel3Layout.createSequentialGroup()
                                    .addGap(1, 1, 1)
                                    .addComponent(txtCustTel))
                                .addComponent(txtTotalCustomerOrder, javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(txtPurQty, javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(txtItemPur)
                                .addComponent(txtCustEma, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(txtCustAddr, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jLabel19)
                        .addGap(40, 40, 40)
                        .addComponent(cmbListCust, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(btnListCust))
                    .addComponent(jLabel22)
                    .addComponent(jLabel23)
                    .addComponent(jLabel25)
                    .addComponent(jLabel26)
                    .addComponent(jLabel24)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jLabel27)
                        .addGap(18, 18, 18)
                        .addComponent(lblOrderNum)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel19)
                    .addComponent(cmbListCust, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnListCust))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel27)
                    .addComponent(lblOrderNum))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel20)
                    .addComponent(txtCustName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel21)
                    .addComponent(txtCustAddr, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(7, 7, 7)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel22)
                    .addComponent(txtCustTel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel23)
                    .addComponent(txtCustEma, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel24)
                    .addComponent(txtItemPur, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel25)
                    .addComponent(txtPurQty, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel26)
                    .addComponent(txtTotalCustomerOrder, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(64, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(496, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(98, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Customers", jPanel2);

        jPanel7.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel31.setText("Total Cost of Stock:");

        lblTotalStockCost.setText("0");

        lblTotalLowQty.setText("0");

        lblTotalQty.setText("0");

        lblNumCust.setText("0");

        lblnumProd.setText("0");

        lblNoMan.setText("0");

        jLabel11.setText("Number of Manufacturers: ");

        jLabel28.setText("Number of Prod lines:");

        jLabel29.setText("Number of Customers:");

        jLabel30.setText("Total Qty of Stock:");

        jLabel32.setText("Total Low Qty Stock:");

        jLabel56.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        jLabel56.setText("General:");

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addGap(21, 21, 21)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel11)
                            .addComponent(jLabel28)
                            .addComponent(jLabel29)
                            .addComponent(jLabel30)
                            .addComponent(jLabel31)
                            .addComponent(jLabel32))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblTotalStockCost)
                            .addComponent(lblTotalLowQty)
                            .addComponent(lblTotalQty)
                            .addComponent(lblNumCust)
                            .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(lblnumProd, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(lblNoMan))))
                    .addComponent(jLabel56, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(123, Short.MAX_VALUE))
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel56)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 11, Short.MAX_VALUE)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(lblNoMan))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel28)
                    .addComponent(lblnumProd))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel29)
                    .addComponent(lblNumCust))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel30)
                    .addComponent(lblTotalQty))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel32)
                    .addComponent(lblTotalLowQty))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel31)
                    .addComponent(lblTotalStockCost))
                .addContainerGap())
        );

        jPanel11.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        lblTotalItemsSold.setText("0");

        lblTotalRev.setText("0");

        lblTotalOrders.setText("0");

        jLabel52.setText("Total Orders:");

        jlabel.setText("Total Order Revenue:");

        anothrJlabe.setText("Total Items Sold:");

        jLabel57.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        jLabel57.setText("Sales:");

        javax.swing.GroupLayout jPanel11Layout = new javax.swing.GroupLayout(jPanel11);
        jPanel11.setLayout(jPanel11Layout);
        jPanel11Layout.setHorizontalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addGap(21, 21, 21)
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel57, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel11Layout.createSequentialGroup()
                        .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(anothrJlabe)
                            .addComponent(jlabel)
                            .addComponent(jLabel52))
                        .addGap(44, 44, 44)
                        .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(lblTotalItemsSold)
                            .addComponent(lblTotalRev)
                            .addComponent(lblTotalOrders))))
                .addContainerGap(85, Short.MAX_VALUE))
        );
        jPanel11Layout.setVerticalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel11Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel57)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel52)
                    .addComponent(lblTotalOrders))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(anothrJlabe)
                    .addComponent(lblTotalItemsSold))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jlabel)
                    .addComponent(lblTotalRev))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        btnGenReport.setText("Generate Reports");
        btnGenReport.setToolTipText("Show Reports");
        btnGenReport.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnGenReportActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(120, 120, 120)
                        .addComponent(jPanel11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGap(293, 293, 293)
                        .addComponent(btnGenReport)))
                .addContainerGap(72, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(56, 56, 56)
                .addComponent(btnGenReport)
                .addContainerGap(156, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Reports", jPanel4);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jLabel1)
                .addGap(0, 386, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 447, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }//                         

    private void txtSearchActionPerformed(java.awt.event.ActionEvent evt) {                                          
        // TODO add your handling code here:
    }                                         

    private void btnSearchActionPerformed(java.awt.event.ActionEvent evt) {                                          

        String searchTerm = txtSearch.getText().toLowerCase();

        ResultSet myrsStockTable;
        DataBaseAccess myDBAccess = new DataBaseAccess();
//        sql query string - query searchs item name, manufactuer or by specification
        String sqlString = "SELECT * FROM stock WHERE itemName like '%" + searchTerm + "%' or itemSpec1 like '%" + searchTerm + "%' or itemSpec2 like '%" + searchTerm + "%' or manName like '%" + searchTerm + "%' ";
        myrsStockTable = myDBAccess.ConnectDB("electronicsDBase", sqlString);

        try {
            while (myrsStockTable.next()) {
//                store item name as variable
                String rsProdName = myrsStockTable.getString("itemName");
//                add item to results combo box
                cmbSearchResults.addItem(rsProdName);
            }
            myDBAccess.CloseResultSet();
        } catch (Exception e) {
            System.out.println("Problem with DataSet");
        }
    }                                         

    private void btnClearSearchActionPerformed(java.awt.event.ActionEvent evt) {                                               
        //        clears search and combobox
        cmbSearchResults.removeAllItems();
    }                                              

    private void cmbSearchResultsActionPerformed(java.awt.event.ActionEvent evt) {                                                 
        //      get currently selected item from combo box
        String selectedItem = cmbSearchResults.getSelectedItem().toString();
//        get currently slected quantity from qty combobox
        String selectedQty = cmbOrderQty.getSelectedItem().toString();
        int orderQty = Integer.parseInt(selectedQty);

        ResultSet myrsSearchResults;
        DataBaseAccess myDBAccess = new DataBaseAccess();
//        sql query
        myrsSearchResults = myDBAccess.ConnectDB("electronicsDBase", "SELECT * FROM stock WHERE itemName='" + selectedItem + "'");

        try {
            myrsSearchResults.next();
//            store info from row as varibles
            String rsManName = myrsSearchResults.getString("manName");
            String rsProdName = myrsSearchResults.getString("itemName");
            String rsItemSp1 = myrsSearchResults.getString("itemSpec1");
            String rsItemSp2 = myrsSearchResults.getString("itemSpec2");
            double ogItemPrc = myrsSearchResults.getDouble("itemPrice");
            String rsItemPrc = Double.toString(ogItemPrc);
            int ogItemQty = myrsSearchResults.getInt("itemInStock");
            String rsItemQty = Integer.toString(ogItemQty);

//            display info from variables in labels
            lblManName.setText(rsManName);
            lblItemName.setText(rsProdName);
            lblItemSp1.setText(rsItemSp1);
            lblItemSp2.setText(rsItemSp2);
            lblPrice.setText(rsItemPrc);
            lblStockLvl.setText(rsItemQty);
            double orTotal = orderQty * ogItemPrc;
            String displayTotal = Double.toString(orTotal);
            lblOrderTotal.setText("£" + displayTotal);
        } catch (Exception e) {
            System.out.println("Problem with Resultset");
        }
        myDBAccess.CloseResultSet();
    }                                                

    private void txtCustomerNameActionPerformed(java.awt.event.ActionEvent evt) {                                                
        // TODO add your handling code here:
    }                                               

    private void txtCustomerAddressActionPerformed(java.awt.event.ActionEvent evt) {                                                   
        // TODO add your handling code here:
    }                                                  

    private void txtCustomerTelActionPerformed(java.awt.event.ActionEvent evt) {                                               
        // TODO add your handling code here:
    }                                              

    private void txtCustomerEmailActionPerformed(java.awt.event.ActionEvent evt) {                                                 
        // TODO add your handling code here:
    }                                                

    private void cmbOrderQtyActionPerformed(java.awt.event.ActionEvent evt) {                                            
        //        get currently selected item from combo box
        String selectedItem = cmbSearchResults.getSelectedItem().toString();
//        get currently selected qty form qty combobox
        String selectedQty = cmbOrderQty.getSelectedItem().toString();
        int orderQty = Integer.parseInt(selectedQty);

        ResultSet myrsUpdateQty;
        DataBaseAccess myDBAccess = new DataBaseAccess();
//        sql query
        myrsUpdateQty = myDBAccess.ConnectDB("electronicsDBase", "SELECT * FROM stock WHERE itemName='" + selectedItem + "'");

        try {
            myrsUpdateQty.next();
//            get info from table and store as variables
            double ogItemPrc = myrsUpdateQty.getDouble("itemPrice");
            String rsItemPrc = Double.toString(ogItemPrc);
//            maths to workout total cost of items dependant on qty
            double orTotal = orderQty * ogItemPrc;
            String displayTotal = Double.toString(orTotal);
//            display order total
            lblOrderTotal.setText("£" + displayTotal);
        } catch (Exception e) {
            System.out.println("Problem with Resultset");
        }
        myDBAccess.CloseResultSet();
    }                                           

    private void btnCancelOrderActionPerformed(java.awt.event.ActionEvent evt) {                                               
        //        clear txt boxes of current information
        txtCustomerName.setText(null);
        txtCustomerAddress.setText(null);
        txtCustomerTel.setText(null);
        txtCustomerEmail.setText(null);
    }                                              

    private void btnPlaceOrderActionPerformed(java.awt.event.ActionEvent evt) {                                              
         //        store item name and qty as variables
        String selectedItem = lblItemName.getText();
        String selectedQty = cmbOrderQty.getSelectedItem().toString();
        int orderQty = Integer.parseInt(selectedQty);
//        random num generator for order number
        Random rndGen = new Random(697697867);
        int low = rndGen.nextInt(123456 + 1);
        int high = rndGen.nextInt(697697867 - 27);
//        generate order number
        int orderNumber = orderQty * (low * high - 1);
//        get info reagarding order and store as variables
        String pricePerunit = lblPrice.getText();
        double getPPU = Double.parseDouble(pricePerunit);
        double getOrderTotal = getPPU * orderQty;
        String stkLvl = lblStockLvl.getText();
        int stockLevel = Integer.parseInt(stkLvl);

        ResultSet myrsCustomers;
        ResultSet myrsStock;
        //sql Strings to update tables
        String sqlCustomer = "SELECT * FROM customer";
        String sqlStock = "SELECT * FROM stock WHERE itemName = '" + selectedItem + "'";
        DataBaseAccess myDBAccess = new DataBaseAccess();
//        sql query
        myrsCustomers = myDBAccess.ConnectDB("electronicsDBase", sqlCustomer);
        myrsStock = myDBAccess.ConnectDB("electronicsDBase", sqlStock);
//      check items for order are in stock 
        if (orderQty > stockLevel) {
//            display error message 
            JOptionPane.showMessageDialog(this, "Error! Order quantity is greater than items in stock.\nPlease try again.", "Problem with Current Order!", JOptionPane.ERROR_MESSAGE);
        } else {

            try {
//            insert new record intotable by moving to the end of the table
                myrsCustomers.next(); // Move to the first row in rs
                myrsCustomers.moveToInsertRow();

//            get order info from text boxes and labels
                String getCustName = txtCustomerName.getText();
                String getCustAddre = txtCustomerAddress.getText();
                String getCustTel = txtCustomerTel.getText();
                String getCustEma = txtCustomerEmail.getText();
                String getItemName = lblItemName.getText();
//            update customer table with info regarding order
                myrsCustomers.updateInt(1, orderNumber);
                myrsCustomers.updateString(2, getCustName);
                myrsCustomers.updateString(3, getCustAddre);
                myrsCustomers.updateString(4, getCustTel);
                myrsCustomers.updateString(5, getCustEma);
                myrsCustomers.updateString(6, getItemName);
                myrsCustomers.updateInt(7, orderQty);
                myrsCustomers.updateDouble(8, getOrderTotal);
//                insert new row
                myrsCustomers.insertRow();
            } catch (Exception e) {
                System.out.println("Problem with the Update");

            }
            try {
                myrsStock.next();
//                update stock levels for selected item
                int currentStockLvl = myrsStock.getInt("itemInStock");
                int newStockLvl = currentStockLvl - orderQty;
//                update stock levels in stock table
                myrsStock.updateInt(7, newStockLvl);
                myrsStock.updateRow();
            } catch (Exception e) {
                System.out.println("Problem with the Updating Stock");
            }
        }
//        show confirmation message
        JOptionPane.showMessageDialog(this, "SUCCESS! Order Placed ", "Click Ok to Continue", JOptionPane.INFORMATION_MESSAGE);
        myDBAccess.CloseResultSet();
    }                                             

    private void cmbListCustActionPerformed(java.awt.event.ActionEvent evt) {                                            
        //     Get currently selected item from combobox
        String selectedItem = cmbListCust.getSelectedItem().toString();

        ResultSet myrsListCust;
        DataBaseAccess myDBAccess = new DataBaseAccess();

        //sql String
        String sqlString = "SELECT * FROM customer WHERE custName='" + selectedItem + "'";
        myrsListCust = myDBAccess.ConnectDB("electronicsDBase", sqlString);

        try {
            myrsListCust.next();
//            get values from table row and store values in variables
            int ogSaleID = myrsListCust.getInt("saleID");
            String rsSaleID = Integer.toString(ogSaleID);
            String rsCustName = myrsListCust.getString("custName");
            String rsCusAdd = myrsListCust.getString("custAdd");
            String rsCustTel = myrsListCust.getString("custTel");
            String rsCustEma = myrsListCust.getString("custEma");
            String rsItemPur = myrsListCust.getString("itemName");
            int ogOrQty = myrsListCust.getInt("ordQty");
            String rsOrQty = Integer.toString(ogOrQty);
            double ogOrTot = myrsListCust.getDouble("ordTotal");
            String rsOrTot = Double.toString(ogOrTot);

//            display dustomer information in txtboxes for manipulation
            lblOrderNum.setText(rsSaleID);
            txtCustName.setText(rsCustName);
            txtCustAddr.setText(rsCusAdd);
            txtCustTel.setText(rsCustTel);
            txtCustEma.setText(rsCustEma);
            txtItemPur.setText(rsItemPur);
            txtPurQty.setText(rsOrQty);
            txtTotalCustomerOrder.setText(rsOrTot);
        } catch (Exception e) {
            System.out.println("Problem with Resultset");
        }
        myDBAccess.CloseResultSet();
    }                                           

    private void btnListCustActionPerformed(java.awt.event.ActionEvent evt) {                                            
        ResultSet myrsListCust;
        DataBaseAccess myDBAccess = new DataBaseAccess();
        //sql string to query batbase
        String sqlString = "select * from customer";
        myrsListCust = myDBAccess.ConnectDB("electronicsDBase", sqlString);

        try {
            while (myrsListCust.next()) {
//                get customer name from table
                String rsCustName = myrsListCust.getString("custName");
//                add customer name to combobox
                cmbListCust.addItem(rsCustName);
            }
            myDBAccess.CloseResultSet();
        } catch (Exception e) {
            System.out.println("Problem with DataSet");
        }
    }                                           

    private void btnGenReportActionPerformed(java.awt.event.ActionEvent evt) {                                             
        ResultSet myrsMan;
        ResultSet myrsCustomers;
        ResultSet myrsStock;
        DataBaseAccess myDBAccess = new DataBaseAccess();

        //sql Strings
        String sqlCustomer = "SELECT * FROM customer";
        String sqlMan = "SELECT * FROM manufacturer";
        String sqlStock = "SELECT * FROM stock";

//        sql querys from sql string variables
        myrsMan = myDBAccess.ConnectDB("electronicsDBase", sqlMan);
        myrsStock = myDBAccess.ConnectDB("electronicsDBase", sqlStock);
        myrsCustomers = myDBAccess.ConnectDB("electronicsDBase", sqlCustomer);

        try {
//            to display man reports
//            count varibles to store number of manufacturers, stock items and customer
            int manCount = 0;
            int stockCount = 0;
            int custCount = 0;
            int totalStockCount = 0;
//            varibles for total stock cost, number of low qty stock and total order costs
            double totalStockCost = 0.0;
            int lowQtyStock = 0;
            double totalOrderCost = 0.0;
            int totalItemsSold = 0;


//            loop to count man
            while (myrsMan.next()) {
                manCount++;
            }
//            loop to display total stock items
            while (myrsStock.next()) {
//             take total qty for each item to display total stock items   
                int stockQty = myrsStock.getInt("itemInStock");
                totalStockCount = stockQty + totalStockCount;
//             take total price for each item to display total cost of items   
                double stockPrice = myrsStock.getInt("itemPrice");
                totalStockCost = stockPrice * stockQty + totalStockCost;

                if (stockQty <= 10) {
                    lowQtyStock++;
                }
//             count number of prod lines
                stockCount++;
            }
//            loop to display total num of customers,cost of orders and items sold
            while (myrsCustomers.next()) {
                custCount++;
                double currentOrderTotal = myrsCustomers.getDouble("ordTotal");
                totalOrderCost = currentOrderTotal + totalOrderCost;
                int currentItQty = myrsCustomers.getInt("ordQty");
                totalItemsSold = currentItQty + totalItemsSold;
            }
            //            display man count
            String cntManString = Integer.toString(manCount);
            lblNoMan.setText(cntManString);
            //            display product count
            String cntItemString = Integer.toString(stockCount);
            lblnumProd.setText(cntItemString);
//               display total num of customers
            String cntCustString = Integer.toString(custCount);
            lblNumCust.setText(cntCustString);
//            display total count of stock items
            String totalStockString = Integer.toString(totalStockCount);
            lblTotalQty.setText(totalStockString);
//            display total cost of stock items
            String totalCostString = Double.toString(totalStockCost);
            lblTotalStockCost.setText("£" + totalCostString);
//            display total low qty stock items
            String totalLowQtyString = Integer.toString(lowQtyStock);
            lblTotalLowQty.setText(totalLowQtyString);
//            display total order revenue label
            String dblTotalOrderCost = Double.toString(totalOrderCost);
            lblTotalRev.setText("£" + dblTotalOrderCost);
//            display total order revenue label
            String displayTotalItemsSold = Integer.toString(totalItemsSold);
            lblTotalItemsSold.setText(displayTotalItemsSold);
//            display total number of order
            lblTotalOrders.setText(cntCustString);
        } catch (Exception e) {
            System.out.println("Problem with Resultset");
        }
        myDBAccess.CloseResultSet();
    }                                            

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Sales.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Sales.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Sales.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Sales.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new Sales().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify                     
    private javax.swing.JLabel anothrJlabe;
    private javax.swing.JButton btnCancelOrder;
    private javax.swing.JButton btnClearSearch;
    private javax.swing.JButton btnGenReport;
    private javax.swing.JButton btnListCust;
    private javax.swing.JButton btnPlaceOrder;
    private javax.swing.JButton btnSearch;
    private javax.swing.JComboBox cmbListCust;
    private javax.swing.JComboBox cmbOrderQty;
    private javax.swing.JComboBox cmbSearchResults;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel28;
    private javax.swing.JLabel jLabel29;
    private javax.swing.JLabel jLabel30;
    private javax.swing.JLabel jLabel31;
    private javax.swing.JLabel jLabel32;
    private javax.swing.JLabel jLabel33;
    private javax.swing.JLabel jLabel34;
    private javax.swing.JLabel jLabel35;
    private javax.swing.JLabel jLabel36;
    private javax.swing.JLabel jLabel37;
    private javax.swing.JLabel jLabel38;
    private javax.swing.JLabel jLabel39;
    private javax.swing.JLabel jLabel40;
    private javax.swing.JLabel jLabel41;
    private javax.swing.JLabel jLabel42;
    private javax.swing.JLabel jLabel43;
    private javax.swing.JLabel jLabel44;
    private javax.swing.JLabel jLabel45;
    private javax.swing.JLabel jLabel46;
    private javax.swing.JLabel jLabel47;
    private javax.swing.JLabel jLabel48;
    private javax.swing.JLabel jLabel49;
    private javax.swing.JLabel jLabel52;
    private javax.swing.JLabel jLabel56;
    private javax.swing.JLabel jLabel57;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel10;
    private javax.swing.JPanel jPanel11;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JLabel jlabel;
    private javax.swing.JLabel lblItemName;
    private javax.swing.JLabel lblItemSp1;
    private javax.swing.JLabel lblItemSp2;
    private javax.swing.JLabel lblManName;
    private javax.swing.JLabel lblNoMan;
    private javax.swing.JLabel lblNumCust;
    private javax.swing.JLabel lblOrderNum;
    private javax.swing.JLabel lblOrderTotal;
    private javax.swing.JLabel lblPrice;
    private javax.swing.JLabel lblStockLvl;
    private javax.swing.JLabel lblTotalItemsSold;
    private javax.swing.JLabel lblTotalLowQty;
    private javax.swing.JLabel lblTotalOrders;
    private javax.swing.JLabel lblTotalQty;
    private javax.swing.JLabel lblTotalRev;
    private javax.swing.JLabel lblTotalStockCost;
    private javax.swing.JLabel lblnumProd;
    private javax.swing.JTextField txtCustAddr;
    private javax.swing.JTextField txtCustEma;
    private javax.swing.JTextField txtCustName;
    private javax.swing.JTextField txtCustTel;
    private javax.swing.JTextField txtCustomerAddress;
    private javax.swing.JTextField txtCustomerEmail;
    private javax.swing.JTextField txtCustomerName;
    private javax.swing.JTextField txtCustomerTel;
    private javax.swing.JTextField txtItemPur;
    private javax.swing.JTextField txtPurQty;
    private javax.swing.JTextField txtSearch;
    private javax.swing.JTextField txtTotalCustomerOrder;
    // End of variables declaration                   
}




Leave a comment

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: