-
Notifications
You must be signed in to change notification settings - Fork 1
/
EngWITH.java
193 lines (169 loc) · 6.57 KB
/
EngWITH.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
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class EngWITH extends JFrame implements ActionListener {
// public static void main(String[] args) {
// new EngWITH();
// }
JFrame frame;
JLabel bankLabel;
JButton fiveHundred;
JButton thousand;
JButton thousand2;
JButton thousand5;
JButton thousand10;
JButton thousand25;
Font myFont = new Font("Serrif", Font.PLAIN, 15);
Font myFont1 = new Font("Monospaced", Font.BOLD, 30);
double balance;
public EngWITH(){
// Defing the frame
frame = new JFrame("Pawan Bank PVT LTD");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(750, 750);
frame.setLayout(null);
frame.getContentPane().setBackground(new Color(0, 0,0));
// define the Main text;
bankLabel = new JLabel("Withdrawal Amount");
bankLabel.setFont(myFont1);
bankLabel.setForeground(new Color(192,192,192));
bankLabel.setBounds(150, 100, 400, 50);
// Button for Five Hundred Rupees
fiveHundred=new JButton("Rupees Five Hundred");
fiveHundred.setFont(myFont);
fiveHundred.addActionListener(this);
fiveHundred.setBackground(new Color(112, 128, 144));
fiveHundred.setForeground(new Color(249, 246, 238));
fiveHundred.setBounds(15,200,230,50);
fiveHundred.setFocusable(false);
// button for thousand
thousand=new JButton("Rupees Thousand");
thousand.setFont(myFont);
thousand.addActionListener(this);
thousand.setBackground(new Color(112, 128, 144));
thousand.setForeground(new Color(249, 246, 238));
thousand.setBounds(15,280,230,50);
thousand.setFocusable(false);
// button for two-thousand
thousand2=new JButton("Rupees Two Thousand");
thousand2.setFont(myFont);
thousand2.addActionListener(this);
thousand2.setBackground(new Color(112, 128, 144));
thousand2.setForeground(new Color(249, 246, 238));
thousand2.setBounds(15,360,230,50);
thousand2.setFocusable(false);
// button for five-thousand
thousand5=new JButton("Rupees Five Thousand");
thousand5.setFont(myFont);
thousand5.addActionListener(this);
thousand5.setBackground(new Color(112, 128, 144));
thousand5.setForeground(new Color(249, 246, 238));
thousand5.setBounds(500,200,230,50);
thousand5.setFocusable(false);
// button for five-thousand
thousand10=new JButton("Rupees Ten Thousand");
thousand10.setFont(myFont);
thousand10.addActionListener(this);
thousand10.setBackground(new Color(112, 128, 144));
thousand10.setForeground(new Color(249, 246, 238));
thousand10.setBounds(500,280,230,50);
thousand10.setFocusable(false);
// button for five-thousand
thousand25=new JButton(" Twenty-Five Thousand");
thousand25.setFont(myFont);
thousand25.addActionListener(this);
thousand25.setBackground(new Color(112, 128, 144));
thousand25.setForeground(new Color(249, 246, 238));
thousand25.setBounds(500,360,230,50);
thousand25.setFocusable(false);
frame.add(bankLabel);
frame.add(fiveHundred);
frame.add(thousand);
frame.add(thousand2);
frame.add(thousand5);
frame.add(thousand10);
frame.add(thousand25);
frame.setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e){
if (e.getSource()==fiveHundred) {
DBconn dbConn=new DBconn();
double balance = dbConn.getBalance(1234,"120");
if (balance >=500) {
// Calculate the new balance after deducting 500
double newBalance = balance - 500;
// Update the balance in the database
dbConn.updateBalance(1234, "120", newBalance);
new EngDONE();
}else{
new EngOFO();
}
}
if (e.getSource()==thousand) {
DBconn dbConn=new DBconn();
double balance = dbConn.getBalance(1234,"120");
if (balance >=1000) {
// Calculate the new balance after deducting 1000
double newBalance = balance - 1000;
// Update the balance in the database
dbConn.updateBalance(1234, "120", newBalance);
new EngDONE();
}else{
new EngOFO();
}
}
if (e.getSource()==thousand2) {
DBconn dbConn=new DBconn();
double balance = dbConn.getBalance(1234,"120");
if (balance >=2000) {
// Calculate the new balance after deducting 2000
double newBalance = balance - 2000;
// Update the balance in the database
dbConn.updateBalance(1234, "120", newBalance);
new EngDONE();
}else{
new EngOFO();
}
}
if (e.getSource()==thousand5) {
DBconn dbConn=new DBconn();
double balance = dbConn.getBalance(1234,"120");
if (balance >=5000) {
// Calculate the new balance after deducting 5000
double newBalance = balance - 5000;
// Update the balance in the database
dbConn.updateBalance(1234, "120", newBalance);
new EngDONE();
}else{
new EngOFO();
}
}
if (e.getSource()==thousand10) {
DBconn dbConn=new DBconn();
double balance = dbConn.getBalance(1234,"120");
if (balance >=10000) {
// Calculate the new balance after deducting 10000
double newBalance = balance - 10000;
// Update the balance in the database
dbConn.updateBalance(1234, "120", newBalance);
new EngDONE();
}else{
new EngOFO();
}
}
if (e.getSource()==thousand25) {
DBconn dbConn=new DBconn();
double balance = dbConn.getBalance(1234,"120");
if (balance >=25000) {
// Calculate the new balance after deducting 25000
double newBalance = balance - 25000;
// Update the balance in the database
dbConn.updateBalance(1234, "120", newBalance);
new EngDONE();
}else{
new EngOFO();
}
}
}
}