-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMiniStatement.java
More file actions
95 lines (77 loc) · 3.21 KB
/
MiniStatement.java
File metadata and controls
95 lines (77 loc) · 3.21 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
package bank.management.system;
import javax.swing.*;
import java.awt.*;
import java.sql.*;
public class MiniStatement extends JFrame {
MiniStatement(String pinnumber) {
setTitle("Mini Statement");
setLayout(null);
JLabel mini = new JLabel();
mini.setBounds(20, 140, 400, 200);
mini.setVerticalAlignment(JLabel.TOP);
add(mini);
JLabel bank = new JLabel("Indian Bank");
bank.setFont(new Font("Raleway", Font.BOLD, 16));
bank.setBounds(150, 20, 200, 20);
add(bank);
JLabel card = new JLabel();
card.setFont(new Font("Raleway", Font.PLAIN, 12));
card.setBounds(20, 80, 300, 20);
add(card);
JLabel balance = new JLabel();
balance.setFont(new Font("Raleway", Font.BOLD, 12));
balance.setBounds(20, 450, 400, 30);
add(balance);
try {
Conn conn = new Conn();
ResultSet rs = conn.s.executeQuery("select * from login where pin = '" + pinnumber + "'");
if (rs.next()) {
String cardnumber = rs.getString("cardnumber");
card.setText("Card Number: " + cardnumber.substring(0, 4) + "XXXXXXXX" + cardnumber.substring(12));
}
} catch (Exception e) {
System.out.println("Error fetching card number: " + e);
}
try {
Conn conn = new Conn();
int bal = 0;
ResultSet rs = conn.s.executeQuery("select * from bank where pin = '" + pinnumber + "'");
StringBuilder statement = new StringBuilder("<html>");
while (rs.next()) {
String date = rs.getString("date");
String type = rs.getString("type");
String amount = rs.getString("amount");
statement.append(date)
.append(" ")
.append(type)
.append(" Rs ")
.append(amount)
.append("<br>");
if (type.equals("Deposit")) {
bal += Integer.parseInt(amount);
} else {
bal -= Integer.parseInt(amount);
}
}
statement.append("</html>");
mini.setText(statement.toString());
balance.setText("Your Current Account Balance is Rs " + bal);
} catch (Exception e) {
System.out.println("Error fetching transactions: " + e);
e.printStackTrace();
}
setSize(400, 600);
setLocation(20, 20);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
getContentPane().setBackground(Color.WHITE);
setVisible(true);
}
public static void main(String args[]) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
System.out.println("Could not set system look and feel: " + e.getMessage());
}
new MiniStatement("1234");
}
}