-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFcultyUpdateId.java
More file actions
291 lines (255 loc) · 8.66 KB
/
FcultyUpdateId.java
File metadata and controls
291 lines (255 loc) · 8.66 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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
package Update;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.swing.ButtonGroup;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
import form.MyConnection;
public class FcultyUpdateId extends JDialog implements ActionListener
{
private JTextField tid;
private JTextField tname;
private JTextField tsalary;
private JTextField tAdhar;
private JButton tsubmit;
private JButton tcancel;
private ButtonGroup bg= new ButtonGroup();
private JRadioButton m;
private JRadioButton f;
private JComboBox tcity;
int id;
private JTextField tDepartment;
private JTextField tEmail;
private JTextField tFname;
private JTextField tMobile;
private JTextField Designation;
private JComboBox Salutation;
public FcultyUpdateId(int id)
{
this.id=id;
setTitle("LoginScreen.........");
getContentPane().setLayout(null);
JLabel mnId = new JLabel(" I D");
mnId.setFont(new Font("Times New Roman", Font.BOLD, 14));
mnId.setBounds(10, 11, 51, 17);
getContentPane().add(mnId);
JLabel mnname = new JLabel("Name");
mnname.setFont(new Font("Times New Roman", Font.BOLD, 14));
mnname.setBounds(25, 51, 51, 17);
getContentPane().add(mnname);
JLabel mnsalary = new JLabel("Salary");
mnsalary.setFont(new Font("Times New Roman", Font.BOLD, 14));
mnsalary.setBounds(25, 467, 51, 17);
getContentPane().add(mnsalary);
JLabel Adhar = new JLabel("Adhar_No");
Adhar.setFont(new Font("Times New Roman", Font.BOLD, 14));
Adhar.setBounds(25, 527, 70, 17);
getContentPane().add(Adhar);
JLabel tgender = new JLabel("Gender");
tgender.setFont(new Font("Times New Roman", Font.BOLD, 14));
tgender.setBounds(25, 99, 51, 17);
getContentPane().add(tgender);
JLabel mncity = new JLabel("City");
mncity.setFont(new Font("Times New Roman", Font.BOLD, 14));
mncity.setBounds(25, 145, 51, 17);
getContentPane().add(mncity);
tid = new JTextField(String.valueOf(id));
tid.setBackground(Color.WHITE);
tid.setEditable(false);
tid.setBounds(129, 10, 228, 20);
getContentPane().add(tid);
tid.setColumns(10);
tname = new JTextField();
tname.setBackground(Color.WHITE);
tname.setEditable(false);
tname.setColumns(10);
tname.setBounds(178, 50, 179, 20);
getContentPane().add(tname);
tsalary = new JTextField();
tsalary.setBackground(Color.WHITE);
tsalary.setForeground(Color.BLACK);
tsalary.setEditable(false);
tsalary.setColumns(10);
tsalary.setBounds(129, 466, 228, 20);
getContentPane().add(tsalary);
tAdhar = new JTextField();
tAdhar.setColumns(10);
tAdhar.setBounds(129, 526, 228, 20);
getContentPane().add(tAdhar);
m = new JRadioButton("MALE");
m.setBackground(Color.WHITE);
m.setEnabled(false);
m.setMnemonic('m');
m.setFont(new Font("Times New Roman", Font.BOLD, 14));
m.setForeground(Color.BLACK);
m.setBounds(129, 96, 82, 23);
getContentPane().add(m);
m.addActionListener(this);
f = new JRadioButton("FEMALE");
f.setBackground(Color.WHITE);
f.setForeground(Color.BLACK);
f.setEnabled(false);
f.setMnemonic('f');
f.setFont(new Font("Times New Roman", Font.BOLD, 14));
f.setBounds(239, 96, 109, 23);
getContentPane().add(f);
f.addActionListener(this);
bg.add(m);
bg.add(f);
tcity = new JComboBox();
tcity.setFont(new Font("Times New Roman", Font.BOLD, 13));
tcity.setModel(new DefaultComboBoxModel(new String[] {"SELECT CITY", "LUCKNOW", "DELHI", "MUMBAI", "BANGLORE", "NOIDA", "VELLORE", "KANPUR", "UNNAO", "RAIBAREILY", "BHOPAL", "INDORE", "GWALIOR"}));
tcity.setBounds(129, 144, 228, 20);
getContentPane().add(tcity);
tsubmit = new JButton("Submit");
tsubmit.setMnemonic('s');
tsubmit.setBounds(47, 587, 89, 23);
getContentPane().add(tsubmit);
tcancel = new JButton("Cancel");
tcancel.setMnemonic('c');
tcancel.setBounds(222, 587, 89, 23);
getContentPane().add(tcancel);
tsubmit.addActionListener(this);
tcancel.addActionListener(this);
setSize(500,700);
setLocationRelativeTo(null);
getRootPane().setDefaultButton(tsubmit);
JLabel lblDepartment = new JLabel("Department");
lblDepartment.setFont(new Font("Times New Roman", Font.BOLD, 14));
lblDepartment.setBounds(25, 199, 82, 17);
getContentPane().add(lblDepartment);
tDepartment = new JTextField();
tDepartment.setForeground(Color.BLACK);
tDepartment.setEditable(false);
tDepartment.setColumns(10);
tDepartment.setBackground(Color.WHITE);
tDepartment.setBounds(129, 198, 228, 20);
getContentPane().add(tDepartment);
JLabel lblDepartment_1 = new JLabel("Mobile");
lblDepartment_1.setFont(new Font("Times New Roman", Font.BOLD, 14));
lblDepartment_1.setBounds(25, 301, 82, 17);
getContentPane().add(lblDepartment_1);
tMobile = new JTextField();
tMobile.setColumns(10);
tMobile.setBackground(Color.WHITE);
tMobile.setBounds(129, 300, 228, 20);
getContentPane().add(tMobile);
JLabel lblEmail = new JLabel("E-Mail");
lblEmail.setFont(new Font("Times New Roman", Font.BOLD, 14));
lblEmail.setBounds(25, 359, 82, 17);
getContentPane().add(lblEmail);
tEmail = new JTextField();
tEmail.setColumns(10);
tEmail.setBackground(Color.WHITE);
tEmail.setBounds(129, 358, 228, 20);
getContentPane().add(tEmail);
JLabel lblEmail_1 = new JLabel("FName");
lblEmail_1.setFont(new Font("Times New Roman", Font.BOLD, 14));
lblEmail_1.setBounds(25, 411, 82, 17);
getContentPane().add(lblEmail_1);
tFname = new JTextField();
tFname.setEditable(false);
tFname.setColumns(10);
tFname.setBackground(Color.WHITE);
tFname.setBounds(129, 410, 228, 20);
getContentPane().add(tFname);
Salutation = new JComboBox();
Salutation.setModel(new DefaultComboBoxModel(new String[] {"Prof.", "Dr.", "Mr."}));
Salutation.setFont(new Font("Times New Roman", Font.BOLD, 12));
Salutation.setBounds(129, 50, 51, 20);
getContentPane().add(Salutation);
JLabel lblDesignation = new JLabel("Designation");
lblDesignation.setFont(new Font("Times New Roman", Font.BOLD, 14));
lblDesignation.setBounds(25, 250, 82, 17);
getContentPane().add(lblDesignation);
Designation = new JTextField();
Designation.setEditable(false);
Designation.setColumns(10);
Designation.setBackground(Color.WHITE);
Designation.setBounds(129, 249, 228, 20);
getContentPane().add(Designation);
getInfo();
setLocationRelativeTo(null);
setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e)
{
Object ob = e.getSource();
if(ob==tcancel)
{
dispose();
}
if(ob==tsubmit)
{
String city= tcity.getSelectedItem().toString();
String Adhar= tAdhar.getText();
String Mob=tMobile.getText();
String s= "update facultydetail set City=?, Adhar_No=?, Mobile=? where FID=?";
Connection con = MyConnection.connect1();
try
{
PreparedStatement ps= con.prepareStatement(s);
ps.setString(1,city);
ps.setString(3, Adhar);
ps.setString(5, Mob);
ps.setInt(6, id);
ps.executeUpdate();
JOptionPane.showMessageDialog(null, "Updated");
dispose();
}
catch(SQLException se)
{
se.printStackTrace();
}
}
}
void getInfo()
{
String s= "select * from facultydetail where FID=?";
Connection con= MyConnection.connect1();
try
{
PreparedStatement ps= con.prepareStatement(s);
ps.setInt(1, id);
ResultSet rs= ps.executeQuery();
while(rs.next())
{
Salutation.setSelectedItem(rs.getString("Salutation"));
tname.setText(rs.getString("Name"));
if(rs.getString("Gender").equals("Male")||rs.getString("Gender").equals("M"))
{
m.setSelected(true);
}
else
{
f.setSelected(true);
}
tcity.setSelectedItem(rs.getString("City"));
tDepartment.setText(rs.getString("Department"));
Designation.setText(rs.getString("Designation"));
tMobile.setText(rs.getString("Mobile"));
tEmail.setText(rs.getString("Email"));
tFname.setText(rs.getString("FName"));
tsalary.setText(String.valueOf(rs.getInt("Salary")));
tAdhar.setText(rs.getString("Adhar_No"));
}
}
catch(SQLException se)
{
se.printStackTrace();
}
}
}