-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDeposit.java
175 lines (116 loc) · 5.04 KB
/
Deposit.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
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.myprojects.bankingsystemmanagement;
/**
*
* @author admin
*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
import java.util.*;
public class Deposit extends JFrame implements ActionListener{
JTextField t1,t2;
JButton b1,b2,b3;
JLabel l1,l2,l3;
Deposit(){
setFont(new Font("System", Font.BOLD, 22));
Font f = getFont();
FontMetrics fm = getFontMetrics(f);
int x = fm.stringWidth("DEPOSIT");
int y = fm.stringWidth(" ");
int z = getWidth() - (5*x);
int w = z/y;
String pad ="";
//for (int i=0; i!=w; i++) pad +=" ";
pad = String.format("%"+w+"s", pad);
setTitle(pad+"DEPOSIT");
l1 = new JLabel("ENTER AMOUNT YOU WANT");
l1.setFont(new Font("System", Font.BOLD, 35));
l2 = new JLabel("TO DEPOSIT");
l2.setFont(new Font("System", Font.BOLD, 35));
l3 = new JLabel("Enter Pin");
l3.setFont(new Font("System", Font.BOLD, 14));
t1 = new JTextField();
t1.setFont(new Font("Raleway", Font.BOLD, 22));
t2 = new JTextField();
t2.setFont(new Font("Raleway", Font.BOLD, 14));
b1 = new JButton("DEPOSIT");
b1.setFont(new Font("System", Font.BOLD, 18));
b1.setBackground(Color.BLACK);
b1.setForeground(Color.WHITE);
b2 = new JButton("BACK");
b2.setFont(new Font("System", Font.BOLD, 18));
b2.setBackground(Color.BLACK);
b2.setForeground(Color.WHITE);
b3 = new JButton("EXIT");
b3.setFont(new Font("System", Font.BOLD, 18));
b3.setBackground(Color.BLACK);
b3.setForeground(Color.WHITE);
setLayout(null);
l3.setBounds(620,10,80,30);
add(l3);
t2.setBounds(700,10,40,30);
add(t2);
l1.setBounds(150,150,800,60);
add(l1);
l2.setBounds(290,210,800,60);
add(l2);
t1.setBounds(250,300,300,50);
add(t1);
b1.setBounds(260,380,125,50);
add(b1);
b2.setBounds(415,380,125,50);
add(b2);
b3.setBounds(300,550,200,50);
add(b3);
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
getContentPane().setBackground(Color.WHITE);
setSize(800,800);
setLocation(500,90);
setVisible(true);
}
public void actionPerformed(ActionEvent ae){
try{
String a = t1.getText();
String b = t2.getText();
if(ae.getSource()==b1){
if(t1.getText().equals("")){
JOptionPane.showMessageDialog(null, "Please enter the Amount to you want to Deposit");
}else{
JdbcConnection c1 = new JdbcConnection();
ResultSet rs = c1.s.executeQuery(" select * from bank where pin = '"+b+"' ");
double balance = 0;
if(rs.next()){
String pin = rs.getString("pin");
balance = rs.getDouble("balance");
double d = Double.parseDouble(a);
balance+=d;
String q1= "insert into bank values('"+pin+"','"+d+"',null,'"+balance+"')";
c1.s.executeUpdate(q1);
}
JOptionPane.showMessageDialog(null, "Rs. "+a+" Deposited Successfully");
new Transcations().setVisible(true);
setVisible(false);
}
}else if(ae.getSource()==b2){
new Transcations().setVisible(true);
setVisible(false);
}else if(ae.getSource()==b3){
System.exit(0);
}
}catch(Exception e){
e.printStackTrace();
System.out.println("error: "+e);
}
}
public static void main(String[] args){
new Deposit().setVisible(true);
}
}