-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindividual.jsp
More file actions
308 lines (306 loc) · 8.21 KB
/
individual.jsp
File metadata and controls
308 lines (306 loc) · 8.21 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
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
<%@ page language="java" contentType="text/html" pageEncoding="UTF-8" %>
<%@ page import="java.sql.*" %>
<%@ page import="jb.dbc.*" %>
<%@ page import="jb.vo.*" %>
<html>
<head>
<title>个人主页</title>
<link href="bootstrap-3.3.7-dist\css\bootstrap.css" rel="stylesheet">
<link href="bootstrap-3.3.7-dist\css\bootstrap-theme.css" rel="stylesheet">
<script src="jquery.js"></script>
<script src="bootstrap-3.3.7-dist\js\bootstrap.js"></script>
</head>
<body>
<%
DatabaseConnection dbc = null;
Connection conn = null;
Statement stat = null;
String UserName = request.getParameter("UserName");
//String Password = request.getParameter("Password");
String SNo = null;
try {
dbc = new DatabaseConnection();
conn = dbc.getConnection();
stat = conn.createStatement();
} catch (Exception e) {
%>
<%= e.getMessage() %>
<%
}
%>
<div class="container">
<div class="row clearfix">
<div class="col-md-12 column">
<h3>
<em><%= UserName %></em>的个人主页
</h3>
</div>
</div>
<div class="row clearfix">
<div class="col-md-2 column">
<img alt="140x140" src="img/spears.jpg" class="img-rounded" width="140" height="140" />
<br>
<p>
<br>
<em><%= UserName %></em> 是一个优秀的学生,就读于重庆邮电大学 <strong> CQUPT </strong>
</p>
</div>
<div class="col-md-10 column">
<div class="tabbable" id="tabs-295567">
<ul class="nav nav-tabs">
<li class="active">
<a href="#panel-1" data-toggle="tab">基本信息</a>
</li>
<li>
<a href="#panel-2" data-toggle="tab">课程信息</a>
</li>
<li>
<a href="#panel-3" data-toggle="tab">统计信息</a>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="panel-1">
<p>
<%
String SName=null;
String SSex=null;
String SDormitory=null;
//request.setCharacterEncoding("UTF-8");
try{
String sql = "select * from student where UserName='" + UserName+"'";
ResultSet rs = stat.executeQuery(sql);
if(rs.next())
SNo = rs.getString("SNo");
else
{
sql = "select * from student where SNo='" + UserName+"'";
rs = stat.executeQuery(sql);
rs.next();
SNo = rs.getString("SNo");
}
session.setAttribute("SNo",SNo);
SName=rs.getString("SName");
session.setAttribute("SName",SName);
SSex=rs.getString("SSex");
SDormitory=rs.getString("SDormitory");
//rs.close();
//dbc.close();
}catch(Exception e){
%>
<%= e.getMessage() %>
<%
}
%>
<ul>
<li>
用户名:<%=UserName%>
</li>
<li>
学号:<%=SNo%>
</li>
<li>
姓名:<%=SName%>
</li>
<li>
性别:<%=SSex%>
</li>
<li>
寝室:<%=SDormitory%>
</li>
</ul>
<a href="student_update.jsp?UserName=<%=UserName%>&SNo=<%=SNo%>&SName=<%=SName%>&SSex=<%=SSex%>&SDormitory=<%=SDormitory%>">
<button type="button" class="btn btn-default">信息完善</button>
</a>
</p>
</div>
<div class="tab-pane" id="panel-2">
<table class="table">
<thead>
<tr>
<th>课程编号</th>
<th>课程名</th>
<th>考试成绩</th>
<th>学分</th>
</tr>
</thead>
<tbody>
<%
try{
String sql = "select SNo from account where UserName='" + UserName+"'";
ResultSet rs = stat.executeQuery(sql);
if(rs.next())
SNo = rs.getString("SNo");
else
{
sql = "select SNo from account where SNo='" + UserName+"'";
rs = stat.executeQuery(sql);
rs.next();
SNo = rs.getString("SNo");
}
sql = "select choose.CNo,Score,CName,CCredit from choose,course where choose.SNo='"+SNo+"' and choose.CNo=course.CNo";
rs = stat.executeQuery(sql);
while(rs.next())
{
%>
<tr>
<td><%= rs.getString("CNo") %></td>
<td><%= rs.getString("CName") %></td>
<td><%= rs.getString("Score") %></td>
<td><%= rs.getString("CCredit") %></td>
</tr>
<%
}
//rs.close();
//dbc.close();
}catch(Exception e){
%>
<%= e.getMessage() %>
<%
}
%>
</tbody>
</table>
<a href="score_update.jsp">
<button type="button" class="btn btn-sm btn-primary btn-block">更新信息</button>
</a>
</div>
<div class="tab-pane" id="panel-3">
<p>
<div class="row clearfix">
<div class="col-md-12 column">
<table class="table">
<thead>
<tr>
<th>
类别
</th>
<th>
统计
</th>
</tr>
</thead>
<tbody>
<tr class="success">
<td>
平均成绩
</td>
<td>
<%
try{
String sql = "select score from choose where SNo='"+SNo+"';";
ResultSet rs = stat.executeQuery(sql);
double sum_score=0;
int cnt=0;
while(rs.next())
{
sum_score+=Double.valueOf(rs.getString("score"));
cnt++;
}
sum_score/=cnt;
%>
<%= sum_score %>
<%
//rs.close();
//dbc.close();
}catch(Exception e){
%>
<%= e.getMessage() %>
<%
}
%>
</td>
</tr>
<tr class="success">
<td>
绩点
</td>
<td>
<%
try{
String sql = "select CCredit,score from choose,course where choose.SNo='"+SNo+"' and choose.CNo=course.CNo;";
ResultSet rs = stat.executeQuery(sql);
float sum_gpa=0,sum_credit=0;
while(rs.next())
{
double tmp=Double.valueOf(rs.getString("score"));
double c=Double.valueOf(rs.getString("CCredit"));
if (tmp>=90)
tmp=4.0*c;
else if (tmp>=85)
tmp=3.7*c;
else if (tmp>=82)
tmp=3.3*c;
else if (tmp>=78)
tmp=3.0*c;
else if (tmp>=75)
tmp=2.7*c;
else if (tmp>=72)
tmp=2.3*c;
else if (tmp>=68)
tmp=2.0*c;
else if (tmp>=64)
tmp=1.5*c;
else if (tmp>=60)
tmp=1.0*c;
sum_gpa+=tmp;
sum_credit+=c;
}
sum_gpa/=sum_credit;
%>
<%= sum_gpa %>
<%
//rs.close();
//dbc.close();
}catch(Exception e){
%>
<%= e.getMessage() %>
<%
}
%>
</td>
</tr>
<tr class="success">
<td>
总学分
</td>
<td>
<%
try{
String sql = "select CCredit from choose,course where choose.SNo='"+SNo+"' and choose.CNo=course.CNo;";
ResultSet rs = stat.executeQuery(sql);
double sum_credit=0;
while(rs.next())
{
sum_credit+=Double.valueOf(rs.getString("CCredit"));
}
%>
<%= sum_credit %>
<%
rs.close();
dbc.close();
}catch(Exception e){
%>
<%= e.getMessage() %>
<%
}
%>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</p>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-12 column">
<a href="login.html">
<button type="button" class="btn btn-default btn-block">返回首页</button>
</a>
</div>
</div>
</body>
</html>