-
Notifications
You must be signed in to change notification settings - Fork 1
/
MiniStatement.java
147 lines (120 loc) · 4.83 KB
/
MiniStatement.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
import java.awt.*;
import java.sql.ResultSet;
import javax.swing.*;
import java.util.*;
import java.text.*;
class MiniStatement extends JFrame{
String pin;
JButton back;
MiniStatement(String pin)
{
this.pin = pin;
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
Date date = new Date();
String data= dateFormat.format(date);
String str_date = data.substring(0,10);
String str_time = data.substring(11);
setLayout(null);
JLabel bankName = new JLabel("King's Bank");
bankName.setBounds(180,20,200,25);
bankName.setFont(new Font("Times New Roman", Font.BOLD, 20));
bankName.setForeground(new Color(156, 91, 194));
add(bankName);
// Date heading
JLabel d_date = new JLabel("DATE");
d_date.setBounds(100,50,100,20);
d_date.setFont(new Font("Times New Roman", Font.BOLD, 18));
d_date.setForeground(new Color(156, 91, 194));
add(d_date);
// Time heading
JLabel d_time = new JLabel("TIME");
d_time.setBounds(300,50,100,20);
d_time.setFont(new Font("Times New Roman", Font.BOLD, 18));
d_time.setForeground(new Color(156, 91, 194));
add(d_time);
// date
JLabel dis_date = new JLabel(" "+str_date+" ");
dis_date.setBounds(80,80,200,20);
dis_date.setFont(new Font("Times New Roman", Font.BOLD, 18));
add(dis_date);
// Time
JLabel dis_time = new JLabel(""+str_time+"");
dis_time.setBounds(280,80,100,20);
dis_time.setFont(new Font("Times New Roman", Font.BOLD, 18));
add(dis_time);
// Carnumber display
JLabel cardNumDisp = new JLabel();
cardNumDisp.setBounds(70,120,400,30);
cardNumDisp.setFont(new Font("Times New Roman", Font.BOLD, 18));
add(cardNumDisp);
// Detials label
JLabel types = new JLabel("DATE TYPE AMOUNT");
types.setBounds(60,220,400,30);
types.setFont(new Font("Times New Roman", Font.BOLD, 16));
types.setForeground(new Color(156, 91, 194));
add(types);
// label for bank detials
JLabel details = new JLabel();
details.setBounds(50,100,400,500);
details.setFont(new Font("Times New Roman", Font.BOLD, 16));
add(details);
// Balance Amount
JLabel amount = new JLabel();
amount.setBounds(50,500,300,20);
amount.setFont(new Font("Times New Roman", Font.BOLD, 20));
amount.setForeground(new Color(156, 91, 194));
add(amount);
// Card Number
try{
mysql c = new mysql();
ResultSet rs = c.s.executeQuery("select cardNumber from login where PinNumber = '"+pin+"' ");
while (rs.next()) {
cardNumDisp.setText("CARD NO. : " + rs.getString("cardNumber").substring(0,4) + "XXXXXXXX" + rs.getString("cardNumber").substring(12) );
}
}catch(Exception e){
System.out.println(e);
}
// Details last 5
try{
int i = 0;
mysql c = new mysql();
ResultSet rs = c.s.executeQuery("select * from bank where pin = '"+pin+"' ");
// rs.last();
while (i < 5){
if(i == 0){
rs.last();
}else if(i > 0){
rs.previous();
}
details.setText(details.getText() + "<html>" + rs.getString("date") + " " + rs.getString("type") + " " + rs.getString("amount") + "<br></br><br></br> <html>");
i++;
}
}catch(Exception e){
System.out.println(e);
}
// Balance
try{
mysql c = new mysql();
ResultSet rs = c.s.executeQuery("select * from bank where pin = '"+pin+"' ");
int balance = 0;
while(rs.next()){
if(rs.getString("type").equals("Deposit")){
balance += Integer.parseInt(rs.getString("amount"));
}else{
balance -= Integer.parseInt(rs.getString("amount"));
}
}
amount.setText("Balance: Rs." + " "+balance+" ");
}catch(Exception e){
System.out.println(e);
}
setSize(500,600);
setLocation(300,50);
// setDefaultCloseOperation(EXIT_ON_CLOSE);
setResizable(false);
setVisible(true);
}
public static void main(String args[]){
new MiniStatement("");
}
}