-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMiniStatement.java
More file actions
144 lines (115 loc) · 4.92 KB
/
MiniStatement.java
File metadata and controls
144 lines (115 loc) · 4.92 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
package BankTransactions;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.*;
public class MiniStatement extends JFrame implements ActionListener {
JLabel label1, label2, underline, label3, label4, label5;
JButton button1, button2;
//String pin;
MiniStatement(String pin){
//this.pin = pin;
setFont(new Font("System", Font.BOLD, 22));
Font font = getFont();
FontMetrics fontMetrics = getFontMetrics(font);
int x = fontMetrics.stringWidth("MINI STATEMENT");
int y = fontMetrics.stringWidth(" ");
int z = getWidth() - x;
int w = z / y;
String pad = "";
pad = String.format("%" + w + "s", pad);
setTitle(pad + "MINI STATEMENT");
ImageIcon imageIcon1 = new ImageIcon(ClassLoader.getSystemResource("BankTransactions/icons/banklogo1.jpg"));
Image imageIcon2 = imageIcon1.getImage().getScaledInstance(120, 120, Image.SCALE_DEFAULT);
ImageIcon imageIcon3 = new ImageIcon(imageIcon2);
label2 = new JLabel(imageIcon3);
label2.setBounds(20, 0, 100, 100);
add(label2);
label1 = new JLabel("MINI STATEMENT");
label1.setForeground(new Color(254, 100, 45));
label1.setFont(new Font("Oswald", Font.BOLD, 25));
label1.setBounds(270, 0, 600, 90);
add(label1);
underline = new JLabel("_______________________________");
underline.setForeground(new Color(254, 100, 45));
underline.setFont(new Font("Raleway", Font.PLAIN, 30));
underline.setBounds(150, 0, 700, 95);
add(underline);
label3 = new JLabel();
//label2.setForeground(new Color(254, 100, 45));
label3.setFont(new Font("Arial", Font.PLAIN, 20));
label3.setBounds(150, 45, 800, 90);
add(label3);
label4 = new JLabel();
//label2.setForeground(new Color(254, 100, 45));
label4.setFont(new Font("Arial", Font.PLAIN, 15));
label4.setBounds(150, 150, 800, 100);
add(label4);
label5 = new JLabel();
//label2.setForeground(new Color(254, 100, 45));
label5.setFont(new Font("Arial", Font.PLAIN, 20));
label5.setBounds(150, 70, 800, 90);
add(label5);
button1 = new JButton("BACK TO TRANSACTIONS");
button1.setBackground(new Color(255, 153, 0));
//button1.setBackground(Color.ORANGE);
button1.setForeground(Color.WHITE);
button1.setFont(new Font("Arial", Font.BOLD, 15));
button1.setBounds(220, 280, 250, 30);
button1.addActionListener(this);
add(button1);
button2 = new JButton("EXIT");
button2.setBackground(new Color(255, 153, 0));
//button1.setBackground(Color.ORANGE);
button2.setForeground(Color.WHITE);
button2.setFont(new Font("Arial", Font.BOLD, 15));
button2.setBounds(220, 320, 250, 30);
button2.addActionListener(this);
add(button2);
try{
Bank connection = new Bank();
ResultSet resultSet = connection.statement.executeQuery("select * from login where pin = '"+pin+"'");
while(resultSet.next()){
label3.setText("Card Number: " + resultSet.getString("cardNumber").substring(0, 4) + "XXXXXXXX" + resultSet.getString("cardNumber").substring(12));
}
}catch(Exception e1){
//e1.printStackTrace();
}
try{
int balance = 0;
Bank connection1 = new Bank();
ResultSet resultSet = connection1.statement.executeQuery("SELECT * FROM transaction where pin = '"+pin+"'");
while(resultSet.next()){
label4.setText(label4.getText() + "<html>"+resultSet.getString("date")+ " " + resultSet.getString("mode") + " " + resultSet.getString("amount") + "<br><br><html>");
if(resultSet.getString("mode").equals("Deposit")){
balance += Integer.parseInt(resultSet.getString("amount"));
}else{
balance -= Integer.parseInt(resultSet.getString("amount"));
}
}
label5.setText("Your total Balance is Rs " + balance);
}catch(Exception e){
e.printStackTrace();
}
getContentPane().setBackground(Color.WHITE);
setLayout(null);
setLocation(400, 70);
setUndecorated(true);
setSize(700, 400);
setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource()==button1){
this.setVisible(false);
//new Transactions(pin).setVisible(true);
}
if (e.getSource()==button2){
System.exit(0);
}
}
public static void main(String[] args) {
new MiniStatement("").setVisible(true);
}
}