Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
ArmanMokammel committed Nov 5, 2023
1 parent 69af30a commit dfcf5a2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 22 deletions.
23 changes: 7 additions & 16 deletions src/DataEditorUI/VoucherEditor_Dialog.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package DataEditorUI;

import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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;
Expand Down
15 changes: 9 additions & 6 deletions src/UI/OrderSystem/Panel_E.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Discount_Voucher> discountVouchers;

Expand Down Expand Up @@ -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);
Expand All @@ -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();
Expand All @@ -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));
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit dfcf5a2

Please sign in to comment.