-
Notifications
You must be signed in to change notification settings - Fork 0
/
AddDrivers.java
179 lines (133 loc) · 5.12 KB
/
AddDrivers.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
/*
* 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 AddDrivers extends JFrame implements ActionListener{
JPanel contentPane;
JTextField t1,t2,t3,t4, t5;
JComboBox comboBox, comboBox_1;
JButton b1,b2;
Choice c1;
public static void main(String[] args) {
new AddDrivers().setVisible(true);
}
public AddDrivers() {
setBounds(450, 200, 1000, 500);
contentPane = new JPanel();
setContentPane(contentPane);
contentPane.setLayout(null);
ImageIcon i1 = new ImageIcon(ClassLoader.getSystemResource("hotel/management/system/icons/eleven.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 Drivers");
l10.setFont(new Font("Tahoma", Font.BOLD, 18));
l10.setBounds(194, 10, 120, 22);
contentPane.add(l10);
JLabel l1 = new JLabel("Name");
l1.setForeground(new Color(25, 25, 112));
l1.setFont(new Font("Tahoma", Font.BOLD, 14));
l1.setBounds(64, 70, 102, 22);
contentPane.add(l1);
t1 = new JTextField();
t1.setBounds(174, 70, 156, 20);
contentPane.add(t1);
JLabel l2 = new JLabel("Age");
l2.setForeground(new Color(25, 25, 112));
l2.setFont(new Font("Tahoma", Font.BOLD, 14));
l2.setBounds(64, 110, 102, 22);
contentPane.add(l2);
t2 = new JTextField();
t2.setBounds(174, 110, 156, 20);
contentPane.add(t2);
JLabel l3 = new JLabel("Gender");
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 = new JComboBox(new String[] { "Male", "Female" });
comboBox.setBounds(176, 150, 154, 20);
contentPane.add(comboBox);
JLabel l4 = new JLabel("Car Company");
l4.setForeground(new Color(25, 25, 112));
l4.setFont(new Font("Tahoma", Font.BOLD, 14));
l4.setBounds(64, 190, 102, 22);
contentPane.add(l4);
t3 = new JTextField();
t3.setBounds(174, 190, 156, 20);
contentPane.add(t3);
JLabel l5 = new JLabel("Car Brand");
l5.setForeground(new Color(25, 25, 112));
l5.setFont(new Font("Tahoma", Font.BOLD, 14));
l5.setBounds(64, 230, 102, 22);
contentPane.add(l5);
t4 = new JTextField();
t4.setBounds(174, 230, 156, 20);
contentPane.add(t4);
JLabel l6 = new JLabel("Available");
l6.setForeground(new Color(25, 25, 112));
l6.setFont(new Font("Tahoma", Font.BOLD, 14));
l6.setBounds(64, 270, 102, 22);
contentPane.add(l6);
comboBox_1 = new JComboBox(new String[] { "Yes", "No" });
comboBox_1.setBounds(176, 270, 154, 20);
contentPane.add(comboBox_1);
JLabel l7 = new JLabel("Location");
l7.setForeground(new Color(25, 25, 112));
l7.setFont(new Font("Tahoma", Font.BOLD, 14));
l7.setBounds(64, 310, 102, 22);
contentPane.add(l7);
t5 = new JTextField();
t5.setBounds(174, 310, 156, 20);
contentPane.add(t5);
b1 = new JButton("Add");
b1.addActionListener(this);
b1.setBounds(64, 380, 111, 33);
b1.setBackground(Color.BLACK);
b1.setForeground(Color.WHITE);
contentPane.add(b1);
b2 = new JButton("Back");
b2.addActionListener(this);
b2.setBounds(198, 380, 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 name = t1.getText();
String age = t2.getText();
String gender = (String)comboBox.getSelectedItem();
String company = t3.getText();
String brand = t4.getText();
String available = (String)comboBox_1.getSelectedItem();
String location = t5.getText();
String str = "INSERT INTO driver values( '"+name+"', '"+age+"', '"+gender+"','"+company+"', '"+brand+"', '"+available+"','"+location+"')";
c.s.executeUpdate(str);
JOptionPane.showMessageDialog(null, "Driver Successfully Added");
this.setVisible(false);
}catch(Exception ee){
System.out.println(ee);
}
}
else if(ae.getSource() == b2){
this.setVisible(false);
}
}catch(Exception eee){
}
}
}