-
Notifications
You must be signed in to change notification settings - Fork 0
/
UpdateRoom.java
183 lines (157 loc) · 6.28 KB
/
UpdateRoom.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
/*
* 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.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import java.awt.Font;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class UpdateRoom extends JFrame {
Connection conn = null;
PreparedStatement pst = null;
private JPanel contentPane;
private JTextField txt_ID;
private JTextField txt_Ava;
private JTextField txt_Status;
private JTextField txt_Room;
Choice c1;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
UpdateRoom frame = new UpdateRoom();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public void close(){
this.dispose();
}
/**
* Create the frame.
* @throws SQLException
*/
public UpdateRoom() throws SQLException {
//conn = Javaconnect.getDBConnection();
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(530, 200, 1000, 450);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
ImageIcon i1 = new ImageIcon(ClassLoader.getSystemResource("hotel/management/system/icons/seventh.jpg"));
Image i3 = i1.getImage().getScaledInstance(550, 250,Image.SCALE_DEFAULT);
ImageIcon i2 = new ImageIcon(i3);
JLabel l1 = new JLabel(i2);
l1.setBounds(400,80,600,250);
add(l1);
JLabel lblUpdateRoomStatus = new JLabel("Update Room Status");
lblUpdateRoomStatus.setFont(new Font("Tahoma", Font.PLAIN, 20));
lblUpdateRoomStatus.setBounds(85, 11, 206, 34);
contentPane.add(lblUpdateRoomStatus);
JLabel lblNewLabel = new JLabel("Guest ID:");
lblNewLabel.setBounds(27, 87, 90, 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(160, 84, 140, 20);
contentPane.add(c1);
JLabel lblAvailability = new JLabel("Availability:");
lblAvailability.setBounds(27, 187, 90, 14);
contentPane.add(lblAvailability);
JLabel lblCleanStatus = new JLabel("Clean Status:");
lblCleanStatus.setBounds(27, 240, 90, 14);
contentPane.add(lblCleanStatus);
txt_Ava = new JTextField();
txt_Ava.setBounds(160, 184, 140, 20);
contentPane.add(txt_Ava);
txt_Ava.setColumns(10);
txt_Status = new JTextField();
txt_Status.setBounds(160, 237, 140, 20);
contentPane.add(txt_Status);
txt_Status.setColumns(10);
txt_Room = new JTextField();
txt_Room.setBounds(160, 130, 140, 20);
contentPane.add(txt_Room);
txt_Room.setColumns(10);
JButton b1 = new JButton("Check");
b1.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_Room.setText(rs1.getString("room"));
}
}catch(Exception ee){}
try{
conn c = new conn();
ResultSet rs2 = c.s.executeQuery("select * from room where room = "+txt_Room.getText());
while(rs2.next()){
txt_Ava.setText(rs2.getString("available"));
txt_Status.setText(rs2.getString("status"));
}
}catch(Exception ee){}
}
});
b1.setBounds(120, 315, 89, 23);
b1.setBackground(Color.BLACK);
b1.setForeground(Color.WHITE);
contentPane.add(b1);
JButton btnUpdate = new JButton("Update");
btnUpdate.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) throws NumberFormatException {
try{
conn c = new conn();
String str = "update room set status= '"+txt_Status.getText()+"' where room = "+txt_Room.getText();
c.s.executeUpdate(str);
JOptionPane.showMessageDialog(null, "Update Sucessful");
new Reception().setVisible(true);
setVisible(false);
}catch (Exception ee){
ee.printStackTrace();
}
}
});
btnUpdate.setBounds(60, 355, 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(180, 355, 89, 23);
btnExit.setBackground(Color.BLACK);
btnExit.setForeground(Color.WHITE);
contentPane.add(btnExit);
JLabel lblRoomId = new JLabel("Room Number:");
lblRoomId.setBounds(27, 133, 100, 14);
contentPane.add(lblRoomId);
getContentPane().setBackground(Color.WHITE);
}
}