/
NearurBank.java
284 lines (231 loc) · 6.23 KB
/
NearurBank.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
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
package com.nearur;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
public class NearurBank {
Image i;
JFrame fr;
JPanel ptil,pnew,pret;
JButton newc,ret;
JLabel ltil;
int[] a[];
protected boolean t;
public NearurBank() {
i=new Image();
fr=new JFrame("Bank");
ltil=new JLabel("Welcome To Nearur Bank");
ltil.setFont(new Font(Font.DIALOG,Font.BOLD,50));
ptil=new JPanel();
pnew=new JPanel();
pret=new JPanel();
newc=new JButton("New Customer");
ret=new JButton("Returning Customer");
newc.setFont(new Font(Font.DIALOG,Font.LAYOUT_LEFT_TO_RIGHT,25));
ret.setFont(new Font(Font.DIALOG,Font.PLAIN,25));
ptil.add(i.getPicLabel());
ptil.add(ltil);
pnew.add(newc);
pnew.add(ret);
fr.add(ptil);
fr.add(pnew);
newc.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
newCustomer();
fr.dispose();
}
});
ret.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
validate();
fr.dispose();
}
});
fr.setLayout(new GridLayout(2,2));
fr.pack();
fr.setVisible(true);
}
void newCustomer() {
JFrame f=new JFrame("Registration");
JLabel ltil=new JLabel("Enter Details");
JLabel lnam=new JLabel("Name:");
JLabel lmob=new JLabel("Mobile:");
JLabel lacc=new JLabel("Account Number:");
JLabel ladd=new JLabel("Address:");
JLabel lbal=new JLabel("Balance:");
JButton add=new JButton("Register");
JPanel ptil=new JPanel();
JPanel pnam=new JPanel();
JPanel pmob=new JPanel();
JPanel pacc=new JPanel();
JPanel padd=new JPanel();
JPanel pbal=new JPanel();
JTextField tnam=new JTextField(20);
tnam.setFont(new Font(Font.DIALOG,Font.PLAIN,15));
JTextField tmob=new JTextField(10);
JTextField tacc=new JTextField(11);
JTextArea tadd=new JTextArea(3,20);
tadd.setAutoscrolls(true);
JTextField tbal=new JTextField(10);
ptil.add(ltil);
pnam.add(lnam);
pnam.add(tnam);
pmob.add(lmob);
pmob.add(tmob);
pacc.add(lacc);
pacc.add(tacc);
padd.add(ladd);
padd.add(tadd);
pbal.add(lbal);
pbal.add(tbal);
pbal.add(add);
f.add(ptil);
f.add(pnam);
f.add(pmob);
f.add(pacc);
f.add(padd);
f.add(pbal);
add.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
Bank b=new Bank(tnam.getText(),tadd.getText(),Long.parseLong(tmob.getText()),Long.parseLong(tacc.getText()),Integer.parseInt(tbal.getText()));;
b.setPt(b.getBal()*0.005);
JDBCUSE u=new JDBCUSE();
u.connect();
u.add(b);
u.close();
f.dispose();
fr.setVisible(true);
}
});
f.setLayout(new GridLayout(6, 1));
f.pack();
f.setVisible(true);
}
void validate() {
JFrame f=new JFrame("Account ");
JLabel lacc=new JLabel("Account Number:");
JPanel pacc=new JPanel();
JTextField tacc=new JTextField(11);
JButton sch=new JButton("Search");
pacc.add(lacc);
pacc.add(tacc);
pacc.add(sch);
f.add(pacc);
sch.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
JDBCUSE u=new JDBCUSE();
u.connect();
Long a=Long.parseLong(tacc.getText());
Bank b=u.search(a);
if(b==null) {
JOptionPane.showMessageDialog(f,"Wrong Account Number");
f.dispose();
u.close();
fr.setVisible(true);
}
else {
u.close();
old(b);
f.dispose();
}
}
});
f.pack();
f.setVisible(true);
}
void old(Bank b) {
JFrame f=new JFrame("Transaction");
JLabel ltil=new JLabel("Customer Details");
JLabel lnam=new JLabel("Name:");
JLabel lmob=new JLabel("Mobile:");
JLabel lacc=new JLabel("Account Number:");
JLabel ladd=new JLabel("Address:");
JLabel lbal=new JLabel("Balance:");
JLabel ldep=new JLabel("Enter Amount:");
JButton add=new JButton("Deposit");
JButton draw=new JButton("Withdraw");
JButton ok=new JButton("Ok");
JPanel ptil=new JPanel();
JPanel pnam=new JPanel();
JPanel pmob=new JPanel();
JPanel pacc=new JPanel();
JPanel padd=new JPanel();
JPanel pbal=new JPanel();
JPanel pbut=new JPanel();
JPanel pdep=new JPanel();
JLabel tnam=new JLabel(b.getName());
JTextField tdep=new JTextField(5);
JLabel tmob=new JLabel(String.valueOf(b.getMobile()));
JLabel tacc=new JLabel(String.valueOf(b.getAccount()));
JLabel tadd=new JLabel(String.valueOf(b.getAddress()));
JLabel tbal=new JLabel(String.valueOf(b.getBal()));
ptil.add(ltil);
pnam.add(lnam);
pnam.add(tnam);
pmob.add(lmob);
pmob.add(tmob);
pacc.add(lacc);
pacc.add(tacc);
padd.add(ladd);
padd.add(tadd);
pbal.add(lbal);
pbal.add(tbal);
pbut.add(add);
pbut.add(draw);
pdep.add(ldep);
pdep.add(tdep);
pdep.add(ok);
f.add(ptil);
f.add(pnam);
f.add(pmob);
f.add(pacc);
f.add(padd);
f.add(pbal);
f.add(pbut);
add.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
f.add(pdep);
t=true;
f.pack();
}
});
ok.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
int bal=Integer.parseInt(tdep.getText());
if(t) {b.setBal(b.getBal()+bal);
b.setPt(b.getPt()+bal*0.005);
}
else {
b.setBal(b.getBal()-bal);
b.setPt(b.getPt()+bal*0.01);
}
JDBCUSE u=new JDBCUSE();
u.connect();
u.update(b);
u.close();
f.setVisible(false);
old(b);
}
});
draw.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
f.add(pdep);
t=false;
f.pack();
}
});
f.setLayout(new GridLayout(8,1));
f.pack();
f.setVisible(true);
}
public static void main(String[] args) {
new NearurBank();
}
}