Public Class Invoice Extends Javax - Swing.Jframe: Form:Invoice STR "Insert Into Invoice Values (" +
Public Class Invoice Extends Javax - Swing.Jframe: Form:Invoice STR "Insert Into Invoice Values (" +
str = "INSERT INTO invoice VALUES(" + Integer.parseInt(tBillNo.getText()) + "," + " ' " + txtDate.getText() + " ' , " + Integer.parseInt(pro_id.getText()) + " , " + " " + Integer.parseInt(qty.getText()) + " , " + " " + Integer.parseInt(unit_price.getText()) + " , "
import java.sql.SQLException; import java.sql.Statement; import java.util.Date; import javax.swing.JOptionPane; import javax.swing.JTextField;
try { stm.executeUpdate(str); stm.close(); // con.close(); } catch (SQLException ex) { System.err.println(ex); int m = (i - t); try { String strs = "update product set Stock=? where Product_Id=?" ; prst = con.prepareStatement(strs); prst.setInt(1, m); prst.setInt(2, Integer.parseInt(pro_id.getText())); prst.executeUpdate(); prst.close(); con.close(); } catch (SQLException ex) { JOptionPane.showMessageDialog(null, ex); } } else { JOptionPane.showMessageDialog(null, "not valid"); } } }
{ int row = 0;
private int count = 0; String url = "jdbc:mysql://localhost:3306/pos"; String driver = "com.mysql.jdbc.Driver"; Connection con ; Statement stm ; PreparedStatement prst ; ResultSet rs ; String str = "" ; ResultSetModle rsmt = new ResultSetModle(); public Invoice() { initComponents(); }
if (i >= t) {
total.setText(""); qty.setText(""); }
loadProductName(tPro_Name, stm.executeQuery("Select Product_Name from product where product_Id=" + Integer.parseInt(pro_id.getText()) + "")); loadProductName(stock, stm.executeQuery("Select stock from product where product_Id=" + Integer.parseInt(pro_id.getText()) + "")); loadProductName(unit_price, stm.executeQuery("Select Sales_Price from product where product_Id=" + Integer.parseInt(pro_id.getText()) + ""));
// stm = con.createStatement(); // loadUnitPrice(stock, stm.executeQuery("Select Stock from product where product_Id="+Integer.parseInt(pro_id.getText())+"")) ; // stm = con.createStatement(); // loadUnitPrice(unit_price, stm.executeQuery("Select Sales_Price from product where product_Id="+Integer.parseInt(pro_id.getText())+""); } catch (SQLException ex) {
int q = Integer.parseInt(qty.getText()); int u = Integer.parseInt(unit_price.getText()); int t = (q * u); total.setText(Integer.toString(t)); } private void loadDriver() { try { Class.forName(driver); con = DriverManager.getConnection(url, "root", "123"); stm = con.createStatement(); } catch (SQLException ex) { System.err.println(ex); } catch (ClassNotFoundException cnf) { System.err.println(cnf); } } }
public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new Invoice().setVisible(true); } }); }
import javax.swing.JOptionPane;
Connection con;
JOptionPane.showMessageDialog(null, ex); } }
ResultSet rs = stm.executeQuery ("Select stock from product " + "where product_Id=" + Integer.parseInt(tPro_Id.getText()) + ""); while (rs.next()) { s = rs.getInt(1); } t = Integer.parseInt(tStock.getText()); total = s + t; } catch (SQLException ex) { JOptionPane.showMessageDialog(null, ex); } try { String strs = "update product set Stock=? " + "where Product_Id=?"; prst = con.prepareStatement(strs); prst.setInt(1, total); prst.setInt(2, Integer.parseInt(tPro_Id.getText()));
private void SaveActionPerformed(java.awt.event.ActionEvent evt) { loadDriver(); str = "INSERT INTO product VALUES(" + Integer.parseInt(tPro_Id.getText()) + " , " + " ' " + tPro_Name.getText() + " ' , " + " " + Integer.parseInt(tSales_Price.getText()) + "," + " " + Integer.parseInt(tStock.getText()) + ")" ; System.out.print(str); try { stm.executeUpdate(str); stm.close(); con.close(); } catch (SQLException ex) { System.err.println(ex); } }
Class.forName(driver);
con = DriverManager.getConnection(url, "root", "123");
stm = con.createStatement(); } catch (SQLException ex) { System.err.println(ex); } catch (ClassNotFoundException cnf) { System.err.println(cnf); } }
private void DeleteActionPerformed(java.awt.event.ActionEvent evt) { loadDriver(); try { String sts = "Delete From product " + "where Product_Id=" + ""+Integer.parseInt(tPro_Id.getText()) + ""; stm.executeUpdate(sts); stm.close(); } catch (SQLException ex) { JOptionPane.showMessageDialog(null, ex); } }
private void ExitActionPerformed(java.awt.event.ActionEvent evt) { dispose(); } public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() {new Product().setVisible(true); } }); }