-
Notifications
You must be signed in to change notification settings - Fork 2
/
AddEmployee.java
175 lines (127 loc) · 5.11 KB
/
AddEmployee.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
package canteen.management.system;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class AddEmployee extends JFrame implements ActionListener{
JTextField t1,t2,t3,t4,t5,t6;
JRadioButton r1,r2;
JComboBox c1;
JButton b1;
AddEmployee(){
super("CONTACLESS COMPUTERIZED CANTEEN MANAGEMENT SYSTEM");
JLabel name = new JLabel("NAME");
name.setFont(new Font("Tahoma",Font.PLAIN,17));
name.setBounds(60,30,120,30);
add(name);
t1= new JTextField();
t1.setBounds(200,30,150,30);
add(t1);
JLabel age = new JLabel("AGE");
age.setFont(new Font("Tahoma",Font.PLAIN,17));
age.setBounds(60,80,120,30);
add(age);
t2= new JTextField();
t2.setBounds(200,80,150,30);
add(t2);
JLabel gender = new JLabel("GENDER");
gender.setFont(new Font("Tahoma",Font.PLAIN,17));
gender.setBounds(60,130,120,30);
add(gender);
r1 = new JRadioButton("Male");
r1.setFont(new Font("Tahoma",Font.PLAIN,14));
r1.setBackground(Color.WHITE);
r1.setBounds(200, 130, 70, 30);
add(r1);
r2 = new JRadioButton("Female");
r2.setFont(new Font("Tahoma",Font.PLAIN,14));
r2.setBackground(Color.WHITE);
r2.setBounds(280, 130, 70, 30);
add(r2);
JLabel job = new JLabel("JOB");
job.setFont(new Font("Tahoma",Font.PLAIN,17));
job.setBounds(60,180,120,30);
add(job);
String str[] = {"Front Desk Clerks","Cleaning","Kitchen Staff","Waiter/Waitress","Manager","Accountant","Chef"};
c1 = new JComboBox(str);
c1.setBackground(Color.WHITE);
c1.setBounds(200,180,150,30);
add(c1);
JLabel salary = new JLabel("SALARY");
salary.setFont(new Font("Tahoma",Font.PLAIN,17));
salary.setBounds(60,230,120,30);
add(salary);
t3= new JTextField();
t3.setBounds(200,230,150,30);
add(t3);
JLabel phone = new JLabel("PHONE");
phone.setFont(new Font("Tahoma",Font.PLAIN,17));
phone.setBounds(60,280,120,30);
add(phone);
t4= new JTextField();
t4.setBounds(200,280,150,30);
add(t4);
JLabel aadhar = new JLabel("AADHAR");
aadhar.setFont(new Font("Tahoma",Font.PLAIN,17));
aadhar.setBounds(60,330,120,30);
add(aadhar);
t5= new JTextField();
t5.setBounds(200,330,150,30);
add(t5);
JLabel email = new JLabel("EMAIL");
email.setFont(new Font("Tahoma",Font.PLAIN,17));
email.setBounds(60,380,120,30);
add(email);
t6= new JTextField();
t6.setBounds(200,380,150,30);
add(t6);
b1 = new JButton("Submit");
b1.setBounds(200, 420, 150, 30);
b1.setBackground(Color.BLACK);
b1.setForeground(Color.WHITE);
b1.addActionListener(this);
add(b1);
ImageIcon i1 = new ImageIcon(ClassLoader.getSystemResource("canteen/management/system/icons/food-picky-logo.PNG"));
Image i2 = i1.getImage().getScaledInstance(200, 50,Image.SCALE_DEFAULT);
ImageIcon i3 = new ImageIcon(i2);
JLabel l1 = new JLabel(i3);
l1.setBounds(360,60,450,450);
add(l1);
JLabel l2 = new JLabel("ADD EMPLOYEE DETAILS");
l2.setForeground(Color.BLUE);
l2.setBounds(410, 30,400 ,30 );
l2.setFont(new Font("Tahoma",Font.PLAIN,30));
add(l2);
getContentPane().setBackground(Color.WHITE);
setLayout(null);
setBounds(400,200,850,530);
setVisible(true);
}
public void actionPerformed(ActionEvent ae){
String name = t1.getText();
String age = t2.getText();
String salary = t3.getText();
String phone = t4.getText();
String aadhar= t5.getText();
String email= t6.getText();
String gender = null;
if(r1.isSelected()){
gender = "Male";
}else if(r2.isSelected()){
gender = "Female";
}
String job = (String)c1.getSelectedItem();
conn c = new conn();
String str = "insert into employee values('"+name+"', '"+age+"', '"+gender+"','"+job+"', '"+salary+"', '"+phone+"','"+aadhar+"', '"+email+"')";
try
{
c.s.executeUpdate(str);
JOptionPane.showMessageDialog(null,"New Employee Added");
this.setVisible(false);
}catch(Exception e){
System.out.println(e);
}
}
public static void main(String[] args){
new AddEmployee().setVisible(true);
}
}