public static void do_edit(String name, String num, String img_path) { try { Connection conn = MyConnection1.connect(); String s0 = "update " + MyDB.getNames() + ".category set cat_name='" + name + "',img_path='" + img_path + "' where cat_num='" + num + "'"; PreparedStatement stmt = conn.prepareStatement(s0); stmt.execute(); String s1 = "update " + MyDB.getNames() + ".category_type set cat_name='" + name + "' where cat_num='" + num + "'"; PreparedStatement stmt1 = conn.prepareStatement(s1); stmt1.execute(); Prompt.call("Updated Successfully"); // JOptionPane.showMessageDialog(null, "Updated Successfully"); } catch (Exception e) { throw new RuntimeException(e); } finally { MyConnection1.close(); } }
public static void do_delete_category_type(String num) { try { Connection conn = MyConnection1.connect(); String s0 = "delete from " + MyDB.getNames() + ".category_type where type_num='" + num + "'"; PreparedStatement stmt = conn.prepareStatement(s0); stmt.execute(); String s1 = "delete from " + MyDB.getNames() + ".inventory2_stocks_left where types_num='" + num + "'"; PreparedStatement stmt1 = conn.prepareStatement(s1); stmt1.execute(); String s2 = "delete from " + MyDB.getNames() + ".inventory2 where types_num='" + num + "'"; PreparedStatement stmt2 = conn.prepareStatement(s2); stmt2.execute(); Prompt.call("Updated Successfully"); // JOptionPane.showMessageDialog(null, "Updated Successfully"); } catch (Exception e) { throw new RuntimeException(e); } finally { MyConnection1.close(); } }
private void pay3(List<to_cust_charges> cus) { for (to_cust_charges t : cus) { S2_customers.pay3(t.ci_number, t.or); data_charges(); } data_charges(); Prompt.call("PAYED"); }
public static void do_add(String num) { if (if_exists(num) == true) { Prompt.call("Already Added"); // JOptionPane.showMessageDialog(null, "Already Added"); return; } try { Connection conn = MyConnection.connect(); String s0 = "insert into " + MyDB.getNames() + ".favorites(prod_code)values(?)"; PreparedStatement stmt = conn.prepareStatement(s0); stmt.setString(1, num); stmt.execute(); Prompt.call("ADDED TO FAVORITES"); // JOptionPane.showMessageDialog(null, "ADDED TO FAVORITES"); } catch (Exception e) { throw new RuntimeException(e); } finally { MyConnection.close(); } }
private void do_save() { String name = tf_prod.getText(); double qty = S15_update_product.get_qty(n, ""); if (qty == 0) { S15_update_product.update_product(n, name); do_ok(); } else { Prompt.call("Cannot Update, Still has available stocks"); // JOptionPane.showMessageDialog(null, "Cannot Update, Still has available // stocks"); } }
public static void do_delete(String num) { // JOptionPane.showMessageDialog(null, "adadad"); try { Connection conn = MyConnection.connect(); String s0 = "delete from " + MyDB.getNames() + ".favorites where prod_code='" + num + "'"; PreparedStatement stmt = conn.prepareStatement(s0); // stmt.setString(1, num); stmt.execute(); Prompt.call("DELETED"); // JOptionPane.showMessageDialog(null, "DELETED"); } catch (Exception e) { throw new RuntimeException(e); } finally { MyConnection.close(); } }
public static void do_cancel( double qty, String cashier_id, String product_id, double new_qty, String id, double price, String name) { double qty_left = S4_endorsements.get_left(product_id, cashier_id); String date = DateType.datetime.format(new Date()); try { Connection conn = MyConnection.connect(); if (qty == new_qty) { String s0 = "delete from " + MyDB.getNames() + ".sales where id='" + id + "'"; PreparedStatement stmt = conn.prepareStatement(s0); stmt.execute(); qty_left += new_qty; String s1 = "update " + MyDB.getNames() + ".endorsements set qty_left='" + qty_left + "' where cashier_id='" + cashier_id + "' and product_id='" + product_id + "'"; PreparedStatement stmt2 = conn.prepareStatement(s1); stmt2.execute(); String s2 = "insert into " + MyDB.getNames() + ".cancelled_sales(product_id,product_name,price,qty,date_added)values(?,?,?,?,?)"; PreparedStatement stmt3 = conn.prepareStatement(s2); stmt3.setString(1, product_id); stmt3.setString(2, name); stmt3.setDouble(3, price); stmt3.setDouble(4, new_qty); stmt3.setString(5, date); stmt3.execute(); } else { double aw = qty - new_qty; double commission = 0; double rate = S4_endorsements.get_commission_rate(product_id); rate = (rate / 100); commission = (new_qty * price) * rate; String s0 = "update " + MyDB.getNames() + ".sales set qty_sold='" + new_qty + "',commission='" + commission + "' where id='" + id + "'"; PreparedStatement stmt = conn.prepareStatement(s0); stmt.execute(); qty_left += new_qty; String s1 = "update " + MyDB.getNames() + ".endorsements set qty_left='" + qty_left + "' where cashier_id='" + cashier_id + "' and product_id='" + product_id + "'"; PreparedStatement stmt2 = conn.prepareStatement(s1); stmt2.execute(); String s2 = "insert into " + MyDB.getNames() + ".cancelled_sales(product_id,product_name,price,qty,date_added)values(?,?,?,?,?)"; PreparedStatement stmt3 = conn.prepareStatement(s2); stmt3.setString(1, product_id); stmt3.setString(2, name); stmt3.setDouble(3, price); stmt3.setDouble(4, qty - new_qty); stmt3.setString(5, date); stmt3.execute(); } Prompt.call("Successfully Updated"); // JOptionPane.showMessageDialog(null, "Successfully Updated"); } catch (Exception e) { throw new RuntimeException(e); } finally { MyConnection.close(); } }