<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="Conn.asp"-->
<!--#include file="../Include/PowerEasy.Common.All.asp"-->
<!--#include file="../Include/PowerEasy.Common.Security.asp"-->

<%
'**************************************************************
' Software name: PowerEasy SiteWeaver
' Web: http://www.powereasy.net
' Copyright (C) 2005－2009 佛山市动易网络科技有限公司 版权所有
'**************************************************************

Server.ScriptTimeOut=9999999
Response.Buffer = True

Dim Action,ComeUrl,FoundErr,ErrMsg,SearchStyle
Dim StudentNum,StudentName,Birthday

FoundErr = False
ErrMsg = ""
ComeUrl = Trim(Request.ServerVariables("HTTP_REFERER"))
Action = Trim(Request("action"))
SearchStyle=Trim(Request("SearchStyle"))
%>
<!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>
<STYLE type=text/css>
a {text-decoration: none;} /* 链接无下划线,有为underline */ 
a:link {color: #000000;text-decoration: none;} /* 未访问的链接 */
a:visited {color: #000000;text-decoration: none;} /* 已访问的链接 */
a:hover {color: #ff6600;text-decoration: none;} /* 鼠标在链接上 */ 
a:active {color: #000000;text-decoration: none;} /* 点击激活链接 */
TD {
	FONT-SIZE: 12px; COLOR: #000000; FONT-FAMILY: '宋体';LINE-HEIGHT: 150%;
}
BODY {
	FONT-SIZE: 12px; COLOR: #000000; FONT-FAMILY: '宋体'
}
INPUT {
	FONT-SIZE: 12px; COLOR: #000000; FONT-FAMILY: '宋体'
}
SELECT {
	FONT-SIZE: 12px; COLOR: #000000; FONT-FAMILY: '宋体'
}
.title
{
	background:#0DB432;
	color: #ffffff;
	font-weight: normal;
}
.border
{
	border: 1px solid #0DB432;
}
.tdbg{
	background:#f0f0f0;
	line-height: 120%;
}
.tdbg1{
	background:#A3E2B1;
	line-height: 120%;
}
</STYLE>
</HEAD>

<BODY text=#000000 bgColor=#ffffff leftMargin=0 topMargin=0>
<br>
<%
Select Case Action
	Case "SearchStep"
		If SearchStyle="ScoreTest" Then
			Call SearchStep1()
		ElseIf SearchStyle="Subject" Then
			Call SearchStep2()
		Else
			FoundErr = True
			ErrMsg=ErrMsg&"<br><li>请选择查询方式！！！</li>"
		End If
	Case "ShowStep1Result"
		Call ShowSearchResult1()
	Case "ShowStep2Result"
		Call ShowSearchResult2()
	Case Else
		Call Main()
End Select
If FoundErr = True Then
	Call WriteErrMsg(ErrMsg, ComeUrl)
End If
Response.write"</BODY></HTML>"


Sub Main
	%>
	<script language="JavaScript">
	function checkform()
	{
	  var strStudentNum
	  strStudentNum=document.form1.StudentNum.value
	  if(strStudentNum=="")
	  {
		alert("你还没有填考号 ！");
		document.form1.StudentNum.focus();
		return false;
	  }	  
	  if(document.form1.StudentName.value=="")
	  {
		alert("你还没有填姓名！");
		document.form1.StudentName.focus();
		return false;
	  }
	  if(document.form1.Birthday.value=="")
	  {
		alert("你还没有填生日！");
		document.form1.Birthday.focus();
		return false;
	  }
	  if(document.form1.SearchStyle.value=="")
	  {
		alert("你还没有选择查询方式！");
		document.form1.SearchStyle.focus();
		return false;
	  }	 
	}

	</script>
	<form Name="form1" onSubmit="return checkform()" action="ScoreQuery.asp" method="post">
	  <table width="500" class="border" border="0" cellspacing="1" cellpadding="4" align="center"> 
		<tr>  
		  <td height="50" colspan="2" align="center" class="title">  
			<p><b> 成 绩 查 询</b>（第一步）----请输入查询条件</p>        </td> 
		</tr>
		<tr>
		  <td width="30%" align="center" class="tdbg1">考号 ：</td>
		  <td width="70%" align="left" class="tdbg"><input name="StudentNum" type="text" id="StudentNum"></td>
		</tr>
		<tr>
		  <td width="30%" align="center" class="tdbg1">姓名：</td>
		  <td width="70%" align="left" class="tdbg"><input name="StudentName" type="text" id="StudentName" value=""></td>
		</tr>
		<tr>
		  <td width="30%" align="center" class="tdbg1">生日：</td>
		  <td width="70%" align="left" class="tdbg"><input name="Birthday" type="text" id="Birthday">    &nbsp;&nbsp;例：1993-3-18</td>
		</tr>
		<tr valign="middle" class="tdbg1"> 
		  <td height="28" colspan="2"> 　　　　 
		  <input type="radio" name="SearchStyle" value="ScoreTest" checked onClick="SearchStyle_Test.style.display='block';SearchStyle_Subject.style.display='none'">
		  <strong>按考试查询 　　　　 </strong> 
		  <input type="radio" name="SearchStyle" value="Subject" onClick="SearchStyle_Test.style.display='none';SearchStyle_Subject.style.display='block'">
		  <strong>按科目查询</strong>  </td>
		</tr>
		<tr valign="middle" class="tdbg" name="SearchStyle_Test" id="SearchStyle_Test" style="display:block"> 
		  <td width="30%" height="30" align="center" class="tdbg1">选择考试：</td>
		  <td width="70%" height="30"><select name="sheetName">
		  <%
			Call OpenSdmsConn
			Dim RsTest,SqlTest,i
			SqlTest = "SELECT * FROM TestName ORDER BY id DESC"
			set RsTest = Server.CreateObject("ADODB.Recordset")
			RsTest.Open SqlTest, conn_Sdms, 1, 1
			i=0						
			While (NOT RsTest.EOF)
				if i=0 then
					response.Write "<option value='" & RsTest("SheetName") & "' selected>" & RsTest("TestName") & "</option>"
				else
					response.Write "<option value='" & RsTest("SheetName") & "'>" & RsTest("TestName") & "</option>"
				end if
				i=i+1
				RsTest.MoveNext()
			Wend
			RsTest.Close
			set RsTest = Nothing
			
			%>
			</select>              
		  </td>
		</tr>
		<tr align="left" valign="middle" class="tdbg" name="SearchStyle_Subject" id="SearchStyle_Subject" style="display:none"> 
		  <td width="30%" height="16" align="center" class="tdbg1">选择科目：</td>
		  <td width="70%" height="16"><select name="Subject">
			<%
			Dim RsSubject,SqlSubject
			Set RsSubject = Server.CreateObject("ADODB.Recordset")
			SqlSubject = "SELECT * FROM Subject ORDER BY ID ASC"
			RsSubject.Open SqlSubject,conn_Sdms,1,1
			i=0
			While (NOT RsSubject.EOF)
				if i=0 then
					response.Write "<option value='" & RsSubject("SubjectName") & "' selected>" & RsSubject("SubjectName") & "</option>"
				else
					response.Write "<option value='" & RsSubject("SubjectName") & "'>" & RsSubject("SubjectName") & "</option>"
				end if
				i=i+1
				RsSubject.MoveNext()
			Wend
			RsSubject.Close
			set RsSubject = Nothing
			
			Call CloseSdmsConn
			%>	
			</select>
		  </td>
		</tr>
		<tr align="center" valign="middle" class="tdbg">
		  <td height="16" colspan="2"><input name="action" type="hidden" id="action" value="SearchStep"><input type="submit" name="Submit" value="下一步"></td>
		</tr>
	  </table>
	</form>
	<%
End Sub

Sub SearchStep1()
	Dim SheetName
	StudentNum=ReplaceBadChar(Trim(Request("StudentNum")))
	StudentName=ReplaceBadChar(Trim(Request("StudentName")))
	Birthday=ReplaceBadChar(Trim(Request("Birthday")))
	SheetName=ReplaceBadChar(Trim(Request("SheetName")))

	If StudentNum="" Then
		FoundErr = True
		ErrMsg=ErrMsg&"<br><li>考号 不能为空！！！</li>"
		Exit Sub
	End If
	If StudentName="" Then
		FoundErr = True
		ErrMsg=ErrMsg&"<br><li>姓名不能为空！！！</li>"
		Exit Sub
	End If
	If Birthday="" Then
		FoundErr = True
		ErrMsg=ErrMsg&"<br><li>生日不能为空！！！</li>"
		Exit Sub
	End If
	If SheetName="" Then
		FoundErr = True
		ErrMsg=ErrMsg&"<br><li>所选考试不能为空！！！</li>"
		Exit Sub
	End If
	If Birthday<>"" And IsDate(Birthday) = False Then
		FoundErr = True
		ErrMsg=ErrMsg&"<br><li>输入的生日不是规则日期！！！</li>"
		Exit Sub
	End If
	Dim IsStudentInfoInclude,IsSheetNameInclude
	Call OpenSdmsConn
	Set IsStudentInfoInclude=conn_Sdms.Execute ("SELECT StudentNum,Name FROM StudentInfo WHERE StudentNum ='" & StudentNum & "' And Name ='" & StudentName & "' And Birthday =#" & Birthday & "#")
	If IsStudentInfoInclude.Eof Then
		FoundErr = True
		ErrMsg=ErrMsg&"<br><li>不存在这个！！！</li><br><li>输入的考号 ，姓名，或者生日有误！</li>"
		Set IsStudentInfoInclude=Nothing
		Exit Sub
	End If
	Set IsStudentInfoInclude=Nothing
	Set IsSheetNameInclude=conn_Sdms.Execute ("SELECT * FROM " & SheetName & " Where StudentNum='"&StudentNum&"'")
	If IsSheetNameInclude.Eof Then
		FoundErr = True
		ErrMsg=ErrMsg&"<br><li>你所选考试的分数数据库中没有你的成绩！！！</li>"
		Set IsSheetNameInclude=Nothing
		Exit Sub
	End If
	Set IsSheetNameInclude=Nothing
	%>
	<form Name="form1" action="ScoreQuery.asp" method="post">
	  <table width="600" class="border" border="0" cellspacing="1" cellpadding="4" align="center"> 
		<tr>  
		  <td height="50" colspan="2" align="center" class="title">  
			<p><b> 成 绩 查 询</b>（第二步）----按考试查询</p>        </td> 
		</tr>
		<tr>
		  <td width="30%" align="center" class="tdbg1">考号 ：</td>
		  <td width="70%" align="left" class="tdbg">
		  <%If StudentNum<>"" Then 
				Response.write StudentNum&"<input name='StudentNum' id='StudentNum' type='hidden' value='"&StudentNum&"'>"
			Else
				Response.write "不指定"
			End If%>
		  </td>
		</tr>
		<tr>
		  <td width="30%" align="center" class="tdbg1">姓名：</td>
		  <td width="70%" align="left" class="tdbg">
		  <%If StudentName<>"" Then 
				Response.write StudentName&"<input name='StudentName' id='StudentName' type='hidden' value='"&StudentName&"'>"
			Else
				Response.write "不指定"
			End If%>	  
		  </td>
		</tr>
		<tr>
		  <td width="30%" align="center" class="tdbg1">生日：</td>
		  <td width="70%" align="left" class="tdbg">
		  <%If Birthday<>"" Then 
				Response.write Birthday&"<input name='Birthday' id='Birthday' type='hidden' value='"&Birthday&"'>"
			Else
				Response.write "不指定"
			End If%>	  
		  </td>
		</tr>
		<tr valign="middle" class="tdbg"> 
		  <td width="30%" height="30" align="center" class="tdbg1">所选考试：</td>
		  <td width="70%" height="30"><%
			Dim RsSheetName,SqlName
			Set RsSheetName = conn_Sdms.Execute ("Select TestName From TestName Where SheetName='" & SheetName & "'")
			SqlName = RsSheetName(0)
			Set RsSheetName = Nothing
			Response.write (SqlName)%>
		  </td>
		</tr>
		<tr align="left" valign="middle" class="tdbg"> 
		  <td width="30%" height="16" align="center" class="tdbg1">选择科目：</td>
		  <td width="70%" height="16">
			<%
			Dim rsSubject,SqlSubject
			Set rsSubject = Server.CreateObject("ADODB.Recordset")
			SqlSubject = "SELECT * FROM " & SheetName
			rsSubject.Open SqlSubject,conn_Sdms

			response.Write("<table border='0' cellspacing='0' cellpadding='3'><tr>")
			For i = 5 to rsSubject.Fields.Count - 1 
				Response.write  "<td><input type='checkbox' name='Subject' value='"&rsSubject.Fields(i).Name&"'>" & rsSubject.Fields(i).Name & "</td>"
				if (i+1-5)>0 and ((i+1-5) mod 5 =0) then response.write "</tr><tr>"
			next
			Response.write "<td><input Name='Subject' type='checkbox' value='总分'>总分</td>"
			if (i+1-5)>0 and ((i+1-5) mod 5 =0) then response.write "</tr><tr>"
			i=i+1
			Response.write "<td><input Name='Subject' type='checkbox' value='平均分'>平均分</td>"
			if (i+1-5)>0 and ((i+1-5) mod 5 =0) then response.write "</tr><tr>"
			i=i+1
			Response.write "<td><input Name='Subject' type='checkbox' value='全级排名'>全级排名</td>"
			if (i+1-5)>0 and ((i+1-5) mod 5 =0) then response.write "</tr><tr>"
			Response.write "<td><input Name='Subject' type='checkbox' value='班级排名'>班级排名</td>"
			response.Write("</tr></table>")
			rsSubject.Close()
			Set rsSubject = Nothing
			Call CloseSdmsConn
			%>	
		  </td>
		</tr>
		<tr align="center" valign="middle" class="tdbg">
		  <td height="16" colspan="2"><input name="SheetName" type="hidden" id="SheetName" value="<%=SheetName%>"><input name="action" type="hidden" id="action" value="ShowStep1Result"><input type="submit" name="Submit" value="下一步"></td>
		</tr>
	  </table>
	</form>
	<%
End Sub

Sub SearchStep2()
	Dim Subject
	StudentNum=ReplaceBadChar(Trim(Request("StudentNum")))
	StudentName=ReplaceBadChar(Trim(Request("StudentName")))
	Birthday=ReplaceBadChar(Trim(Request("Birthday")))
	Subject=ReplaceBadChar(Trim(Request("Subject")))

	If StudentNum="" Then
		FoundErr = True
		ErrMsg=ErrMsg&"<br><li>考号 不能为空！！！</li>"
		Exit Sub
	End If
	If StudentName="" Then
		FoundErr = True
		ErrMsg=ErrMsg&"<br><li>姓名不能为空！！！</li>"
		Exit Sub
	End If	
	If Birthday="" Then
		FoundErr = True
		ErrMsg=ErrMsg&"<br><li>生日不能为空！！！</li>"
		Exit Sub
	End If
	If Subject="" Then
		FoundErr = True
		ErrMsg=ErrMsg&"<br><li>所选科目不能为空！！！</li>"
		Exit Sub
	End If
	If Birthday<>"" And IsDate(Birthday) = False Then
		FoundErr = True
		ErrMsg=ErrMsg&"<br><li>输入的生日不是规则日期！！！</li>"
		Exit Sub
	End If
	Dim IsStudentInfoInclude
	Call OpenSdmsConn
	Set IsStudentInfoInclude=conn_Sdms.Execute ("SELECT StudentNum,Name FROM StudentInfo WHERE StudentNum ='" & StudentNum & "' And Name ='" & StudentName & "' And Birthday =#" & Birthday & "#")
	If IsStudentInfoInclude.Eof Then
		FoundErr = True
		ErrMsg=ErrMsg&"<br><li>不存在这个！！！</li><br><li>输入的考号 ，姓名，或者生日有误！</li>"
		Set IsStudentInfoInclude=Nothing
		Exit Sub
	End If
	Set IsStudentInfoInclude=Nothing
	%>
	<form Name="form1" action="ScoreQuery.asp" method="post">
	  <table width="600" class="border" border="0" cellspacing="1" cellpadding="4" align="center"> 
		<tr>  
		  <td height="50" colspan="2" align="center" class="title">  
			<p><b> 成 绩 查 询</b>（第二步）----按科目查询</p>        </td> 
		</tr>
		<tr>
		  <td width="30%" align="center" class="tdbg1">考号 ：</td>
		  <td width="70%" align="left" class="tdbg">
		  <%If StudentNum<>"" Then 
				Response.write StudentNum&"<input name='StudentNum' id='StudentNum' type='hidden' value='"&StudentNum&"'>"
			Else
				Response.write "不指定"
			End If%>
		  </td>
		</tr>
		<tr>
		  <td width="30%" align="center" class="tdbg1">姓名：</td>
		  <td width="70%" align="left" class="tdbg">
		  <%If StudentName<>"" Then 
				Response.write StudentName&"<input name='StudentName' id='StudentName' type='hidden' value='"&StudentName&"'>"
			Else
				Response.write "不指定"
			End If%>	  
		  </td>
		</tr>
		<tr>
		  <td width="30%" align="center" class="tdbg1">生日：</td>
		  <td width="70%" align="left" class="tdbg">
		  <%If Birthday<>"" Then 
				Response.write Birthday&"<input name='Birthday' id='Birthday' type='hidden' value='"&Birthday&"'>"
			Else
				Response.write "不指定"
			End If%>	  
		  </td>
		</tr>
		<tr valign="middle" class="tdbg"> 
		  <td width="30%" height="30" align="center" class="tdbg1">所选科目：</td>
		  <td width="70%" height="30"><%=Subject%></td>
		</tr>
		<tr align="left" valign="middle" class="tdbg"> 
		  <td width="30%" height="16" align="center" class="tdbg1">选择考试：</td>
		  <td width="70%" height="16">
			<%
            Set RsTest = Server.CreateObject("ADODB.Recordset")
            SqlSubject = "SELECT * FROM TestName"
            RsTest.Open SqlSubject, Conn_Sdms, 1, 1
            Set rsSubject = Server.CreateObject("ADODB.Recordset")
            response.Write ("<table border='0' cellspacing='0' cellpadding='3'><tr>")
            Do While Not RsTest.EOF
                
                rsSubject.Open "SELECT * FROM " & RsTest("SheetName"), Conn_Sdms, 1, 3
                For i = 5 To rsSubject.Fields.Count - 1
                    If rsSubject.Fields(i).Name = Subject Then
                        response.Write "<td><input type='checkbox' name='SheetName' value='" & RsTest("SheetName") & "'>" & RsTest("TestName") & "</td></tr><tr>"
                    End If
                Next
                rsSubject.Close

                RsTest.Movenext
            Loop
            response.Write ("</tr></table>")
            Set rsSubject = Nothing
            RsTest.Close
            Set RsTest = Nothing
            Call CloseSdmsConn
			%>	
		  </td>
		</tr>
		<tr align="center" valign="middle" class="tdbg">
		  <td height="16" colspan="2"><input name="Subject" type="hidden" id="Subject" value="<%=Subject%>"><input name="action" type="hidden" id="action" value="ShowStep2Result"><input type="submit" name="Submit" value="下一步"></td>
		</tr>
	  </table>
	</form>
	<%
End Sub

Sub ShowSearchResult1()
	Dim SheetName,strSubjects,SelectedSubject
	StudentNum=Trim(Request("StudentNum"))
	StudentName=Trim(Request("StudentName"))
	Birthday=Trim(Request("Birthday"))
	SheetName=ReplaceBadChar(Trim(Request("SheetName")))
	SelectedSubject=ReplaceBadChar(Request("Subject"))
	strSubjects = SheetName & "." & Replace(SelectedSubject,", ",", " & SheetName & ".")
	If SelectedSubject="" Then
		FoundErr = True
		ErrMsg=ErrMsg&"<br><li>至少要选择一个科目！！！</li>"
		Exit Sub
	End If
	If SheetName="" Then
		FoundErr = True
		ErrMsg=ErrMsg&"<br><li>所选考试不能为空！！！</li>"
		Exit Sub
	End If
	If StudentNum="" Then
		FoundErr = True
		ErrMsg=ErrMsg&"<br><li>考号 不能为空！！！</li>"
		Exit Sub
	End If
	If Birthday="" Then
		FoundErr = True
		ErrMsg=ErrMsg&"<br><li>生日不能为空！！！</li>"
		Exit Sub
	End If
	If StudentName="" Then
		FoundErr = True
		ErrMsg=ErrMsg&"<br><li>姓名不能为空！！！</li>"
		Exit Sub
	End If
	If Birthday<>"" And IsDate(Birthday) = False Then
		FoundErr = True
		ErrMsg=ErrMsg&"<br><li>输入的生日不是规则日期！！！</li>"
		Exit Sub
	End If
	%>
	<TABLE cellSpacing=0 cellPadding=0 width=700 align=center border=0>
	  <TR> 
		<TD valign="top" >
		  <br>
		  <b><font color="#FF0000">
			考试名称：</font></b>&nbsp;<%=SheetName%><font color="#FF0000"><b><font color="#0066cc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font></b></font><font color="#FF0000"><b>&nbsp;查询条件：</b></font> 
			考号 （<%If StudentNum<>"" Then 
			Response.write StudentNum
			Else
				Response.write "不指定"
			End If%>） 姓名（<%If StudentName<>"" Then 
				Response.write StudentName
			Else
				Response.write "不指定"
			End If%>） 生日（<%If Birthday<>"" Then 
				Response.write Birthday
			Else
				Response.write "不指定"
			End If%>）<br><br><%
			Dim rsScore,strSQL
			Call OpenSdmsConn
			set rsScore = Server.CreateObject("ADODB.Recordset")
			strSQL = "Select " & SheetName & ".StudentNum, StudentInfo.Name, " & strSubjects & " From " & SheetName
			strSQL = strSQL & " LEFT JOIN StudentInfo ON " & SheetName & ".StudentNum = StudentInfo.StudentNum"
			strSQL = strSQL & " Where " & SheetName & ".StudentNum ='" & ReplaceBadChar(StudentNum) & "'"
			strSQL = strSQL & " And StudentInfo.Name ='" & ReplaceBadChar(StudentName) & "'"
			strSQL = strSQL & " And StudentInfo.Birthday=#"&ReplaceBadChar(Birthday)&"#"

			'strSQL = strSQL & " ORDER BY " & SheetName & ".StudentNum ASC"
			rsScore.Open strSQL, conn_Sdms ,1 ,1
			If Not rsScore.EOF Or Not rsScore.BOF Then %>
			 <table class='border' border='0' cellspacing='1' cellpadding='4' align='center'>       
				<tr class="title"> 
				  <td width="50" align="center"><font color="#000000"><strong>学 号</strong></font></td>
				  <td width="45" align="center"><font color="#000000"><strong>姓 名</strong></font></td>
					<%Dim strTemp,ArrSubject,strSubject,SubjectCount,ScoreCount
					  strTemp = Trim(Request("Subject"))					  
					  ArrSubject = split(strTemp,",")					  
					  For i = LBound(ArrSubject) To UBound(ArrSubject)
						  strSubject=trim(ReplaceBadChar(ArrSubject(i)))
						  response.write "<td height='20' align='center'><font color='#000000'><b>" & strSubject & "</b></font></td>"
						  if strSubject<>"总分" and strSubject<>"平均分" and strSubject<>"全级排名" and strSubject<>"班级排名" then
							SubjectCount=SubjectCount+1
						  end if
					  next
					%>
				</tr>
				<% 
				While NOT rsScore.EOF 
					ScoreCount=0
					strName=trim(rsScore.Fields.Item("Name").Value)
					if strName="" then strName="&nbsp;"%>
					<tr class="tdbg" onmouseout=this.style.backgroundColor="" onmouseover=this.style.backgroundColor="#BFDFFF">   
					  <td height="20" align="center" nowrap><font color="#000000"><%=(rsScore.Fields.Item("StudentNum").Value)%></font></td>
					  <td height="20" align="center" nowrap><font color="#000000"><%=strName%></font></td>
					  <%
						  For i = LBound(ArrSubject) To UBound(ArrSubject)
							  strSubject=trim(ReplaceBadChar(ArrSubject(i)))
							  if strSubject="总分" then
								  strScore=ScoreCount
								  if strScore<60*SubjectCount then
									  strScore = "<font color='#ff0000'>" & strScore & "</font>"
								  elseif strScore>=60*SubjectCount and strScore<80*SubjectCount then
									  strScore = "<font color='#0000ff'>" & strScore & "</font>"
								  elseif strScore>=80*SubjectCount then
									  strScore = "<font color='#009900'>" & strScore & "</font>"
								  end if
							  elseif strSubject="全级排名" or strSubject="班级排名"	then
								  strScore=rsScore.Fields.Item(strSubject).Value
								  if IsNull(strScore) then strScore=0
							  else
								  if strSubject="平均分" then
									  strScore=Round(ScoreCount/SubjectCount,1)
								  else
									  strScore=rsScore.Fields.Item(strSubject).Value
									  if IsNull(strScore) then strScore=0
									  ScoreCount=ScoreCount+strScore
								  end if
								  if strScore<60 then
									  strScore = "<font color='#ff0000'>" & strScore & "</font>"
								  elseif strScore>=60 and strScore<80 then
									  strScore = "<font color='#0000ff'>" & strScore & "</font>"
								  elseif strScore>=80 then
									  strScore = "<font color='#009900'>" & strScore & "</font>"
								  end if
							  end if
							  response.write "<td height='20' align='center'>" & strScore & "</td>"
						  next						  
						  response.write "</tr>"
						  rsScore.MoveNext()
					  Wend
				  rsScore.Close()
				  Set rsScore = Nothing
				  Call CloseSdmsConn
				  %>
			  </table><% 
		  Else 
			  FoundErr = True
			  ErrMsg=ErrMsg&"<br><li>找不到符合条件的记录！！！</li>"
			  rsScore.Close()
			  Set rsScore = Nothing
			  Call CloseSdmsConn
			  Exit Sub
		  End If 
			%><br><br><br><div align=center><a href="javascript:window.close();">【关闭】</a></div>			
		</TD>
	  </TR>
	</TABLE><%
End Sub

Sub ShowSearchResult2()
	Dim strSubjects
	StudentNum=Trim(Request("StudentNum"))
	StudentName=Trim(Request("StudentName"))
	Birthday=Trim(Request("Birthday"))
	strSubject=Trim(Request("Subject"))
	If strSubject="" Then
		FoundErr = True
		ErrMsg=ErrMsg&"<br><li>所选科目不能为空！！！</li>"
		Exit Sub
	End If
	If StudentNum="" Then
		FoundErr = True
		ErrMsg=ErrMsg&"<br><li>考号 不能为空！！！</li>"
		Exit Sub
	End If
	If Birthday="" Then
		FoundErr = True
		ErrMsg=ErrMsg&"<br><li>生日不能为空！！！</li>"
		Exit Sub
	End If
	If StudentName="" Then
		FoundErr = True
		ErrMsg=ErrMsg&"<br><li>姓名不能为空！！！</li>"
		Exit Sub
	End If
	If Birthday<>"" And IsDate(Birthday) = False Then
		FoundErr = True
		ErrMsg=ErrMsg&"<br><li>输入的生日不是规则日期！！！</li>"
		Exit Sub
	End If
	%>
	<TABLE cellSpacing=0 cellPadding=0 width=700 align=center border=0>
	  <TR> 
		<TD valign="top" ><font size="5">&nbsp;</font><br>
		  <b>
		  <font color="#FF0000">科目名称：</font></b>&nbsp;<%=strSubject%><font color="#FF0000"><b><font color="#0066cc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font></b></font><font color="#FF0000"><b>&nbsp;查询条件：</b></font> 
            考号 （<%If StudentNum<>"" Then 
	  		Response.write StudentNum
			Else
				Response.write "不指定"
			End If%>） 姓名（<%If StudentName<>"" Then 
				Response.write StudentName
			Else
				Response.write "不指定"
			End If%>） 生日（<%If Birthday<>"" Then 
				Response.write Birthday
			Else
				Response.write "不指定"
			End If%>）<br><br><%
			Dim Sql,Recordset1
			Call OpenSdmsConn
			set Recordset1 = Server.CreateObject("ADODB.Recordset")
			Sql = "SELECT StudentNum,Name FROM StudentInfo WHERE 1=1"
			Sql =Sql& " And StudentNum ='" & ReplaceBadChar(StudentNum) & "'"
			Sql =Sql& " And Name ='" & ReplaceBadChar(StudentName) & "'"
			Sql =Sql& " And Birthday =#" & ReplaceBadChar(Birthday) & "#"

			'Sql =Sql& " ORDER BY StudentNum Asc"
			Recordset1.Open Sql, conn_Sdms, 1, 1

			If Not Recordset1.EOF Or Not Recordset1.BOF Then %>
				<table class='border' border='0' cellspacing='1' cellpadding='4' align='center'>
				  <tr valign="middle" class="title"> 		   
					<td width="60" rowspan="2" align="center">学 号</td>
					<td width="50" rowspan="2" align="center">姓 名</td>
					<%
					Dim strTemp,arrSheetName,strSheetName
					Dim rsSubjects()

					strTemp = Trim(Request("SheetName"))
					arrSheetName = split(strTemp,",")

					Redim rsSubjects(Ubound(arrSheetName)+1)
		  
					For i = LBound(arrSheetName) To UBound(arrSheetName)
						strSheetName=trim(ReplaceBadChar(arrSheetName(i)))
						Dim rsTestName__MMColParam,strTestName
						rsTestName__MMColParam=strSheetName
						Dim rsTestName,sqlTestName
						set rsTestName = Server.CreateObject("ADODB.Recordset")
						sqlTestName = "SELECT SheetName, TestName FROM TestName WHERE SheetName = '" + Replace(rsTestName__MMColParam, "'", "''") + "'"
						rsTestName.Open sqlTestName,conn_Sdms, 1, 1
						strTestName=rsTestName.Fields.Item("TestName")
						rsTestName.close
						set rsTestName = Nothing
						
						strTestName=left(strTestName,len(strTestName)\2) & "<br>" & mid(strTestName,len(strTestName)\2+1,len(strTestName))
						response.write "<td height='20' align='center'>" & strTestName & "</td>"
					next
					%>
				  </tr>
				  <tr align="center" valign="middle" class="tdbg1"> 
					<%
					For i = LBound(arrSheetName) To UBound(arrSheetName)
						if strSubject<>"全级排名" and strSubject<>"班级排名" then
							response.write "<td height='20' align='center'>"&strSubject&"成绩</td>"
						else
							response.write "<td height='20' align='center'>名次</td>"
						end if	
					next
				  %>
				  </tr>
				  <% 
					While NOT Recordset1.EOF 
						For i = LBound(arrSheetName) To UBound(arrSheetName)
							strSheetName=trim(ReplaceBadChar(arrSheetName(i)))
							set rsSubjects(i) = Server.CreateObject("ADODB.Recordset")
							rsSubjects__MMColParam =ReplaceBadChar(Recordset1.Fields.Item("StudentNum"))
							sqlSubjects = "SELECT " & ReplaceBadChar(strSubject) & " FROM " & strSheetName & " WHERE StudentNum = '" + Replace(rsSubjects__MMColParam,"'","''") + "'"
							rsSubjects(i).Open sqlSubjects,conn_Sdms,1,1
						next
						%>
						<tr class="tdbg" onmouseout=this.style.backgroundColor="" onmouseover=this.style.backgroundColor="#BFDFFF">  
						  <td height="20" nowrap align="center"><%=(Recordset1.Fields.Item("StudentNum").Value)%></td>
						  <td height="20" nowrap align="center"><%=(Recordset1.Fields.Item("Name").Value)%></td>
							<%
							For i = LBound(arrSheetName) To UBound(arrSheetName)
								if rsSubjects(i).bof or  rsSubjects(i).eof then
									strScore=0
								else
									strScore=rsSubjects(i).Fields.Item(strSubject).Value
									if IsNull(strScore) then strScore=0
								end if
								rsSubjects(i).Close
								set rsSubjects(i) = Nothing
								
								strScore = "<font color='#009900'>" & strScore & "</font>"

								response.write "<td height='20' align='center'>" & strScore & "</td>"
							next%>
						</tr>
						<% 
						Recordset1.MoveNext()
					Wend
					Recordset1.Close()
				    Set Recordset1 = Nothing
				    Call CloseSdmsConn%>
				</table><%
		    Else 
			    FoundErr = True
			    ErrMsg=ErrMsg&"<br><li>找不到符合条件的记录！！！</li>"
				Recordset1.Close()
				Set Recordset1 = Nothing
				Call CloseSdmsConn
			    Exit Sub
		    End If%><br><br><br><div align=center><a href="javascript:window.close();">【关闭】</a></div>		
	    </TD>
	  </TR>
	</TABLE><%
End Sub
%>
