-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPinChange.java
More file actions
157 lines (107 loc) · 4.76 KB
/
PinChange.java
File metadata and controls
157 lines (107 loc) · 4.76 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
package bank.management.system;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class PinChange extends JFrame implements ActionListener {
JPasswordField pin,repin;
JButton change, back;
String pinnumber;
PinChange(String pinnumber) {
this.pinnumber = pinnumber;
setLayout(null);
try {
ImageIcon i1 = new ImageIcon(ClassLoader.getSystemResource("icons/atm.jpg"));
Image i2 = i1.getImage().getScaledInstance(900, 900, Image.SCALE_DEFAULT);
ImageIcon i3 = new ImageIcon(i2);
JLabel image = new JLabel(i3);
image.setBounds(0, 0, 900, 900);
add(image);
JLabel text = new JLabel("CHANGE YOUR PIN:");
text.setForeground(Color.WHITE);
text.setFont(new Font("System", Font.BOLD, 16));
text.setBounds(250, 280, 500, 35);
image.add(text);
JLabel pintext = new JLabel("New PIN:");
pintext.setForeground(Color.WHITE);
pintext.setFont(new Font("System", Font.BOLD, 16));
pintext.setBounds(165, 320, 180, 25);
image.add(pintext);
pin = new JPasswordField();
pin.setFont(new Font("Raleway", Font.BOLD,25));
pin.setBounds(330, 320, 180, 25);
image.add(pin);
JLabel repintext = new JLabel("Re-Enter New PIN:");
repintext.setForeground(Color.WHITE);
repintext.setFont(new Font("System", Font.BOLD, 16));
repintext.setBounds(165, 360, 180, 25);
image.add(repintext);
repin = new JPasswordField();
repin.setFont(new Font("Raleway", Font.BOLD,25));
repin.setBounds(330, 360, 180, 25);
image.add(repin);
change = new JButton("CHANGE");
change.setBounds(355, 485, 150, 30);
change.addActionListener(this);
image.add(change);
back = new JButton("BACK");
back.setBounds(355, 520, 150, 30);
back.addActionListener(this);
image.add(back);
} catch (Exception e) {
System.out.println("Error loading image: " + e.getMessage());
JLabel placeholder = new JLabel("ATM Interface", JLabel.CENTER);
placeholder.setBounds(0, 0, 900, 900);
placeholder.setBackground(Color.LIGHT_GRAY);
placeholder.setOpaque(true);
add(placeholder);
}
setSize(900, 900);
setLocation(300, 0);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setUndecorated(true);
setVisible(true);
}
public void actionPerformed(ActionEvent ae){
if (ae.getSource() == change) {
try{
String npin = pin.getText();
String rpin = repin.getText();
if (!npin.equals(rpin)) {
JOptionPane.showMessageDialog(null, "Entered PIN does not match");
return;
}
if (npin.equals("")) {
JOptionPane.showMessageDialog(null, "Please enter new PIN");
return;
}
if (rpin.equals("")) {
JOptionPane.showMessageDialog(null, "Please re-enter new PIN");
return;
}
Conn conn = new Conn();
String query1 = "update bank set pin='" + rpin + "' where pin='" + pinnumber + "'";
String query2 = "update login set pin='" + rpin + "' where pin='" + pinnumber + "'";
String query3 = "update signupthree set pin='" + rpin + "' where pin='" + pinnumber + "'";
conn.s.executeUpdate(query1);
conn.s.executeUpdate(query2);
conn.s.executeUpdate(query3);
JOptionPane.showMessageDialog(null, "PIN changed successfully");
setVisible(false);
new Transactions(rpin).setVisible(true);
} catch (Exception e) {
System.out.println(e);
}
}else {
setVisible(false);
new Transactions(pinnumber).setVisible(true);
}
}
public static void main(String args[]) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
System.out.println("Could not set system look and feel: " + e.getMessage());
}
new PinChange("");
}
}