-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFastCash.java
200 lines (193 loc) · 8.06 KB
/
FastCash.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
package bank.management.system;
import java.awt.Color;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
public class FastCash extends JFrame implements ActionListener {
JLabel l1,l2;
JButton b1,b2,b3,b4,b5,b6,b7,b8;
JTextField t1;
FastCash(){
setFont(new Font("System",Font.BOLD,22));
Font f = getFont();
FontMetrics fm = getFontMetrics(f);
int x = fm.stringWidth("FASH CASH");
int y = fm.stringWidth(" ");
int z = getWidth() - (4*x);
int w = z/y;
String pad ="";
pad = String.format("%"+w+"s",pad);
setTitle(pad+"FAST CASH");
l1 = new JLabel("SELECT WITHDRAWL AMOUNT");
l1.setFont(new Font("System",Font.BOLD,38));
l2 = new JLabel("ENTER PIN");
l2.setFont(new Font("System",Font.BOLD,10));
t1 = new JTextField();
t1.setFont(new Font("System",Font.BOLD,13));
b1 = new JButton("RS 100");
b1.setFont(new Font("System",Font.BOLD,18));
b1.setBackground(Color.BLACK);
b1.setForeground(Color.WHITE);
b2 = new JButton("RS 500");
b2.setFont(new Font("System",Font.BOLD,18));
b2.setBackground(Color.BLACK);
b2.setForeground(Color.WHITE);
b3 = new JButton("RS 1000");
b3.setFont(new Font("System",Font.BOLD,18));
b3.setBackground(Color.BLACK);
b3.setForeground(Color.WHITE);
b4 = new JButton("RS 2000");
b4.setFont(new Font("System",Font.BOLD,18));
b4.setBackground(Color.BLACK);
b4.setForeground(Color.WHITE);
b5 = new JButton("RS 5000");
b5.setFont(new Font("System",Font.BOLD,18));
b5.setBackground(Color.BLACK);
b5.setForeground(Color.WHITE);
b6 = new JButton("10000");
b6.setFont(new Font("System",Font.BOLD,18));
b6.setBackground(Color.BLACK);
b6.setForeground(Color.WHITE);
b7 = new JButton("BACK");
b7.setFont(new Font("System",Font.BOLD,18));
b7.setBackground(Color.BLACK);
b7.setForeground(Color.WHITE);
b8 = new JButton("EXIT");
b8.setFont(new Font("System",Font.BOLD,18));
b8.setBackground(Color.BLACK);
b8.setForeground(Color.WHITE);
setLayout(null);
t1.setBounds(700,20,60,20);
add(t1);
l1.setBounds(100,100,700,40);
add(l1);
l2.setBounds(640,10,60,40);
add(l2);
b1.setBounds(40,250,300,60);
add(b1);
b2.setBounds(440,250,300,60);
add(b2);
b3.setBounds(40,360,300,60);
add(b3);
b4.setBounds(440,360,300,60);
add(b4);
b5.setBounds(40,470,300,60);
add(b5);
b6.setBounds(440,470,300,60);
add(b6);
b7.setBounds(440,470,300,60);
add(b7);
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
b4.addActionListener(this);
b5.addActionListener(this);
b6.addActionListener(this);
b7.addActionListener(this);
getContentPane().setBackground(Color.WHITE);
setSize(800,800);
setLocation(500,90);
setVisible(true);
}
public void actionPerformed(ActionEvent ae){
try{
String a = t1.getText();
double balance = 0;
if(ae.getSource()==b1){
conn c1 = new conn();
ResultSet rs = c1.s.executeQuery("ResultSetselect * from Bank where pin = '"+a+"' ");
if(rs.next()){
String pin = rs.getString("pin");
balance = rs.getDouble("balance");
balance-=100;
String q1 = "insert into bank values('"+pin+"',null,100,'"+balance+"')";
c1.s.executeUpdate(q1);
}
JOptionPane.showMessageDialog(null,"Rs."+100+" Debited Successfully.");
new Transcations().setVisible(true);
setVisible(false);
}
else if(ae.getSource()==b2){
conn c1 = new conn();
ResultSet rs = c1.s.executeQuery("ResultSetselect * from Bank where pin = '"+a+"' ");
if(rs.next()){
String pin = rs.getString("pin");
balance = rs.getDouble("balance");
balance-=500;
String q1 = "insert into bank values('"+pin+"',null,500,'"+balance+"')";
c1.s.executeUpdate(q1);
}
JOptionPane.showMessageDialog(null,"Rs."+500+" Debited Successfully.");
new Transcations().setVisible(true);
setVisible(false);
}
else if(ae.getSource()==b3){
conn c1 = new conn();
ResultSet rs = c1.s.executeQuery("ResultSetselect * from Bank where pin = '"+a+"' ");
if(rs.next()){
String pin = rs.getString("pin");
balance = rs.getDouble("balance");
balance-=1000;
String q1 = "insert into bank values('"+pin+"',null,1000,'"+balance+"')";
c1.s.executeUpdate(q1);
}
JOptionPane.showMessageDialog(null,"Rs."+1000+" Debited Successfully.");
new Transcations().setVisible(true);
setVisible(false);
}
else if(ae.getSource()==b4){
conn c1 = new conn();
ResultSet rs = c1.s.executeQuery("ResultSetselect * from Bank where pin = '"+a+"' ");
if(rs.next()){
String pin = rs.getString("pin");
balance = rs.getDouble("balance");
balance-=2000;
String q1 = "insert into bank values('"+pin+"',null,2000,'"+balance+"')";
c1.s.executeUpdate(q1);
}
JOptionPane.showMessageDialog(null,"Rs."+2000+" Debited Successfully.");
new Transcations().setVisible(true);
setVisible(false);
}
else if(ae.getSource()==b5){
conn c1 = new conn();
ResultSet rs = c1.s.executeQuery("ResultSetselect * from Bank where pin = '"+a+"' ");
if(rs.next()){
String pin = rs.getString("pin");
balance = rs.getDouble("balance");
balance-=5000;
String q1 = "insert into bank values('"+pin+"',null,5000,'"+balance+"')";
c1.s.executeUpdate(q1);
}
JOptionPane.showMessageDialog(null,"Rs."+5000+" Debited Successfully.");
new Transcations().setVisible(true);
setVisible(false);
}
else if(ae.getSource()==b6){
conn c1 = new conn();
ResultSet rs = c1.s.executeQuery("ResultSetselect * from Bank where pin = '"+a+"' ");
if(rs.next()){
String pin = rs.getString("pin");
balance = rs.getDouble("balance");
balance-=10000;
String q1 = "insert into bank values('"+pin+"',null,10000,'"+balance+"')";
c1.s.executeUpdate(q1);
}
JOptionPane.showMessageDialog(null,"Rs."+10000+" Debited Successfully.");
new Transcations().setVisible(true);
setVisible(false);
}
else if(ae.getSource()==b7){
System.exit(0);
}
}catch(Exception e){
e.printStackTrace();
System.out.println("Error: "+e);
}
}
public static void main(String[] args){
new FastCash().setVisible(true);
}
}