package frames;

import function.Function;
import function.database.StaffProcess;
import java.awt.Color;
import java.util.ArrayList;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import main.Main;
import object.itemmanager.ItemApp;
import object.itemmanager.ProductApp;
import object.billmanager.BillItem;
import object.tablemanager.Table;
import object.itemmanager.Size;

public class StaffManagement extends javax.swing.JFrame {

    ArrayList<ItemApp> alItemApps;
    ArrayList<ProductApp> alProductApps;

    static final int totalTable = 16;
    Table[] arrTable;

    public StaffManagement() {
        initComponents();
        setLocationRelativeTo(null);

        arrTable = initSetNumberTable();

        alItemApps = StaffProcess.getArrayListItem(Main.sqlServerConn);
        fillToComboBoxMH(alItemApps);
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        jPanel1 = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        lbPrice = new javax.swing.JLabel();
        cbSP = new javax.swing.JComboBox<>();
        cbMH = new javax.swing.JComboBox<>();
        jLabel13 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        txtAmount = new javax.swing.JTextField();
        cbSize = new javax.swing.JComboBox<>();
        cbOption = new javax.swing.JComboBox<>();
        jLabel16 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        taNote = new javax.swing.JEditorPane();
        btnClearOrder = new javax.swing.JButton();
        btnDeleteOrder = new javax.swing.JButton();
        btnUpdateOrder = new javax.swing.JButton();
        btnAddOrder = new javax.swing.JButton();
        btnPayOrder = new javax.swing.JButton();
        lbAllTotalMoney = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        btnTable1 = new javax.swing.JButton();
        btnTable2 = new javax.swing.JButton();
        btnTable3 = new javax.swing.JButton();
        btnTable4 = new javax.swing.JButton();
        btnTable11 = new javax.swing.JButton();
        btnTable12 = new javax.swing.JButton();
        btnTable13 = new javax.swing.JButton();
        btnTable14 = new javax.swing.JButton();
        btnTable15 = new javax.swing.JButton();
        btnTable6 = new javax.swing.JButton();
        btnTable10 = new javax.swing.JButton();
        btnTable9 = new javax.swing.JButton();
        btnTable8 = new javax.swing.JButton();
        btnTable7 = new javax.swing.JButton();
        btnTable5 = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        tbSP = new javax.swing.JTable();
        btnTable16 = new javax.swing.JButton();
        btnLogout = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setTitle("Quản lý Quán Cafe - Coffee Master - V1.0.0");
        setResizable(false);
        getContentPane().setLayout(new java.awt.GridBagLayout());

        jPanel1.setOpaque(false);

        jLabel3.setFont(new java.awt.Font("Pristina", 1, 36)); // NOI18N
        jLabel3.setForeground(new java.awt.Color(255, 255, 0));
        jLabel3.setText("Order Coffee");

        jLabel5.setFont(new java.awt.Font("Pristina", 1, 36)); // NOI18N
        jLabel5.setForeground(new java.awt.Color(255, 255, 0));
        jLabel5.setText("Menu Coffee");

        jLabel8.setFont(new java.awt.Font("Tahoma", 1, 13)); // NOI18N
        jLabel8.setForeground(new java.awt.Color(255, 255, 0));
        jLabel8.setText("Danh mục : ");

        jLabel12.setFont(new java.awt.Font("Tahoma", 1, 13)); // NOI18N
        jLabel12.setForeground(new java.awt.Color(255, 255, 0));
        jLabel12.setText("Sản Phẩm : ");

        jLabel14.setFont(new java.awt.Font("Tahoma", 1, 13)); // NOI18N
        jLabel14.setForeground(new java.awt.Color(255, 255, 0));
        jLabel14.setText("Giá : ");

        lbPrice.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        lbPrice.setForeground(new java.awt.Color(255, 255, 0));
        lbPrice.setText("..................");

        cbSP.setFont(new java.awt.Font("Tahoma", 1, 13)); // NOI18N

        cbMH.setFont(new java.awt.Font("Tahoma", 1, 13)); // NOI18N
        cbMH.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbMHActionPerformed(evt);
            }
        });

        jLabel13.setFont(new java.awt.Font("Tahoma", 1, 13)); // NOI18N
        jLabel13.setForeground(new java.awt.Color(255, 255, 0));
        jLabel13.setText("Tùy Chọn : ");

        jLabel17.setFont(new java.awt.Font("Tahoma", 1, 13)); // NOI18N
        jLabel17.setForeground(new java.awt.Color(255, 255, 0));
        jLabel17.setText("Size : ");

        jLabel15.setFont(new java.awt.Font("Tahoma", 1, 13)); // NOI18N
        jLabel15.setForeground(new java.awt.Color(255, 255, 0));
        jLabel15.setText("Số Lượng : ");

        txtAmount.setFont(new java.awt.Font("Tahoma", 1, 13)); // NOI18N
        txtAmount.setText("1");

        cbSize.setFont(new java.awt.Font("Tahoma", 1, 13)); // NOI18N

        cbOption.setFont(new java.awt.Font("Tahoma", 1, 13)); // NOI18N
        cbOption.setEnabled(false);

        jLabel16.setFont(new java.awt.Font("Tahoma", 1, 13)); // NOI18N
        jLabel16.setForeground(new java.awt.Color(255, 255, 0));
        jLabel16.setText("Ghi Chú : ");

        taNote.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jScrollPane1.setViewportView(taNote);

        btnClearOrder.setBackground(new java.awt.Color(255, 255, 0));
        btnClearOrder.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        btnClearOrder.setIcon(new javax.swing.ImageIcon(getClass().getResource("/coffeemaster/delete.png"))); // NOI18N
        btnClearOrder.setText("Clear");
        btnClearOrder.setBorder(null);
        btnClearOrder.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnClearOrderActionPerformed(evt);
            }
        });

        btnDeleteOrder.setBackground(new java.awt.Color(255, 255, 0));
        btnDeleteOrder.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        btnDeleteOrder.setIcon(new javax.swing.ImageIcon(getClass().getResource("/coffeemaster/quit.png"))); // NOI18N
        btnDeleteOrder.setText("Xóa");
        btnDeleteOrder.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDeleteOrderActionPerformed(evt);
            }
        });

        btnUpdateOrder.setBackground(new java.awt.Color(255, 255, 0));
        btnUpdateOrder.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        btnUpdateOrder.setIcon(new javax.swing.ImageIcon(getClass().getResource("/coffeemaster/update.png"))); // NOI18N
        btnUpdateOrder.setText("Sửa");
        btnUpdateOrder.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnUpdateOrderActionPerformed(evt);
            }
        });

        btnAddOrder.setBackground(new java.awt.Color(255, 255, 0));
        btnAddOrder.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        btnAddOrder.setIcon(new javax.swing.ImageIcon(getClass().getResource("/coffeemaster/basket.png"))); // NOI18N
        btnAddOrder.setText("Thêm");
        btnAddOrder.setFocusable(false);
        btnAddOrder.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAddOrderActionPerformed(evt);
            }
        });

        btnPayOrder.setBackground(new java.awt.Color(255, 255, 0));
        btnPayOrder.setFont(new java.awt.Font("Tahoma", 1, 25)); // NOI18N
        btnPayOrder.setForeground(new java.awt.Color(255, 255, 0));
        btnPayOrder.setIcon(new javax.swing.ImageIcon(getClass().getResource("/coffeemaster/buy.png"))); // NOI18N
        btnPayOrder.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPayOrderActionPerformed(evt);
            }
        });

        lbAllTotalMoney.setBackground(new java.awt.Color(0, 0, 0));
        lbAllTotalMoney.setFont(new java.awt.Font("Tahoma", 1, 20)); // NOI18N
        lbAllTotalMoney.setForeground(new java.awt.Color(255, 255, 0));
        lbAllTotalMoney.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lbAllTotalMoney.setText("Tổng Tiền :  0 VND");
        lbAllTotalMoney.setOpaque(true);

        jLabel7.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N

        btnTable1.setBackground(new java.awt.Color(51, 255, 0));
        btnTable1.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        btnTable1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/coffeemaster/dinner.png"))); // NOI18N
        btnTable1.setText("Bàn 1");
        btnTable1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnTable1.setPreferredSize(new java.awt.Dimension(50, 50));
        btnTable1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnTable1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnTable1ActionPerformed(evt);
            }
        });

        btnTable2.setBackground(new java.awt.Color(51, 255, 0));
        btnTable2.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        btnTable2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/coffeemaster/dinner.png"))); // NOI18N
        btnTable2.setText("Bàn 2");
        btnTable2.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnTable2.setPreferredSize(new java.awt.Dimension(50, 50));
        btnTable2.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnTable2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnTable2ActionPerformed(evt);
            }
        });

        btnTable3.setBackground(new java.awt.Color(51, 255, 0));
        btnTable3.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        btnTable3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/coffeemaster/dinner.png"))); // NOI18N
        btnTable3.setText("Bàn 3");
        btnTable3.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnTable3.setPreferredSize(new java.awt.Dimension(50, 50));
        btnTable3.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnTable3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnTable3ActionPerformed(evt);
            }
        });

        btnTable4.setBackground(new java.awt.Color(51, 255, 0));
        btnTable4.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        btnTable4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/coffeemaster/dinner.png"))); // NOI18N
        btnTable4.setText("Bàn 4");
        btnTable4.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnTable4.setPreferredSize(new java.awt.Dimension(50, 50));
        btnTable4.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnTable4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnTable4ActionPerformed(evt);
            }
        });

        btnTable11.setBackground(new java.awt.Color(51, 255, 0));
        btnTable11.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        btnTable11.setIcon(new javax.swing.ImageIcon(getClass().getResource("/coffeemaster/dinner.png"))); // NOI18N
        btnTable11.setText("Bàn 11");
        btnTable11.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnTable11.setPreferredSize(new java.awt.Dimension(50, 50));
        btnTable11.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnTable11.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnTable11ActionPerformed(evt);
            }
        });

        btnTable12.setBackground(new java.awt.Color(51, 255, 0));
        btnTable12.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        btnTable12.setIcon(new javax.swing.ImageIcon(getClass().getResource("/coffeemaster/dinner.png"))); // NOI18N
        btnTable12.setText("Bàn 12");
        btnTable12.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnTable12.setPreferredSize(new java.awt.Dimension(50, 50));
        btnTable12.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnTable12.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnTable12ActionPerformed(evt);
            }
        });

        btnTable13.setBackground(new java.awt.Color(51, 255, 0));
        btnTable13.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        btnTable13.setIcon(new javax.swing.ImageIcon(getClass().getResource("/coffeemaster/dinner.png"))); // NOI18N
        btnTable13.setText("Bàn 13");
        btnTable13.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnTable13.setPreferredSize(new java.awt.Dimension(50, 50));
        btnTable13.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnTable13.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnTable13ActionPerformed(evt);
            }
        });

        btnTable14.setBackground(new java.awt.Color(51, 255, 0));
        btnTable14.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        btnTable14.setIcon(new javax.swing.ImageIcon(getClass().getResource("/coffeemaster/dinner.png"))); // NOI18N
        btnTable14.setText("Bàn 14");
        btnTable14.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnTable14.setPreferredSize(new java.awt.Dimension(50, 50));
        btnTable14.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnTable14.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnTable14ActionPerformed(evt);
            }
        });

        btnTable15.setBackground(new java.awt.Color(51, 255, 0));
        btnTable15.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        btnTable15.setIcon(new javax.swing.ImageIcon(getClass().getResource("/coffeemaster/dinner.png"))); // NOI18N
        btnTable15.setText("Bàn 15");
        btnTable15.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnTable15.setPreferredSize(new java.awt.Dimension(50, 50));
        btnTable15.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnTable15.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnTable15ActionPerformed(evt);
            }
        });

        btnTable6.setBackground(new java.awt.Color(51, 255, 0));
        btnTable6.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        btnTable6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/coffeemaster/dinner.png"))); // NOI18N
        btnTable6.setText("Bàn 6");
        btnTable6.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnTable6.setPreferredSize(new java.awt.Dimension(50, 50));
        btnTable6.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnTable6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnTable6ActionPerformed(evt);
            }
        });

        btnTable10.setBackground(new java.awt.Color(51, 255, 0));
        btnTable10.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        btnTable10.setIcon(new javax.swing.ImageIcon(getClass().getResource("/coffeemaster/dinner.png"))); // NOI18N
        btnTable10.setText("Bàn 10");
        btnTable10.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnTable10.setPreferredSize(new java.awt.Dimension(50, 50));
        btnTable10.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnTable10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnTable10ActionPerformed(evt);
            }
        });

        btnTable9.setBackground(new java.awt.Color(51, 255, 0));
        btnTable9.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        btnTable9.setIcon(new javax.swing.ImageIcon(getClass().getResource("/coffeemaster/dinner.png"))); // NOI18N
        btnTable9.setText("Bàn 9");
        btnTable9.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnTable9.setPreferredSize(new java.awt.Dimension(50, 50));
        btnTable9.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnTable9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnTable9ActionPerformed(evt);
            }
        });

        btnTable8.setBackground(new java.awt.Color(51, 255, 0));
        btnTable8.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        btnTable8.setIcon(new javax.swing.ImageIcon(getClass().getResource("/coffeemaster/dinner.png"))); // NOI18N
        btnTable8.setText("Bàn 8");
        btnTable8.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnTable8.setPreferredSize(new java.awt.Dimension(50, 50));
        btnTable8.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnTable8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnTable8ActionPerformed(evt);
            }
        });

        btnTable7.setBackground(new java.awt.Color(51, 255, 0));
        btnTable7.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        btnTable7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/coffeemaster/dinner.png"))); // NOI18N
        btnTable7.setText("Bàn 7");
        btnTable7.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnTable7.setPreferredSize(new java.awt.Dimension(50, 50));
        btnTable7.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnTable7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnTable7ActionPerformed(evt);
            }
        });

        btnTable5.setBackground(new java.awt.Color(51, 255, 0));
        btnTable5.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        btnTable5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/coffeemaster/dinner.png"))); // NOI18N
        btnTable5.setText("Bàn 5");
        btnTable5.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnTable5.setPreferredSize(new java.awt.Dimension(50, 50));
        btnTable5.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnTable5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnTable5ActionPerformed(evt);
            }
        });

        tbSP.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Mã MH", "Tên MH", "Mã SP", "Tên SP", "Giá tiền", "Số Lượng", "Size", "Thành tiền", "Ghi chú"
            }
        ));
        tbSP.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tbSPMouseClicked(evt);
            }
        });
        jScrollPane2.setViewportView(tbSP);

        btnTable16.setBackground(new java.awt.Color(51, 255, 0));
        btnTable16.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        btnTable16.setIcon(new javax.swing.ImageIcon(getClass().getResource("/coffeemaster/dinner.png"))); // NOI18N
        btnTable16.setText("Bàn 16");
        btnTable16.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnTable16.setPreferredSize(new java.awt.Dimension(50, 50));
        btnTable16.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnTable16.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnTable16ActionPerformed(evt);
            }
        });

        btnLogout.setBackground(new java.awt.Color(255, 255, 0));
        btnLogout.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        btnLogout.setIcon(new javax.swing.ImageIcon(getClass().getResource("/coffeemaster/quit.png"))); // NOI18N
        btnLogout.setText("Đăng xuất");
        btnLogout.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnLogoutActionPerformed(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()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                            .addContainerGap()
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel1Layout.createSequentialGroup()
                                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                                .addGroup(jPanel1Layout.createSequentialGroup()
                                                    .addComponent(btnTable1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                    .addGap(7, 7, 7))
                                                .addGroup(jPanel1Layout.createSequentialGroup()
                                                    .addComponent(btnTable5, 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.LEADING)
                                                .addGroup(jPanel1Layout.createSequentialGroup()
                                                    .addComponent(btnTable6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                    .addComponent(btnTable7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                    .addComponent(btnTable8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                                .addGroup(jPanel1Layout.createSequentialGroup()
                                                    .addComponent(btnTable2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                    .addComponent(btnTable3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                    .addComponent(btnTable4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                            .addGap(65, 65, 65))
                                        .addGroup(jPanel1Layout.createSequentialGroup()
                                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addGroup(jPanel1Layout.createSequentialGroup()
                                                    .addComponent(btnTable9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                    .addComponent(btnTable10, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                    .addComponent(btnTable11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                                .addGroup(jPanel1Layout.createSequentialGroup()
                                                    .addComponent(btnTable13, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                    .addComponent(btnTable14, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                    .addComponent(btnTable15, 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.LEADING)
                                                .addComponent(btnTable12, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .addComponent(btnTable16, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addGap(66, 66, 66)))
                                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                            .addComponent(jLabel12)
                                            .addComponent(jLabel14)
                                            .addComponent(jLabel8))
                                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                                            .addGap(16, 16, 16)
                                            .addComponent(jLabel16)))
                                    .addGap(34, 34, 34)
                                    .addComponent(lbPrice, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(jPanel1Layout.createSequentialGroup()
                                    .addGap(97, 97, 97)
                                    .addComponent(jLabel3)
                                    .addGap(249, 249, 249)
                                    .addComponent(jLabel7)))
                            .addGap(48, 48, 48))
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addGap(638, 638, 638)
                            .addComponent(jLabel5)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addContainerGap()
                                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 172, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                                .addGap(536, 536, 536)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(cbMH, javax.swing.GroupLayout.PREFERRED_SIZE, 170, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(cbSP, javax.swing.GroupLayout.PREFERRED_SIZE, 172, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addGap(35, 35, 35)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel13)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(cbOption, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel15)
                                    .addComponent(jLabel17))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(txtAmount)
                                    .addComponent(cbSize, 0, 123, Short.MAX_VALUE))))))
                .addGap(0, 0, Short.MAX_VALUE))
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(btnLogout)
                        .addGap(400, 400, 400)
                        .addComponent(lbAllTotalMoney, javax.swing.GroupLayout.PREFERRED_SIZE, 330, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(btnPayOrder, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 933, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addComponent(btnDeleteOrder)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(btnClearOrder))
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addComponent(btnAddOrder)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(btnUpdateOrder))))
                .addContainerGap(37, Short.MAX_VALUE))
        );

        jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {btnTable1, btnTable10, btnTable11, btnTable12, btnTable13, btnTable14, btnTable15, btnTable16, btnTable2, btnTable3, btnTable4, btnTable5, btnTable6, btnTable7, btnTable8, btnTable9});

        jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {btnAddOrder, btnClearOrder, btnDeleteOrder, btnUpdateOrder});

        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel5)
                    .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(btnTable1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(btnTable3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(btnTable2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(btnTable4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 7, Short.MAX_VALUE)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(btnTable6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(btnTable8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(btnTable7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(0, 0, Short.MAX_VALUE)
                                .addComponent(btnTable5, 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.LEADING)
                            .addComponent(btnTable10, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnTable9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(btnTable11, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnTable12, 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.LEADING)
                            .addComponent(btnTable13, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnTable14, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnTable15, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnTable16, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(15, 15, 15)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(btnClearOrder)
                            .addComponent(btnDeleteOrder)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel13)
                                    .addComponent(cbOption, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(14, 14, 14)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel17)
                                    .addComponent(cbSize, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(15, 15, 15)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel15)
                                    .addComponent(txtAmount, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addGap(37, 37, 37)
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                            .addComponent(cbSP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jLabel12)))
                                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(cbMH, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(jLabel8)))
                                .addGap(18, 18, 18)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel14)
                                    .addComponent(lbPrice))
                                .addGap(18, 18, 18)
                                .addComponent(jLabel16)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(btnUpdateOrder)
                            .addComponent(btnAddOrder))
                        .addGap(2, 2, 2)
                        .addComponent(jLabel7)
                        .addGap(37, 37, 37)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 208, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(lbAllTotalMoney)
                        .addComponent(btnLogout))
                    .addComponent(btnPayOrder, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(1, 1, 1))
        );

        jPanel1Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {btnTable1, btnTable11, btnTable12, btnTable13, btnTable14, btnTable15, btnTable2, btnTable3, btnTable4, btnTable5, btnTable6, btnTable7, btnTable8, btnTable9});

        jPanel1Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {btnAddOrder, btnClearOrder, btnDeleteOrder, btnUpdateOrder});

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        getContentPane().add(jPanel1, gridBagConstraints);

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/coffeemaster/caphe3.jpg"))); // NOI18N
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        getContentPane().add(jLabel1, gridBagConstraints);

        pack();
    }// </editor-fold>//GEN-END:initComponents


    private void cbMHActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbMHActionPerformed
        int index = cbMH.getSelectedIndex();
        alProductApps = StaffProcess.getArrayListProduct(Main.sqlServerConn, alItemApps.get(index).getId());
        fillToComboBoxSP(alProductApps);
        fillToComboBoxSize(alItemApps.get(index).getListSize());
        fillToComboBoxOption(alItemApps.get(index).getListOption());
        fillToLabelPrice(alProductApps.get(0).getPriceSP());
    }//GEN-LAST:event_cbMHActionPerformed

    private void btnTable1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTable1ActionPerformed
        setColorButtonTable(btnTable1, Color.yellow, arrTable);
        fillToTable(arrTable[0]);
    }//GEN-LAST:event_btnTable1ActionPerformed

    private void btnTable2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTable2ActionPerformed
        setColorButtonTable(btnTable2, Color.yellow, arrTable);
        fillToTable(arrTable[1]);
    }//GEN-LAST:event_btnTable2ActionPerformed

    private void btnTable3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTable3ActionPerformed
        setColorButtonTable(btnTable3, Color.yellow, arrTable);
        fillToTable(arrTable[2]);
    }//GEN-LAST:event_btnTable3ActionPerformed

    private void btnTable4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTable4ActionPerformed
        setColorButtonTable(btnTable4, Color.yellow, arrTable);
        fillToTable(arrTable[3]);
    }//GEN-LAST:event_btnTable4ActionPerformed

    private void btnTable5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTable5ActionPerformed
        setColorButtonTable(btnTable5, Color.yellow, arrTable);
        fillToTable(arrTable[4]);
    }//GEN-LAST:event_btnTable5ActionPerformed

    private void btnTable6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTable6ActionPerformed
        setColorButtonTable(btnTable6, Color.yellow, arrTable);
        fillToTable(arrTable[5]);
    }//GEN-LAST:event_btnTable6ActionPerformed

    private void btnTable7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTable7ActionPerformed
        setColorButtonTable(btnTable7, Color.yellow, arrTable);
        fillToTable(arrTable[6]);
    }//GEN-LAST:event_btnTable7ActionPerformed

    private void btnTable8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTable8ActionPerformed
        setColorButtonTable(btnTable8, Color.yellow, arrTable);
        fillToTable(arrTable[7]);
    }//GEN-LAST:event_btnTable8ActionPerformed

    private void btnTable9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTable9ActionPerformed
        setColorButtonTable(btnTable9, Color.yellow, arrTable);
        fillToTable(arrTable[8]);
    }//GEN-LAST:event_btnTable9ActionPerformed

    private void btnTable10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTable10ActionPerformed
        setColorButtonTable(btnTable10, Color.yellow, arrTable);
        fillToTable(arrTable[9]);
    }//GEN-LAST:event_btnTable10ActionPerformed

    private void btnTable11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTable11ActionPerformed
        setColorButtonTable(btnTable11, Color.yellow, arrTable);
        fillToTable(arrTable[10]);
    }//GEN-LAST:event_btnTable11ActionPerformed

    private void btnTable12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTable12ActionPerformed
        setColorButtonTable(btnTable12, Color.yellow, arrTable);
        fillToTable(arrTable[11]);
    }//GEN-LAST:event_btnTable12ActionPerformed

    private void btnTable13ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTable13ActionPerformed
        setColorButtonTable(btnTable13, Color.yellow, arrTable);
        fillToTable(arrTable[12]);
    }//GEN-LAST:event_btnTable13ActionPerformed

    private void btnTable14ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTable14ActionPerformed
        setColorButtonTable(btnTable14, Color.yellow, arrTable);
        fillToTable(arrTable[13]);
    }//GEN-LAST:event_btnTable14ActionPerformed

    private void btnTable15ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTable15ActionPerformed
        setColorButtonTable(btnTable15, Color.yellow, arrTable);
        fillToTable(arrTable[14]);
    }//GEN-LAST:event_btnTable15ActionPerformed

    private void btnTable16ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTable16ActionPerformed
        setColorButtonTable(btnTable16, Color.yellow, arrTable);
        fillToTable(arrTable[15]);
    }//GEN-LAST:event_btnTable16ActionPerformed

    private void btnAddOrderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddOrderActionPerformed
        int id = getIdTableSelected(Color.yellow);
        if (id == -1) {
            alert("Bạn chưa chọn bàn cần order!");
            return;
        }
        if (!checkForm()) {
            return;
        }
        if (!confirm("Bạn chắc chắn muốn thêm chứ?")) {
            return;
        }
        if (arrTable[id] == null) {
            arrTable[id] = new Table();
            arrTable[id].setIdFloor("t1");
            arrTable[id].setNameFloor("Tầng 1");
            arrTable[id].setIdTable("b" + (id + 1));
            arrTable[id].setNameTable("Bàn " + (id + 1));
            arrTable[id].setColorTable(Color.RED);
        }
        BillItem billItem = formToBillItem();
        arrTable[id].getAlBillItems().add(billItem);
        updateMoneyTable(arrTable[id]);
        System.out.println(arrTable[id].getTotalMoney());
        fillToTable(arrTable[id]);
        alert("Thêm order thành công!");
    }//GEN-LAST:event_btnAddOrderActionPerformed

    private void tbSPMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tbSPMouseClicked
        int indexTableSelect = getIdTableSelected(Color.yellow);
        int indexJTableSelect = tbSP.getSelectedRow();
        fillToForm(arrTable[indexTableSelect].getAlBillItems().get(indexJTableSelect));
    }//GEN-LAST:event_tbSPMouseClicked

    private void btnUpdateOrderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnUpdateOrderActionPerformed
        int indexTableSelect = getIdTableSelected(Color.yellow);
        int indexJTableSelect = tbSP.getSelectedRow();

        if (indexJTableSelect == -1) {
            alert("Bạn chưa chọn item cần cập nhật!");
            return;
        }
        if (!checkForm()) {
            return;
        }
        if (!confirm("Bạn chắc chắn muốn cập nhật chứ?")) {
            return;
        }
        arrTable[indexTableSelect].getAlBillItems().set(indexJTableSelect, formToBillItem());
        updateMoneyTable(arrTable[indexTableSelect]);
        fillToTable(arrTable[indexTableSelect]);
        alert("Cập nhật thành công!");
    }//GEN-LAST:event_btnUpdateOrderActionPerformed

    private void btnDeleteOrderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDeleteOrderActionPerformed
        int indexTableSelect = getIdTableSelected(Color.yellow);
        int indexJTableSelect = tbSP.getSelectedRow();

        if (indexJTableSelect == -1) {
            alert("Bạn chưa chọn item cần xóa!");
            return;
        }
        if (!confirm("Bạn chắc chắn muốn xóa chứ?")) {
            return;
        }
        arrTable[indexTableSelect].getAlBillItems().remove(indexJTableSelect);
        updateMoneyTable(arrTable[indexTableSelect]);
        fillToTable(arrTable[indexTableSelect]);
        alert("xóa thành công!");
    }//GEN-LAST:event_btnDeleteOrderActionPerformed

    private void btnClearOrderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnClearOrderActionPerformed
        clearForm();
    }//GEN-LAST:event_btnClearOrderActionPerformed

    private void btnPayOrderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPayOrderActionPerformed
        int index = getIdTableSelected(Color.yellow);
        if (arrTable == null || arrTable[index].getAlBillItems().isEmpty()) {
            alert("Không có item nào cần thanh toán!");
            return;
        }
        if (!confirm("Bạn chắc chắn muốn thanh toán chứa?")) {
            return;
        }
        confirm("Bạn muốn in hóa đơn không?");
        if (!StaffProcess.addBill(Main.sqlServerConn, arrTable[index])) {
            alert("Không thể thêm hóa đơn vào CSDL!");
            return;
        }
        arrTable[index] = null;
        clearForm();
        fillToTable(null);
        alert("Thanh toán thành công!");
    }//GEN-LAST:event_btnPayOrderActionPerformed

    private void btnLogoutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLogoutActionPerformed
        setVisible(false);
    }//GEN-LAST:event_btnLogoutActionPerformed

    private Table updateMoneyTable(Table table) {
        table.setTotalMoney(0);
        table.getAlBillItems().forEach((bi) -> {
            table.setTotalMoney(table.getTotalMoney() + bi.getTotalMoney());
        });
        return table;
    }

    private void fillToForm(BillItem billItem) {
        cbMH.setSelectedItem("[" + billItem.getProductApp().getId() + "] " + billItem.getProductApp().getName());
        cbSP.setSelectedItem("[" + billItem.getProductApp().getIdSP() + "] " + billItem.getProductApp().getNameSP());
        lbPrice.setText(Function.formatMoney(billItem.getProductApp().getPriceSP() + "") + " VND");
        cbSize.setSelectedItem(billItem.getSize().getName());
        txtAmount.setText(billItem.getAmount() + "");
        taNote.setText(billItem.getNote());
    }

    private BillItem formToBillItem() {
        BillItem billItem = new BillItem();
        //tạo product APP và thêm
        ProductApp productApp = new ProductApp();
        productApp.setId(Function.parseIdString(cbMH.getSelectedItem().toString()));
        productApp.setName(Function.parseNameString(cbMH.getSelectedItem().toString()));
        productApp.setIdSP(Function.parseIdString(cbSP.getSelectedItem().toString()));
        productApp.setNameSP(Function.parseNameString(cbSP.getSelectedItem().toString()));
        productApp.setPriceSP(Function.getNumberFromString(lbPrice.getText().replaceAll("\\.", "")));
        billItem.setProductApp(productApp);
        //tạo size từ alItemApps và thêm
        int index = cbMH.getSelectedIndex();
        Size size = alItemApps.get(index).getListSize()[cbSize.getSelectedIndex()];
        billItem.setSize(size);
        //
        //thêm số lượng
        billItem.setAmount(Integer.parseInt(txtAmount.getText().trim()));
        //thêm note
        billItem.setNote(taNote.getText());

        return billItem;
    }

    private boolean checkForm() {
        try {
            Integer.parseInt(txtAmount.getText().trim());
        } catch (NumberFormatException e) {
            alert("Số lượng không đúng định dạng!");
            return false;
        }
        return true;
    }

    private void fillToTable(Table table) {
        DefaultTableModel model = (DefaultTableModel) tbSP.getModel();
        model.setRowCount(0);
        if (table != null && table.getAlBillItems() != null) {
            double totalMoney = 0;
            for (BillItem billItem : table.getAlBillItems()) {
                model.addRow(billItem.toArray());
                totalMoney += billItem.getTotalMoney();
            }
            lbAllTotalMoney.setText("Tổng tiền: " + Function.formatMoney(((int) totalMoney) + "") + " VND");
        }
    }

    private int getIdTableSelected(Color colorSelected) {
        if (btnTable1.getBackground() == colorSelected) {
            return 0;
        }
        if (btnTable2.getBackground() == colorSelected) {
            return 1;
        }
        if (btnTable3.getBackground() == colorSelected) {
            return 2;
        }
        if (btnTable4.getBackground() == colorSelected) {
            return 3;
        }
        if (btnTable5.getBackground() == colorSelected) {
            return 4;
        }
        if (btnTable6.getBackground() == colorSelected) {
            return 5;
        }
        if (btnTable7.getBackground() == colorSelected) {
            return 6;
        }
        if (btnTable8.getBackground() == colorSelected) {
            return 7;
        }
        if (btnTable9.getBackground() == colorSelected) {
            return 8;
        }
        if (btnTable10.getBackground() == colorSelected) {
            return 9;
        }
        if (btnTable11.getBackground() == colorSelected) {
            return 10;
        }
        if (btnTable12.getBackground() == colorSelected) {
            return 11;
        }
        if (btnTable13.getBackground() == colorSelected) {
            return 12;
        }
        if (btnTable14.getBackground() == colorSelected) {
            return 13;
        }
        if (btnTable15.getBackground() == colorSelected) {
            return 14;
        }
        if (btnTable16.getBackground() == colorSelected) {
            return 15;
        }
        return -1;
    }

    private void setColorButtonTable(javax.swing.JButton btn, Color color, Table[] table) {
        if (table != null && table.length == totalTable) {
            btnTable1.setBackground(table[0] == null ? Color.green : table[0].getColorTable());
            btnTable2.setBackground(table[1] == null ? Color.green : table[1].getColorTable());
            btnTable3.setBackground(table[2] == null ? Color.green : table[2].getColorTable());
            btnTable4.setBackground(table[3] == null ? Color.green : table[3].getColorTable());
            btnTable5.setBackground(table[4] == null ? Color.green : table[4].getColorTable());
            btnTable6.setBackground(table[5] == null ? Color.green : table[5].getColorTable());
            btnTable7.setBackground(table[6] == null ? Color.green : table[6].getColorTable());
            btnTable8.setBackground(table[7] == null ? Color.green : table[7].getColorTable());
            btnTable9.setBackground(table[8] == null ? Color.green : table[8].getColorTable());
            btnTable10.setBackground(table[9] == null ? Color.green : table[9].getColorTable());
            btnTable11.setBackground(table[10] == null ? Color.green : table[10].getColorTable());
            btnTable12.setBackground(table[11] == null ? Color.green : table[11].getColorTable());
            btnTable13.setBackground(table[12] == null ? Color.green : table[12].getColorTable());
            btnTable14.setBackground(table[13] == null ? Color.green : table[13].getColorTable());
            btnTable15.setBackground(table[14] == null ? Color.green : table[14].getColorTable());
            btnTable16.setBackground(table[15] == null ? Color.green : table[15].getColorTable());
        }
        btn.setBackground(color);
    }

    private Table[] initSetNumberTable() {
        return new Table[totalTable];
    }

    private void fillToLabelPrice(int price) {
        lbPrice.setText(Function.formatMoney(price + "") + " VND");
    }

    private void fillToComboBoxSize(Size[] size) {
        DefaultComboBoxModel model = (DefaultComboBoxModel) cbSize.getModel();
        model.removeAllElements();
        for (Size s : size) {
            model.addElement(s.getName());
        }
    }

    private void fillToComboBoxOption(String[] option) {
        DefaultComboBoxModel model = (DefaultComboBoxModel) cbOption.getModel();
        model.removeAllElements();
        for (String op : option) {
            model.addElement(op);
        }
    }

    private void fillToComboBoxSP(ArrayList<ProductApp> alProductApps) {
        DefaultComboBoxModel model = (DefaultComboBoxModel) cbSP.getModel();
        model.removeAllElements();
        alProductApps.forEach((productApp) -> {
            model.addElement("[" + productApp.getIdSP() + "] " + productApp.getNameSP());
        });
    }

    private void fillToComboBoxMH(ArrayList<ItemApp> alItemApps) {
        DefaultComboBoxModel model = (DefaultComboBoxModel) cbMH.getModel();
        model.removeAllElements();
        alItemApps.forEach((itemApp) -> {
            model.addElement("[" + itemApp.getId() + "] " + itemApp.getName());
        });
    }

    private void clearForm() {
        cbMH.setSelectedIndex(0);
        cbSP.setSelectedIndex(0);
        cbSize.setSelectedIndex(0);
        txtAmount.setText("1");
        taNote.setText("");
    }

    private boolean confirm(String content) {
        return JOptionPane.showConfirmDialog(this, content) == 0;
    }

    private void alert(String content) {
        JOptionPane.showMessageDialog(this, content);
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAddOrder;
    private javax.swing.JButton btnClearOrder;
    private javax.swing.JButton btnDeleteOrder;
    private javax.swing.JButton btnLogout;
    private javax.swing.JButton btnPayOrder;
    private javax.swing.JButton btnTable1;
    private javax.swing.JButton btnTable10;
    private javax.swing.JButton btnTable11;
    private javax.swing.JButton btnTable12;
    private javax.swing.JButton btnTable13;
    private javax.swing.JButton btnTable14;
    private javax.swing.JButton btnTable15;
    private javax.swing.JButton btnTable16;
    private javax.swing.JButton btnTable2;
    private javax.swing.JButton btnTable3;
    private javax.swing.JButton btnTable4;
    private javax.swing.JButton btnTable5;
    private javax.swing.JButton btnTable6;
    private javax.swing.JButton btnTable7;
    private javax.swing.JButton btnTable8;
    private javax.swing.JButton btnTable9;
    private javax.swing.JButton btnUpdateOrder;
    private javax.swing.JComboBox<String> cbMH;
    private javax.swing.JComboBox<String> cbOption;
    private javax.swing.JComboBox<String> cbSP;
    private javax.swing.JComboBox<String> cbSize;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JLabel lbAllTotalMoney;
    private javax.swing.JLabel lbPrice;
    private javax.swing.JEditorPane taNote;
    private javax.swing.JTable tbSP;
    private javax.swing.JTextField txtAmount;
    // End of variables declaration//GEN-END:variables
}
