
package frames;

import function.Function;
import java.util.ArrayList;
import javax.swing.table.DefaultTableModel;
import object.billmanager.BillItem;


public class ItemDetailAdminManagement extends javax.swing.JFrame {

    public ItemDetailAdminManagement() {
        initComponents();
        setVisible(true);
        setLocationRelativeTo(null);
    }

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

        jScrollPane1 = new javax.swing.JScrollPane();
        tbCTHD = new javax.swing.JTable();
        jLabel1 = new javax.swing.JLabel();
        lbNameHD = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        lbTimeHD = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        lbTotalMoneyHD = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Coffee Master - BillDetail - V1.0.0");
        setResizable(false);

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

            },
            new String [] {
                "Mã HD", "Mã CTHD", "Mã SP", "Tên SP", "Size", "Số lượng", "Thành tiền", "Ghi chú"
            }
        ));
        jScrollPane1.setViewportView(tbCTHD);

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
        jLabel1.setText("THÔNG TIN CHI TIẾT HÓA ĐƠN:");

        lbNameHD.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
        lbNameHD.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lbNameHD.setText("..........");

        jLabel3.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        jLabel3.setText("Thời gian: ");

        lbTimeHD.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        lbTimeHD.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lbTimeHD.setText(".............");

        jLabel5.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        jLabel5.setText("Tổng tiền:");

        lbTotalMoneyHD.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        lbTotalMoneyHD.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lbTotalMoneyHD.setText(".............");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(44, 44, 44)
                        .addComponent(jLabel1)
                        .addGap(18, 18, 18)
                        .addComponent(lbNameHD, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel3)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(lbTimeHD, javax.swing.GroupLayout.PREFERRED_SIZE, 244, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel5)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(lbTotalMoneyHD, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jScrollPane1))))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(lbNameHD))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 233, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(lbTimeHD)
                    .addComponent(jLabel5)
                    .addComponent(lbTotalMoneyHD))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
    
    public void setIdHD(String idHD){
        lbNameHD.setText(idHD);
    }
    public void setTimeHD(String time){
        lbTimeHD.setText(time);
    }
    public void setTotalMoneyHD(int totalMoney){
        lbTotalMoneyHD.setText(Function.formatMoney(totalMoney+"")+" VND");
    }
    public void setArrayListBillItem(ArrayList<BillItem> alBillItems){
        DefaultTableModel model = (DefaultTableModel) tbCTHD.getModel();
        model.setRowCount(0);
        alBillItems.forEach((billItemCTHD)->{
            model.addRow(billItemCTHD.toArrayCTHD());
        });
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel lbNameHD;
    private javax.swing.JLabel lbTimeHD;
    private javax.swing.JLabel lbTotalMoneyHD;
    private javax.swing.JTable tbCTHD;
    // End of variables declaration//GEN-END:variables
}
