-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRemove_Employee.java
174 lines (145 loc) · 4.88 KB
/
Remove_Employee.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
import java.sql.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class Remove_Employee implements ActionListener{
JFrame f;
JTextField t;
JLabel l1,l2,l3,l4,l5,l6,l7,l8;
JButton b,b1,b2,b3;
Remove_Employee(){
f=new JFrame("Remove Employee");
f.setBackground(Color.black);
f.setLayout(null);
l5=new JLabel();
l5.setBounds(0,0,500,500);
l5.setLayout(null);
ImageIcon img=new ImageIcon(ClassLoader.getSystemResource("Icons/remove.jpg"));
l5.setIcon(img);
f.add(l5);
l1=new JLabel("Employee ID:");
l1.setBounds(50,50,250,30);
l1.setForeground(Color.black);
Font f2 = new Font("Comic Sans MS",Font.BOLD,20);
l1.setFont(f2);
l5.add(l1);
t=new JTextField();
t.setBounds(250,50,150,30);
l5.add(t);
b=new JButton("Search");
b.setBounds(200,100,100,30);
b.addActionListener(this);
l5.add(b);
b3=new JButton("Back");
b3.setBounds(360,100,100,30);
b3.addActionListener(this);
l5.add(b3);
l2=new JLabel("Name:");
l2.setBounds(50,150,250,30);
l2.setForeground(Color.black);
Font f3 = new Font("Comic Sans MS",Font.BOLD,20);
l2.setFont(f3);
l5.add(l2);
l6=new JLabel();
l6.setBounds(200,150,350,30);
l6.setForeground(Color.black);
Font F6=new Font("Comic Sans MS",Font.BOLD,20);
l6.setFont(F6);
l5.add(l6);
l3=new JLabel("Phone:");
l3.setBounds(50,200,250,30);
l3.setForeground(Color.black);
Font f4 = new Font("Comic Sans MS",Font.BOLD,20);
l3.setFont(f4);
l5.add(l3);
l7=new JLabel();
l7.setBounds(200,200,350,30);
l7.setForeground(Color.black);
Font F7=new Font("Comic Sans MS",Font.BOLD,20);
l7.setFont(F7);
l5.add(l7);
l4=new JLabel("Email Id:");
l4.setBounds(50,250,250,30);
l4.setForeground(Color.black);
Font F5=new Font("Comic Sans MS",Font.BOLD,20);
l4.setFont(F5);
l5.add(l4);
l8=new JLabel();
l8.setBounds(200,250,350,30);
l8.setForeground(Color.black);
Font f8=new Font("Comic Sans MS",Font.BOLD,20);
l8.setFont(f8);
l5.add(l8);
b1=new JButton("Remove");
b1.setBounds(120,300,100,30);
b1.addActionListener(this);
l5.add(b1);
b2=new JButton("Cancel");
b2.setBounds(300,300,100,30);
b2.addActionListener(this);
l5.add(b2);
l2.setVisible(false);
l3.setVisible(false);
l4.setVisible(false);
b1.setVisible(false);
b2.setVisible(false);
f.setSize(500,500);
f.setLocation(500,250);
f.setVisible(true);
}
public void actionPerformed(ActionEvent ae){
if(ae.getSource()==b){
try{
conn con = new conn();
String str = "select name,phone,email from employee where emp_id ='"+t.getText()+"' ";
ResultSet rs = con.s.executeQuery(str);
int i=0;
if(rs.next()){
String name = rs.getString(1);
String mob = rs.getString(2);
String email=rs.getString(3);
l2.setVisible(true);
l3.setVisible(true);
l4.setVisible(true);
b1.setVisible(true);
b2.setVisible(true);
i=1;
l6.setText(name);
l7.setText(mob);
l8.setText(email);
}
if(i==0)
JOptionPane.showMessageDialog(null,"Id not found");
}catch(Exception ex){}
}
if(ae.getSource()==b1){
try{
conn con = new conn();
String str = "delete from employee where emp_id = '"+t.getText()+"'";
con.s.executeUpdate(str);
JOptionPane.showMessageDialog(null,"deleted successfully");
l2.setVisible(false);
l3.setVisible(false);
l4.setVisible(false);
l6.setVisible(false);
l7.setVisible(false);
l8.setVisible(false);
b1.setVisible(false);
b2.setVisible(false);
}catch(Exception ex){
JOptionPane.showMessageDialog(null,"Exception occured while delting record "+ex);
}
}
if(ae.getSource()==b2){
f.setVisible(false);
details d=new details();
}
if(ae.getSource()==b3){
f.setVisible(false);
details d=new details();
}
}
public static void main(String[]ar){
new Remove_Employee();
}
}