-
Notifications
You must be signed in to change notification settings - Fork 0
/
UpdateFee.java
113 lines (93 loc) · 3.65 KB
/
UpdateFee.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
package hostel.management.system;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
public class UpdateFee extends JFrame implements ActionListener {
Choice c1;
JTextField t1;
JButton b1,b2,b3;
UpdateFee() {
JLabel l1 = new JLabel("Update Fees");
l1.setFont(new Font("Tahoma", Font.BOLD,25));
l1.setForeground(Color.blue);
l1.setBounds(100,10,250,30);
add(l1);
JLabel l2 = new JLabel("Room Type");
l2.setBounds(40,100,80,30);
add(l2);
c1= new Choice();
try{
conn c = new conn();
ResultSet rs = c.s.executeQuery("select * from hostelfees");
while(rs.next()) {
c1.add(rs.getString("type"));
}
}catch(Exception e){}
c1.setBackground(Color.white);
c1.setBounds(130,100,150,30);
add(c1);
JLabel l3 = new JLabel("Fees");
l3.setBounds(40,160,80,30);
add(l3);
t1 = new JTextField();
t1.setBounds(130,160,150,30);
add(t1);
ImageIcon i1 = new ImageIcon(ClassLoader.getSystemResource("hostel/management/system/icons/fees.jpeg"));
Image i2 = i1.getImage().getScaledInstance(250,280,Image.SCALE_DEFAULT);
ImageIcon i3 = new ImageIcon(i2);
JLabel l4 = new JLabel(i3);
l4.setBounds(320,10,250,280);
add(l4);
ImageIcon i4 = new ImageIcon(ClassLoader.getSystemResource("hostel/management/system/icons/check.jpg"));
Image i5 = i4.getImage().getScaledInstance(25,23,Image.SCALE_DEFAULT);
ImageIcon i6 = new ImageIcon(i5);
b1 = new JButton(i6);
b1.setBounds(290,100,25,23);
b1.addActionListener(this);
add(b1);
b2 = new JButton("Update");
b2.setBounds(180,250,100,30);
b2.setBackground(Color.BLACK);
b2.setForeground(Color.white);
b2.addActionListener(this);
add(b2);
b3 = new JButton("Back");
b3.setBounds(50,250,100,30);
b3.setBackground(Color.BLACK);
b3.setForeground(Color.white);
b3.addActionListener(this);
add(b3);
getContentPane().setBackground(Color.white);
setLayout(null);
setVisible(true);
setBounds(400,200,600,350);
}
public void actionPerformed(ActionEvent ae) {
if(ae.getSource()== b1) {
String s1 = c1.getSelectedItem();
conn c = new conn();
try{
ResultSet rs = c.s.executeQuery("select * from hostelfees where type = '"+s1+"'");
while(rs.next()){
t1.setText(rs.getString("fee"));
}
} catch(Exception e) {System.out.println(e);}
} else if(ae.getSource()== b2) {
try{
conn c = new conn();
String type = c1.getSelectedItem();
String fee = t1.getText();
String str = "update hostelfees set fee = '"+fee+"' where type = '"+type+"'";
c.s.executeUpdate(str);
JOptionPane.showMessageDialog(null,"Fees updated successfully!");
this.setVisible(false);
} catch(Exception e) {System.out.println(e);}
} else if(ae.getSource()== b3) {
this.setVisible(false);
}
}
public static void main(String[] args) {
new UpdateFee();
}
}