Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.afrisoftech.hospinventory; import com.afrisoftech.accounting.ProcurementPlanIntfr; import com.lowagie.text.Font; import com.lowagie.text.FontFactory; import java.awt.Color; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Locale; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.BorderFactory; import javax.swing.JOptionPane; /** * * @author sytem partners */ public class ProcurementPlanDialog extends javax.swing.JDialog { /** * Creates new form ProcurementPlanDialog */ public static java.sql.Connection connectDB = null; double totalSum = 0.00; Boolean checkStatus = false; public ProcurementPlanDialog(java.awt.Frame parent, boolean modal, java.sql.Connection connDB) { //super(parent, modal); connectDB = connDB; initComponents(); procurementPlanTbl.getTableHeader().setFont(new java.awt.Font("Garamond", Font.BOLD, 9)); } /** * 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") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; jSearchDialog4 = new javax.swing.JDialog(); jSearchPanel4 = new javax.swing.JPanel(); jTextField14 = new javax.swing.JTextField(); jSearchScrollPane4 = new javax.swing.JScrollPane(); jSearchTable4 = new com.afrisoftech.dbadmin.JTable(); jButton10 = new javax.swing.JButton(); actionsPanel = new javax.swing.JPanel(); saveBtn = new javax.swing.JButton(); editBtn = new javax.swing.JButton(); removeRowBtn = new javax.swing.JButton(); clearFormBtn = new javax.swing.JButton(); spacerLbl = new javax.swing.JLabel(); closeFormBtn = new javax.swing.JButton(); mainPanel = new javax.swing.JPanel(); headerPanel = new javax.swing.JPanel(); financialPeriodlbl = new javax.swing.JLabel(); departmentLbl = new javax.swing.JLabel(); voteLbl = new javax.swing.JLabel(); voteAmountLbl = new javax.swing.JLabel(); voteAmountTxt = new javax.swing.JTextField(); financialPeriodCmbx = new javax.swing.JComboBox(); departmentCmbx = new javax.swing.JComboBox(); voteCmbx = new javax.swing.JComboBox(); bodyPanel = new javax.swing.JPanel(); jScrollPane1 = new javax.swing.JScrollPane(); procurementPlanTbl = new javax.swing.JTable(); jSearchDialog4.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); jSearchDialog4.setModal(true); jSearchDialog4.setUndecorated(true); jSearchDialog4.getContentPane().setLayout(new java.awt.GridBagLayout()); jSearchPanel4.setBorder(javax.swing.BorderFactory.createEtchedBorder()); jSearchPanel4.setLayout(new java.awt.GridBagLayout()); jTextField14.addCaretListener(new javax.swing.event.CaretListener() { public void caretUpdate(javax.swing.event.CaretEvent evt) { jTextField14CaretUpdate(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 10.0; gridBagConstraints.weighty = 1.0; gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 100); jSearchPanel4.add(jTextField14, gridBagConstraints); jSearchScrollPane4.setDoubleBuffered(true); jSearchTable4.setDoubleBuffered(true); jSearchTable4.setShowHorizontalLines(false); /* try { searchRowSet.setCommand("select product,selling_price,gl_code FROM st_stock_prices WHERE department = 'Pharmacy' order by product"); searchRowSet.setConnectionSource(pConnDB); searchRowSet.execute(); // crset2.setExecuteOnLoad(true); jSearchTable.setModel(new org.netbeans.lib.sql.models.TableModel(searchRowSet, new org.netbeans.lib.sql.models.TableModel.Column[] { new org.netbeans.lib.sql.models.TableModel.Column("product", "Description", false), new org.netbeans.lib.sql.models.TableModel.Column("selling_price", "Amount", false), new org.netbeans.lib.sql.models.TableModel.Column("gl_code", "Gl_code", false) })); // jSearchScrollPane.setViewportView(jSearchTable); } catch(java.sql.SQLException sqlex){ javax.swing.JOptionPane.showMessageDialog(this,sqlex.getMessage(),"Error Message!",javax.swing.JOptionPane.ERROR_MESSAGE); System.out.println(sqlex.getMessage()); } */ jSearchTable4.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jSearchTable4MouseClicked(evt); } }); jSearchScrollPane4.setViewportView(jSearchTable4); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1; gridBagConstraints.gridwidth = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 20.0; jSearchPanel4.add(jSearchScrollPane4, gridBagConstraints); jButton10.setText("Dispose"); jButton10.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton10ActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; jSearchPanel4.add(jButton10, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; jSearchDialog4.getContentPane().add(jSearchPanel4, gridBagConstraints); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setTitle("The Procurement Plan"); getContentPane().setLayout(new java.awt.GridBagLayout()); actionsPanel.setLayout(new java.awt.GridBagLayout()); saveBtn.setText("Save procurement plan data"); saveBtn.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { saveBtnActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; actionsPanel.add(saveBtn, gridBagConstraints); editBtn.setText("Edit data"); editBtn.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { editBtnActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; actionsPanel.add(editBtn, gridBagConstraints); removeRowBtn.setText("Remove row"); removeRowBtn.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { removeRowBtnActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 3; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; actionsPanel.add(removeRowBtn, gridBagConstraints); clearFormBtn.setText("Clear form"); clearFormBtn.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { clearFormBtnActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 4; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; actionsPanel.add(clearFormBtn, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 100.0; gridBagConstraints.weighty = 1.0; actionsPanel.add(spacerLbl, gridBagConstraints); closeFormBtn.setText("Close form"); closeFormBtn.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { closeFormBtnActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 5; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; actionsPanel.add(closeFormBtn, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; getContentPane().add(actionsPanel, gridBagConstraints); mainPanel.setLayout(new java.awt.GridBagLayout()); headerPanel.setLayout(new java.awt.GridBagLayout()); financialPeriodlbl.setText("Financial Period"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; headerPanel.add(financialPeriodlbl, gridBagConstraints); departmentLbl.setText("Department"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; headerPanel.add(departmentLbl, gridBagConstraints); voteLbl.setText("Vote"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 4; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; headerPanel.add(voteLbl, gridBagConstraints); voteAmountLbl.setText("Vote Amount"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 6; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; headerPanel.add(voteAmountLbl, gridBagConstraints); voteAmountTxt.setEditable(false); voteAmountTxt.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { voteAmountTxtActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; headerPanel.add(voteAmountTxt, gridBagConstraints); financialPeriodCmbx.setModel(com.afrisoftech.lib.ComboBoxModel.ComboBoxModel(connectDB, "SELECT distinct financial_year FROM ac_aie_allocation ORDER BY 1")); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; headerPanel.add(financialPeriodCmbx, gridBagConstraints); departmentCmbx.setModel(com.afrisoftech.lib.ComboBoxModel.ComboBoxModel(connectDB, "SELECT department_desc FROM vote_departments order by department_desc")); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 3; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; headerPanel.add(departmentCmbx, gridBagConstraints); voteCmbx.setModel(com.afrisoftech.lib.ComboBoxModel.ComboBoxModel(connectDB, "SELECT subhead||'-'||subitem as vote FROM ac_aie_allocation order by vote")); voteCmbx.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(java.awt.event.ItemEvent evt) { voteCmbxItemStateChanged(evt); } }); voteCmbx.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { voteCmbxActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 5; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; headerPanel.add(voteCmbx, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 20.0; mainPanel.add(headerPanel, gridBagConstraints); bodyPanel.setLayout(new java.awt.GridBagLayout()); procurementPlanTbl.setBackground(new java.awt.Color(204, 255, 204)); procurementPlanTbl.setFont(new java.awt.Font("Vrinda", 0, 12)); // NOI18N procurementPlanTbl.setModel(new javax.swing.table.DefaultTableModel( new Object[][] { { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null, null, null, null, null, null } }, new String[] { "Item Description", "Qty", "Est. Unit Cost", "Est. Total Cost", "Proc. Method", "Bidding Doc Date", "Sale Bidding Doc", "Open Bids Date", "Bid Eval. Date", "Proc/Tender Cmte. Action Date", "Order Draw Date", "Contract Sign Date", "Comp. Delivery/Service Date" }) { Class[] types = new Class[] { java.lang.Object.class, java.lang.Float.class, java.lang.Double.class, java.lang.Double.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class }; boolean[] canEdit = new boolean[] { true, true, true, false, true, true, true, true, true, true, true, true, true }; public Class getColumnClass(int columnIndex) { return types[columnIndex]; } public boolean isCellEditable(int rowIndex, int columnIndex) { return canEdit[columnIndex]; } }); procurementPlanTbl.setGridColor(new java.awt.Color(102, 102, 255)); this.procurementPlanTbl.getColumnModel().getColumn(4).setCellEditor( new javax.swing.DefaultCellEditor(new javax.swing.JComboBox(com.afrisoftech.lib.ComboBoxModel .ComboBoxModel(connectDB, "SELECT DISTINCT method_desc FROM st_procurement_method")))); for (int i = 5; i < 13; i++) { javax.swing.table.TableColumn ccDateEditorw = procurementPlanTbl.getColumnModel().getColumn(i); com.afrisoftech.lib.DateCellEditor ccDateCellEditorw = new com.afrisoftech.lib.DateCellEditor( new com.afrisoftech.lib.DatePicker(), procurementPlanTbl); ccDateEditorw.setCellEditor(ccDateCellEditorw); //jTable1.setRowHeight(30); javax.swing.table.DefaultTableCellRenderer ccCellRendererw = new javax.swing.table.DefaultTableCellRenderer(); ccCellRendererw.setHorizontalAlignment(ccCellRendererw.TRAILING); ccDateEditorw.setCellRenderer(ccCellRendererw); //this.procurementPlanTbl.getColumnModel().getColumn(i).setCellEditor(new javax.swing.DefaultCellEditor((javax.swing.JComboBox)new com.afrisoftech.lib.DatePicker())); } javax.swing.table.TableColumn column = null; for (int i = 0; i < 13; i++) { column = procurementPlanTbl.getColumnModel().getColumn(i); if (i == 0) { column.setPreferredWidth(500); //sport column is bigger } else { //if (i == 2) { column.setPreferredWidth(200); // } else //column.setPreferredWidth(50); } } procurementPlanTbl.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { procurementPlanTblMouseClicked(evt); } }); procurementPlanTbl.addKeyListener(new java.awt.event.KeyAdapter() { public void keyReleased(java.awt.event.KeyEvent evt) { procurementPlanTblKeyReleased(evt); } }); jScrollPane1.setViewportView(procurementPlanTbl); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.ipadx = 429; gridBagConstraints.ipady = 257; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; bodyPanel.add(jScrollPane1, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 500.0; mainPanel.add(bodyPanel, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 500.0; getContentPane().add(mainPanel, gridBagConstraints); pack(); }// </editor-fold>//GEN-END:initComponents private void saveBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveBtnActionPerformed //swap to know whether its an update or a new save if (procurementPlanTbl.isEditing()) { procurementPlanTbl.getCellEditor().stopCellEditing(); } if (voteAmountTxt.getText().toString().length() > 0) { if (totalSum <= Double.parseDouble(voteAmountTxt.getText().toString())) { switch (this.saveBtn.getText()) { case "Save procurement plan data": //Lets do a new save //saveNewProcurementPlan(); try { //if(voteAmountTxt.getText().toString().length()>0||voteAmountTxt.getText().toString()!=null){ for (int i = 0; i < procurementPlanTbl.getRowCount(); i++) { if (procurementPlanTbl.getValueAt(i, 0) != null) { java.sql.PreparedStatement pstmt = connectDB .prepareStatement("INSERT INTO st_procurement_plan(" + "item_id, item_description, qty, estimated_unit_cost, estimated_total_cost," + "proc_method, prep_of_bidding_date, sale_of_bidding_doc_date, " + "receipt_open_bids_date, bid_evaluation_date, proc_tender_committee_action_date," + "order_drawn_date, contract_sign_date, compliance_delivery_date, " + "proc_department, financial_year, vote_no,item_code)" + "VALUES (nextval('vote_no_seq'), ?, ?,?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); try { pstmt.setObject(1, procurementPlanTbl.getValueAt(i, 0)); pstmt.setDouble(2, Double.parseDouble(procurementPlanTbl.getValueAt(i, 1).toString())); pstmt.setDouble(3, Double.parseDouble(procurementPlanTbl.getValueAt(i, 2).toString())); pstmt.setDouble(4, Double.parseDouble(procurementPlanTbl.getValueAt(i, 3).toString())); pstmt.setObject(5, procurementPlanTbl.getValueAt(i, 4).toString()); pstmt.setDate(6, com.afrisoftech.lib.SQLDateFormat.getSQLDate( new SimpleDateFormat("MMMM d, yyyy", Locale.ENGLISH).parse( procurementPlanTbl.getValueAt(i, 5).toString()))); pstmt.setDate(7, com.afrisoftech.lib.SQLDateFormat.getSQLDate( new SimpleDateFormat("MMMM d, yyyy", Locale.ENGLISH).parse( procurementPlanTbl.getValueAt(i, 6).toString()))); pstmt.setDate(8, com.afrisoftech.lib.SQLDateFormat.getSQLDate( new SimpleDateFormat("MMMM d, yyyy", Locale.ENGLISH).parse( procurementPlanTbl.getValueAt(i, 7).toString()))); pstmt.setDate(9, com.afrisoftech.lib.SQLDateFormat.getSQLDate( new SimpleDateFormat("MMMM d, yyyy", Locale.ENGLISH).parse( procurementPlanTbl.getValueAt(i, 8).toString()))); pstmt.setDate(10, com.afrisoftech.lib.SQLDateFormat.getSQLDate( new SimpleDateFormat("MMMM d, yyyy", Locale.ENGLISH).parse( procurementPlanTbl.getValueAt(i, 9).toString()))); pstmt.setDate(11, com.afrisoftech.lib.SQLDateFormat.getSQLDate( new SimpleDateFormat("MMMM d, yyyy", Locale.ENGLISH).parse( procurementPlanTbl.getValueAt(i, 10).toString()))); pstmt.setDate(12, com.afrisoftech.lib.SQLDateFormat.getSQLDate( new SimpleDateFormat("MMMM d, yyyy", Locale.ENGLISH).parse( procurementPlanTbl.getValueAt(i, 11).toString()))); pstmt.setDate(13, com.afrisoftech.lib.SQLDateFormat.getSQLDate( new SimpleDateFormat("MMMM d, yyyy", Locale.ENGLISH).parse( procurementPlanTbl.getValueAt(i, 12).toString()))); } catch (Exception ex) { //ex.printStackTrace(); //Logger.getLogger(ProcurementPlanIntfr.class.getName()).log(Level.SEVERE, null, ex); //javax.swing.JOptionPane.showMessageDialog(null, "You need to double check your entries"); } pstmt.setObject(14, departmentCmbx.getSelectedItem().toString()); pstmt.setObject(15, financialPeriodCmbx.getSelectedItem().toString()); pstmt.setObject(16, voteCmbx.getSelectedItem().toString()); ///select the item code String item_code = null; java.sql.Statement stmt = connectDB.createStatement(); java.sql.ResultSet rs = stmt.executeQuery( "select distinct item_code from st_stock_item where description='" + procurementPlanTbl.getValueAt(i, 0).toString() + "' "); while (rs.next()) { item_code = rs.getString("item_code"); //externalprtbl.setValueAt(java.lang.String.valueOf(bal), externalprtbl.getSelectedRow(), 4); //jComboBox1.setSelectedItem(rs.getString(1)); } // pstmt.setObject(17, item_code); connectDB.setAutoCommit(false); pstmt.execute(); connectDB.commit(); connectDB.setAutoCommit(true); // saveBtn.setEnabled(false); checkStatus = true; //javax.swing.JOptionPane.showMessageDialog(this, "Procurement plan data saved successfully."); } } ///////clearing the procurement table and the votebook amount for (int k = 0; k < procurementPlanTbl.getRowCount(); k++) { for (int r = 0; r < procurementPlanTbl.getColumnCount(); r++) { procurementPlanTbl.getModel().setValueAt(null, k, r); } } //////setting the votebook amount to zero voteAmountTxt.setText(null); //} if (checkStatus == true) { javax.swing.JOptionPane.showMessageDialog(this, "Procurement plan data saved successfully."); } // else{ // javax.swing.JOptionPane.showMessageDialog(this, "Can you Double Check your Entries.","ERROR MESSAGE",JOptionPane.ERROR_MESSAGE); // } // } // else{ // // javax.swing.JOptionPane.showMessageDialog(this, "You cannot affect the Procurement Plan without a Vote Amount"); // // voteAmountTxt.setBorder(BorderFactory.createLineBorder(Color.red)); // } } catch (java.sql.SQLException sqEx) { sqEx.printStackTrace(); try { connectDB.rollback(); } catch (Exception rf) { } // javax.swing.JOptionPane.showMessageDialog(null, sqEx.getMessage()); javax.swing.JOptionPane.showMessageDialog(null, "You need to double check your entries"); } // this.getContentPane().removeAll(); // initComponents(); // this.setSize(this.getParent().getSize()); // this.validate(); break; case "Update": updateProcurementPlan(); saveBtn.setText("Save procurement plan data"); // this.getContentPane().removeAll(); // initComponents(); // this.setSize(this.getParent().getSize()); // this.validate(); break; } } else { javax.swing.JOptionPane.showMessageDialog(this, "The total for the procurement plan MUST be less or equal to allocated vote amount."); } //End switch } else { javax.swing.JOptionPane.showMessageDialog(this, "You cannot affect the Procurement Plan without a Vote Amount"); voteAmountTxt.setBorder(BorderFactory.createLineBorder(Color.red)); voteAmountLbl.setForeground(Color.red); } }//GEN-LAST:event_saveBtnActionPerformed private void editBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editBtnActionPerformed saveBtn.setText("Update"); procurementPlanTbl.setModel(com.afrisoftech.dbadmin.TableModel.createTableVectors(connectDB, "SELECT item_description as item_desc, qty, estimated_unit_cost as est_unit_cost, estimated_total_cost as est_total_cost, \n" + " proc_method, prep_of_bidding_date, sale_of_bidding_doc_date, \n" + " receipt_open_bids_date, bid_evaluation_date, proc_tender_committee_action_date, \n" + " order_drawn_date, contract_sign_date, compliance_delivery_date, \n" + " proc_department, financial_year, vote_no, vote_balance FROM st_procurement_plan WHERE vote_no = '" + voteCmbx.getSelectedItem().toString() + "' AND financial_year = '" + financialPeriodCmbx.getSelectedItem().toString() + "'")); // TODO add your handling code here: }//GEN-LAST:event_editBtnActionPerformed private void removeRowBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeRowBtnActionPerformed javax.swing.table.DefaultTableModel procTable = (javax.swing.table.DefaultTableModel) procurementPlanTbl .getModel(); procTable.removeRow(this.procurementPlanTbl.getSelectedRow()); // TODO add your handling code here: }//GEN-LAST:event_removeRowBtnActionPerformed private void clearFormBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clearFormBtnActionPerformed // TODO add your handling code here: for (int k = 0; k < procurementPlanTbl.getRowCount(); k++) { for (int r = 0; r < procurementPlanTbl.getColumnCount(); r++) { procurementPlanTbl.getModel().setValueAt(null, k, r); } } //////setting the votebook amount to zero voteAmountTxt.setText(null); // saveBtn.setText("Save Procurement Plan Data"); }//GEN-LAST:event_clearFormBtnActionPerformed private void closeFormBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_closeFormBtnActionPerformed this.setVisible(false); // TODO add your handling code here: }//GEN-LAST:event_closeFormBtnActionPerformed private void voteAmountTxtActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_voteAmountTxtActionPerformed // TODO add your handling code here: }//GEN-LAST:event_voteAmountTxtActionPerformed private void procurementPlanTblMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_procurementPlanTblMouseClicked //if (voteAmountTxt.getText().toCharArray().length > 0) { // if (voteAmountTxt.getText().toString().length() > 0) { if (procurementPlanTbl.getSelectedColumn() == 0) { System.out.println("Showing dialog"); java.awt.Point point = procurementPlanTbl.getLocationOnScreen(); jSearchDialog4.setSize(700, 200); jSearchDialog4.setLocation(point); jSearchDialog4.setVisible(true); } // } // else{ // javax.swing.JOptionPane.showMessageDialog(null, "You cannot add any item in the Procurement Plan Unless you specify the Vote Amount","ERROR MESSAGE",JOptionPane.ERROR_MESSAGE); // } // TODO add your handling code here: }//GEN-LAST:event_procurementPlanTblMouseClicked private void procurementPlanTblKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_procurementPlanTblKeyReleased //swap to know whether its an update or a new save switch (this.saveBtn.getText()) { case "Save procurement plan data": if (procurementPlanTbl.getValueAt(procurementPlanTbl.getSelectedRow(), 2) != null) { float qty = java.lang.Float.parseFloat( procurementPlanTbl.getValueAt(procurementPlanTbl.getSelectedRow(), 1).toString()); float price = java.lang.Float.parseFloat( procurementPlanTbl.getValueAt(procurementPlanTbl.getSelectedRow(), 2).toString()); System.out.println("This is the price " + price); float total = (qty * price); procurementPlanTbl.setValueAt(total, procurementPlanTbl.getSelectedRow(), 3); totalSum = com.afrisoftech.lib.TableColumnTotal.getTableColumnTotal(procurementPlanTbl, 3); if (totalSum > Double.parseDouble(voteAmountTxt.getText().toString())) { javax.swing.JOptionPane.showMessageDialog(this, "CAUTION! You MUST ensure that your plan total is not more than allocated vote."); } } break; case "Update": if (procurementPlanTbl.getValueAt(procurementPlanTbl.getSelectedRow(), 3) != null) { float qty = java.lang.Float.parseFloat( procurementPlanTbl.getValueAt(procurementPlanTbl.getSelectedRow(), 2).toString()); float price = java.lang.Float.parseFloat( procurementPlanTbl.getValueAt(procurementPlanTbl.getSelectedRow(), 3).toString()); System.out.println("This is the price " + price); double total = (qty * price); procurementPlanTbl.setValueAt(total, procurementPlanTbl.getSelectedRow(), 4); totalSum = com.afrisoftech.lib.TableColumnTotal.getTableColumnTotal(procurementPlanTbl, 4); if (totalSum > Double.parseDouble(voteAmountTxt.getText())) { javax.swing.JOptionPane.showMessageDialog(this, "CAUTION! You MUST ensure that your plan total is not more than allocated vote."); } } break; }//End switch }//GEN-LAST:event_procurementPlanTblKeyReleased private void jTextField14CaretUpdate(javax.swing.event.CaretEvent evt) {//GEN-FIRST:event_jTextField14CaretUpdate if (jTextField14.getCaretPosition() < 1) { System.out.println("Nothing"); } else { jSearchTable4.setModel(com.afrisoftech.dbadmin.TableModel.createTableVectors(connectDB, "SELECT DISTINCT item_code, description, sub_cat_code as category, department FROM st_stock_item where description ilike '%" + jTextField14.getText().toString() + "%' order by description")); // jSearchTable4.setModel(com.afrisoftech.dbadmin.TableModel.createTableVectors(connectDB,"SELECT service_type,rate as price,'"+jTextField7.getText()+"' as glcode FROM pb_operating_parameters WHERE service_type ILIKE '%"+jTextField14.getText().toString()+"%' AND gl_account ILIKE '%"+jTextField7.getText()+"%'")); System.out.println("Cannot sort out"); } // } // // Add your handling code here: }//GEN-LAST:event_jTextField14CaretUpdate private void jSearchTable4MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jSearchTable4MouseClicked procurementPlanTbl.setValueAt(jSearchTable4.getValueAt(jSearchTable4.getSelectedRow(), 1), procurementPlanTbl.getSelectedRow(), 0); jSearchDialog4.dispose(); // Add your handling code here: }//GEN-LAST:event_jSearchTable4MouseClicked private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton10ActionPerformed jSearchDialog4.dispose(); // Add your handling code here: }//GEN-LAST:event_jButton10ActionPerformed private void voteCmbxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_voteCmbxActionPerformed try { java.sql.PreparedStatement pstmt = connectDB.prepareStatement( "SELECT amount FROM ac_aie_allocation WHERE subhead||'-'||subitem = ? AND financial_year = ?"); pstmt.setString(1, voteCmbx.getSelectedItem().toString()); pstmt.setString(2, financialPeriodCmbx.getSelectedItem().toString()); java.sql.ResultSet rset = pstmt.executeQuery(); if (rset.next()) { voteAmountTxt.setText(rset.getString(1)); } } catch (java.sql.SQLException ex) { ex.printStackTrace(); javax.swing.JOptionPane.showMessageDialog(this, ex.getMessage()); } // TODO add your handling code here: }//GEN-LAST:event_voteCmbxActionPerformed private void voteCmbxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_voteCmbxItemStateChanged voteAmountLbl.setForeground(Color.black); voteAmountTxt.setBorder(BorderFactory.createLineBorder(Color.black)); }//GEN-LAST:event_voteCmbxItemStateChanged /** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* 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(ProcurementPlanDialog.class.getName()) .log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(ProcurementPlanDialog.class.getName()) .log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(ProcurementPlanDialog.class.getName()) .log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(ProcurementPlanDialog.class.getName()) .log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the dialog */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { ProcurementPlanDialog dialog = new ProcurementPlanDialog(new javax.swing.JFrame(), true, null); dialog.addWindowListener(new java.awt.event.WindowAdapter() { @Override public void windowClosing(java.awt.event.WindowEvent e) { System.exit(0); } }); dialog.setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JPanel actionsPanel; private javax.swing.JPanel bodyPanel; private javax.swing.JButton clearFormBtn; private javax.swing.JButton closeFormBtn; private javax.swing.JComboBox departmentCmbx; private javax.swing.JLabel departmentLbl; private javax.swing.JButton editBtn; private javax.swing.JComboBox financialPeriodCmbx; private javax.swing.JLabel financialPeriodlbl; private javax.swing.JPanel headerPanel; private javax.swing.JButton jButton10; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JDialog jSearchDialog4; private javax.swing.JPanel jSearchPanel4; private javax.swing.JScrollPane jSearchScrollPane4; private javax.swing.JTable jSearchTable4; private javax.swing.JTextField jTextField14; private javax.swing.JPanel mainPanel; private javax.swing.JTable procurementPlanTbl; private javax.swing.JButton removeRowBtn; private javax.swing.JButton saveBtn; private javax.swing.JLabel spacerLbl; private javax.swing.JLabel voteAmountLbl; private javax.swing.JTextField voteAmountTxt; private javax.swing.JComboBox voteCmbx; private javax.swing.JLabel voteLbl; // End of variables declaration//GEN-END:variables private void saveNewProcurementPlan() { // try { // //if(voteAmountTxt.getText().toString().length()>0||voteAmountTxt.getText().toString()!=null){ // for (int i = 0; i < procurementPlanTbl.getRowCount(); i++) { // if (procurementPlanTbl.getValueAt(i, 0)!=null) { // java.sql.PreparedStatement pstmt = connectDB.prepareStatement("INSERT INTO st_procurement_plan(" // + "item_id, item_description, qty, estimated_unit_cost, estimated_total_cost," // + "proc_method, prep_of_bidding_date, sale_of_bidding_doc_date, " // + "receipt_open_bids_date, bid_evaluation_date, proc_tender_committee_action_date," // + "order_drawn_date, contract_sign_date, compliance_delivery_date, " // + "proc_department, financial_year, vote_no)" // + "VALUES (nextval('vote_no_seq'), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); // try { // pstmt.setObject(1, procurementPlanTbl.getValueAt(i, 0)); // pstmt.setDouble(2, Double.parseDouble(procurementPlanTbl.getValueAt(i, 1).toString())); // pstmt.setDouble(3, Double.parseDouble(procurementPlanTbl.getValueAt(i, 2).toString())); // pstmt.setDouble(4, Double.parseDouble(procurementPlanTbl.getValueAt(i, 3).toString())); // pstmt.setObject(5, procurementPlanTbl.getValueAt(i, 4).toString()); // // pstmt.setDate(6, com.afrisoftech.lib.SQLDateFormat.getSQLDate(new SimpleDateFormat("MMMM d, yyyy", Locale.ENGLISH).parse(procurementPlanTbl.getValueAt(i, 5).toString()))); // pstmt.setDate(7, com.afrisoftech.lib.SQLDateFormat.getSQLDate(new SimpleDateFormat("MMMM d, yyyy", Locale.ENGLISH).parse(procurementPlanTbl.getValueAt(i, 6).toString()))); // pstmt.setDate(8, com.afrisoftech.lib.SQLDateFormat.getSQLDate(new SimpleDateFormat("MMMM d, yyyy", Locale.ENGLISH).parse(procurementPlanTbl.getValueAt(i, 7).toString()))); // pstmt.setDate(9, com.afrisoftech.lib.SQLDateFormat.getSQLDate(new SimpleDateFormat("MMMM d, yyyy", Locale.ENGLISH).parse(procurementPlanTbl.getValueAt(i, 8).toString()))); // pstmt.setDate(10, com.afrisoftech.lib.SQLDateFormat.getSQLDate(new SimpleDateFormat("MMMM d, yyyy", Locale.ENGLISH).parse(procurementPlanTbl.getValueAt(i, 9).toString()))); // pstmt.setDate(11, com.afrisoftech.lib.SQLDateFormat.getSQLDate(new SimpleDateFormat("MMMM d, yyyy", Locale.ENGLISH).parse(procurementPlanTbl.getValueAt(i, 10).toString()))); // pstmt.setDate(12, com.afrisoftech.lib.SQLDateFormat.getSQLDate(new SimpleDateFormat("MMMM d, yyyy", Locale.ENGLISH).parse(procurementPlanTbl.getValueAt(i, 11).toString()))); // pstmt.setDate(13, com.afrisoftech.lib.SQLDateFormat.getSQLDate(new SimpleDateFormat("MMMM d, yyyy", Locale.ENGLISH).parse(procurementPlanTbl.getValueAt(i, 12).toString()))); // } catch (Exception ex) { // // ex.printStackTrace(); //// Logger.getLogger(ProcurementPlanIntfr.class.getName()).log(Level.SEVERE, null, ex); // // //javax.swing.JOptionPane.showMessageDialog(null, "You need to double check your entries"); // // } // pstmt.setObject(14, departmentCmbx.getSelectedItem().toString()); // pstmt.setObject(15, financialPeriodCmbx.getSelectedItem().toString()); // pstmt.setObject(16, voteCmbx.getSelectedItem().toString()); // // ///select the item code //// String item_code=null; //// java.sql.Statement stmt = connectDB.createStatement(); //// java.sql.ResultSet rs = stmt.executeQuery("select distinct item_code from st_stock_item where description='"+procurementPlanTbl.getValueAt(i, 0).toString()+"' "); //// while (rs.next()) { //// //// item_code = rs.getString("item_code"); //// //externalprtbl.setValueAt(java.lang.String.valueOf(bal), externalprtbl.getSelectedRow(), 4); //// //jComboBox1.setSelectedItem(rs.getString(1)); //// } //// //// pstmt.setObject(17, item_code); // // //connectDB.setAutoCommit(false); // pstmt.execute(); // // ///connectDB.commit(); // // connectDB.setAutoCommit(true); // // saveBtn.setEnabled(false); // // // checkStatus=true; // javax.swing.JOptionPane.showMessageDialog(this, "Procurement plan data saved successfully."); // // ///////clearing the procurement table and the votebook amount // for (int k = 0; k < procurementPlanTbl.getRowCount(); k++) { // for (int r = 0; r < procurementPlanTbl.getColumnCount(); r++) { // procurementPlanTbl.getModel().setValueAt(null, k, r); // } // } // // //////setting the votebook amount to zero // voteAmountTxt.setText(null); // // } // } // //// if(checkStatus==true){ //// //// javax.swing.JOptionPane.showMessageDialog(this, "Procurement plan data saved successfully."); //// //// } //// else{ //// javax.swing.JOptionPane.showMessageDialog(this, "Can you Double Check your Entries.","ERROR MESSAGE",JOptionPane.ERROR_MESSAGE); //// } // // } // else{ // // javax.swing.JOptionPane.showMessageDialog(this, "You cannot affect the Procurement Plan without a Vote Amount"); // // voteAmountTxt.setBorder(BorderFactory.createLineBorder(Color.red)); // } // // } catch (java.sql.SQLException sqEx) { // sqEx.printStackTrace(); // try{ // //connectDB.rollback(); // } // catch(Exception rf){ // // // } // // javax.swing.JOptionPane.showMessageDialog(null, sqEx.getMessage()); // javax.swing.JOptionPane.showMessageDialog(null, "You need to double check your entries"); // // } }//End method saveNewProcurementPlan /** * } * update an existing procurement plan * */ private void updateProcurementPlan() { try { for (int i = 0; i < procurementPlanTbl.getRowCount(); i++) { if (procurementPlanTbl.getValueAt(i, 0).toString().length() > 0) { //java.sql.PreparedStatement pstmt = connectDB.prepareCall("UPDATE st_procurement_plan SET qty=?, estimated_unit_cost=?,estimated_total_cost=?, proc_method=?, prep_of_bidding_date=?,sale_of_bidding_doc_date=?, receipt_open_bids_date=?, bid_evaluation_date=?,proc_tender_committee_action_date=?, order_drawn_date=?, contract_sign_date=?,compliance_delivery_date=?, proc_department=?, financial_year=?,vote_no=? WHERE item_id=" + procurementPlanTbl.getValueAt(procurementPlanTbl.getSelectedRow(), 0) + ";"); java.sql.PreparedStatement pstmt = connectDB.prepareCall( "UPDATE st_procurement_plan SET qty=?, estimated_unit_cost=?,estimated_total_cost=?, proc_method=?, prep_of_bidding_date=?,sale_of_bidding_doc_date=?, receipt_open_bids_date=?, bid_evaluation_date=?,proc_tender_committee_action_date=?, order_drawn_date=?, contract_sign_date=?,compliance_delivery_date=?, proc_department=?, financial_year=?,vote_no=?,item_code=? WHERE item_id='" + procurementPlanTbl.getValueAt(i, 0).toString() + "'"); try { pstmt.setDouble(1, Double.parseDouble(procurementPlanTbl.getValueAt(i, 2).toString())); pstmt.setDouble(2, Double.parseDouble(procurementPlanTbl.getValueAt(i, 3).toString())); pstmt.setDouble(3, Double.parseDouble(procurementPlanTbl.getValueAt(i, 4).toString())); pstmt.setString(4, procurementPlanTbl.getValueAt(i, 5).toString()); pstmt.setDate(5, com.afrisoftech.lib.SQLDateFormat .getSQLDate(new SimpleDateFormat("yyyy-MM-d", Locale.ENGLISH) .parse(procurementPlanTbl.getValueAt(i, 6).toString()))); pstmt.setDate(6, com.afrisoftech.lib.SQLDateFormat .getSQLDate(new SimpleDateFormat("yyyy-MM-d", Locale.ENGLISH) .parse(procurementPlanTbl.getValueAt(i, 7).toString()))); pstmt.setDate(7, com.afrisoftech.lib.SQLDateFormat .getSQLDate(new SimpleDateFormat("yyyy-MM-d", Locale.ENGLISH) .parse(procurementPlanTbl.getValueAt(i, 8).toString()))); pstmt.setDate(8, com.afrisoftech.lib.SQLDateFormat .getSQLDate(new SimpleDateFormat("yyyy-MM-d", Locale.ENGLISH) .parse(procurementPlanTbl.getValueAt(i, 9).toString()))); pstmt.setDate(9, com.afrisoftech.lib.SQLDateFormat .getSQLDate(new SimpleDateFormat("yyyy-MM-d", Locale.ENGLISH) .parse(procurementPlanTbl.getValueAt(i, 10).toString()))); pstmt.setDate(10, com.afrisoftech.lib.SQLDateFormat .getSQLDate(new SimpleDateFormat("yyyy-MM-d", Locale.ENGLISH) .parse(procurementPlanTbl.getValueAt(i, 11).toString()))); pstmt.setDate(11, com.afrisoftech.lib.SQLDateFormat .getSQLDate(new SimpleDateFormat("yyyy-MM-d", Locale.ENGLISH) .parse(procurementPlanTbl.getValueAt(i, 12).toString()))); pstmt.setDate(12, com.afrisoftech.lib.SQLDateFormat .getSQLDate(new SimpleDateFormat("yyyy-MM-d", Locale.ENGLISH) .parse(procurementPlanTbl.getValueAt(i, 13).toString()))); } catch (ParseException ex) { Logger.getLogger(ProcurementPlanIntfr.class.getName()).log(Level.SEVERE, null, ex); javax.swing.JOptionPane.showMessageDialog(null, "You need to double check your entries"); } pstmt.setObject(13, departmentCmbx.getSelectedItem().toString()); pstmt.setObject(14, financialPeriodCmbx.getSelectedItem().toString()); pstmt.setObject(15, voteCmbx.getSelectedItem().toString()); String item_code = null; java.sql.Statement stmt = connectDB.createStatement(); java.sql.ResultSet rs = stmt .executeQuery("select distinct item_code from st_stock_item where description='" + procurementPlanTbl.getValueAt(i, 0).toString() + "' "); while (rs.next()) { item_code = rs.getString("item_code"); //externalprtbl.setValueAt(java.lang.String.valueOf(bal), externalprtbl.getSelectedRow(), 4); //jComboBox1.setSelectedItem(rs.getString(1)); } pstmt.setObject(16, item_code); pstmt.execute(); javax.swing.JOptionPane.showMessageDialog(this, "Procurement plan data updated successfully."); } } } catch (java.sql.SQLException sqEx) { sqEx.printStackTrace(); //javax.swing.JOptionPane.showMessageDialog(this, sqEx.getMessage()); javax.swing.JOptionPane.showMessageDialog(null, "You need to double check your entries"); } return; }//End method updateProcurementPlan }