-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAddCustomer.java
195 lines (162 loc) · 5.37 KB
/
AddCustomer.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
package hotel.management.system;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.ResultSet;
import java.util.Stack;
public class AddCustomer extends JFrame implements ActionListener
{
JTextField t1,t2,t3,t4,t5;
JButton b1,b2;
JComboBox c1; //In Swing package
Choice c2; //In Choice package
JRadioButton r1,r2;
AddCustomer()
{
JLabel l1 = new JLabel("NEW CUSTOMER FORM");
l1.setBounds(100,20,300,30);
l1.setFont(new Font("Tahoma", Font.PLAIN,20));
l1.setForeground(Color.BLUE);
add(l1);
JLabel l2=new JLabel("ID");
l2.setBounds(35,80,100,20);
add(l2);
String str[]={"Passport","Voter ID Card","Driving Licence","Aadhar Card"};
c1=new JComboBox(str);
c1.setBounds(200,80,150,25);
c1.setBackground(Color.WHITE);
add(c1);
JLabel l3=new JLabel("Number");
l3.setBounds(35,120,100,20);
add(l3);
t1 = new JTextField();
t1.setBounds(200,120,150,25);
add(t1);
JLabel l4=new JLabel("Name");
l4.setBounds(35,160,100,20);
add(l4);
t2 = new JTextField();
t2.setBounds(200,160,150,25);
add(t2);
JLabel l5=new JLabel("Gender");
l5.setBounds(35,200,100,20);
add(l5);
r1=new JRadioButton("Male");
r1.setBounds(200,200,60,25);
r1.setBackground(Color.WHITE);
add(r1);
r2=new JRadioButton("Female");
r2.setBounds(270,200,80,25);
r2.setBackground(Color.WHITE);
add(r2);
JLabel l6=new JLabel("Country");
l6.setBounds(35,240,100,20);
add(l6);
t3 = new JTextField();
t3.setBounds(200,240,150,25);
add(t3);
JLabel l7=new JLabel("Allocated Room Number");
l7.setBounds(35,280,150,20);
add(l7);
c2=new Choice();
try
{
conn c=new conn();
String s = "select * from room";
ResultSet rs=c.s.executeQuery(s);
while (rs.next())
{
c2.add(rs.getString("room_number"));
}
}
catch (Exception e)
{
System.out.println(e);
}
c2.setBounds(200,280,188,25);
add(c2);
JLabel l8=new JLabel("Checked In");
l8.setBounds(35,320,200,20);
add(l8);
t4 = new JTextField();
t4.setBounds(200,320,150,25);
add(t4);
JLabel l9=new JLabel("Deposit");
l9.setBounds(35,360,200,20);
add(l9);
t5 = new JTextField();
t5.setBounds(200,360,150,25);
add(t5);
b1=new JButton("Add Customer");
b1.setBounds(60,420,120,25);
b1.setForeground(Color.WHITE);
b1.setBackground(Color.BLACK);
b1.addActionListener(this);
add(b1);
b2=new JButton("Back");
b2.setBounds(220,420,120,25);
b2.setForeground(Color.WHITE);
b2.setBackground(Color.BLACK);
b2.addActionListener(this);
add(b2);
ImageIcon i1=new ImageIcon(ClassLoader.getSystemResource("hotel/management/system/icons/fifth.png"));
Image i2= i1.getImage().getScaledInstance(400,500,Image.SCALE_DEFAULT);
ImageIcon i3= new ImageIcon(i2);
JLabel icon= new JLabel(i3);
icon.setBounds(300,0,500,500);
add(icon);
getContentPane().setBackground(Color.WHITE);
setLayout(null);
setBounds(420,200,750,500);
setVisible(true);
}
@Override
public void actionPerformed(ActionEvent ae)
{
if (ae.getSource()==b1)
{
String id=(String) c1.getSelectedItem();
String number = t1.getText();
String name = t2.getText();
String gender = null;
if(r1.isSelected())
{
gender="Male";
}
else if(r2.isSelected())
{
gender="Female";
}
String country = t3.getText();
String room_number = c2.getSelectedItem();
String status = t4.getText();
String deposit = t5.getText();
String str1 = "insert into customer values ('"+id+"','"+number+"','"+name+"','"+gender+"','"+country+"','"+room_number+"','"+status+"','"+deposit+"') ";
String str2 = "update room set available = 'Occupied' where room_number = '"+room_number+"'";
try {
{
conn c=new conn();
c.s.executeUpdate(str1);
JOptionPane.showMessageDialog(null,"New Customer Added");
c.s.executeUpdate(str2);
new Reception().setVisible(true);
this.setVisible(false);
}
}
catch (Exception e)
{
System.out.println(e);
}
}
else if(ae.getSource()==b2)
{
new Reception().setVisible(true);
this.setVisible(false);
}
}
public static void main(String[] args)
{
new AddCustomer().setVisible(true);
}
}