-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFrameSenroll.java
498 lines (417 loc) · 15 KB
/
FrameSenroll.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
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
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import java.awt.Color;
import java.awt.Font;
import javax.swing.ImageIcon;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.JTextField;
import javax.swing.border.LineBorder;
import javax.swing.border.EtchedBorder;
import javax.swing.JScrollBar;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import javax.swing.JPasswordField;
import javax.swing.SwingConstants;
import javax.swing.JList;
import javax.swing.AbstractListModel;
import javax.swing.ListSelectionModel;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.DefaultComboBoxModel;
public class FrameSenroll extends JFrame{
private JPanel contentPane;
public static JLabel lblid;
static String a=null;
private JTextField course_id;
private JTextField course_title;
private JTextField pre_req;
private JTextField pre_tit;
private JTextField pre_id;
private JTextField ins_name;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
FrameSenroll frame = new FrameSenroll();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public FrameSenroll() {
String[] a=new String[120];
a[0]="null";
try {
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/lms","root","root");
String query="Select course_id from course";
Statement st=con.createStatement();
ResultSet rs=st.executeQuery(query);
int c=1;
while(rs.next()) {
a[c]=rs.getString("course_id");
c++;
}
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(-6,0, 1350, 1200);
contentPane = new JPanel();
contentPane.setLocation(-46, -318);
contentPane.setBackground(Color.WHITE);
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
JLabel lblNewLabel = new JLabel("");
lblNewLabel.setIcon(new ImageIcon("C:\\Users\\mhdha\\Downloads\\allfiles\\logo.png"));
lblNewLabel.setBackground(Color.BLACK);
lblNewLabel.setBounds(32, 3, 205, 195);
contentPane.add(lblNewLabel);
JLabel lblNewLabel_1 = new JLabel("E-Learning SUKKUR IBA Khairpur Campus");
lblNewLabel_1.setFont(new Font("Tahoma", Font.BOLD, 35));
lblNewLabel_1.setBounds(289, 29, 920, 118);
contentPane.add(lblNewLabel_1);
JPanel panel_3 = new JPanel();
panel_3.setBackground(new Color(25, 25, 112));
panel_3.setBounds(0, 209, 329, 447);
contentPane.add(panel_3);
panel_3.setLayout(null);
JPanel pnlbtn_1 = new JPanel();
pnlbtn_1.addMouseListener(new MouseAdapter() {
@Override
public void mouseEntered(MouseEvent e) {
pnlbtn_1.setBackground(new Color(0, 0, 139));
}
public void mouseExited(MouseEvent e) {
pnlbtn_1.setBackground(new Color(25, 25, 112));
}
@Override
public void mouseClicked(MouseEvent e) {
FrameStd f=new FrameStd();
f.setVisible(true);
f.lblid.setText(lblid.getText());
FrameSenroll.this.dispose();
}
});
pnlbtn_1.setBorder(new LineBorder(Color.WHITE));
pnlbtn_1.setBounds(0, 0, 329, 76);
panel_3.add(pnlbtn_1);
pnlbtn_1.setLayout(null);
pnlbtn_1.setBackground(new Color(25, 25, 112));
JLabel lblNewLabel_2_1_5_5 = new JLabel("Home");
lblNewLabel_2_1_5_5.setForeground(Color.WHITE);
lblNewLabel_2_1_5_5.setFont(new Font("Arial", Font.BOLD, 19));
lblNewLabel_2_1_5_5.setBounds(122, 25, 152, 28);
pnlbtn_1.add(lblNewLabel_2_1_5_5);
JLabel lblNewLabel_2_1_5_4 = new JLabel("Enrol course");
lblNewLabel_2_1_5_4.setForeground(Color.BLACK);
lblNewLabel_2_1_5_4.setFont(new Font("Arial", Font.BOLD, 19));
lblNewLabel_2_1_5_4.setBounds(90, 25, 179, 28);
JPanel pnlbtn_1_1 = new JPanel();
pnlbtn_1_1.addMouseListener(new MouseAdapter() {
@Override
public void mouseEntered(MouseEvent e) {
pnlbtn_1_1.setBackground(new Color(0, 0, 139));
lblNewLabel_2_1_5_4.setForeground(Color.white);
}
@Override
public void mouseExited(MouseEvent e) {
pnlbtn_1_1.setBackground(Color.white);
lblNewLabel_2_1_5_4.setForeground(Color.black);
}
});
pnlbtn_1_1.setLayout(null);
pnlbtn_1_1.setBorder(new LineBorder(new Color(25, 25, 112), 2));
pnlbtn_1_1.setBackground(Color.WHITE);
pnlbtn_1_1.setBounds(0, 74, 329, 76);
panel_3.add(pnlbtn_1_1);
pnlbtn_1_1.add(lblNewLabel_2_1_5_4);
JPanel pnlbtn_1_2 = new JPanel();
pnlbtn_1_2.addMouseListener(new MouseAdapter() {
@Override
public void mouseEntered(MouseEvent e) {
pnlbtn_1_2.setBackground(new Color(0, 0, 139));
}
@Override
public void mouseExited(MouseEvent e) {
pnlbtn_1_2.setBackground(new Color(25, 25, 112));
}
@Override
public void mouseClicked(MouseEvent e) {
FrameAquiz f=new FrameAquiz();
f.setVisible(true);
f.lblid.setText(lblid.getText());
FrameSenroll.this.dispose();
}
});
pnlbtn_1_2.setLayout(null);
pnlbtn_1_2.setBorder(new LineBorder(Color.WHITE));
pnlbtn_1_2.setBackground(new Color(25, 25, 112));
pnlbtn_1_2.setBounds(0, 151, 329, 76);
panel_3.add(pnlbtn_1_2);
JLabel lblNewLabel_2_1_5_3 = new JLabel("Attempt Quiz");
lblNewLabel_2_1_5_3.setForeground(Color.WHITE);
lblNewLabel_2_1_5_3.setFont(new Font("Arial", Font.BOLD, 19));
lblNewLabel_2_1_5_3.setBounds(92, 24, 178, 28);
pnlbtn_1_2.add(lblNewLabel_2_1_5_3);
JPanel pnlbtn_1_3 = new JPanel();
pnlbtn_1_3.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
FrameQueries f=new FrameQueries();
f.setVisible(true);
f.lblid.setText(lblid.getText());
FrameSenroll.this.dispose();
}
@Override
public void mouseEntered(MouseEvent e) {
pnlbtn_1_3.setBackground(new Color(0, 0, 139));
}
@Override
public void mouseExited(MouseEvent e) {
pnlbtn_1_3.setBackground(new Color(25, 25, 112));
}
});
pnlbtn_1_3.setLayout(null);
pnlbtn_1_3.setBorder(new LineBorder(Color.WHITE));
pnlbtn_1_3.setBackground(new Color(25, 25, 112));
pnlbtn_1_3.setBounds(0, 227, 329, 76);
panel_3.add(pnlbtn_1_3);
JLabel lblNewLabel_2_1_5_2 = new JLabel("Ask instructor");
lblNewLabel_2_1_5_2.setForeground(Color.WHITE);
lblNewLabel_2_1_5_2.setFont(new Font("Arial", Font.BOLD, 19));
lblNewLabel_2_1_5_2.setBounds(77, 24, 188, 28);
pnlbtn_1_3.add(lblNewLabel_2_1_5_2);
JPanel pnlbtn_1_4 = new JPanel();
pnlbtn_1_4.addMouseListener(new MouseAdapter() {
@Override
public void mouseEntered(MouseEvent e) {
pnlbtn_1_4.setBackground(new Color(0, 0, 139));
}
@Override
public void mouseExited(MouseEvent e) {
pnlbtn_1_4.setBackground(new Color(25, 25, 112));
}
@Override
public void mouseClicked(MouseEvent e) {
FrameEcheck f=new FrameEcheck();
f.setVisible(true);
f.lblid.setText(lblid.getText());
FrameSenroll.this.dispose();
}
});
pnlbtn_1_4.setLayout(null);
pnlbtn_1_4.setBorder(new LineBorder(Color.WHITE));
pnlbtn_1_4.setBackground(new Color(25, 25, 112));
pnlbtn_1_4.setBounds(0, 301, 329, 76);
panel_3.add(pnlbtn_1_4);
JLabel lblNewLabel_2_1_5_1 = new JLabel("Enrolled Course");
lblNewLabel_2_1_5_1.setForeground(Color.WHITE);
lblNewLabel_2_1_5_1.setFont(new Font("Arial", Font.BOLD, 19));
lblNewLabel_2_1_5_1.setBounds(79, 22, 152, 28);
pnlbtn_1_4.add(lblNewLabel_2_1_5_1);
JPanel pnlbtn_1_5 = new JPanel();
pnlbtn_1_5.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if(JOptionPane.showConfirmDialog(null,"Are you sure want to logout?")==0) {
FrameLOG framelogin=new FrameLOG();
framelogin.setVisible(true);
FrameSenroll.this.dispose();
}
}
@Override
public void mouseEntered(MouseEvent e) {
pnlbtn_1_5.setBackground(new Color(0,0,139));
}
@Override
public void mouseExited(MouseEvent e) {
pnlbtn_1_5.setBackground(new Color(25, 25, 112));
}
});
pnlbtn_1_5.setLayout(null);
pnlbtn_1_5.setBorder(new LineBorder(Color.WHITE));
pnlbtn_1_5.setBackground(new Color(25, 25, 112));
pnlbtn_1_5.setBounds(0, 371, 329, 76);
panel_3.add(pnlbtn_1_5);
JLabel lblNewLabel_2_1_5 = new JLabel("Sign out");
lblNewLabel_2_1_5.setForeground(Color.WHITE);
lblNewLabel_2_1_5.setFont(new Font("Arial", Font.BOLD, 19));
lblNewLabel_2_1_5.setBounds(110, 22, 152, 28);
pnlbtn_1_5.add(lblNewLabel_2_1_5);
JPanel panel = new JPanel();
panel.setBackground(Color.WHITE);
panel.setBorder(new LineBorder(new Color(25, 25, 112)));
panel.setBounds(335, 209, 938, 430);
contentPane.add(panel);
panel.setLayout(null);
JLabel lblNewLabel_3 = new JLabel("Course ID:");
lblNewLabel_3.setHorizontalAlignment(SwingConstants.CENTER);
lblNewLabel_3.setFont(new Font("Tahoma", Font.PLAIN, 17));
lblNewLabel_3.setBounds(10, 25, 156, 48);
panel.add(lblNewLabel_3);
JLabel lblNewLabel_3_1 = new JLabel("Course Title:");
lblNewLabel_3_1.setHorizontalAlignment(SwingConstants.CENTER);
lblNewLabel_3_1.setFont(new Font("Tahoma", Font.PLAIN, 19));
lblNewLabel_3_1.setBounds(10, 97, 156, 48);
panel.add(lblNewLabel_3_1);
course_id = new JTextField();
course_id.setColumns(10);
course_id.setBounds(176, 25, 401, 48);
panel.add(course_id);
course_title = new JTextField();
course_title.setEditable(false);
course_title.setColumns(10);
course_title.setBounds(176, 97, 635, 48);
panel.add(course_title);
JPanel Back = new JPanel();
Back.setLayout(null);
Back.setBorder(new LineBorder(Color.WHITE));
Back.setBackground(new Color(25, 25, 112));
Back.setBounds(176, 363, 234, 56);
panel.add(Back);
JLabel lblNewLabel_2_1_5_6 = new JLabel("Back");
lblNewLabel_2_1_5_6.setForeground(Color.WHITE);
lblNewLabel_2_1_5_6.setFont(new Font("Arial", Font.BOLD, 19));
lblNewLabel_2_1_5_6.setBounds(90, 13, 134, 28);
Back.add(lblNewLabel_2_1_5_6);
JLabel lblcreate = new JLabel("Enroll");
lblcreate.setForeground(Color.WHITE);
lblcreate.setFont(new Font("Arial", Font.BOLD, 19));
lblcreate.setBounds(72, 13, 152, 28);
JLabel lblNewLabel_3_1_1 = new JLabel("Pre-Requisit ID");
lblNewLabel_3_1_1.setHorizontalAlignment(SwingConstants.CENTER);
lblNewLabel_3_1_1.setFont(new Font("Tahoma", Font.PLAIN, 19));
lblNewLabel_3_1_1.setBounds(10, 228, 156, 48);
panel.add(lblNewLabel_3_1_1);
pre_req = new JTextField();
pre_req.setColumns(10);
pre_req.setBounds(176, 287, 401, 48);
pre_tit = new JTextField();
pre_tit.setEditable(false);
pre_tit.setColumns(10);
pre_tit.setBounds(176, 287, 401, 48);
panel.add(pre_tit);
JLabel lblid_1 = new JLabel("User ID:");
lblid_1.setHorizontalAlignment(SwingConstants.CENTER);
lblid_1.setBounds(42, 178, 87, 24);
contentPane.add(lblid_1);
lblid = new JLabel();
lblid.setBounds(139, 178, 264, 24);
contentPane.add(lblid);
JPanel Submit = new JPanel();
Submit.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if(!course_id.getText().isEmpty()) {
try {
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/lms","root","root");
Statement st=con.createStatement();
String query="Insert into std_enrol(course_id,logid) value('"+course_id.getText()+"','"+lblid.getText()+"')";
st.executeUpdate(query);
JOptionPane.showMessageDialog(null,"Enrolment Successful");
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
JOptionPane.showInternalMessageDialog(null,"Please enter a valid course id information");
}
}
}
});
Submit.setLayout(null);
Submit.setBorder(new LineBorder(Color.WHITE));
Submit.setBackground(new Color(25, 25, 112));
Submit.setBounds(431, 363, 234, 56);
Submit.add(lblcreate);
panel.add(Submit);
JLabel lblNewLabel_3_1_1_1 = new JLabel("Pre-Requisit Title:");
lblNewLabel_3_1_1_1.setHorizontalAlignment(SwingConstants.CENTER);
lblNewLabel_3_1_1_1.setFont(new Font("Tahoma", Font.PLAIN, 19));
lblNewLabel_3_1_1_1.setBounds(10, 287, 156, 48);
panel.add(lblNewLabel_3_1_1_1);
pre_id = new JTextField();
pre_id.setEditable(false);
pre_id.setColumns(10);
pre_id.setBounds(176, 228, 401, 48);
panel.add(pre_id);
JLabel lblNewLabel_3_1_2 = new JLabel("Instructor Name:");
lblNewLabel_3_1_2.setHorizontalAlignment(SwingConstants.CENTER);
lblNewLabel_3_1_2.setFont(new Font("Tahoma", Font.PLAIN, 19));
lblNewLabel_3_1_2.setBounds(10, 169, 156, 48);
panel.add(lblNewLabel_3_1_2);
ins_name = new JTextField();
ins_name.setEditable(false);
ins_name.setColumns(10);
ins_name.setBounds(176, 169, 635, 48);
panel.add(ins_name);
JPanel Submit_1 = new JPanel();
Submit_1.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
try {
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/lms","root","root");
String query="select course_title,pre_req from course where course_id='"+course_id.getText()+"'";
String query1="select concat(i.fname,' ',i.lname) as 'Full Name' from enroll e join instructor i on e.ins_id=i.logid and e.course_id='"+course_id.getText()+"'";
String query2 ="select course_title from course where course_id='"+pre_id.getText()+"'";
Statement st=con.createStatement();
Statement st1=con.createStatement();
Statement st2=con.createStatement();
ResultSet rs=st.executeQuery(query);
ResultSet rs1=st1.executeQuery(query1);
ResultSet rs2=st2.executeQuery(query2);
while(rs.next()) {
String ctitle=rs.getString("course_title");
String pre=rs.getString("pre_req");
course_title.setText(ctitle);
pre_id.setText(pre);
}
while(rs1.next()) {
String name=rs1.getString("Full Name");
ins_name.setText(name);
}
pre_tit.setText(null);
while (rs2.next()) {
String course=rs2.getString("course_title");
pre_tit.setText(course);
}
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
JOptionPane.showMessageDialog(null,"Please enter a valid course id");
}
}
});
Submit_1.setLayout(null);
Submit_1.setBorder(new LineBorder(Color.WHITE));
Submit_1.setBackground(new Color(25, 25, 112));
Submit_1.setBounds(619, 17, 234, 56);
panel.add(Submit_1);
JLabel lblFindCourse = new JLabel("Find Course");
lblFindCourse.setForeground(Color.WHITE);
lblFindCourse.setFont(new Font("Arial", Font.BOLD, 19));
lblFindCourse.setBounds(49, 11, 152, 28);
Submit_1.add(lblFindCourse);
}
}