-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUpdate_Employee.java
More file actions
180 lines (147 loc) · 5.29 KB
/
Update_Employee.java
File metadata and controls
180 lines (147 loc) · 5.29 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
import java.awt.*;
import java.sql.*;
import javax.swing.*;
import java.awt.event.*;
class Update_Employee extends Add_Employee implements ActionListener{
JFrame f;
JLabel id,id1,id2,id3,id4,id5,id6,id7,id8,id9,id10,id11,id12,id15,lab,lab1;
JTextField t,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11;
JButton b,b1,b2,b3;
String id_emp;
Update_Employee(String idaa){
super(0);
f=new JFrame("Update Employee details");
f.setVisible(true);
f.setSize(900,500);
f.setLocation(450,250);
f.setBackground(Color.white);
f.setLayout(null);
id_emp=idaa;
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("UPDATE EMPLOYEE DETAILS");
id8.setBounds(320,30,500,50);
id8.setFont(new Font("Comic Sans MS",Font.ITALIC,25));
id8.setForeground(Color.black);
id15.add(id8);
f.add(id15);
id1 = new JLabel("Name:");
id1.setBounds(50,100,100,30);
id1.setFont(new Font("Comic Sans MS",Font.BOLD,20));
id15.add(id1);
t1=new JTextField();
t1.setBounds(200,100,150,30);
id15.add(t1);
id2 = new JLabel("Father's Name:");
id2.setBounds(400,100,200,30);
id2.setFont(new Font("Comic Sans MS",Font.BOLD,20));
id15.add(id2);
t2=new JTextField();
t2.setBounds(600,100,150,30);
id15.add(t2);
id3= new JLabel("Address:");
id3.setBounds(50,150,100,30);
id3.setFont(new Font("Comic Sans MS",Font.BOLD,20));
id15.add(id3);
t3=new JTextField();
t3.setBounds(200,150,150,30);
id15.add(t3);
id4= new JLabel("Phone N:");
id4.setBounds(400,150,100,30);
id4.setFont(new Font("Comic Sans MS",Font.BOLD,20));
id15.add(id4);
t4=new JTextField();
t4.setBounds(600,150,150,30);
id15.add(t4);
id5= new JLabel("Email Id:");
id5.setBounds(50,200,100,30);
id5.setFont(new Font("Comic Sans MS",Font.BOLD,20));
id15.add(id5);
t5=new JTextField();
t5.setBounds(200,200,150,30);
id15.add(t5);
id6= new JLabel("Education:");
id6.setBounds(400,200,100,30);
id6.setFont(new Font("Comic Sans MS",Font.BOLD,20));
id15.add(id6);
t6=new JTextField();
t6.setBounds(600,200,150,30);
id15.add(t6);
id7= new JLabel("Job Post:");
id7.setBounds(50,250,100,30);
id7.setFont(new Font("Comic Sans MS",Font.BOLD,20));
id15.add(id7);
t7=new JTextField();
t7.setBounds(200,250,150,30);
id15.add(t7);
id9= new JLabel("Emp_ID:");
id9.setBounds(400,250,100,30);
id9.setFont(new Font("Comic Sans MS",Font.BOLD,20));
id15.add(id9);
t8=new JTextField();
t8.setBounds(600,250,150,30);
id15.add(t8);
b=new JButton("Update");
b.setBounds(250,400,100,30);
b.addActionListener(this);
id15.add(b);
b1=new JButton("Cancel");
b1.setBounds(450,400,100,30);
b1.addActionListener(this);
id15.add(b1);
showData(idaa);
}
int i=0;
String age,dat;
void showData(String s){
try{
conn con = new conn();
String str = "select * from employee where emp_id = '"+s+"'";
ResultSet rs = con.s.executeQuery(str);
if(rs.next()){
f.setVisible(true);
i=1;
t1.setText(rs.getString(1));
t2.setText(rs.getString(2));
t3.setText(rs.getString(5));
t4.setText(rs.getString(6));
t5.setText(rs.getString(7));
t6.setText(rs.getString(8));
t7.setText(rs.getString(9));
t8.setText(rs.getString(10));
age=rs.getString(3);
dat=rs.getString(4);
}
if(i==0)
JOptionPane.showMessageDialog(null,"Id not found");
new Search_Employee();
}catch(Exception ex){}
f.setVisible(true);
f.setSize(900,500);
f.setLocation(400,100);
}
public void actionPerformed(ActionEvent ae){
if(ae.getSource()==b && i==1){
try{
conn con = new conn();
String str = "update employee set name='"+t1.getText()+"',fname='"+t2.getText()+"',age='"+age+"',dob='"+dat+"',address='"+t3.getText()+"',phone='"+t4.getText()+"',email='"+t5.getText()+"',education='"+t6.getText()+"',post='"+t7.getText()+"',emp_id='"+t8.getText()+"' where emp_id='"+id_emp+"'";
con.s.executeUpdate(str);
JOptionPane.showMessageDialog(null,"successfully updated");
f.setVisible(false);
new Search_Employee();
}catch(Exception e){
System.out.println("The error is:"+e);
}
}
if(ae.getSource()==b1){
f.setVisible(false);
details d=new details();
}
}
public static void main(String[] arg){
new Update_Employee("Update Employee");
}
}