<!--#include file="SetMdbTab.asp"-->
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=gb2312'>
<meta name='GENERATOR' content='Microsoft FrontPage 4.0'>
<meta name='ProgId' content='FrontPage.Editor.Document'>
<title>成绩统计查询</title>
</head>
<body>
<center>
<form Name='Searchfrm' method="POST" action="TongJiContent.asp">
<input type="hidden" name="Num">
</form>
<script>
function RUNonclick(){
with(document.Searchfrm){
Num.value=parent.Num.value;
submit();
}
}
</script>
<table border='1' borderColorDark='#ffffff' borderColorLight='#000000' cellSpacing='0' width='700'>
<tbody>
<tr>
<td align='center' vAlign='top' width='50'><small>项目</small></td>
<td align='center' vAlign='top' width='40'><small>班级</small></td>
<td align='center' vAlign='top' width='58'><small>语文</small></td>
<td align='center' vAlign='top' width='58'><small>数学</small></td>
<td align='center' vAlign='top' width='58'><small>外语</small></td>
<td align='center' vAlign='top' width='58'><small>物理</small></td>
<td align='center' vAlign='top' width='58'><small>化学</small></td>
<!--td align='center' vAlign='top' width='51'><small>政治</small></td-->
<td align='center' vAlign='top' width='120'><small> 总分</small></td>
</tr>
<%
on error resume next
TimeBegin = timer()
'********************************初始化开始******************************************
'全局变量,为下面的引用做准备
dim conn,DBPath,rs '数据库记录集
dim XiangMu
dim BanJi
dim ShuXue
dim YuWen
dim WaiYu
dim HuaXue
dim ShowXiangMu
dim WuLi
dim ZongFen
XiangMu = request("XiangMu")
BanJi = request("Num")
ShuXue = "0"
YuWen = "0"
WaiYu = "0"
HuaXue = "0"
ShowXiangMu = "人数"
WuLi = "0"
ZongFen = "0"
If BanJi="" or BanJi<>"1" and BanJi<>"2" and BanJi<>"3" Then BanJi="1-3"
Set conn = Server.CreateObject("ADODB.Connection")
DBPath = Server.MapPath(DBPath)
conn.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & DBPath
Set rs = Server.CreateObject("ADODB.Recordset")
'********************************初始化结束******************************************
'********************************Main Begin******************************************
Select Case BanJi
Case "1-3"
ShowGrade rs,"BJiuShi"
ShowGrade rs,"BaShiJiuShi"
ShowGrade rs,"QishiBashi"
ShowGrade rs,"LiushiQishi"
ShowGrade rs,"SLiushi"
for i=1 to 3
PhyAvg rs,i
ShowTongJi ShowXiangMu,BanJi,YuWen,ShuXue,WaiYu,WuLi,HuaXue,Zongfen
next
PhyAvg rs,"1-3"
ShowTongJi ShowXiangMu,BanJi,YuWen,ShuXue,WaiYu,WuLi,HuaXue,Zongfen
Case Else
ShowClass rs,Banji
End select
'********************************Main End******************************************
'********************************函数部分开始******************************************
Function ShowGrade(VarRs,XiangMu)
For i=1 to 3
ShowFenShuDuan VarRs,XiangMu,i
Next
ShowTongJi "","","","","","","","" '显示一个空行
End Function
Function ShowClass(VarRs,Banji)
ShowFenShuDuan VarRs,"BJiuShi",BanJi
ShowFenShuDuan VarRs,"BaShiJiuShi",BanJi
ShowFenShuDuan VarRs,"QishiBashi",BanJi
ShowFenShuDuan VarRs,"LiushiQishi",BanJi
ShowFenShuDuan VarRs,"SLiushi",BanJi
PhyAvg VarRs,BanJi
ShowTongJi ShowXiangMu,BanJi,YuWen,ShuXue,WaiYu,WuLi,HuaXue,Zongfen
End Function
Function ShowFenShuDuan(VarRs,XiangMu,BanJi)
WuLi = PhyCount(VarRs,XiangMu,"物理",BanJi)
ShuXue = PhyCount(VarRs,XiangMu,"数学",BanJi)
YuWen = PhyCount(VarRs,XiangMu,"语文",BanJi)
WaiYu = PhyCount(VarRs,XiangMu,"外语",BanJi)
HuaXue = PhyCount(VarRs,XiangMu,"化学",BanJi)
ShowTongJi ShowXiangMu,BanJi,YuWen,ShuXue,WaiYu,WuLi,HuaXue,Zongfen
End Function
Function PhyAvg(VarRs,VarBanJi) '平均值统计
dim sql
sql = "Select avg(语文) as T语文,avg(数学) as T数学,avg(外语) as T外语,avg(物理) as T物理,avg(化学) as T化学,avg(总分) as T总分 From "&Table
If VarBanJi <> "1-3" Then sql= sql & " Where 班级='"&VarBanJi&"'"
ShowXiangMu = "平均分"
BanJi = VarBanJi
VarRs.Open sql, conn,1,1
If VarRs.eof Then response.write "没有相关记录!":response.end
YuWen=round(VarRs("T语文"),2)
ShuXue=round(VarRs("T数学"),2)
WaiYu=round(VarRs("T外语"),2)
HuaXue = round(VarRs("T化学"),2)
WuLi=round(VarRs("T物理"),2)
ZongFen =round(VarRs("T总分"),2)
VarRs.close
End Function
Function PhyCount(VarRs,XiangMu,KeMu,BanJi) '分数段统计
dim sql
sql = "Select * From Table Where "& KeMu
If BanJi <> "1-3" Then sql="Select * From "& Table &" Where 班级='"&BanJi&"' And " & KeMu
Select Case XiangMu
Case "BJiuShi"
sql = sql & ">=90"
ShowXiangMu = "大于90"
Case "BaShiJiuShi"
sql = sql & "<90 and "& KeMu &">=80"
ShowXiangMu = "80-90"
Case "QishiBashi"
sql = sql & "<80 and "& KeMu &">=70"
ShowXiangMu = "70-80"
Case "LiushiQishi"
sql = sql & "<70 and "& KeMu &">=60"
ShowXiangMu = "60-70"
Case "SLiushi"
sql = sql & "<60"
ShowXiangMu = "小于60"
End Select
'response.write sql
VarRs.Open sql, conn,1,1
PhyCount = VarRs.recordcount
VarRs.close
End function
Function ShowTongJi(ShowXiangMu,BanJi,YuWen,ShuXue,WaiYu,WuLi,HuaXue,ZongFen)
Tab = ""
Tab = Tab &" <tr>" &VbCrlf
Tab = Tab &" <td align='center' vAlign='top' width='50'><small>"& ShowXiangMu &" </small></td>" &VbCrlf
Tab = Tab &" <td align='center' vAlign='top' width='40'><small>"& BanJi &" </small></td>" &VbCrlf
Tab = Tab &" <td align='center' vAlign='top' width='58'><small>"& YuWen &" </small></td>" &VbCrlf
Tab = Tab &" <td align='center' vAlign='top' width='58'><small>"& ShuXue &" </small></td>" &VbCrlf
Tab = Tab &" <td align='center' vAlign='top' width='58'><small>"& WaiYu &" </small></td>" &VbCrlf
Tab = Tab &" <td align='center' vAlign='top' width='58'><small>"& WuLi &" </small></td>" &VbCrlf
Tab = Tab &" <td align='center' vAlign='top' width='58'><small>"& HuaXue &" </small></td>" &VbCrlf
Tab = Tab &" <!--td align='center' vAlign='top' width='51'><small>"& ZhengZhi &" </small></td-->" &VbCrlf
Tab = Tab &" <td align='center' vAlign='top' width='120'><small>"& ZongFen &" </small></td>" &VbCrlf
Tab = Tab &" </tr>" &VbCrlf
Response.write Tab
End Function
'********************************函数部分结束******************************************
%>
</tbody>
</table>
页面执行时间:
<%
TimeEnd = timer()
TimeSpan= TimeEnd - TimeBegin
response.write cstr(int(( TimeSpan*10000 )+0.5)/10) &"毫秒" ' 保留小数点后一位
%>
</center>
</body>
</html>
联系客服