-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathViewResult.java
More file actions
246 lines (214 loc) · 7.01 KB
/
Copy pathViewResult.java
File metadata and controls
246 lines (214 loc) · 7.01 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
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import java.awt.Font;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.swing.SwingConstants;
import javax.swing.JButton;
import javax.swing.JTextField;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
public class ViewResult extends JFrame {
private JPanel contentPane;
private JTextField viewText;
ExamData db;
Connection cn;
Statement st;
String sql;
ResultSet rs;
JLabel ename,std,emailLabel,questionAttemtedLabel,correctAttempts,wrongAttempts,totalMarks,achivedMarks;
private JButton homeBtn;
private JButton insertQuestionBtn;
private JButton setupQuestionsBtn;
public static void main(String[] args) {
ViewResult frame = new ViewResult();
frame.setVisible(true);
}
/**
* Create the frame.
*/
public ViewResult() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setExtendedState(JFrame.MAXIMIZED_BOTH);
setBounds(100, 100, 779, 572);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
JLabel mainLabel = new JLabel("Result viewer");
mainLabel.setHorizontalAlignment(SwingConstants.CENTER);
mainLabel.setFont(new Font("Arial Black", Font.PLAIN, 20));
mainLabel.setBounds(377, 0, 254, 29);
contentPane.add(mainLabel);
JButton viewBtn = new JButton("View");
viewBtn.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e)
{
if (e.getKeyCode()==KeyEvent.VK_ENTER)
{
loadResult();
}
}
});
viewBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("calling");
loadResult();
}
});
viewBtn.setFont(new Font("Arial", Font.PLAIN, 12));
viewBtn.setBounds(245, 52, 126, 41);
contentPane.add(viewBtn);
viewText = new JTextField();
viewText.setColumns(10);
viewText.setBounds(0, 56, 238, 29);
contentPane.add(viewText);
ename = new JLabel("Exam Name");
ename.setFont(new Font("Arial", Font.PLAIN, 15));
ename.setBounds(10, 109, 228, 32);
contentPane.add(ename);
std = new JLabel("student name");
std.setFont(new Font("Arial", Font.PLAIN, 15));
std.setBounds(247, 109, 244, 32);
contentPane.add(std);
emailLabel = new JLabel("email");
emailLabel.setFont(new Font("Arial", Font.PLAIN, 15));
emailLabel.setBounds(10, 165, 196, 32);
contentPane.add(emailLabel);
questionAttemtedLabel = new JLabel("Question Attempted");
questionAttemtedLabel.setFont(new Font("Arial", Font.PLAIN, 15));
questionAttemtedLabel.setBounds(247, 165, 228, 32);
contentPane.add(questionAttemtedLabel);
correctAttempts = new JLabel("correct attempts");
correctAttempts.setFont(new Font("Arial", Font.PLAIN, 15));
correctAttempts.setBounds(10, 215, 228, 32);
contentPane.add(correctAttempts);
wrongAttempts = new JLabel("worng attempts");
wrongAttempts.setFont(new Font("Arial", Font.PLAIN, 15));
wrongAttempts.setBounds(245, 219, 206, 32);
contentPane.add(wrongAttempts);
totalMarks = new JLabel("total marks");
totalMarks.setFont(new Font("Arial", Font.PLAIN, 15));
totalMarks.setBounds(10, 272, 225, 32);
contentPane.add(totalMarks);
achivedMarks = new JLabel("achived marks");
achivedMarks.setFont(new Font("Arial", Font.PLAIN, 15));
achivedMarks.setBounds(245, 270, 228, 32);
contentPane.add(achivedMarks);
homeBtn = new JButton("Logout");
homeBtn.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
if (e.getKeyCode()==KeyEvent.VK_ENTER)
{
new Home().setVisible(true);
kill();
}
}
});
homeBtn.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
new Home().setVisible(true);
kill();
}
});
homeBtn.setFont(new Font("Arial", Font.PLAIN, 12));
homeBtn.setEnabled(true);
homeBtn.setBounds(260, 0, 112, 33);
contentPane.add(homeBtn);
insertQuestionBtn = new JButton("Insert Questions");
insertQuestionBtn.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
if (e.getKeyCode()==KeyEvent.VK_ENTER)
{
new InsertFrom().setVisible(true);
kill();
}
}
});
insertQuestionBtn.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
new InsertFrom().setVisible(true);
kill();
}
});
insertQuestionBtn.setFont(new Font("Arial", Font.PLAIN, 12));
insertQuestionBtn.setEnabled(true);
insertQuestionBtn.setBounds(0, 0, 126, 32);
contentPane.add(insertQuestionBtn);
setupQuestionsBtn = new JButton("Setup Question");
setupQuestionsBtn.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
if (e.getKeyCode()==KeyEvent.VK_ENTER)
{
new SetupExam().setVisible(true);
kill();
}
}
});
setupQuestionsBtn.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
new SetupExam().setVisible(true);
kill();
}
});
setupQuestionsBtn.setFont(new Font("Arial", Font.PLAIN, 12));
setupQuestionsBtn.setBounds(137, 0, 119, 32);
contentPane.add(setupQuestionsBtn);
fload();
}
public void fload()
{
try
{
db=new ExamData();
cn=db.getConnection();
st = cn.createStatement();
}
catch (Exception ex)
{
System.err.print("Exception: ");
System.err.println(ex.getMessage());
}
}
public void loadResult()
{
try
{
sql="select * from student where id="+viewText.getText()+"";
System.out.println(sql);
rs=st.executeQuery(sql);
//loading stuff into form;
if(rs.next())
{
ename.setText("Exam Name:"+rs.getString(2));//changes goes here ? ass :) here only its fine.... ;)
std.setText("Student Name:"+rs.getString(3));
emailLabel.setText("Email:"+rs.getString(4));
questionAttemtedLabel.setText("Question Attempted:"+rs.getString(5));
correctAttempts.setText("Correct Attempts:"+rs.getString(6));
wrongAttempts.setText("Wrong Attempts:"+rs.getString(7));
totalMarks.setText("Total Marks:"+rs.getString(8));
achivedMarks.setText("Achived Marks:"+rs.getString(9));
}
else
JOptionPane.showMessageDialog(null,"Student id not found...!");
}
catch (Exception ex)
{
JOptionPane.showMessageDialog(null,"Student id not found...!");
System.err.print("Exception: ");
System.err.println(ex.getMessage());
}
}
public void kill()
{
this.dispose();
}
}