-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeposit.java
More file actions
87 lines (73 loc) · 2.8 KB
/
Deposit.java
File metadata and controls
87 lines (73 loc) · 2.8 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
package Bank.Management.System;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Date;
public class Deposit extends JFrame implements ActionListener{
String pin;
TextField textField;
JButton b1, b2;
Deposit (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 label1 = new JLabel("ENTER AMOUNT YOU WANT TO DEPOSIT");
label1.setForeground(Color.white);
label1.setFont(new Font("System", Font.BOLD,16));
label1.setBounds(460, 180, 400,40);
l3.add(label1);
textField = new TextField();
textField.setBackground(new Color(65,125,128));
textField.setForeground(Color.white);
textField.setBounds(460,230,320,35);
textField.setFont(new Font("Raleway", Font.BOLD,22));
l3.add(textField);
b1 = new JButton("DEPOSIT");
b1.setBounds(700,363,150,35);
b1.setBackground(new Color(65,125,128));
b1.setForeground(Color.white);
b1.addActionListener(this);
l3.add(b1);
b2 = new JButton("BACK");
b2.setBounds(700,407,150,35);
b2.setBackground(new Color(65,125,128));
b2.setForeground(Color.white);
b2.addActionListener(this);
l3.add(b2);
setLayout(null);
setSize(1550,1080);
setLocation(0, 0);
setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
try {
String ammount = textField.getText();
Date date = new Date();
if (e.getSource() == b1){
if (textField.getText().equals("")){
JOptionPane.showMessageDialog(null, "Please enter a valid amount to Deposit");
}else {
Connections connections = new Connections();
connections.statement.executeUpdate("insert into bank values('"+pin+"', '"+date+"','Deposit','"+ammount+"')");
JOptionPane.showMessageDialog(null,"Rs." + ammount + " Deposit Successfully");
setVisible(false);
new main_Class(pin);
}
}else if (e.getSource() == b2){
setVisible(false);
new main_Class(pin);
}
}catch (Exception E){
E.printStackTrace();
}
}
public static void main(String[] args) {
new Deposit("");
}
}