-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWithdrawl.java
More file actions
109 lines (75 loc) · 3.07 KB
/
Withdrawl.java
File metadata and controls
109 lines (75 loc) · 3.07 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
package bank.management.system;
import javax.swing.*;
import java.awt.*;
import java.net.URL;
import java.awt.event.*;
import java.util.*;
public class Withdrawl extends JFrame implements ActionListener {
JTextField amount;
JButton withdrawl, back;
String pinnumber;
Withdrawl(String pinnumber) {
this.pinnumber = pinnumber;
setLayout(null);
URL imageURL = ClassLoader.getSystemResource("icons/atm.jpg");
ImageIcon i1 = new ImageIcon(imageURL);
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);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JLabel text = new JLabel("Enter the amount you want to withdrawl");
text.setForeground(Color.WHITE);
text.setFont(new Font("System", Font.BOLD, 16));
text.setBounds(170, 300, 400, 20);
image.add(text);
amount = new JTextField();
amount.setFont(new Font("Raleway", Font.BOLD,22));
amount.setBounds(170,350, 320, 25);
image.add(amount);
withdrawl = new JButton("Withdraw");
withdrawl.setBounds(355, 485, 150, 30);
withdrawl.addActionListener(this);
image.add(withdrawl);
back = new JButton("Back");
back.setBounds(355, 520, 150, 30);
back.addActionListener(this);
image.add(back);
setSize(900, 900);
setLocation(300, 0);
setUndecorated(true);
setVisible(true);
}
public void actionPerformed(ActionEvent ae) {
if (ae.getSource() == withdrawl) {
String number = amount.getText();
Date date = new Date();
if(number.equals("")) {
JOptionPane.showMessageDialog(null, "Please enter the amount you want to withdrawl" );
return;
}
if (!number.matches("\\d+(\\.\\d+)?")) {
JOptionPane.showMessageDialog(null, "Please enter a valid numeric amount.");
return;
}
try{
Conn conn = new Conn();
String query = "insert into bank values('" + pinnumber + "', '" + date + "', 'Withdrawl', '" + number + "')";
conn.s.executeUpdate(query);
JOptionPane.showMessageDialog(null, "Rs "+number+" Withdrawl Successfully");
setVisible(false);
new Transactions(pinnumber).setVisible(true);
} catch (Exception e){
System.out.println(e);
JOptionPane.showMessageDialog(null, "Error during withdrawl: " + e.getMessage());
}
} else if (ae.getSource() == back) {
setVisible(false);
new Transactions(pinnumber).setVisible(true);
}
}
public static void main(String args[]) {
new Withdrawl("");
}
}