From dfcf5a2343cbf8646ecb10d11d47e879f5091bc8 Mon Sep 17 00:00:00 2001 From: Arman Mokammel Date: Sun, 5 Nov 2023 17:06:52 +0600 Subject: [PATCH] Update --- src/DataEditorUI/VoucherEditor_Dialog.java | 23 +++++++--------------- src/UI/OrderSystem/Panel_E.java | 15 ++++++++------ 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/src/DataEditorUI/VoucherEditor_Dialog.java b/src/DataEditorUI/VoucherEditor_Dialog.java index add2971..90d964c 100644 --- a/src/DataEditorUI/VoucherEditor_Dialog.java +++ b/src/DataEditorUI/VoucherEditor_Dialog.java @@ -1,6 +1,5 @@ package DataEditorUI; -import java.awt.Color; import java.awt.Font; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -17,14 +16,13 @@ public class VoucherEditor_Dialog extends JDialog{ - private JTextField txt_customer = new JTextField(); private JTextField txt_voucherId = new JTextField(); private JTextField txt_voucher = new JTextField(); private JTextField txt_value = new JTextField(); - private String A, C; - private int B; - private double D; + private String B; + private int A; + private double C; public VoucherEditor_Dialog(MainWindow frame, Voucher_Panel parent, String title, int row) { super(frame, title, true); @@ -43,40 +41,33 @@ public VoucherEditor_Dialog(MainWindow frame, Voucher_Panel parent, String title setContentPane(Bg_Icon); JLabel lbl_title = new JLabel("Voucher"); - JLabel lbl_customer = new JLabel("Customer:", SwingConstants.RIGHT); JLabel lbl_voucherId = new JLabel("Voucher ID:", SwingConstants.RIGHT); JLabel lbl_voucher = new JLabel("Voucher:", SwingConstants.RIGHT); JLabel lbl_value = new JLabel("Value:", SwingConstants.RIGHT); lbl_title.setFont(f1); - lbl_customer.setFont(f2); lbl_voucherId.setFont(f2); lbl_voucher.setFont(f2); lbl_value.setFont(f2); lbl_title.setBounds(210, 60, 130, 30); - lbl_customer.setBounds(30, 150, 140, 30); lbl_voucherId.setBounds(30, 200, 140, 30); lbl_voucher.setBounds(30, 250, 140, 30); lbl_value.setBounds(30, 300, 140, 30); add(lbl_title); - add(lbl_customer); add(lbl_voucherId); add(lbl_voucher); add(lbl_value); - txt_customer.setBounds(180, 150, 240, 30); txt_voucherId.setBounds(180, 200, 240, 30); txt_voucher.setBounds(180, 250, 240, 30); txt_value.setBounds(180, 300, 240, 30); - txt_customer.setFont(f3); txt_voucherId.setFont(f3); txt_voucher.setFont(f3); txt_value.setFont(f3); - add(txt_customer); add(txt_voucherId); add(txt_voucher); add(txt_value); @@ -88,10 +79,10 @@ public VoucherEditor_Dialog(MainWindow frame, Voucher_Panel parent, String title public void actionPerformed(ActionEvent e) { Discount_Voucher voucher = null; try { - B = Utility.checkInt(txt_voucherId, lbl_voucherId); - C = Utility.checkString(txt_voucher, lbl_voucher, InputType.Alphanumeric); - D = Utility.checkDouble(txt_value, lbl_value); - voucher = new Discount_Voucher(B, C, D); + A = Utility.checkInt(txt_voucherId, lbl_voucherId); + B = Utility.checkString(txt_voucher, lbl_voucher, InputType.Alphanumeric); + C = Utility.checkDouble(txt_value, lbl_value); + voucher = new Discount_Voucher(A, B, C); } catch (InputException e2) { Utility.showErrorMessage(e2); return; diff --git a/src/UI/OrderSystem/Panel_E.java b/src/UI/OrderSystem/Panel_E.java index a6ddb4e..ece2c26 100644 --- a/src/UI/OrderSystem/Panel_E.java +++ b/src/UI/OrderSystem/Panel_E.java @@ -37,6 +37,7 @@ public class Panel_E extends JPanelX{ public static JLabel amtPaid; public static JLabel amtDue; public static JTextField amt; + private JLabel lbl_vchAmt; private ArrayList discountVouchers; @@ -162,18 +163,20 @@ public void actionPerformed(ActionEvent e) { if(((String)cmbx_1.getSelectedItem()).equals("Voucher")) { pnl_2.remove(amt); pnl_2.add(cmbx_2); + lbl_vchAmt.setText("Voucher Code:"); pnl_2.updateUI(); } else { pnl_2.remove(cmbx_2); pnl_2.add(amt); + lbl_vchAmt.setText("Amount:"); pnl_2.updateUI(); } } }); - JLabel lbl_11 = new JLabel("Amount:", SwingConstants.RIGHT); - lbl_11.setBounds(50, 50, 140, 30); - lbl_11.setFont(f3); + lbl_vchAmt = new JLabel("Amount:", SwingConstants.RIGHT); + lbl_vchAmt.setBounds(50, 50, 140, 30); + lbl_vchAmt.setFont(f3); amt = new JTextField(); amt.setBounds(200, 50, 150, 30); @@ -198,7 +201,7 @@ public void actionPerformed(ActionEvent e) { try { A = (String)cmbx_1.getSelectedItem(); if(A.equals("Voucher")) { - Utility.checkString(cmbx_2, lbl_11); + Utility.checkString(cmbx_2, lbl_vchAmt); for(Discount_Voucher v : discountVouchers) { if(((String)cmbx_2.getSelectedItem()).equals(v.getVoucher())){ B = v.getValue(); @@ -207,7 +210,7 @@ public void actionPerformed(ActionEvent e) { } } else { - B = Utility.checkDouble(amt, lbl_11); + B = Utility.checkDouble(amt, lbl_vchAmt); } OrderController.getOrder().addPayment(new Payment(A, B)); @@ -323,7 +326,7 @@ public void actionPerformed(ActionEvent e) { pnl_2.add(lbl_10); pnl_2.add(cmbx_1); - pnl_2.add(lbl_11); + pnl_2.add(lbl_vchAmt); pnl_2.add(amt); pnl_2.add(btn_addPayment); pnl_2.add(scrollPane);