-
Notifications
You must be signed in to change notification settings - Fork 0
/
UpdateCheck.java
216 lines (178 loc) · 7.69 KB
/
UpdateCheck.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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
/*
* 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 hotel.management.system;
import java.awt.BorderLayout;
import java.awt.*;
import java.sql.*;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.Font;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class UpdateCheck extends JFrame {
Connection conn = null;
PreparedStatement pst = null;
private JPanel contentPane;
private JTextField txt_ID;
private JTextField txt_Room;
private JTextField txt_Status;
private JTextField txt_Date;
private JTextField txt_Time;
private JTextField txt_Payment;
Choice c1, c2;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
UpdateCheck frame = new UpdateCheck();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public void close(){
this.dispose();
}
/**
* Create the frame.
* @throws SQLException
*/
public UpdateCheck() throws SQLException {
//conn = Javaconnect.getDBConnection();
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(500, 200, 950, 500);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
JLabel lblUpdateCheckStatus = new JLabel("Check-In Details");
lblUpdateCheckStatus.setFont(new Font("Tahoma", Font.PLAIN, 20));
lblUpdateCheckStatus.setBounds(124, 11, 222, 25);
contentPane.add(lblUpdateCheckStatus);
ImageIcon i1 = new ImageIcon(ClassLoader.getSystemResource("hotel/management/system/icons/nine.jpg"));
JLabel l1 = new JLabel(i1);
l1.setBounds(450,70,476,270);
add(l1);
JLabel lblNewLabel = new JLabel("ID:");
lblNewLabel.setBounds(25, 88, 46, 14);
contentPane.add(lblNewLabel);
c1 = new Choice();
try{
conn c = new conn();
ResultSet rs = c.s.executeQuery("select * from customer");
while(rs.next()){
c1.add(rs.getString("number"));
}
}catch(Exception e){ }
c1.setBounds(248, 85, 140, 20);
contentPane.add(c1);
JLabel lblNewLabel_1 = new JLabel("Room Number :");
lblNewLabel_1.setBounds(25, 129, 107, 14);
contentPane.add(lblNewLabel_1);
txt_ID = new JTextField();
txt_ID.setBounds(248, 126, 140, 20);
contentPane.add(txt_ID);
JLabel lblNewLabel_2 = new JLabel("Name : ");
lblNewLabel_2.setBounds(25, 174, 97, 14);
contentPane.add(lblNewLabel_2);
JLabel lblNewLabel_3 = new JLabel("Checked-in :");
lblNewLabel_3.setBounds(25, 216, 107, 14);
contentPane.add(lblNewLabel_3);
JLabel lblNewLabel_4 = new JLabel("Amount Paid (Rs) : ");
lblNewLabel_4.setBounds(25, 261, 107, 14);
contentPane.add(lblNewLabel_4);
JLabel lblNewLabel_5 = new JLabel("Pending Amount (Rs) : ");
lblNewLabel_5.setBounds(25, 302, 150, 14);
contentPane.add(lblNewLabel_5);
txt_Status = new JTextField();
txt_Status.setBounds(248, 171, 140, 20);
contentPane.add(txt_Status);
txt_Status.setColumns(10);
txt_Date = new JTextField();
txt_Date.setBounds(248, 216, 140, 20);
contentPane.add(txt_Date);
txt_Date.setColumns(10);
txt_Time = new JTextField();
txt_Time.setBounds(248, 258, 140, 20);
contentPane.add(txt_Time);
txt_Time.setColumns(10);
txt_Payment = new JTextField();
txt_Payment.setBounds(248, 299, 140, 20);
contentPane.add(txt_Payment);
txt_Payment.setColumns(10);
JButton btnUpdate = new JButton("Update");
btnUpdate.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
try{
conn c = new conn();
String s1 = c1.getSelectedItem();
String s2 = txt_ID.getText(); //room_number;
String s3 = txt_Status.getText(); //name
String s4 = txt_Date.getText(); //status;
String s5 = txt_Time.getText(); //deposit
c.s.executeUpdate("update customer set room = '"+s2+"', name = '"+s3+"', status = '"+s4+"', deposit = '"+s5+"' where number = '"+s1+"'");
JOptionPane.showMessageDialog(null, "Data Updated Successfully");
new Reception().setVisible(true);
setVisible(false);
}catch(Exception ee){
System.out.println(ee);
}
}
});
btnUpdate.setBounds(168, 378, 89, 23);
btnUpdate.setBackground(Color.BLACK);
btnUpdate.setForeground(Color.WHITE);
contentPane.add(btnUpdate);
JButton btnExit = new JButton("Back");
btnExit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
new Reception().setVisible(true);
setVisible(false);
}
});
btnExit.setBounds(281, 378, 89, 23);
btnExit.setBackground(Color.BLACK);
btnExit.setForeground(Color.WHITE);
contentPane.add(btnExit);
JButton btnAdd = new JButton("Check");
btnAdd.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try{
String s1 = c1.getSelectedItem();
conn c = new conn();
ResultSet rs1 = c.s.executeQuery("select * from customer where number = "+s1);
while(rs1.next()){
txt_ID.setText(rs1.getString("room"));
txt_Status.setText(rs1.getString("name"));
txt_Date.setText(rs1.getString("status"));
txt_Time.setText(rs1.getString("deposit"));
}
}catch(Exception ee){}
try{
String total = "";
conn c = new conn();
ResultSet rs2 = c.s.executeQuery("select * from room where room = "+txt_ID.getText());
while(rs2.next()){
total = rs2.getString("price");
}
String paid = txt_Time.getText();
int pending = Integer.parseInt(total)- Integer.parseInt(paid);
txt_Payment.setText(Integer.toString(pending));
}catch(Exception ee){}
}
});
btnAdd.setBounds(56, 378, 89, 23);
btnAdd.setBackground(Color.BLACK);
btnAdd.setForeground(Color.WHITE);
contentPane.add(btnAdd);
getContentPane().setBackground(Color.WHITE);
}
}