?? scorequery3.asp
字號:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="Connections/StudentConn.asp" -->
<%
Dim Recordset1__MMColParam,Recordset2__MMColParam,Recordset3__MMColParam
Dim strSheetName, strStudentNum, strName, strGrade, strClass
strSheetName = Request("SheetName")
Recordset2__MMColParam = Request("SheetName")
Session("txtSheetName")=Request("SheetName")
strStudentNum= Request("StudentNum")
strGrade=Request("Grade")
strClass=Request("ClassSelect")
Session("txtStudentNum")=strStudentNum
Session("txtGrade")=strGrade
Session("txtClass")=strClass
strOrderField=Request("OrderField")
if (strStudentNum <> "") then
Recordset3__MMColParam =strStudentNum
else
If len(Year(Now()))<=2 Then
NewYear="20" & Year(Now())
Else
NewYear=Year(Now())
End If
If len(Month(Now()))<=1 Then
NewMonth="0" & Month(Now())
Else
NewMonth=Month(Now())
End If
if NewMonth<9 then
strStudentNum=NewYear-strGrade-1
else
strStudentNum=NewYear-strGrade
end if
if strClass="All" then strClass=""
if Len(strClass)=1 then
strClass="0" & strClass
end if
Recordset3__MMColParam =strStudentNum & strClass
end if
%>
<%
set Recordset2 = Server.CreateObject("ADODB.Recordset")
Recordset2.ActiveConnection = MM_StudentConn_STRING
Recordset2.Source = "SELECT SheetName, TestName FROM TestName WHERE SheetName = '" + Replace(Recordset2__MMColParam, "'", "''") + "'"
Recordset2.CursorType = 0
Recordset2.CursorLocation = 2
Recordset2.LockType = 3
Recordset2.Open()
Recordset2_numRows = 0
%>
<%
set Recordset3 = Server.CreateObject("ADODB.Recordset")
Recordset3.ActiveConnection = MM_StudentConn_STRING
Recordset3.Source = "SELECT * FROM " & strSheetName & " WHERE StudentNum like '" & Recordset3__MMColParam & "%' ORDER BY " & strOrderField
Recordset3.CursorType = 0
Recordset3.CursorLocation = 2
Recordset3.LockType = 3
Recordset3.Open()
Recordset3_numRows = 0
%>
<%
Dim Repeat1__numRows
Repeat1__numRows = -1
Dim Repeat1__index
Repeat1__index = 0
Recordset3_numRows = Recordset3_numRows + Repeat1__numRows
%>
<%
' *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters
' create the list of parameters which should not be maintained
MM_removeList = "&index="
If (MM_paramName <> "") Then MM_removeList = MM_removeList & "&" & MM_paramName & "="
MM_keepURL="":MM_keepForm="":MM_keepBoth="":MM_keepNone=""
' add the URL parameters to the MM_keepURL string
For Each Item In Request.QueryString
NextItem = "&" & Item & "="
If (InStr(1,MM_removeList,NextItem,1) = 0) Then
MM_keepURL = MM_keepURL & NextItem & Server.URLencode(Request.QueryString(Item))
End If
Next
' add the Form variables to the MM_keepForm string
For Each Item In Request.Form
NextItem = "&" & Item & "="
If (InStr(1,MM_removeList,NextItem,1) = 0) Then
MM_keepForm = MM_keepForm & NextItem & Server.URLencode(Request.Form(Item))
End If
Next
' create the Form + URL string and remove the intial '&' from each of the strings
MM_keepBoth = MM_keepURL & MM_keepForm
if (MM_keepBoth <> "") Then MM_keepBoth = Right(MM_keepBoth, Len(MM_keepBoth) - 1)
if (MM_keepURL <> "") Then MM_keepURL = Right(MM_keepURL, Len(MM_keepURL) - 1)
if (MM_keepForm <> "") Then MM_keepForm = Right(MM_keepForm, Len(MM_keepForm) - 1)
' a utility function used for adding additional parameters to these strings
Function MM_joinChar(firstItem)
If (firstItem <> "") Then
MM_joinChar = "&"
Else
MM_joinChar = ""
End If
End Function
%>
<%
' *** Recordset Stats, Move To Record, and Go To Record: declare stats variables
Dim Recordset3_total
Dim Recordset3_first
Dim Recordset3_last
' set the record count
Recordset3_total = Recordset3.RecordCount
' set the number of rows displayed on this page
If (Recordset3_numRows < 0) Then
Recordset3_numRows = Recordset3_total
Elseif (Recordset3_numRows = 0) Then
Recordset3_numRows = 1
End If
' set the first and last displayed record
Recordset3_first = 1
Recordset3_last = Recordset3_first + Recordset3_numRows - 1
' if we have the correct record count, check the other stats
If (Recordset3_total <> -1) Then
If (Recordset3_first > Recordset3_total) Then
Recordset3_first = Recordset3_total
End If
If (Recordset3_last > Recordset3_total) Then
Recordset3_last = Recordset3_total
End If
If (Recordset3_numRows > Recordset3_total) Then
Recordset3_numRows = Recordset3_total
End If
End If
%>
<%
' *** Recordset Stats: if we don't know the record count, manually count them
If (Recordset3_total = -1) Then
' count the total records by iterating through the recordset
Recordset3_total=0
While (Not Recordset3.EOF)
Recordset3_total = Recordset3_total + 1
Recordset3.MoveNext
Wend
' reset the cursor to the beginning
If (Recordset3.CursorType > 0) Then
Recordset3.MoveFirst
Else
Recordset3.Requery
End If
' set the number of rows displayed on this page
If (Recordset3_numRows < 0 Or Recordset3_numRows > Recordset3_total) Then
Recordset3_numRows = Recordset3_total
End If
' set the first and last displayed record
Recordset3_first = 1
Recordset3_last = Recordset3_first + Recordset3_numRows - 1
If (Recordset3_first > Recordset3_total) Then
Recordset3_first = Recordset3_total
End If
If (Recordset3_last > Recordset3_total) Then
Recordset3_last = Recordset3_total
End If
End If
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>計算總分與排名</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META content="MSHTML 6.00.2600.0" Name=GENERATOR>
<link href="home.css" rel="stylesheet" type="text/css">
<SCRIPT language=javascript>
function unselectall()
{
if(document.del.chkAll.checked){
document.del.chkAll.checked = document.del.chkAll.checked&0;
}
}
function CheckAll(form)
{
for (var i=0;i<form.elements.length;i++)
{
var e = form.elements[i];
if (e.Name != 'chkAll')
e.checked = form.chkAll.checked;
}
}
function ConfirmDel()
{
if(confirm("確定要刪除選中的記錄嗎?一旦刪除將不能恢復!"))
return true;
else
return false;
}
</SCRIPT>
</HEAD>
<BODY text=#000000 bgColor=#ffffff leftMargin=0 topMargin=0>
<!--#include file="Top.asp"-->
<TABLE cellSpacing=0 cellPadding=0 width=750 align=center border=0>
<TBODY>
<TR>
<TD vAlign=top width=46 background=images/p_left_2.gif></TD>
<TD width=20> </TD>
<TD> <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<tr>
<td height=30 width="20%"><img src="images/friendsite.GIF" width="19" height="19">
<a href="ScoreInputStep1.asp">錄入學生成績</a></td>
<td height=30 width="20%"><img src="images/friendsite.gif" width="19" height="19">
<a href="ScoreQueryStep1.asp">查詢學生成績</a></td>
<td height=30 width="20%"><img src="images/friendsite.gif" width="19" height="19">
<a href="ScoreModifyDel.asp">修改/刪除學生成績</a></td>
<td height=30 width="20%"><img src="images/friendsite.gif" width="19" height="19">
<a href="ScoreOrder.asp">計算總分與排名</a></td>
<td height=30 width="20%"><img src="images/friendsite.gif" width="19" height="19"><a href="TargetManage.asp">目標分管理</a></td>
</tr>
</TABLE>
<table cellspacing=0 cellpadding=0 width="100%" border=0>
<tbody>
<tr>
<td align=center height=18><br>
<b><font color="#0066cc" size="5">計算總分與排名結果</font></b> </td>
</tr>
<tr>
<td bgcolor=#3399ff height=1></td>
</tr>
<tr>
<td><b><font color="#FF0000"><br>
<font color="#0066cc">考試名稱:</font></font></b> <%=(Recordset2.Fields.Item("TestName").Value)%><font color="#FF0000"><b><font color="#0066cc"> </font></b></font><font color="#FF0000"><b>查詢條件:</b></font>
<%
if Request("StudentNum")<>"" then
response.write "學號中含有“" & strStudentNum & "”"
elseif strName<>"" then
response.write "姓名中含有“" & strName & "”"
else
if strClass<>"" then strClass=strClass & "班"
response.write "高" & strGrade+1 & "級" & strClass
end if
%>
<br>
<% If Not Recordset3.EOF Or Not Recordset3.BOF Then %>
<form Name="del" onsubmit="return ConfirmDel()" method="post" action="ScoreDel2.asp">
共找到 <font color="#FF0000"><%=(Recordset3_total)%></font> 條記錄!
<table cellspacing=0 width="100%" border=1 cellpadding="0" bordercolor="#FFCC00">
<tr align="center" valign="middle" bordercolor="#FFCC00">
<td height="28"><font color="#000000">學 號</font></td>
<td height="28"><font color="#000000">姓 名</font></td>
<%
for i=5 to Recordset3.Fields.Count-1
Response.Write "<td height='28'><font color='#000000'>" & Recordset3.Fields.Item(i).Name & "</font></td>"
next
%>
<td height="28"><font color="#000000">總分</font></td>
<td><font color="#000000">平均分</font></td>
<td><font color="#000000">全級排名</font></td>
<td><font color="#000000">班級排名</font></td>
</tr>
<%
While ((Repeat1__numRows <> 0) AND (NOT Recordset3.EOF))
%>
<%
Recordset1__MMColParam = CStr(Recordset3.Fields.Item("StudentNum").Value)
set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_StudentConn_STRING
Recordset1.Source = "SELECT StudentNum, Name FROM StudentInfo WHERE StudentNum = '" + Replace(Recordset1__MMColParam, "'", "''") + "'"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 3
Recordset1.Open()
Recordset1_numRows = 0
if not recordset1.bof or not recordset1.eof then
strName=cstr(Recordset1.Fields.Item("Name").Value)
else
strName=" "
end if
%>
<tr align="center" valign="middle">
<td height="20"><%=(Recordset3.Fields.Item("StudentNum").Value)%></td>
<td height="20"><%=strName%></td>
<%
for i=5 to Recordset3.Fields.Count-1
tmpScore=Recordset3.Fields.Item(i).Value
if IsNull(tmpScore) then tmpScore=" "
Response.Write "<td height='20'>" & tmpScore & "</td>"
next
%>
<td><%=(Recordset3.Fields.Item("總分").Value & " ") %></td>
<td><%=(Recordset3.Fields.Item("平均分").Value & " ") %></td>
<td><%=(Recordset3.Fields.Item("全級排名").Value & " ")%></td>
<td><%=(Recordset3.Fields.Item("班級排名").Value & " ")%></td>
</tr>
<%
Recordset1.Close()
%>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
Recordset3.MoveNext()
Wend
%>
</table>
</form>
<% else %>
<br>
<br>
<br>
找不到符合條件的記錄!<br>
<br>
<br>
<% end if %>
</td>
</tr>
</tbody>
</table>
</TD>
</TR>
</TBODY>
</TABLE>
<!--#include file="CopyRight.asp"-->
</BODY>
</HTML>
<%
Recordset2.Close()
%>
<%
Recordset3.Close()
%>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -