-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFastCash.java
More file actions
130 lines (107 loc) · 4.21 KB
/
FastCash.java
File metadata and controls
130 lines (107 loc) · 4.21 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
package Bank.Management.System;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.ResultSet;
import java.util.Date;
public class FastCash extends JFrame implements ActionListener {
JButton b1,b2,b3,b4,b5,b6,b7;
String pin;
FastCash(String pin){
this.pin = pin;
ImageIcon i1 = new ImageIcon(ClassLoader.getSystemResource("icon/atm2.png"));
Image i2 = i1.getImage().getScaledInstance(1550, 830, Image.SCALE_DEFAULT);
ImageIcon i3 = new ImageIcon(i2);
JLabel l3 = new JLabel(i3);
l3.setBounds(0, 0, 1550, 830);
add(l3);
JLabel label = new JLabel("SELECT WITHDRAWAL AMOUNT");
label.setBounds(438, 180, 700, 35);
label.setForeground(Color.white);
label.setFont(new Font("System", Font.BOLD, 24));
l3.add(label);
b1 = new JButton("Rs. 100");
b1.setForeground(Color.white);
b1.setBackground(new Color(65, 125, 128));
b1.setBounds(403, 270, 150, 35);
b1.addActionListener(this);
l3.add(b1);
b2 = new JButton("Rs. 500");
b2.setForeground(Color.white);
b2.setBackground(new Color(65, 125, 128));
b2.setBounds(706, 270, 150, 35);
b2.addActionListener(this);
l3.add(b2);
b3 = new JButton("Rs. 1000");
b3.setForeground(Color.white);
b3.setBackground(new Color(65, 125, 128));
b3.setBounds(403, 316, 150, 35);
b3.addActionListener(this);
l3.add(b3);
b4 = new JButton("Rs. 2000");
b4.setForeground(Color.white);
b4.setBackground(new Color(65, 125, 128));
b4.setBounds(706, 316, 150, 35);
b4.addActionListener(this);
l3.add(b4);
b5 = new JButton("Rs. 5000");
b5.setForeground(Color.white);
b5.setBackground(new Color(65, 125, 128));
b5.setBounds(403, 364, 150, 35);
b5.addActionListener(this);
l3.add(b5);
b6 = new JButton("Rs. 10000");
b6.setForeground(Color.white);
b6.setBackground(new Color(65, 125, 128));
b6.setBounds(706, 364, 150, 35);
b6.addActionListener(this);
l3.add(b6);
b7 = new JButton("Back");
b7.setForeground(Color.white);
b7.setBackground(new Color(65, 125, 128));
b7.setBounds(706, 410, 150, 35);
b7.addActionListener(this);
l3.add(b7);
setLayout(null);
setSize(1550, 1080);
setLocation(0, 0);
setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == b7){
setVisible(false);
new main_Class(pin);
}else {
String amount = ((JButton)e.getSource()).getText().substring(4);
Connections connections = new Connections();
Date date = new Date();
try{
ResultSet resultSet = connections.statement.executeQuery("select * from bank where pin = '"+pin+"' ");
int balance = 0;
while (resultSet.next()){
if (resultSet.getString("type").equals("Deposit")){
balance += Integer.parseInt(resultSet.getString("ammount"));
}else {
balance -= Integer.parseInt(resultSet.getString("ammount"));
}
}
String num = "17";
if (e.getSource() != b7 && balance < Integer.parseInt(amount)){
JOptionPane.showMessageDialog(null, "Insufficient Balance");
return;
}
connections.statement.executeUpdate("insert into bank values('"+pin+"', '"+date+"', 'Withdrawal', '"+amount+"')");
JOptionPane.showMessageDialog(null, "Rs. "+amount+" Debited Successfully");
}catch (Exception E){
E.printStackTrace();
}
setVisible(false);
new main_Class(pin);
}
}
public static void main(String[] args) {
new FastCash("");
}
}