-
Notifications
You must be signed in to change notification settings - Fork 1
/
DeleteCustomer.java
60 lines (44 loc) · 1.47 KB
/
DeleteCustomer.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class DeleteCustomer extends JFrame implements ActionListener {
private JLabel ID;
private JTextField IDText;
private JButton delete , back;
public DeleteCustomer() {
super("Delete By ID");
this.setSize(600, 600);
this.setForeground(Color.BLACK);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLayout(new GridLayout(2, 2));
ID = new JLabel("Customer ID");
IDText = new JTextField();
delete = new JButton("Delete");
back = new JButton("Back");
this.add(ID);
this.add(IDText);
this.add(delete);
this.add(back);
delete.addActionListener(this);
back.addActionListener(this);
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == delete) {
AdminOperations ao = new AdminOperations();
String ID = IDText.getText();
boolean found = ao.removeCustomer(ID);
if (found) {
JOptionPane.showMessageDialog(null, " deleted successfully");
}
else {
JOptionPane.showMessageDialog(null, "user not found");
}
}
else if(e.getSource() == back) {
this.dispose();
new Admin();
}
}
}