-
Notifications
You must be signed in to change notification settings - Fork 3
/
EnterMarks.java
153 lines (121 loc) · 5.18 KB
/
EnterMarks.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
package university.management.system;
import javax.swing.*;
import java.awt.*;
import java.sql.*;
import java.awt.event.*;
public class EnterMarks extends JFrame implements ActionListener {
Choice crollno;
JComboBox cbsemester;
JTextField tfsub1, tfsub2,tfsub3,tfsub4,tfsub5,tfmarks1,tfmarks2,tfmarks3,tfmarks4,tfmarks5;
JButton cancel, submit;
EnterMarks() {
setSize(1000, 500);
setLocation(300, 150);
setLayout(null);
getContentPane().setBackground(Color.WHITE);
ImageIcon i1 = new ImageIcon(ClassLoader.getSystemResource("icons/exam.jpg"));
Image i2 = i1.getImage().getScaledInstance(400, 300, Image.SCALE_DEFAULT);
ImageIcon i3 = new ImageIcon(i2);
JLabel image = new JLabel(i3);
image.setBounds(500, 40, 400, 300);
add(image);
JLabel heading = new JLabel("Enter Marks of Student");
heading.setBounds(50, 0, 500, 50);
heading.setFont(new Font("Tahoma", Font.BOLD, 20));
add(heading);
JLabel lblrollnumber = new JLabel("Select Roll Number");
lblrollnumber.setBounds(50, 70, 150, 20);
add(lblrollnumber);
crollno = new Choice();
crollno.setBounds(200, 70, 150, 20);
add(crollno);
try {
Conn c = new Conn();
ResultSet rs = c.s.executeQuery("select * from student");
while(rs.next()) {
crollno.add(rs.getString("rollno"));
}
} catch (Exception e) {
e.printStackTrace();
}
JLabel lblsemester = new JLabel("Select Semester");
lblsemester.setBounds(50, 110, 150, 20);
add(lblsemester);
String semester[] = {"1st Semester", "2nd Semester", "3rd Semester", "4th Semester", "5th Semester", "6th Semester", "7th Semester", "8th Semester" };
cbsemester = new JComboBox(semester);
cbsemester.setBounds(200, 110, 150, 20);
cbsemester.setBackground(Color.WHITE);
add(cbsemester);
JLabel lblentersubject = new JLabel("Enter Subject");
lblentersubject.setBounds(100, 150, 200, 40);
add(lblentersubject);
JLabel lblentermarks = new JLabel("Enter Marks");
lblentermarks.setBounds(320, 150, 200, 40);
add(lblentermarks);
tfsub1 = new JTextField();
tfsub1.setBounds(50, 200, 200, 20);
add(tfsub1);
tfsub2 = new JTextField();
tfsub2.setBounds(50, 230, 200, 20);
add(tfsub2);
tfsub3 = new JTextField();
tfsub3.setBounds(50, 260, 200, 20);
add(tfsub3);
tfsub4 = new JTextField();
tfsub4.setBounds(50, 290, 200, 20);
add(tfsub4);
tfsub5 = new JTextField();
tfsub5.setBounds(50, 320, 200, 20);
add(tfsub5);
tfmarks1 = new JTextField();
tfmarks1.setBounds(250, 200, 200, 20);
add(tfmarks1);
tfmarks2 = new JTextField();
tfmarks2.setBounds(250, 230, 200, 20);
add(tfmarks2);
tfmarks3 = new JTextField();
tfmarks3.setBounds(250, 260, 200, 20);
add(tfmarks3);
tfmarks4 = new JTextField();
tfmarks4.setBounds(250, 290, 200, 20);
add(tfmarks4);
tfmarks5 = new JTextField();
tfmarks5.setBounds(250, 320, 200, 20);
add(tfmarks5);
submit = new JButton("Submit");
submit.setBounds(70, 360, 150, 25);
submit.setBackground(Color.BLACK);
submit.setForeground(Color.WHITE);
submit.addActionListener(this);
submit.setFont(new Font("Tahoma", Font.BOLD, 15));
add(submit);
cancel = new JButton("Back");
cancel.setBounds(280, 360, 150, 25);
cancel.setBackground(Color.BLACK);
cancel.setForeground(Color.WHITE);
cancel.addActionListener(this);
cancel.setFont(new Font("Tahoma", Font.BOLD, 15));
add(cancel);
setVisible(true);
}
public void actionPerformed(ActionEvent ae) {
if (ae.getSource() == submit) {
try {
Conn c = new Conn();
String query1 = "insert into subject values('"+crollno.getSelectedItem()+"', '"+cbsemester.getSelectedItem()+"', '"+tfsub1.getText()+"', '"+tfsub2.getText()+"', '"+tfsub3.getText()+"', '"+tfsub4.getText()+"', '"+tfsub5.getText()+"')";
String query2 = "insert into marks values('"+crollno.getSelectedItem()+"', '"+cbsemester.getSelectedItem()+"', '"+tfmarks1.getText()+"', '"+tfmarks2.getText()+"', '"+tfmarks3.getText()+"', '"+tfmarks4.getText()+"', '"+tfmarks5.getText()+"')";
c.s.executeUpdate(query1);
c.s.executeUpdate(query2);
JOptionPane.showMessageDialog(null, "Marks Inserted Sucessfully");
setVisible(false);
} catch (Exception e) {
e.printStackTrace();
}
} else {
setVisible(false);
}
}
public static void main(String[] args) {
new EnterMarks();
}
}