-
Notifications
You must be signed in to change notification settings - Fork 1
/
ChangeEmail.java
66 lines (45 loc) · 1.58 KB
/
ChangeEmail.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
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class ChangeEmail extends JFrame implements ActionListener {
private JLabel email;
private JTextField emailText;
private JButton update, back;
private String ID;
public ChangeEmail(String ID) {
super("Update Email");
this.ID = ID;
this.setSize(600, 600);
this.setForeground(Color.BLACK);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLayout(new GridLayout(2, 2));
email = new JLabel("Email");
emailText = new JTextField();
update = new JButton("Update");
back = new JButton("Back");
this.add(email);
this.add(emailText);
this.add(update);
this.add(back);
update.addActionListener(this);
back.addActionListener(this);
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == update) {
String email = emailText.getText();
CustomerOperations ho = new CustomerOperations();
boolean updated = ho.updateEmail(ID, email);
if (updated) {
JOptionPane.showMessageDialog(null, "Email Updated");
} else {
JOptionPane.showMessageDialog(null, "Email Not Updated");
}
}
else if(e.getSource() == back) {
this.dispose();
new CustomerPage(ID);
}
}
}