-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddRoom.java
More file actions
155 lines (115 loc) · 4.41 KB
/
Copy pathAddRoom.java
File metadata and controls
155 lines (115 loc) · 4.41 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
145
146
147
148
149
150
151
152
153
154
155
/*
* 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.*;
import javax.swing.*;
import javax.swing.border.*;
import java.awt.event.*;
import java.sql.*;
import java.util.*;
public class AddRoom extends JFrame implements ActionListener{
private JPanel contentPane;
private JTextField t1,t2,t3,t4;
private JComboBox comboBox, comboBox_1, comboBox_2, comboBox_3;
JButton b1,b2;
Choice c1;
public static void main(String[] args) {
new AddRoom().setVisible(true);
}
public AddRoom() {
setBounds(450, 200, 1000, 450);
contentPane = new JPanel();
setContentPane(contentPane);
contentPane.setLayout(null);
ImageIcon i1 = new ImageIcon(ClassLoader.getSystemResource("hotel/management/system/icons/twelve.jpg"));
Image i3 = i1.getImage().getScaledInstance(500, 300,Image.SCALE_DEFAULT);
ImageIcon i2 = new ImageIcon(i3);
JLabel l15 = new JLabel(i2);
l15.setBounds(400,30,500,370);
add(l15);
JLabel l10 = new JLabel("Add Rooms");
l10.setFont(new Font("Tahoma", Font.BOLD, 18));
l10.setBounds(194, 10, 120, 22);
contentPane.add(l10);
JLabel l1 = new JLabel("Room Number");
l1.setForeground(new Color(25, 25, 112));
l1.setFont(new Font("Tahoma", Font.BOLD, 14));
l1.setBounds(64, 70, 102, 22);
contentPane.add(l1);
t4 = new JTextField();
t4.setBounds(174, 70, 156, 20);
contentPane.add(t4);
JLabel l2 = new JLabel("Availability");
l2.setForeground(new Color(25, 25, 112));
l2.setFont(new Font("Tahoma", Font.BOLD, 14));
l2.setBounds(64, 110, 102, 22);
contentPane.add(l2);
comboBox = new JComboBox(new String[] { "Available", "Occupied" });
comboBox.setBounds(176, 110, 154, 20);
contentPane.add(comboBox);
JLabel l3 = new JLabel("Cleaning Status");
l3.setForeground(new Color(25, 25, 112));
l3.setFont(new Font("Tahoma", Font.BOLD, 14));
l3.setBounds(64, 150, 102, 22);
contentPane.add(l3);
comboBox_2 = new JComboBox(new String[] { "Cleaned", "Dirty" });
comboBox_2.setBounds(176, 150, 154, 20);
contentPane.add(comboBox_2);
JLabel l4 = new JLabel("Price");
l4.setForeground(new Color(25, 25, 112));
l4.setFont(new Font("Tahoma", Font.BOLD, 14));
l4.setBounds(64, 190, 102, 22);
contentPane.add(l4);
t2 = new JTextField();
t2.setBounds(174, 190, 156, 20);
contentPane.add(t2);
JLabel l5 = new JLabel("Bed Type");
l5.setForeground(new Color(25, 25, 112));
l5.setFont(new Font("Tahoma", Font.BOLD, 14));
l5.setBounds(64, 230, 102, 22);
contentPane.add(l5);
comboBox_3 = new JComboBox(new String[] { "Single Bed", "Double Bed"});
comboBox_3.setBounds(176, 230, 154, 20);
contentPane.add(comboBox_3);
b1 = new JButton("Add");
b1.addActionListener(this);
b1.setBounds(64, 321, 111, 33);
b1.setBackground(Color.BLACK);
b1.setForeground(Color.WHITE);
contentPane.add(b1);
b2 = new JButton("Back");
b2.addActionListener(this);
b2.setBounds(198, 321, 111, 33);
b2.setBackground(Color.BLACK);
b2.setForeground(Color.WHITE);
contentPane.add(b2);
contentPane.setBackground(Color.WHITE);
}
public void actionPerformed(ActionEvent ae){
try{
if(ae.getSource() == b1){
try{
conn c = new conn();
String room = t4.getText();
String available = (String)comboBox.getSelectedItem();
String status = (String)comboBox_2.getSelectedItem();
String price = t2.getText();
String type = (String)comboBox_3.getSelectedItem();
String str = "INSERT INTO room values( '"+room+"', '"+available+"', '"+status+"','"+price+"', '"+type+"')";
c.s.executeUpdate(str);
JOptionPane.showMessageDialog(null, "Room Successfully Added");
this.setVisible(false);
}catch(Exception ee){
System.out.println(ee);
}
}
else if(ae.getSource() == b2){
this.setVisible(false);
}
}catch(Exception eee){
}
}
}