-
Notifications
You must be signed in to change notification settings - Fork 0
/
NewCustomer.java
214 lines (174 loc) · 7.17 KB
/
NewCustomer.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
/*
* 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.awt.EventQueue;
import javax.swing.border.EmptyBorder;
import java.awt.Font;
import java.awt.Image;
import java.sql.*;
import javax.swing.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class NewCustomer extends JFrame {
Connection conn = null;
PreparedStatement pst = null;
private JPanel contentPane;
private JTextField t1,t2,t3,t4,t5,t6;
JComboBox comboBox;
JRadioButton r1,r2;
Choice c1;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
NewCustomer frame = new NewCustomer();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public NewCustomer() throws SQLException {
setBounds(530, 200, 850, 550);
contentPane = new JPanel();
setContentPane(contentPane);
contentPane.setLayout(null);
ImageIcon i1 = new ImageIcon(ClassLoader.getSystemResource("hotel/management/system/icons/fifth.png"));
Image i3 = i1.getImage().getScaledInstance(300, 400,Image.SCALE_DEFAULT);
ImageIcon i2 = new ImageIcon(i3);
JLabel l1 = new JLabel(i2);
l1.setBounds(480,10,300,500);
add(l1);
JLabel lblName = new JLabel("NEW CUSTOMER FORM");
lblName.setFont(new Font("Yu Mincho", Font.PLAIN, 20));
lblName.setBounds(118, 11, 260, 53);
contentPane.add(lblName);
JLabel lblId = new JLabel("ID :");
lblId.setBounds(35, 76, 200, 14);
contentPane.add(lblId);
comboBox = new JComboBox(new String[] {"Passport", "Aadhar Card", "Voter Id", "Driving license"});
comboBox.setBounds(271, 73, 150, 20);
contentPane.add(comboBox);
JLabel l2 = new JLabel("Number :");
l2.setBounds(35, 111, 200, 14);
contentPane.add(l2);
t1 = new JTextField();
t1.setBounds(271, 111, 150, 20);
contentPane.add(t1);
t1.setColumns(10);
JLabel lblName_1 = new JLabel("Name :");
lblName_1.setBounds(35, 151, 200, 14);
contentPane.add(lblName_1);
t2 = new JTextField();
t2.setBounds(271, 151, 150, 20);
contentPane.add(t2);
t2.setColumns(10);
JLabel lblGender = new JLabel("Gender :");
lblGender.setBounds(35, 191, 200, 14);
contentPane.add(lblGender);
r1 = new JRadioButton("Male");
r1.setFont(new Font("Raleway", Font.BOLD, 14));
r1.setBackground(Color.WHITE);
r1.setBounds(271, 191, 80, 12);
add(r1);
r2 = new JRadioButton("Female");
r2.setFont(new Font("Raleway", Font.BOLD, 14));
r2.setBackground(Color.WHITE);
r2.setBounds(350, 191, 100, 12);
add(r2);
JLabel lblCountry = new JLabel("Country :");
lblCountry.setBounds(35, 231, 200, 14);
contentPane.add(lblCountry);
JLabel lblReserveRoomNumber = new JLabel("Allocated Room Number :");
lblReserveRoomNumber.setBounds(35, 274, 200, 14);
contentPane.add(lblReserveRoomNumber);
c1 = new Choice();
try{
conn c = new conn();
ResultSet rs = c.s.executeQuery("select * from room");
while(rs.next()){
c1.add(rs.getString("room"));
}
}catch(Exception e){ }
c1.setBounds(271, 274, 150, 20);
contentPane.add(c1);
JLabel lblCheckInStatus = new JLabel("Checked-In :");
lblCheckInStatus.setBounds(35, 316, 200, 14);
contentPane.add(lblCheckInStatus);
JLabel lblDeposite = new JLabel("Deposit :");
lblDeposite.setBounds(35, 359, 200, 14);
contentPane.add(lblDeposite);
t3 = new JTextField();
t3.setBounds(271, 231, 150, 20);
contentPane.add(t3);
t3.setColumns(10);
t5 = new JTextField();
t5.setBounds(271, 316, 150, 20);
contentPane.add(t5);
t5.setColumns(10);
t6 = new JTextField();
t6.setBounds(271, 359, 150, 20);
contentPane.add(t6);
t6.setColumns(10);
JButton btnNewButton = new JButton("Add");
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
conn c = new conn();
String radio = null;
if(r1.isSelected()){
radio = "Male";
}
else if(r2.isSelected()){
radio = "Female";
}
String s6 = c1.getSelectedItem();
try{
String s1 = (String)comboBox.getSelectedItem();
String s2 = t1.getText();
String s3 = t2.getText();
String s4 = radio;
String s5 = t3.getText();
String s7 = t5.getText();
String s8 = t6.getText();
String q1 = "insert into customer values('"+s1+"','"+s2+"','"+s3+"','"+s4+"','"+s5+"','"+s6+"','"+s7+"','"+s8+"')";
String q2 = "update room set available = 'Occupied' where room = "+s6;
c.s.executeUpdate(q1);
c.s.executeUpdate(q2);
JOptionPane.showMessageDialog(null, "Data Inserted Successfully");
new Reception().setVisible(true);
setVisible(false);
}catch(SQLException e1){
System.out.println(e1.getMessage());
}
catch(NumberFormatException s){
JOptionPane.showMessageDialog(null, "Please enter a valid Number");
}
}
});
btnNewButton.setBounds(100, 430, 120, 30);
btnNewButton.setBackground(Color.BLACK);
btnNewButton.setForeground(Color.WHITE);
contentPane.add(btnNewButton);
JButton btnExit = new JButton("Back");
btnExit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
new Reception().setVisible(true);
setVisible(false);
}
});
btnExit.setBounds(260, 430, 120, 30);
btnExit.setBackground(Color.BLACK);
btnExit.setForeground(Color.WHITE);
contentPane.add(btnExit);
getContentPane().setBackground(Color.WHITE);
}
}