-
Notifications
You must be signed in to change notification settings - Fork 1
/
UpdateCustomer.java
72 lines (54 loc) · 1.89 KB
/
UpdateCustomer.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
61
62
63
64
65
66
67
68
69
70
71
72
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class UpdateCustomer extends JFrame implements ActionListener {
private JLabel lID, CarNo, CarReg;
private JTextField tID, CarNoText, CarRegText;
private JButton update, back;
public UpdateCustomer() {
super("Update Customer Car");
this.setSize(600, 600);
this.setForeground(Color.BLACK);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLayout(new GridLayout(4, 2));
lID = new JLabel(" ID");
CarNo = new JLabel("Car Name");
CarReg = new JLabel("Car Reg ");
tID = new JTextField();
CarNoText = new JTextField();
CarRegText = new JTextField();
update = new JButton("Update");
back = new JButton("Back");
this.add(lID);
this.add(tID);
this.add(CarNo);
this.add(CarNoText);
this.add(CarReg);
this.add(CarRegText);
this.add(update);
this.add(back);
update.addActionListener(this);
back.addActionListener(this);
}
@Override
public void actionPerformed(ActionEvent e) {
if(e.getSource() == update) {
String ID = tID.getText();
String CarNo = CarNoText.getText();
String RegNo = CarRegText.getText();
AdminOperations ao = new AdminOperations();
boolean found = ao.updateCar(ID, CarNo, RegNo);
if (found) {
JOptionPane.showMessageDialog(null, "car updated successfully");
}
else {
JOptionPane.showMessageDialog(null, "No such ID Found ");
}
}
else if(e.getSource() == back) {
this.dispose();
new Admin();
}
}
}