public billmotors() { initComponents(); FillList(); setLocationRelativeTo(null); CurrentDate(); Connection con = null; ResultSet rs = null; PreparedStatement pst = null; model = (DefaultTableModel) Table.getModel(); }
private void jButton1ActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButton1ActionPerformed // TODO add your handling code here: String part = partno.getText(); String itemname = name.getText(); String qty1 = qty.getText(); String rate1 = rate.getText(); String no1 = no.getText(); String cname = custname.getText(); String bill1 = bill.getText(); String addr1 = addr.getText(); String ta = tax.getText(); String str1 = amount.getText(); DefaultTableModel model = (DefaultTableModel) Table.getModel(); model.addRow( new Object[] { (String.valueOf(++i)), partno.getText(), name.getText(), tax.getText(), qty.getText(), rate.getText(), amount.getText() }); pd = pd + "," + "(" + part + "," + itemname + "," + qty1 + ")"; tamount = tamount + Integer.parseInt(str1); try { Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/bharatmotors", "root", ""); Statement stmt2 = con.createStatement(); stmt2.executeUpdate( "UPDATE MOTORS SET QUANTITY=QUANTITY-'" + qty1 + "' WHERE ITEM_NAME='" + part + "'"); } catch (Exception e) { JOptionPane.showMessageDialog(null, e.toString()); } } // GEN-LAST:event_jButton1ActionPerformed