-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAdd_Employee.java
More file actions
190 lines (149 loc) · 5.28 KB
/
Add_Employee.java
File metadata and controls
190 lines (149 loc) · 5.28 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
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
import java.sql.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
class Add_Employee implements ActionListener{
JFrame f;
JLabel id,id1,id2,id3,id4,id5,id6,id7,id8,id9,id10,id11,id12,id15,id16,id17,lab,lab1;
JTextField t,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13;
JButton b,b1,b2,b3;
Add_Employee(int i){}
Add_Employee(){
f = new JFrame("Add Employee");
f.setBackground(Color.white);
f.setLayout(null);
id15=new JLabel();
id15.setBounds(0,0,900,700);
id15.setLayout(null);
ImageIcon img = new ImageIcon(ClassLoader.getSystemResource("Icons/add_employee.jpg"));
id15.setIcon(img);
id8 = new JLabel("NEW EMPLOYEE DETAILS");
id8.setBounds(320,30,500,50);
id8.setFont(new Font("Comic Sans MS",Font.BOLD,25));
id8.setForeground(Color.black);
id15.add(id8);
f.add(id15);
id1 = new JLabel("Name");
id1.setBounds(50,150,100,30);
id1.setFont(new Font("Comic Sans MS",Font.BOLD,20));
id15.add(id1);
t1=new JTextField();
t1.setBounds(200,150,150,30);
id15.add(t1);
id2 = new JLabel("Father's Name");
id2.setBounds(400,150,200,30);
id2.setFont(new Font("Comic Sans MS",Font.BOLD,20));
id15.add(id2);
t2=new JTextField();
t2.setBounds(600,150,150,30);
id15.add(t2);
id3= new JLabel("Age");
id3.setBounds(50,200,100,30);
id3.setFont(new Font("Comic Sans MS",Font.BOLD,20));
id15.add(id3);
t3=new JTextField();
t3.setBounds(200,200,150,30);
id15.add(t3);
id4= new JLabel("Date Of Birth");
id4.setBounds(400,200,200,30);
id4.setFont(new Font("Comic Sans MS",Font.BOLD,20));
id15.add(id4);
t4=new JTextField();
t4.setBounds(600,200,150,30);
id15.add(t4);
id5= new JLabel("Address");
id5.setBounds(50,250,100,30);
id5.setFont(new Font("Comic Sans MS",Font.BOLD,20));
id15.add(id5);
t5=new JTextField();
t5.setBounds(200,250,150,30);
id15.add(t5);
id6= new JLabel("Phone N");
id6.setBounds(400,250,100,30);
id6.setFont(new Font("Comic Sans MS",Font.BOLD,20));
id15.add(id6);
t6=new JTextField();
t6.setBounds(600,250,150,30);
id15.add(t6);
id7= new JLabel("Email Id");
id7.setBounds(50,300,100,30);
id7.setFont(new Font("Comic Sans MS",Font.BOLD,20));
id15.add(id7);
t7=new JTextField();
t7.setBounds(200,300,150,30);
id15.add(t7);
id9= new JLabel("Education");
id9.setBounds(400,300,100,30);
id9.setFont(new Font("Comic Sans MS",Font.BOLD,20));
id15.add(id9);
t8=new JTextField();
t8.setBounds(600,300,150,30);
id15.add(t8);
id10= new JLabel("Job Post");
id10.setBounds(50,350,100,30);
id10.setFont(new Font("Comic Sans MS",Font.BOLD,20));
id15.add(id10);
t9=new JTextField();
t9.setBounds(200,350,150,30);
id15.add(t9);
id11= new JLabel("Emp_ID");
id11.setBounds(400,350,100,30);
id11.setFont(new Font("Comic Sans MS",Font.BOLD,20));
id15.add(id11);
t10=new JTextField();
t10.setBounds(600,350,150,30);
id15.add(t10);
lab=new JLabel();
lab.setBounds(200,450,250,200);
id15.add(lab);
lab1=new JLabel("");
lab1.setBounds(600,450,250,200);
id15.add(lab1);
b = new JButton("Submit");
b.setBackground(Color.BLACK);
b.setForeground(Color.WHITE);
b.setBounds(250,550,150,40);
id15.add(b);
b1=new JButton("Cancel");
b1.setBackground(Color.BLACK);
b1.setForeground(Color.WHITE);
b1.setBounds(450,550,150,40);
id15.add(b1);
b.addActionListener(this);
b1.addActionListener(this);
f.setVisible(true);
f.setSize(900,700);
f.setLocation(400,150);
}
public void actionPerformed(ActionEvent ae){
String name = t1.getText();
String fname = t2.getText();
String age= t3.getText();
String dob = t4.getText();
String address = t5.getText();
String phone = t6.getText();
String email = t7.getText();
String education = t8.getText();
String post = t9.getText();
String emp_id = t10.getText();
if(ae.getSource() == b){
try{
conn cc = new conn();
String q = "insert into employee values('"+name+"','"+fname+"','"+age+"','"+dob+"','"+address+"','"+phone+"','"+email+"','"+education+"','"+post+"','"+emp_id+"')";
cc.s.executeUpdate(q);
JOptionPane.showMessageDialog(null,"Details Successfully Inserted");
f.setVisible(false);
new details();
}catch(Exception ee){
System.out.println("The error is:"+ee);
}
}else if(ae.getSource() == b1){
f.setVisible(false);
new details();
}
}
public static void main(String[ ] arg){
new Add_Employee();
}
}