<!--#include file="Admin_CommonCode_SDMS.asp"-->
<%
'**************************************************************
' Software name: PowerEasy SiteWeaver
' Web: http://www.powereasy.net
' Copyright (C) 2005－2009 佛山市动易网络科技有限公司 版权所有
'**************************************************************

Const NeedCheckComeUrl = True   '是否需要检查外部访问

Const PurviewLevel = 2      '0--不检查，1--超级管理员，2--普通管理员
Const PurviewLevel_Channel = 0   '0--不检查，1--频道管理员，2--栏目总编，3--栏目管理员
Const PurviewLevel_Others = "ScoreManage"   '其他权限

If Action <> "ScorePrintStep1_1_1" And Action <> "ScorePrintStep1_1_2" And Action <> "ScorePrintStep1_2_1" Then
    Response.Write "<html><head><title>修改/删除学生信息</title>" & vbCrLf
    Response.Write "<meta http-equiv='Content-Type' content='text/html; charset=gb2312'>" & vbCrLf
    Response.Write "<link href='Admin_Style.css' rel='stylesheet' type='text/css'>" & vbCrLf
    Response.Write "<link href='home.css' rel='stylesheet' type='text/css'>" & vbCrLf
    Response.Write "</head>" & vbCrLf
    Response.Write "<body leftmargin='2' topmargin='0' marginwidth='0' marginheight='0'>" & vbCrLf
    Response.Write "<table width='100%' border='0' align='center' cellpadding='2' cellspacing='1' class='border'>" & vbCrLf
    Call ShowPageTitle("学 生 成 绩 管 理", 10302)
    Response.Write "  <tr class='tdbg'>" & vbCrLf
    Response.Write "    <td width='70' height='30'><strong>管理导航：</strong></td>" & vbCrLf
    Response.Write "    <td width='617' >" & vbCrLf
    Response.Write "  <a href='Admin_ScoreManage.asp'>成绩管理主界面</a>&nbsp;|&nbsp;<a href='Admin_ScoreManage.asp?Action=ScoreInputStep1'>录入成绩 </a>&nbsp;|&nbsp;<a href='Admin_ScoreManage.asp?Action=ScoreQueryStep1'>查询成绩 </a>&nbsp;|&nbsp;<a href='Admin_ScoreManage.asp?Action=ScoreModifyQuery'>修改/删除成绩 </a>&nbsp;|&nbsp;<a href='Admin_ScoreManage.asp?Action=ScorePrintStep1'>打印成绩 </a>&nbsp;|&nbsp;<a href='Admin_ScoreManage.asp?Action=ScoreOrder'>计算总分与排名</a>&nbsp;|&nbsp;<a href='Admin_ScoreManage.asp?Action=TargetManage'>目标分管理</a>" & vbCrLf
    Response.Write "    </td>" & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "</table>" & vbCrLf
End If
Call OpenSdmsConn
Select Case Action
'学生成绩的录入
Case "ScoreInputStep1"
    Call ScoreInputStep1
Case "ScoreInputStep2"
    Call ScoreInputStep2
'学生成绩的录入------单条记录方式
Case "ScoreInput1"
    Call ScoreInput1
'学生成绩的录入-------列表方式
Case "ScoreInput2"
    Call ScoreInput2

'学生成绩的查询
Case "ScoreQueryStep1"
    Call ScoreQueryStep1
'学生成绩的查询-------按考试查询方式
Case "ScoreQueryStep1_1"
    Call ScoreQueryStep1_1
Case "ScoreQueryStep1_1_1"
    Call ScoreQueryStep1_1_1
Case "ScoreQueryStep1_1_2"
    Call ScoreQueryStep1_1_2
'学生成绩的查询-------按科目查询方式
Case "ScoreQueryStep1_2"
    Call ScoreQueryStep1_2
Case "ScoreQueryStep1_2_1"
    Call ScoreQueryStep1_2_1

'学生成绩的修改/删除
Case "ScoreModifyQuery"
    Call ScoreModifyQuery
'学生成绩的修改/删除------查询结果主界面
Case "ScoreModifyQueryResult"
    Call ScoreModifyQueryResult
'学生成绩的修改/删除------修改及保存
Case "ScoreModify"
    Call ScoreModify
Case "SaveScoreModify"
    Call SaveScoreModify
'学生成绩的修改/删除------删除及批量删除
Case "DelScore"
    Call DelScore
Case "BatchDelScore"
    Call BatchDelScore

'打印成绩
Case "ScorePrintStep1"
    Call ScorePrintStep1
'按考试打印成绩
Case "ScorePrintStep1_1"
    Call ScorePrintStep1_1
Case "ScorePrintStep1_1_1"
    Call ScorePrintStep1_1_1
Case "ScorePrintStep1_1_2"
    Call ScorePrintStep1_1_2
'按科目打印成绩
Case "ScorePrintStep1_2"
    Call ScorePrintStep1_2
Case "ScorePrintStep1_2_1"
    Call ScorePrintStep1_2_1

'计算总分与排名
Case "ScoreOrder"
    Call ScoreOrder
Case "ScoreOrderCalculate"
    Call ScoreOrderCalculate
Case "ScoreOrderResult"
    Call ScoreOrderResult

'学生目标分管理
Case "TargetManage"
    Call TargetManage
Case "TargetManageMain"
    Call TargetManageMain
Case "TargetModify"
    Call TargetModify
Case "SaveTargetModify"
    Call SaveTargetModify
Case "TargetDel"
    Call TargetDel
    
Case Else
    Call main
End Select

If FoundErr = True Then
    Call WriteErrMsg(ErrMsg, ComeUrl)
End If
Response.Write "</body></html>"
Call CloseSdmsConn
Call CloseConn


Sub main()
    Response.Write "<table width='100%' border='0' align='center' cellpadding='0' cellspacing='0'>" & vbCrLf
    Response.Write "  <tr> " & vbCrLf
    Response.Write "     " & vbCrLf
    Response.Write "    <td valign='top'> <table width='100%' border='0' cellspacing='8' cellpadding='0'>" & vbCrLf
    Response.Write "        <tr> " & vbCrLf
    Response.Write "          <td> <p><br>" & vbCrLf
    Response.Write "              &nbsp;&nbsp;&nbsp;&nbsp;本模块主要是对学生成绩进行管理。本模块又分为录入学生成绩、查询学生成绩、修改/删除学生成绩、打印学生成绩、计算总分与排名、目标分管理六个子模块：<br>" & vbCrLf
    Response.Write "            </p>" & vbCrLf
    Response.Write "            <table width='100%' border='0' cellspacing='0' cellpadding='0'>" & vbCrLf
    Response.Write "              <tr align='center'> " & vbCrLf
    Response.Write "                <td><a href='Admin_ScoreManage.asp?Action=ScoreInputStep1'>" & vbCrLf
    Response.Write "                <img src='images/ScoreInput_A.JPG' width='150' height='113' border='0' onMouseOver=""this.src='images/ScoreInput_B.jpg';"" onMouseOut=""this.src='images/ScoreInput_A.jpg';"">" & vbCrLf
    Response.Write "                <br>" & vbCrLf
    Response.Write "                  录入学生成绩</a>" & vbCrLf
    Response.Write "                  </td>" & vbCrLf
    Response.Write "                <td><a href='Admin_ScoreManage.asp?Action=ScoreQueryStep1'>" & vbCrLf
    Response.Write "                <img src='images/ScoreQuery_A.JPG' width='150' height='113' border='0' onMouseOver=""this.src='images/ScoreQuery_B.jpg';"" onMouseOut=""this.src='images/ScoreQuery_A.jpg';"">" & vbCrLf
    Response.Write "                <br>" & vbCrLf
    Response.Write "                  查询学生成绩</a>" & vbCrLf
    Response.Write "                  </td>" & vbCrLf
    Response.Write "                <td><a href='Admin_ScoreManage.asp?Action=ScoreModifyQuery'>" & vbCrLf
    Response.Write "                <img src='images/ScoreModifyDel_A.JPG' width='150' height='113' border='0' onMouseOver=""this.src='images/ScoreModifyDel_B.jpg';"" onMouseOut=""this.src='images/ScoreModifyDel_A.jpg';"">" & vbCrLf
    Response.Write "                <br>" & vbCrLf
    Response.Write "                  修改/删除学生成绩</a>" & vbCrLf
    Response.Write "                  </td>" & vbCrLf
    Response.Write "              </tr>" & vbCrLf
    Response.Write "              <tr align='center'> " & vbCrLf
    Response.Write "                <td height='25'>&nbsp;</td>" & vbCrLf
    Response.Write "                <td height='25'>&nbsp;</td>" & vbCrLf
    Response.Write "                <td>&nbsp;</td>" & vbCrLf
    Response.Write "              </tr>" & vbCrLf
    Response.Write "              <tr> " & vbCrLf
    Response.Write "                <td align='center'><a href='Admin_ScoreManage.asp?Action=ScorePrintStep1'>" & vbCrLf
    Response.Write "                <img src='images/ScorePrint_A.JPG' width='150' height='113' border='0' onMouseOver=""this.src='images/ScorePrint_B.jpg';"" onMouseOut=""this.src='images/ScorePrint_A.jpg';"">" & vbCrLf
    Response.Write "                <br>" & vbCrLf
    Response.Write "                  打印学生成绩</a>" & vbCrLf
    Response.Write "                  </td>" & vbCrLf
    Response.Write "                <td align='center'><a href='Admin_ScoreManage.asp?Action=ScoreOrder'>" & vbCrLf
    Response.Write "                <img src='images/ScoreOrder_A.JPG' width='150' height='113' border='0' onMouseOver=""this.src='images/ScoreOrder_B.jpg';"" onMouseOut=""this.src='images/ScoreOrder_A.jpg';"">" & vbCrLf
    Response.Write "                <br>" & vbCrLf
    Response.Write "                  计算总分与排名</a>" & vbCrLf
    Response.Write "                  </td>" & vbCrLf
    Response.Write "                <td align='center'><a href='Admin_ScoreManage.asp?Action=TargetManage'>" & vbCrLf
    Response.Write "                <img src='images/TargetManage_A.JPG' width='150' height='113' border='0' onMouseOver=""this.src='images/TargetManage_B.jpg';"" onMouseOut=""this.src='images/TargetManage_A.jpg';"">" & vbCrLf
    Response.Write "                <br>" & vbCrLf
    Response.Write "                  目标分管理</a>" & vbCrLf
    Response.Write "                  </td>" & vbCrLf
    Response.Write "              </tr>" & vbCrLf
    Response.Write "            </table>" & vbCrLf
    Response.Write "            <ul>" & vbCrLf
    Response.Write "              <li><a href='Admin_ScoreManage.asp?Action=ScoreInputStep1'>录入学生成绩</a>模块：<br>" & vbCrLf
    Response.Write "                &nbsp;&nbsp;&nbsp;&nbsp;录入某次考试中一科或多科的成绩。提供两种录入方式：单条记录方式和列表方式。单条记录方式比较简单，但不容易出错。列表方式提供了批量录入的功能，可以一次性录入所有成绩，但容易出错。<br>" & vbCrLf
    Response.Write "                <br>" & vbCrLf
    Response.Write "              </li>" & vbCrLf
    Response.Write "              <li><a href='Admin_ScoreManage.asp?Action=ScoreQueryStep1'>查询学生成绩</a>模块：<br>" & vbCrLf
    Response.Write "                &nbsp;&nbsp;&nbsp;&nbsp;提供两种方式查询学生成绩：按考试查询和按科目查询。按考试查询是指首先选择要查询成绩的考试名称，然后查询这一次考试中的某一科或多科的成绩，这种方式适合某一次考试的横向比较；按科目查询是指首先选择要查询成绩的某一科目，然后查询这一科的某次或多次考试的成绩，这种方式适合科任老师对学生几次考试的成绩进行纵向比较。<br>" & vbCrLf
    Response.Write "                <br>" & vbCrLf
    Response.Write "              </li>" & vbCrLf
    Response.Write "              <li><a href='Admin_ScoreManage.asp?Action=ScoreModifyQuery'>学生成绩修改/删除</a>模块：<br>" & vbCrLf
    Response.Write "                &nbsp;&nbsp;&nbsp;&nbsp;修改/删除某次考试中某个学生的成绩。<br>" & vbCrLf
    Response.Write "                <br>" & vbCrLf
    Response.Write "              </li>" & vbCrLf
    Response.Write "              <li><a href='Admin_ScoreManage.asp?Action=ScoreOrder'>计算总分与排名</a>模块：<br>" & vbCrLf
    Response.Write "                自动计算各科总分并按照总分进行全级排名与班级排名，然后把排名结果显示出来。<br>" & vbCrLf
    Response.Write "                <br>" & vbCrLf
    Response.Write "              </li>" & vbCrLf
    Response.Write "              <li><a href='Admin_ScoreManage.asp?Action=TargetManage'>目标分管理</a>模块：<br>" & vbCrLf
    Response.Write "                &nbsp;&nbsp;&nbsp;&nbsp;对目标分进行录入/修改/删除等操作。这一功能是根据我校实际情况而设计的，操作与成绩管理基本相似。因为现在不允许对学生排名，但又要对学生进行评价，所以我校采用了目标分管理的方法，根据学生的实际情况给每个学生制定了一个目标分，然后进行达标/不达标的评价方法。</li>" & vbCrLf
    Response.Write "            </ul>" & vbCrLf
    Response.Write "            &nbsp;&nbsp;&nbsp;&nbsp;其中，学生成绩查询不需登录即可使用，其他模块则需要先登录后才能使用。<br>" & vbCrLf
    Response.Write "          </td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "      </table>" & vbCrLf
    Response.Write "     " & vbCrLf
    Response.Write "  </tr></table>" & vbCrLf
End Sub

Sub ScoreInputStep1()
    Response.Write "<br><br>" & vbCrLf
    Response.Write "<table width='100%' class='border' border='0' cellspacing='1' cellpadding='4' align='center'> " & vbCrLf
    Response.Write "  <tr>  " & vbCrLf
    Response.Write "    <td align='center' class='title' colspan='2'>  " & vbCrLf
    Response.Write "      <b>学 生 成 绩 录 入</b> " & vbCrLf
    Response.Write "    (第一步)----选择考试</td> " & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "<form Name='form1' action='Admin_ScoreManage.asp?Action=ScoreInputStep2' method='post'> " & vbCrLf
    Response.Write " <tr class='tdbg'>" & vbCrLf
    Response.Write "                    <td width='32%' height='40' align='right'>" & vbCrLf
    Response.Write "                    <strong>请选择考试：</strong>" & vbCrLf
    Response.Write "                    </td>" & vbCrLf
    Response.Write "                    <td width='68%'> <select Name='sheetName'>" & vbCrLf
    Response.Write "" & vbCrLf
    Dim Recordset1, i
    Set Recordset1 = Server.CreateObject("ADODB.Recordset")
    Recordset1.Open "SELECT * FROM TestName ORDER BY ID DESC", Conn_Sdms, 1, 3
    i = 0
    While (Not Recordset1.EOF)
        If i = 0 Then
            Response.Write "<option value='" & Recordset1.Fields.Item("SheetName").value & "' selected>" & Recordset1.Fields.Item("TestName").value & "</option>"
        Else
            Response.Write "<option value='" & Recordset1.Fields.Item("SheetName").value & "'>" & Recordset1.Fields.Item("TestName").value & "</option>"
        End If
        i = i + 1
        Recordset1.MoveNext
    Wend

    Response.Write "                      </select> <font color='#FF0000'>*</font></td>" & vbCrLf
    Response.Write "                  </tr>" & vbCrLf
    Response.Write "                  <tr class='tdbg'> " & vbCrLf
    Response.Write "                    <td height='43' colspan='2' align='center'><input type='submit' Name='Submit' value='下一步'></td>" & vbCrLf
    Response.Write "                  </tr>" & vbCrLf
    Response.Write "" & vbCrLf
    Response.Write "              </form>" & vbCrLf
    Response.Write "</TABLE" & vbCrLf
    Response.Write "" & vbCrLf

    Recordset1.Close
    Set Recordset1 = Nothing
End Sub

Sub ScoreInputStep2()
    Response.Write "<script language=""JavaScript"">" & vbCrLf
    Response.Write "function check()" & vbCrLf
    Response.Write "{" & vbCrLf
    Response.Write "var total=0;" & vbCrLf
    Response.Write "var intmax=document.form1.chkbox.length;" & vbCrLf
    Response.Write "if(intmax>1){" & vbCrLf
    Response.Write "  for(var idx=0;idx<intmax;idx++){" & vbCrLf
    Response.Write "    if(eval(""document.form1.chkbox["" + idx + ""].checked"")==true){" & vbCrLf
    Response.Write "      total+=1;" & vbCrLf
    Response.Write "    }" & vbCrLf
    Response.Write "  }" & vbCrLf
    Response.Write "  if(total==0){" & vbCrLf
    Response.Write "    alert(""您未选择任何科目！"");" & vbCrLf
    Response.Write "    document.form1.chkbox[0].focus();" & vbCrLf
    Response.Write "    return false;" & vbCrLf
    Response.Write "  }" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "else{" & vbCrLf
    Response.Write "  if(document.form1.chkbox.checked==false){" & vbCrLf
    Response.Write "    alert(""您未选择任何科目！"");" & vbCrLf
    Response.Write "    document.form1.chkbox.focus();" & vbCrLf
    Response.Write "    return false;" & vbCrLf
    Response.Write "  }" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "document.form1.action=""Admin_ScoreManage.asp?Action=ScoreInput""+document.form1.InputType.options.value;" & vbCrLf
    Response.Write "return true;" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "</script>" & vbCrLf
    Response.Write "<script language=""JavaScript"" type=""text/JavaScript"">" & vbCrLf
    Response.Write "function ChangeClass(num)" & vbCrLf
    Response.Write "{" & vbCrLf
    Response.Write "    var i;" & vbCrLf
    Response.Write "    var j;" & vbCrLf
    Response.Write "    for(i=document.form1.ClassSelect.options.length-1;i>=0;i--)" & vbCrLf
    Response.Write "    {" & vbCrLf
    Response.Write "        document.form1.ClassSelect.options[i]=null;" & vbCrLf
    Response.Write "    }" & vbCrLf
    Response.Write "" & vbCrLf
    Response.Write "    for(j=0;j<document.Classes.all(""Grade""+num).options.length;j++)" & vbCrLf
    Response.Write "    {" & vbCrLf
    Response.Write "        document.form1.ClassSelect.options[j]=new Option(document.Classes.all(""Grade""+num).options[j].text,document.Classes.all(""Grade""+num).options[j].value);" & vbCrLf
    Response.Write "    }" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "</script>" & vbCrLf
    Response.Write "" & vbCrLf

    Response.Write "<div id='Layer1' style='position:absolute; left:445px; top:220px; width:188px; height:64px; z-index:1; visibility: hidden;'> " & vbCrLf
    Response.Write GetClass_Option(0)
    Response.Write "</div>" & vbCrLf
    Dim Recordset1
    Dim strSheetName
    strSheetName = ReplaceBadChar(Trim(Request("SheetName")))
    If Request("SheetName") = "" Then
        Response.Write "<br><br>未选择任何考试,请先添加考试!!"
        Response.End
    End If

    Set Recordset1 = Server.CreateObject("ADODB.Recordset")
    Recordset1.Open "SELECT Top 1 * FROM " & strSheetName, Conn_Sdms, 1, 3

    Response.Write "<br>" & vbCrLf
    Response.Write "<table width='100%' class='border' border='0' cellspacing='1' cellpadding='4' align='center'> " & vbCrLf
    Response.Write "  <tr>  " & vbCrLf
    Response.Write "    <td align='center' class='title' colspan='3'>  " & vbCrLf
    Response.Write "      <b>学 生 成 绩 录 入(第二步)----请输入查询条件并选择科目</b> " & vbCrLf
    Response.Write "    </td> " & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write " <form Name='form1'  onSubmit='return check()' action='Admin_ScoreManage.asp?Action=ScoreInput1' method='post'>" & vbCrLf
    Response.Write "                  <tr class='tdbg'> " & vbCrLf
    Response.Write "                    <td width='160' align='right'>" & vbCrLf
    Response.Write "                    <strong>考试名称：</strong>" & vbCrLf
    Response.Write "                    </td>" & vbCrLf
    Dim Recordset2
    Set Recordset2 = Server.CreateObject("ADODB.Recordset")
    Recordset2.Open "SELECT * FROM TestName WHERE SheetName = '" & strSheetName & "'", Conn_Sdms, 1, 3
    Response.Write "                    <td colspan='2'> " & Recordset2("TestName")
    Recordset2.Close
    Set Recordset2 = Nothing
    Response.Write "                    <input name='SheetName' type='hidden' value='" & strSheetName & "'>" & vbCrLf
    Response.Write "                    </td>" & vbCrLf
    Response.Write "                  </tr>" & vbCrLf
    Response.Write "                  <tr class='tdbg'> " & vbCrLf
    Response.Write "                    <td width='160' align='right'><strong>请输入查询条件：</strong><br> " & vbCrLf
    Response.Write "                      <br>" & vbCrLf
    Response.Write "                    （可从学号或班级两种查询方法任选其一进行查询）</td>" & vbCrLf
    Response.Write "                    <td nowrap>学号： " & vbCrLf
    Response.Write "                      <input type='text' Name='StudentNum' maxlength='8' size='18'> " & vbCrLf
    Response.Write "                      <br> <br>" & vbCrLf
    Response.Write "                      班级： " & vbCrLf
    Response.Write "                      <select name='Grade' onChange=""ChangeClass(this.value)"">" & vbCrLf
    Response.Write "" & vbCrLf
    Response.Write GetGrade_Option
    Response.Write "                      </select> " & vbCrLf
    Response.Write "                      <select name='ClassSelect'>" & vbCrLf
    Response.Write "                        <option value='All' selected>全级</option>" & vbCrLf
    Response.Write "" & vbCrLf

    Dim RsFirst, FirstGradeID, Rsin, Sqlin, i
    Set RsFirst = Conn_Sdms.Execute("select top 1 GradeID from Grade order by OrderID asc")
    FirstGradeID = RsFirst("GradeID")
    Set RsFirst = Nothing
    Set Rsin = Server.CreateObject("ADODB.REcordset")
    Sqlin = "select * from Class where GradeID=" & FirstGradeID & " order by OrderID asc"
    Rsin.Open Sqlin, Conn_Sdms, 1, 3
    Do While Not Rsin.EOF
        Response.Write "<option value='" & Rsin("ClassID") & "' >" & Rsin("ClassName") & "</option>"
        Rsin.MoveNext
    Loop
    Set Rsin = Nothing


    Response.Write "                      </select> " & vbCrLf
    Response.Write "                      </td>" & vbCrLf
    Response.Write "                    <td><b>" & vbCrLf
    Response.Write "                    <font color='#0066cc'>注：</font>" & vbCrLf
    Response.Write "                    </b>" & vbCrLf
    Response.Write "                    <br>" & vbCrLf
    Response.Write "                      　　1 、若输入了学号，则优先按学号进行查询。 <br> " & vbCrLf
    Response.Write "                      <font color='#FF0000'>　　2、支持模糊查询！</font>" & vbCrLf
    Response.Write "                      <br>" & vbCrLf
    Response.Write "                      例如：<br> &nbsp;&nbsp;&nbsp;&nbsp;在学号查询框中输入2001，则查询结果为学号中包含“2001”的学生</td>" & vbCrLf
    Response.Write "                  </tr>" & vbCrLf
    Response.Write "                  <tr class='tdbg'> " & vbCrLf
    Response.Write "                    <td width='160' align='right'><strong>请选择科目：</strong></td>" & vbCrLf
    Response.Write "                    <td colspan='2'> <table border='0' cellspacing='5' cellpadding='0'>" & vbCrLf
    Response.Write "                        <tr class='tdbg'>" & vbCrLf
    Response.Write "" & vbCrLf

    For i = 5 To Recordset1.Fields.Count - 1
        Response.Write "<td width='80'><input Name='chkbox' type='checkbox' value='" & Recordset1.Fields(i).name & "'>" & Recordset1.Fields(i).name & "</td>"
        If (i + 1 - 5) > 0 And ((i + 1 - 5) Mod 5 = 0) Then Response.Write "</tr><tr>"
    Next
                       
    Response.Write "                        </tr>" & vbCrLf
    Response.Write "                      </table></td>" & vbCrLf
    Response.Write "                  </tr>" & vbCrLf
    Response.Write "                  <tr class='tdbg'> " & vbCrLf
    Response.Write "                    <td width='160' align='right'><strong>请选择录入方式：</strong></td>" & vbCrLf
    Response.Write "                    <td colspan='2'><select name='InputType'>" & vbCrLf
    Response.Write "                        <option value='1' selected>单条记录方式</option>" & vbCrLf
    Response.Write "                        <option value='2'>列表方式</option>" & vbCrLf
    Response.Write "                      </select></td>" & vbCrLf
    Response.Write "                  </tr>" & vbCrLf
    Response.Write "                  <tr align='center' class='tdbg'> " & vbCrLf
    Response.Write "                    <td height='43' colspan='3'><input type='submit' Name='Submit' value='下一步'></td>" & vbCrLf
    Response.Write "                  </tr>" & vbCrLf
    Response.Write "  </form>          " & vbCrLf
    Response.Write "</TABLE>" & vbCrLf
    Response.Write "" & vbCrLf
    Recordset1.Close
    Set Recordset1 = Nothing
End Sub

Sub ScoreInput1()
    Dim strFileName, tmpSheetName, tmpStudentNum, fieldsStr, MM_columnsStr, MM_fields, MM_columns, MM_tableValues
    Dim MM_dbValues, FormVal, MM_typeArray, Delim, AltVal, EmptyVal, MM_editColumn, MM_recordId, MM_editQuery
    Dim i, j, intRows, strTemp, strSubject

    If Trim(Request.Form("InputScore")) <> "" And Trim(Request.Form("StudentNum")) = "" Then
        Dim MM_editRedirectUrl
        MM_editRedirectUrl = "Admin_ScoreManage.asp?" & Session("strQureyString")
        Response.Redirect MM_editRedirectUrl
    End If

    If (Trim(Request.Form("InputScore")) <> "" And Trim(Request.Form("StudentNum")) <> "") Then
        tmpSheetName = Request("SheetName")
        If InStr(Request.Form("StudentNum"), ",") > 0 Then
            tmpStudentNum = Left(Request.Form("StudentNum"), InStr(Request.Form("StudentNum"), ",") - 1)
        Else
            tmpStudentNum = Request.Form("StudentNum")
        End If
        '通过判断学号是否存在来检查是否已录入任何一科成绩
        Dim rsKey
        Set rsKey = Server.CreateObject("ADODB.Recordset")
        rsKey.Open "SELECT Top 1 * FROM " & tmpSheetName & " WHERE StudentNum='" & tmpStudentNum & "'", Conn_Sdms, 1, 3

        If Not rsKey.EOF Or Not rsKey.BOF Then
        ' 如果已录入任何一科成绩，则进行更新记录操作
            'Call UpdateRecord(tmpStudentNum)
            MM_editColumn = "StudentNum"
            MM_recordId = "'" & ReplaceBadChar(tmpStudentNum) & "'"
            fieldsStr = Request.Form("Subject")
            MM_columnsStr = Replace(fieldsStr, "value", "',none,''")

            MM_fields = Split(fieldsStr, "|")
            MM_columns = Split(MM_columnsStr, "|")

            
            For i = LBound(MM_fields) To UBound(MM_fields) Step 2
                MM_fields(i + 1) = ReplaceBadChar(Request.Form(MM_fields(i))) & ""
                If MM_fields(i + 1) = "" Then MM_fields(i + 1) = "0"
            Next
            MM_editQuery = "update " & tmpSheetName & " set "
            For i = LBound(MM_fields) To UBound(MM_fields) Step 2
                FormVal = MM_fields(i + 1)
                MM_typeArray = Split(MM_columns(i + 1), ",")
                Delim = MM_typeArray(0)
                If (Delim = "none") Then Delim = ""
                AltVal = MM_typeArray(1)
                If (AltVal = "none") Then AltVal = ""
                EmptyVal = MM_typeArray(2)
                If (EmptyVal = "none") Then EmptyVal = ""
                If (FormVal = "") Then
                    FormVal = EmptyVal
                Else
                    If (AltVal <> "") Then
                        FormVal = AltVal
                    ElseIf (Delim = "'") Then  ' escape quotes
                        FormVal = "'" & Replace(FormVal, "'", "''") & "'"
                    Else
                        FormVal = Delim + FormVal + Delim
                    End If
                End If
                If (i <> LBound(MM_fields)) Then
                    MM_editQuery = MM_editQuery & ","
                End If
                MM_editQuery = MM_editQuery & MM_columns(i) & " = " & FormVal
            Next
            Conn_Sdms.Execute MM_editQuery & " where " & MM_editColumn & " = " & MM_recordId
        Else   '否则进行插入记录操作
            'Call InsertRecord(tmpStudentNum)
            fieldsStr = "StudentNum|value|" & Request.Form("Subject")
            MM_columnsStr = "StudentNum|',none,''|" & Replace(Request.Form("SubJect"), "value", "none,none,NULL")
            MM_fields = Split(fieldsStr, "|")
            MM_columns = Split(MM_columnsStr, "|")
            MM_fields(1) = ReplaceBadChar(tmpStudentNum)
            For i = 2 To UBound(MM_fields) Step 2
                MM_fields(i + 1) = ReplaceBadChar(Request.Form(MM_fields(i))) & ""
                If MM_fields(i + 1) = "" Then MM_fields(i + 1) = "0"
            Next
            MM_tableValues = ""
            MM_dbValues = ""
            For i = LBound(MM_fields) To UBound(MM_fields) Step 2
                FormVal = MM_fields(i + 1)
                MM_typeArray = Split(MM_columns(i + 1), ",")
                Delim = MM_typeArray(0)
                If (Delim = "none") Then Delim = ""
                AltVal = MM_typeArray(1)
                If (AltVal = "none") Then AltVal = ""
                EmptyVal = MM_typeArray(2)
                If (EmptyVal = "none") Then EmptyVal = ""
                If (FormVal = "") Then
                    FormVal = EmptyVal
                Else
                    If (AltVal <> "") Then
                    FormVal = AltVal
                    ElseIf (Delim = "'") Then  ' escape quotes
                    FormVal = "'" & Replace(FormVal, "'", "''") & "'"
                    Else
                    FormVal = Delim + FormVal + Delim
                    End If
                End If
                If (i <> LBound(MM_fields)) Then
                    MM_tableValues = MM_tableValues & ","
                    MM_dbValues = MM_dbValues & ","
                End If
                MM_tableValues = MM_tableValues & MM_columns(i)
                MM_dbValues = MM_dbValues & FormVal
            Next

            Conn_Sdms.Execute "insert into " & tmpSheetName & " (" & MM_tableValues & ") values (" & MM_dbValues & ")"
        End If
        rsKey.Close
        If InStr(LCase(Session("strQureyString")), "action") <= 0 Then
            Response.Redirect ("Admin_ScoreManage.asp?Action=ScoreInput1&" & Session("strQureyString"))
        Else
            Response.Redirect ("Admin_ScoreManage.asp?" & Session("strQureyString"))
        End If
    End If


    Dim strSheetName, strStudentNum, strName, strGrade, strClass
    strSheetName = ReplaceBadChar(Trim(Request("SheetName")))
    strStudentNum = ReplaceBadChar(Trim(Request("StudentNum")))
    strGrade = PE_CLng(Trim(Request("Grade")))
    strClass = Trim(Request("ClassSelect"))
    strFileName = CStr(Request("URL"))
    If (Request.QueryString <> "") Then
        strFileName = strFileName & "?" & Request.QueryString
    End If
    If Request.QueryString <> "" Then Session("strQureyString") = Request.QueryString
    If Request.Form <> "" Then Session("strQureyString") = Request.Form

    Dim Recordset1, Recordset1Sql
    Set Recordset1 = Server.CreateObject("ADODB.Recordset")
    If (strStudentNum <> "") Then
        Recordset1Sql = "SELECT StudentNum, Name FROM StudentInfo WHERE StudentNum like '%" & strStudentNum & "%'  ORDER BY StudentNum"
    Else
        If strClass = "All" Then
            Recordset1Sql = "SELECT StudentNum, Name FROM StudentInfo WHERE GradeID=" & strGrade & " ORDER BY StudentNum"
        Else
            strClass = PE_CLng(strClass)
            Recordset1Sql = "SELECT StudentNum, Name FROM StudentInfo WHERE GradeID=" & strGrade & " And ClassID=" & strClass & " ORDER BY StudentNum"
        End If
    End If
    Recordset1.Open Recordset1Sql, Conn_Sdms, 1, 3


    Response.Write "<script language=""JavaScript"" type=""text/JavaScript"">" & vbCrLf
    Response.Write "function SetScore(){" & vbCrLf
    Response.Write "  var strTemp,intStart,intEnd;" & vbCrLf
    Response.Write "  strTemp=document.form1.StudentNum.options.value;" & vbCrLf
    Response.Write "  if(strTemp.indexOf("","")>0){" & vbCrLf
    Response.Write "    do{" & vbCrLf
    Response.Write "      intStart=strTemp.indexOf("","")+1;" & vbCrLf
    Response.Write "      strTemp=strTemp.substring(intStart,strTemp.length);" & vbCrLf
    Response.Write "      intEnd=strTemp.indexOf("","");" & vbCrLf
    Response.Write "      if(intEnd>0){" & vbCrLf
    Response.Write "        eval(""document.form1.""+strTemp.substring(0,intEnd)+"";"");" & vbCrLf
    Response.Write "      }" & vbCrLf
    Response.Write "      else{" & vbCrLf
    Response.Write "        eval(""document.form1.""+strTemp+"";"");" & vbCrLf
    Response.Write "      }" & vbCrLf
    Response.Write "    }" & vbCrLf
    Response.Write "    while(strTemp.indexOf("","")>0)" & vbCrLf
    Response.Write "  }" & vbCrLf
    Response.Write "  else{" & vbCrLf
    Response.Write "    for (var i=0;i<document.form1.elements.length;i++){" & vbCrLf
    Response.Write "      var e=document.form1.elements[i];" & vbCrLf
    Response.Write "      if (e.type=='text'){" & vbCrLf
    Response.Write "         e.value="""";" & vbCrLf
    Response.Write "      }" & vbCrLf
    Response.Write "    }" & vbCrLf
    Response.Write "  }" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "</script>" & vbCrLf
    Response.Write "<br>" & vbCrLf
    Response.Write "<table width='100%' class='border' border='0' cellspacing='1' cellpadding='4' align='center'> " & vbCrLf
    Response.Write "  <tr>  " & vbCrLf
    Response.Write "    <td align='center' class='title'>  " & vbCrLf
    Response.Write "    <b>学 生 成 绩 录 入（单条记录方式）</b>    </td> " & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "</table>" & vbCrLf
    Response.Write "<table width='100%' border=0 align='center' cellPadding=0 cellSpacing=0>" & vbCrLf
    Response.Write "  <TBODY>" & vbCrLf
    Response.Write "    <TR> " & vbCrLf
    Response.Write "      <TD ><table width='100%' border='0' cellpadding='0' cellspacing='0'>" & vbCrLf
    Response.Write "          <tr> " & vbCrLf
    Response.Write "            <TD valign='top'>" & vbCrLf
    Response.Write "              <form Name='form1' action='" & strFileName & "' method='POST'>" & vbCrLf
    Response.Write "                <b>" & vbCrLf
    Response.Write "                <font color='#FF0000'><br>" & vbCrLf
    Response.Write "                考试名称：</font></b> " & vbCrLf
    
    Dim rsTestName
    Set rsTestName = Server.CreateObject("ADODB.Recordset")
    rsTestName.Open "SELECT SheetName, TestName FROM TestName WHERE SheetName = '" & strSheetName & "'", Conn_Sdms, 1, 3
    Response.Write rsTestName("TestName")
    rsTestName.Close
    Set rsTestName = Nothing

    Response.Write "                <b>" & vbCrLf
    Response.Write "                <input name='SheetName' type='hidden' value='" & strSheetName & "'>" & vbCrLf
    Response.Write "                </b>" & vbCrLf
    Response.Write "                " & vbCrLf
    Response.Write "                <font color='#FF0000'>" & vbCrLf
    Response.Write "                <b>查询条件： </b>" & vbCrLf
    Response.Write "                </font> " & vbCrLf
    Response.Write "" & vbCrLf

    Dim arrGrade
    arrGrade = Split("一,二,三,四,五,六", ",")
    If Request("StudentNum") <> "" Then
        Response.Write "学号中含有“" & strStudentNum & "”"
    ElseIf strName <> "" Then
        Response.Write "姓名中含有“" & strName & "”"
    Else
        If strClass <> "" Then
            Dim GradeName, strSearch, SearchResult
            If Trim(strClass) = "All" Then
                strClass = " 全级"
                Set GradeName = Conn_Sdms.Execute("Select GradeName From Grade Where GradeID=" & strGrade & "")
                strSearch = GradeName(0) & " " & strClass
                Set GradeName = Nothing
            Else

                Set SearchResult = Conn_Sdms.Execute("Select G.GradeName,C.ClassName From Class C Left join Grade G On C.GradeID= G.GradeID Where C.ClassID=" & strClass & "")

                strSearch = SearchResult(0) & " " & SearchResult(1)
                Set SearchResult = Nothing
            End If
        End If
        Response.Write strSearch
    End If

    Response.Write "                <table border='1' align='center' cellpadding='0' cellspacing=3 bordercolorlight='#CCCCCC' bordercolordark='#FFFFFF'>" & vbCrLf
    Response.Write "                  <tr align='left'> " & vbCrLf
    Response.Write "                    <td height='44' colspan='4'>" & vbCrLf
    Response.Write "                      <table border='0' cellspacing='0' cellpadding='3'>" & vbCrLf
    Response.Write "                        <tr> " & vbCrLf
    Response.Write "                          <td align='left' rowspan='2'>" & vbCrLf
    Response.Write "                           <b><font color='#FF0000'>未录入成绩<br>" & vbCrLf
    Response.Write "                            的学生名单</font></b> " & vbCrLf
    Response.Write "                          </td>" & vbCrLf
    Response.Write "                          <td align='center'>学号：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " & vbCrLf
    Response.Write "                            姓名： </td>" & vbCrLf
    Response.Write "                        </tr>" & vbCrLf
    Response.Write "                        <tr> " & vbCrLf
    Response.Write "                          <td> " & vbCrLf
    Dim Recordset5, InsertFlag, OptionValue
    If Not Recordset1.EOF Or Not Recordset1.BOF Then
        Response.Write "<select Name='StudentNum' onChange=""SetScore()"">" & vbCrLf
        i = 0
        While (Not Recordset1.EOF)
            Set Recordset5 = Server.CreateObject("ADODB.Recordset")
            Recordset5.Open "SELECT StudentNum," & Request("chkbox") & " FROM " & strSheetName & " WHERE StudentNum = '" & ReplaceBadChar(Recordset1("StudentNum")) & "'", Conn_Sdms, 1, 3
            If Recordset5.BOF Or Recordset5.EOF Then
                i = i + 1
                Response.Write "<option value='" & Recordset1.Fields.Item("StudentNum").value & "'"
                If i = 1 Then Response.Write " selected"
                Response.Write ">" & Recordset1.Fields.Item("StudentNum").value & "&nbsp;&nbsp;&nbsp;&nbsp;" & Recordset1.Fields.Item("Name").value & "</option>"
            Else
              strTemp = CStr(Request("chkbox"))
              InsertFlag = False
              If InStr(strTemp, ",") > 0 Then
                Dim ArrSubject
                ArrSubject = Split(strTemp, ",")
                OptionValue = Recordset5.Fields.Item("StudentNum").value
                For j = LBound(ArrSubject) To UBound(ArrSubject)
                    If IsNull(Recordset5.Fields.Item(Trim(ArrSubject(j))).value) Or Recordset5.Fields.Item(Trim(ArrSubject(j))).value = 0 Then
                        OptionValue = OptionValue & "," & Trim(ArrSubject(j)) & ".value=0"
                        InsertFlag = True
                    Else
                        OptionValue = OptionValue & "," & Trim(ArrSubject(j)) & ".value=" & Recordset5.Fields.Item(Trim(ArrSubject(j))).value
                    End If
                Next
                If InsertFlag = True Then
                    i = i + 1
                    Response.Write "<option value='" & OptionValue & "'"
                    If i = 1 Then Response.Write " selected"
                    Response.Write ">" & Recordset1.Fields.Item("StudentNum").value & "&nbsp;&nbsp;&nbsp;&nbsp;" & Recordset1.Fields.Item("Name").value & "</option>"
                End If
              Else
                If IsNull(Recordset5.Fields.Item(strTemp).value) Or Recordset5.Fields.Item(strTemp).value = 0 Then
                    i = i + 1
                    Response.Write "<option value='" & Recordset1.Fields.Item("StudentNum").value & "," & strTemp & ".value=0' selected>" & Recordset1.Fields.Item("StudentNum").value & "&nbsp;&nbsp;&nbsp;&nbsp;" & Recordset1.Fields.Item("Name").value & "</option>"
                End If
              End If
            End If
            Recordset5.Close
            Recordset1.MoveNext
        Wend

        If i = 0 Then
            Response.Write "<option value=''>全部成绩都已经录入</option>"
        End If

        Response.Write "</select>"
    Else
        Response.Write "   找不到学生，请先在学生信息管理中录入相应的学生信息！"
    End If
    Response.Write "                          </td>" & vbCrLf
    Response.Write "                        </tr>" & vbCrLf
    Response.Write "                      </table></td>" & vbCrLf
    Response.Write "                  </tr>" & vbCrLf
    Response.Write "" & vbCrLf
    
    If i > 0 Then
        Response.Write "                  <tr align='center'> " & vbCrLf
        Response.Write "                    <td width='60' height='30'><b>科目</b></td>" & vbCrLf
        Response.Write "                    <td width='100' height='30' align='center' valign='middle'><b>成绩</b></td>" & vbCrLf
        Response.Write "                    <td width='60' height='30' align='center' valign='middle'><b>科目</b></td>" & vbCrLf
        Response.Write "                    <td width='100' height='30' align='center' valign='middle'><b>成绩</b></td>" & vbCrLf
        Response.Write "                  </tr>" & vbCrLf
        Response.Write "                  <tr valign='middle'>" & vbCrLf
        Response.Write "" & vbCrLf

        intRows = 0
        strTemp = Request("chkbox")
        If InStr(strTemp, ",") > 0 Then
            ArrSubject = Split(strTemp, ",")
            For i = LBound(ArrSubject) To UBound(ArrSubject)
                Response.Write "<td width='60' height='25' align=right>" & Trim(ArrSubject(i)) & "：</td>"
                Response.Write "<td height='25' align=left valign='middle'><input type='text' maxlength=6 size=10 Name='" & Trim(ArrSubject(i)) & "'></td>"
                intRows = intRows + 1
                If intRows Mod 2 = 0 Then
                    Response.Write "</tr>"
                    Response.Write "<tr valign='middle'>"
                End If
            Next
        Else
            Response.Write "<td width='60' height='25' align=right>" & strTemp & "：</td>"
            Response.Write "<td height='25' align=left valign='middle'> <input type='text' maxlength=6 size=10 Name='" & strTemp & "'></td>"
        End If

        Response.Write "              </tr>"
    End If
    Response.Write "                </table>" & vbCrLf
    Response.Write "                <br>" & vbCrLf

    If i > 0 Then
        strSubject = Replace(Replace(Request("chkbox"), ",", "|value|") & "|value", " ", "")
        Response.Write "                <input name='Action' type='hidden' value='ScoreInput1'>" & vbCrLf
        Response.Write "                <input name='InputScore' type='hidden' value='True'>" & vbCrLf
        Response.Write "                <input type='hidden' Name='Subject' value='" & strSubject & "'>" & vbCrLf
        Response.Write "                <input type='submit' Name='Submit2' value='保存当前学生成绩并录入下一个学生的成绩'>" & vbCrLf
        Response.Write "              </form>" & vbCrLf
        Response.Write "              <script language=""JavaScript"" type=""text/JavaScript"">" & vbCrLf
        Response.Write "                SetScore()" & vbCrLf
        Response.Write "              </script> " & vbCrLf
        Response.Write "" & vbCrLf
    End If
    Response.Write "            </td>" & vbCrLf
    Response.Write "          </tr>" & vbCrLf
    Response.Write "        </table>" & vbCrLf
    Response.Write "      </td>" & vbCrLf
    Response.Write "       " & vbCrLf
    Response.Write "    </TR> " & vbCrLf
    Response.Write "  </TBODY>" & vbCrLf
    Response.Write "</TABLE>" & vbCrLf
    Response.Write "<p> <br>" & vbCrLf
    Response.Write "                <strong>注：</strong><br>" & vbCrLf
    Response.Write "               " & vbCrLf
    Response.Write "                　　1、输入成绩后可直接按回车键保存录入成绩<br>" & vbCrLf
    Response.Write "                " & vbCrLf
    Response.Write "                　　2、输入过程中可用Tab键将光标在各输入框中切换<br>" & vbCrLf
    Response.Write "                " & vbCrLf
    Response.Write "                　　3、录入记录后，系统会自动选择下一个学生<br>" & vbCrLf
    Response.Write "              </p>" & vbCrLf
    Response.Write "" & vbCrLf

    Recordset1.Close
End Sub

Sub ScoreInput2()
    Dim strFileName, MM_editTable, MM_editQuery, EditType
    Dim strTemp, i, Recordset5__MMColParam, Recordset5
    Dim UpdateFlag, j, tmpScore
    Dim strSheetName, strStudentNum, strName, strGrade, strClass

    If (Trim(Request.Form("InputScore")) <> "" And Trim(Request.Form("StudentNum")) <> "") Then
        MM_editTable = Request("SheetName")

        MM_editQuery = ""
        Dim arrStudentNum, ArrSubject, intTemp, MM_fieldsStr, MM_columnsStr, MM_fields, MM_columns, arrTemp, MM_tableValues
        Dim FormVal, MM_typeArray, Delim, AltVal, EmptyVal, MM_dbValues, MM_recordId
        If InStr(Request.Form("StudentNum"), ",") > 0 Then     '需要对多条记录进行操作
            arrStudentNum = Split(Replace(Request.Form("StudentNum"), " ", ""), ",")
            'arrEditType = Split(Replace(Request.Form("EditType")," ",""),",")
            ArrSubject = Split(Replace(Request.Form("Subject"), "|value", ""), "|")
            Dim arrScore()
            ReDim arrScore(UBound(ArrSubject) + 1)
            For intTemp = LBound(ArrSubject) To UBound(ArrSubject)
                arrScore(intTemp) = Replace(Replace(Request.Form(ArrSubject(intTemp)), " ", ""), ",", "|")
            Next
            EditType = "Insert"
            
            For intTemp = LBound(arrStudentNum) To UBound(arrStudentNum)     '对每一条记录进行插入或更新操作
                EditType = CheckExist(CStr(arrStudentNum(intTemp)), MM_editTable)
                If EditType = "Insert" Then  '插入记录
                    MM_fieldsStr = "StudentNum|value|" & Request.Form("Subject")
                    MM_columnsStr = "StudentNum|',none,''|" & Replace(Request.Form("Subject"), "value", "none,none,NULL")
                    MM_fields = Split(MM_fieldsStr, "|")
                    MM_columns = Split(MM_columnsStr, "|")
                
                    MM_fields(1) = arrStudentNum(intTemp)
                    For j = 2 To UBound(MM_fields) Step 2
                        arrTemp = Split(arrScore((j - 2) / 2), "|")
                        MM_fields(j + 1) = arrTemp(intTemp) & ""
                        If MM_fields(j + 1) = "" Then MM_fields(j + 1) = "0"
                    Next
                    'InsertRecord
                    '---------------------
                    MM_tableValues = ""
                    MM_dbValues = ""
                    For i = LBound(MM_fields) To UBound(MM_fields) Step 2
                        FormVal = MM_fields(i + 1)
                        MM_typeArray = Split(MM_columns(i + 1), ",")
                        Delim = MM_typeArray(0)
                        If (Delim = "none") Then Delim = ""
                        AltVal = MM_typeArray(1)
                        If (AltVal = "none") Then AltVal = ""
                        EmptyVal = MM_typeArray(2)
                        If (EmptyVal = "none") Then EmptyVal = ""
                        If (FormVal = "") Then
                            FormVal = EmptyVal
                        Else
                            If (AltVal <> "") Then
                                FormVal = AltVal
                            ElseIf (Delim = "'") Then  ' escape quotes
                                FormVal = "'" & Replace(FormVal, "'", "''") & "'"
                            Else
                                FormVal = Delim + FormVal + Delim
                            End If
                        End If
                        If (i <> LBound(MM_fields)) Then
                            MM_tableValues = MM_tableValues & ","
                            MM_dbValues = MM_dbValues & ","
                        End If
                        MM_tableValues = MM_tableValues & MM_columns(i)
                        MM_dbValues = MM_dbValues & FormVal
                    Next

                    MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & ") values (" & MM_dbValues & ")"
                    '---------------------
                End If
                If EditType = "Update" Then  '更新记录
                    MM_recordId = "'" & arrStudentNum(intTemp) & "'"
                    MM_fieldsStr = Request.Form("Subject")
                    MM_columnsStr = Replace(Request.Form("Subject"), "value", "',none,''")
                    MM_fields = Split(MM_fieldsStr, "|")
                    MM_columns = Split(MM_columnsStr, "|")
                    For j = LBound(MM_fields) To UBound(MM_fields) Step 2
                        arrTemp = Split(arrScore(j / 2), "|")
                        MM_fields(j + 1) = arrTemp(intTemp) & ""
                        If MM_fields(j + 1) = "" Then MM_fields(j + 1) = "0"
                    Next
                    'UpdateRecord(MM_fields)
                    '-------------------------
                    MM_editQuery = "update " & MM_editTable & " set "
                    For i = LBound(MM_fields) To UBound(MM_fields) Step 2
                        FormVal = MM_fields(i + 1)
                        MM_typeArray = Split(MM_columns(i + 1), ",")
                        Delim = MM_typeArray(0)
                        If (Delim = "none") Then Delim = ""
                        AltVal = MM_typeArray(1)
                        If (AltVal = "none") Then AltVal = ""
                        EmptyVal = MM_typeArray(2)
                        If (EmptyVal = "none") Then EmptyVal = ""
                        If (FormVal = "") Then
                            FormVal = EmptyVal
                        Else
                            If (AltVal <> "") Then
                                FormVal = AltVal
                            ElseIf (Delim = "'") Then  ' escape quotes
                                FormVal = "'" & Replace(FormVal, "'", "''") & "'"
                            Else
                                FormVal = Delim + FormVal + Delim
                            End If
                        End If
                        If (i <> LBound(MM_fields)) Then
                            MM_editQuery = MM_editQuery & ","
                        End If
                        MM_editQuery = MM_editQuery & MM_columns(i) & " = " & FormVal
                    Next

                    MM_editQuery = MM_editQuery & " where StudentNum = " & MM_recordId
                    '-------------------------
                End If
                Conn_Sdms.Execute MM_editQuery
            Next
        Else             '只有一条记录时
            strStudentNum = Trim(Request.Form("StudentNum"))
            EditType = Trim(Request.Form("EditType"))
            EditType = CheckExist(strStudentNum, MM_editTable)
            If EditType = "Insert" Then '插入记录
                MM_fieldsStr = "StudentNum|value|" & Request.Form("Subject")
                MM_columnsStr = "StudentNum|',none,''|" & Replace(Request.Form("Subject"), "value", "none,none,NULL")
                MM_fields = Split(MM_fieldsStr, "|")
                MM_columns = Split(MM_columnsStr, "|")
                
                MM_fields(1) = strStudentNum
                For intTemp = 2 To UBound(MM_fields) Step 2
                    MM_fields(intTemp + 1) = CStr(Request.Form(MM_fields(intTemp)))
                    If MM_fields(intTemp + 1) = "" Then MM_fields(intTemp + 1) = "0"
                Next
                'InsertRecord
                '----------------
                MM_tableValues = ""
                MM_dbValues = ""
                For i = LBound(MM_fields) To UBound(MM_fields) Step 2
                    FormVal = MM_fields(i + 1)
                    MM_typeArray = Split(MM_columns(i + 1), ",")
                    Delim = MM_typeArray(0)
                    If (Delim = "none") Then Delim = ""
                    AltVal = MM_typeArray(1)
                    If (AltVal = "none") Then AltVal = ""
                    EmptyVal = MM_typeArray(2)
                    If (EmptyVal = "none") Then EmptyVal = ""
                    If (FormVal = "") Then
                        FormVal = EmptyVal
                    Else
                        If (AltVal <> "") Then
                            FormVal = AltVal
                        ElseIf (Delim = "'") Then  ' escape quotes
                            FormVal = "'" & Replace(FormVal, "'", "''") & "'"
                        Else
                            FormVal = Delim + FormVal + Delim
                        End If
                    End If
                    If (i <> LBound(MM_fields)) Then
                        MM_tableValues = MM_tableValues & ","
                        MM_dbValues = MM_dbValues & ","
                    End If
                    MM_tableValues = MM_tableValues & MM_columns(i)
                    MM_dbValues = MM_dbValues & FormVal
                Next

                MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & ") values (" & MM_dbValues & ")"
                '----------------
            End If
            If EditType = "Update" Then  '更新记录
                MM_recordId = "'" & strStudentNum & "'"
                MM_fieldsStr = Request.Form("Subject")
                MM_columnsStr = Replace(Request.Form("Subject"), "value", "',none,''")
                MM_fields = Split(MM_fieldsStr, "|")
                MM_columns = Split(MM_columnsStr, "|")
                For intTemp = LBound(MM_fields) To UBound(MM_fields) Step 2
                    MM_fields(intTemp + 1) = CStr(Request.Form(MM_fields(intTemp)))
                    If MM_fields(intTemp + 1) = "" Then MM_fields(intTemp + 1) = "0"
                Next
                'UpdateRecord(MM_fields)
                '---------------------------
                MM_editQuery = "update " & MM_editTable & " set "
                For i = LBound(MM_fields) To UBound(MM_fields) Step 2
                    FormVal = MM_fields(i + 1)
                    MM_typeArray = Split(MM_columns(i + 1), ",")
                    Delim = MM_typeArray(0)
                    If (Delim = "none") Then Delim = ""
                    AltVal = MM_typeArray(1)
                    If (AltVal = "none") Then AltVal = ""
                    EmptyVal = MM_typeArray(2)
                    If (EmptyVal = "none") Then EmptyVal = ""
                    If (FormVal = "") Then
                        FormVal = EmptyVal
                    Else
                        If (AltVal <> "") Then
                            FormVal = AltVal
                        ElseIf (Delim = "'") Then  ' escape quotes
                            FormVal = "'" & Replace(FormVal, "'", "''") & "'"
                        Else
                            FormVal = Delim + FormVal + Delim
                        End If
                    End If
                    If (i <> LBound(MM_fields)) Then
                        MM_editQuery = MM_editQuery & ","
                    End If
                    MM_editQuery = MM_editQuery & MM_columns(i) & " = " & FormVal
                Next

                MM_editQuery = MM_editQuery & " where StudentNum = " & MM_recordId
                '---------------------------
            End If
            Conn_Sdms.Execute MM_editQuery
        End If
        
        'MM_editRedirectUrl = "ScoreInputStep1.asp?" & session("strQureyString")
        'Response.Redirect(MM_editRedirectUrl)
        If InStr(LCase(Session("strQureyString")), "action") <= 0 Then
            Response.Redirect ("Admin_ScoreManage.asp?Action=ScoreInput2&" & Session("strQureyString"))
        Else
            Response.Redirect ("Admin_ScoreManage.asp?" & Session("strQureyString"))
        End If
    End If

    strSheetName = Trim(Request("SheetName"))

    strStudentNum = Trim(Request("StudentNum"))
    strGrade = Trim(Request("Grade"))
    strClass = Trim(Request("ClassSelect"))
    strFileName = CStr(Request("URL"))
    If (Request.QueryString <> "") Then
        strFileName = strFileName & "?" & Request.QueryString
    End If
    'strFileName="ScoreInputStep1.asp?Action=ScoreInput2&SheetName=" & strSheetName &"&StudentNum=" &strStudentNum &"&Grade=" &strGrade&"&ClassSelect=" &strClass
    If Request.QueryString <> "" Then Session("strQureyString") = Request.QueryString
    If Request.Form <> "" Then Session("strQureyString") = Request.Form

    Dim Recordset1, Recordset1Sql, rsTestName
    Set Recordset1 = Server.CreateObject("ADODB.Recordset")
    If (strStudentNum <> "") Then
        Recordset1Sql = "SELECT StudentNum, Name FROM StudentInfo WHERE StudentNum like '%" & CStr(strStudentNum) & "%'  ORDER BY StudentNum"
    Else
        If strClass = "All" Then
            Recordset1Sql = "SELECT StudentNum, Name FROM StudentInfo WHERE GradeID=" & CLng(strGrade) & "  ORDER BY StudentNum"
        Else
            Recordset1Sql = "SELECT StudentNum, Name FROM StudentInfo WHERE GradeID=" & CLng(strGrade) & " And ClassID=" & CLng(strClass) & " ORDER BY StudentNum"
        End If
    End If
    Recordset1.Open Recordset1Sql, Conn_Sdms, 1, 3

    Set rsTestName = Server.CreateObject("ADODB.Recordset")
    rsTestName.Open "SELECT SheetName, TestName FROM TestName WHERE SheetName = '" + Replace(strSheetName, "'", "''") + "'", Conn_Sdms, 1, 3


    Response.Write "" & vbCrLf
    Response.Write "    <br>" & vbCrLf
    Response.Write "    <table width='100%' class='border' border='0' cellspacing='1' cellpadding='4' align='center'> " & vbCrLf
    Response.Write "      <tr>  " & vbCrLf
    Response.Write "        <td align='center' class='title'>  " & vbCrLf
    Response.Write "        <b>学 生 成 绩 录 入（列表方式）</b>    </td> " & vbCrLf
    Response.Write "      </tr>" & vbCrLf
    Response.Write "    </table>" & vbCrLf
    Response.Write "    <table width='100%' border=0 align='center' cellPadding=0 cellSpacing=0>" & vbCrLf
    Response.Write "      <TBODY>" & vbCrLf
    Response.Write "        <TR> " & vbCrLf
    Response.Write "          <TD >" & vbCrLf
    Response.Write "          <form Name='form1' action='" & strFileName & "' method='POST'>" & vbCrLf
    Response.Write "              <b>" & vbCrLf
    Response.Write "              <font color='#FF0000'>考试名称：</font>" & vbCrLf
    Response.Write "              </b> " & rsTestName("TestName") & "<font color='#FF0000'><b>" & vbCrLf
    Response.Write "              </b></font>" & vbCrLf
    Response.Write "              <font color='#FF0000'><b>" & vbCrLf
    Response.Write "              <input name='SheetName' type='hidden' value='" & strSheetName & "'>" & vbCrLf
    Response.Write "              &nbsp;查询条件：</b>" & vbCrLf
    Response.Write "              </font> " & vbCrLf
    Response.Write "" & vbCrLf


    If Request("StudentNum") <> "" Then
        Response.Write "学号中含有“" & strStudentNum & "”"
    ElseIf strName <> "" Then
        Response.Write "姓名中含有“" & strName & "”"
    Else

        If strClass <> "" Then
            Dim SearchResult, GradeName, strSearch
            If Trim(strClass) = "All" Then
                strClass = " 全级"
                Set GradeName = Conn_Sdms.Execute("Select GradeName From Grade Where GradeID=" & CLng(strGrade) & "")
                strSearch = GradeName(0) & " " & strClass
                Set GradeName = Nothing
            Else
                Set SearchResult = Conn_Sdms.Execute("Select G.GradeName,C.ClassName From Class C Left join Grade G On C.GradeID=G.GradeID Where C.GradeID=" & CLng(strGrade) & " And C.ClassID=" & CLng(strClass) & "")

                If SearchResult.BOF And SearchResult.EOF Then
                    Response.Write "strGrade=" & strClass
                    Response.Write "strClass=" & strClass
                    Response.Write "输入的类别并不存在！"
                Else
                    strSearch = SearchResult(0) & "&nbsp;" & SearchResult(1)
                End If
                
                Set SearchResult = Nothing
            End If
        End If
        Response.Write strSearch
    End If


    Response.Write "              <br>" & vbCrLf
    Response.Write "              <br>" & vbCrLf
    Response.Write "              <b><font color='#FF0000'>未录入成绩的学生名单：</font></b><br>" & vbCrLf
    Response.Write "" & vbCrLf
    
    If Not Recordset1.EOF Or Not Recordset1.BOF Then
        Response.Write "             <table class='border' border='0' cellspacing='1' cellpadding='4' align='center'>" & vbCrLf
        Response.Write "              　<tr valign='middle' class='title'>     " & vbCrLf
        Response.Write "                  <td width='60' height='25' align='center'>学号</td>" & vbCrLf
        Response.Write "                  <td width='60' align='center'>姓名</td>" & vbCrLf
        Response.Write "" & vbCrLf
                     
        strTemp = Request("chkbox")
        If InStr(strTemp, ",") > 0 Then
            ArrSubject = Split(strTemp, ",")
            For i = LBound(ArrSubject) To UBound(ArrSubject)
                Response.Write "<td align='center'>" & Trim(ArrSubject(i)) & "</td>"
            Next
        Else
            Response.Write "<td align='center'>" & strTemp & "</td>"
        End If
                     
        Response.Write "</tr>"
        Response.Write (vbCrLf)
                    
        i = 0
        While (Not Recordset1.EOF)
            Recordset5__MMColParam = CStr(Recordset1.Fields.Item("StudentNum").value)
            Set Recordset5 = Server.CreateObject("ADODB.Recordset")
            Recordset5.Open "SELECT StudentNum," & Request("chkbox") & " FROM " & strSheetName & " WHERE StudentNum = '" + Replace(Recordset5__MMColParam, "'", "''") + "'", Conn_Sdms, 1, 3
            
            If Recordset5.BOF Or Recordset5.EOF Then
                i = i + 1
                Response.Write "    <tr class='tdbg' onmouseout=""this.className='tdbg'"" onmouseover=""this.className='tdbgmouseover'"">"
                Response.Write ("<td height='25' align='center'>" & Recordset1.Fields.Item("StudentNum").value & "</td>")
                Response.Write ("<input name='StudentNum' type='hidden' value='" & Recordset1.Fields.Item("StudentNum").value & "'>")
                Response.Write ("<input name='EditType' type='hidden' value='Insert'>")
                Response.Write ("<td align='center'>" & Recordset1.Fields.Item("Name").value & "</td>")
                strTemp = Request("chkbox")
                If InStr(strTemp, ",") > 0 Then
                    ArrSubject = Split(strTemp, ",")
                    For i = LBound(ArrSubject) To UBound(ArrSubject)
                        Response.Write "<td align='center'><input type='text' maxlength=6 size=6 Name='" & Trim(ArrSubject(i)) & "'></td>"
                    Next
                Else
                    Response.Write "<td align='center'><input type='text' maxlength=6 size=6 Name='" & strTemp & "'></td>"
                End If
                Response.Write ("</tr>" & vbCrLf)
            Else
                strTemp = CStr(Request("chkbox"))
                UpdateFlag = False
                If InStr(strTemp, ",") > 0 Then
                    ArrSubject = Split(strTemp, ",")
                    For j = LBound(ArrSubject) To UBound(ArrSubject)
                        If IsNull(Recordset5.Fields.Item(Trim(ArrSubject(j))).value) Or Recordset5.Fields.Item(Trim(ArrSubject(j))).value = 0 Then
                            UpdateFlag = True
                        End If
                    Next
                    If UpdateFlag = True Then
                        i = i + 1
                        Response.Write "    <tr class='tdbg' onmouseout=""this.className='tdbg'"" onmouseover=""this.className='tdbgmouseover'"">"
                        Response.Write ("<td height='25' align='center'>" & Recordset1.Fields.Item("StudentNum").value & "</td>")
                        Response.Write ("<input name='StudentNum' type='hidden' value='" & Recordset1.Fields.Item("StudentNum").value & "'>")
                        Response.Write ("<input name='EditType' type='hidden' value='Update'>")
                        Response.Write ("<td align='center'>" & Recordset1.Fields.Item("Name").value & "</td>")
                        For j = LBound(ArrSubject) To UBound(ArrSubject)
                            tmpScore = Recordset5.Fields.Item(Trim(ArrSubject(j))).value
                            Response.Write "<td align='center'><input type='text' maxlength=6 size=6 Name='" & Trim(ArrSubject(j)) & "' value='" & tmpScore & "'></td>"
                        Next
                        Response.Write ("</tr>" & vbCrLf)
                    End If
                Else
                    If IsNull(Recordset5.Fields.Item(strTemp).value) Or Recordset5.Fields.Item(strTemp).value = 0 Then
                        i = i + 1
                         Response.Write "    <tr class='tdbg' onmouseout=""this.className='tdbg'"" onmouseover=""this.className='tdbgmouseover'"">"
                        Response.Write ("<td height='25' align='center'>" & Recordset1.Fields.Item("StudentNum").value & "</td>")
                        Response.Write ("<input name='StudentNum' type='hidden' value='" & Recordset1.Fields.Item("StudentNum").value & "'>")
                        Response.Write ("<td align='center'>" & Recordset1.Fields.Item("Name").value & "</td>")
                        Response.Write ("<td align='center'><input type='text' maxlength=6 size=6 Name='" & strTemp & "'></td>")
                        Response.Write ("</tr>" & vbCrLf)
                    End If
                End If
            End If
            Recordset5.Close
            Recordset1.MoveNext
        Wend

        If (Recordset1.CursorType > 0) Then
            Recordset1.movefirst
        Else
            Recordset1.Requery
        End If
                          
        If i = 0 Then
            Response.Write "<tr><td colspan=99>全部成绩都已经录入</td></tr>"
        End If

        Response.Write "              </table>" & vbCrLf
        Response.Write "              <br>" & vbCrLf
        Response.Write "" & vbCrLf

        
        If i > 0 Then
            Response.Write "                <input name='Action' type='hidden' value='ScoreInput1'>" & vbCrLf
            Response.Write "              <input type='hidden' Name='InputScore' value='True'>" & vbCrLf
            Response.Write "              <input type='hidden' Name='Subject' value='" & Replace(Replace(Request("chkbox"), ",", "|value|") & "|value", " ", "") & "'>" & vbCrLf
            Response.Write "              <input type='submit' Name='Submit2' value='保存已录入的学生成绩'>" & vbCrLf
        End If
    Else
        Response.Write ("找不到学生，请先在学生信息管理中录入相应的学生信息！")
    End If

    Response.Write "            </form> </td>" & vbCrLf
    Response.Write "           " & vbCrLf
    Response.Write "        </TR> " & vbCrLf
    Response.Write "      </TBODY>" & vbCrLf
    Response.Write "    </TABLE>" & vbCrLf
    Response.Write "" & vbCrLf
    Recordset1.Close
    rsTestName.Close
End Sub


Function CheckExist(tmpStudentNum, MM_editTable)
    '通过判断学号是否存在来检查是否已录入任何一科成绩
    Dim MM_rsKey
    Set MM_rsKey = Server.CreateObject("ADODB.Recordset")
    MM_rsKey.Open "SELECT Top 1 * FROM " & MM_editTable & " WHERE StudentNum='" & tmpStudentNum & "'", Conn_Sdms, 1, 3

    If Not MM_rsKey.EOF Or Not MM_rsKey.BOF Then
    ' 如果已录入任何一科成绩，则进行更新记录操作
        CheckExist = "Update"
    Else   '否则进行插入记录操作
        CheckExist = "Insert"
    End If
    MM_rsKey.Close
    Set MM_rsKey = Nothing

End Function

Sub ScoreQueryStep1()
    Response.Write "<br>" & vbCrLf
    Response.Write "<table width='100%' class='border' border='0' cellspacing='1' cellpadding='4' align='center'> " & vbCrLf
    Response.Write "  <tr>  " & vbCrLf
    Response.Write "    <td align='center' class='title' colspan='3'>  " & vbCrLf
    Response.Write "      <b>学 生 成 绩 查 询</b>（第一步）----请选择查询方式 " & vbCrLf
    Response.Write "    </td> " & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "          <form Name='form1' action='Admin_ScoreManage.asp?Action=ScoreQueryStep1_1' method='post'>" & vbCrLf
    Response.Write "            <tr valign='middle' class='tdbg'> " & vbCrLf
    Response.Write "              <td width='20%' height='30' align='right'><font color='#FF0000'>※</font><strong>按考试查询：</strong></td>" & vbCrLf
    Response.Write "              <td width='25%' height='30'> <select Name='sheetName'>" & vbCrLf
    Response.Write "" & vbCrLf
    Dim Recordset1, i
    Set Recordset1 = Server.CreateObject("ADODB.Recordset")
    Recordset1.Open "SELECT * FROM TestName ORDER BY id DESC", Conn_Sdms, 1, 3

    i = 0
    While (Not Recordset1.EOF)
        If i = 0 Then
            Response.Write "<option value='" & Recordset1.Fields.Item("SheetName").value & "' selected>" & Recordset1.Fields.Item("TestName").value & "</option>"
        Else
            Response.Write "<option value='" & Recordset1.Fields.Item("SheetName").value & "'>" & Recordset1.Fields.Item("TestName").value & "</option>"
        End If
        i = i + 1
        Recordset1.MoveNext
    Wend

    Response.Write "                </select> </td>" & vbCrLf
    Response.Write "              <td height='30'> <input type='submit' name='Submit' value='下一步'> " & vbCrLf
    Response.Write "              </td>" & vbCrLf
    Response.Write "            </tr>" & vbCrLf
    Response.Write "            <tr valign='middle' class='tdbg'> " & vbCrLf
    Response.Write "              <td width='20%' height='30' align='right'>&nbsp;</td>" & vbCrLf
    Response.Write "              <td height='30' colspan='2'>查询指定考试中某一科或几科的成绩及总分、达标等信息。此种方式便于班任或科任掌握相应考试的考试情况。</td>" & vbCrLf
    Response.Write "            </tr>" & vbCrLf
    Response.Write "          </form>" & vbCrLf
    Response.Write "          <form Name='form2' action='Admin_ScoreManage.asp?Action=ScoreQueryStep1_2' method='post'>" & vbCrLf
    Response.Write "            <tr valign='middle' class='tdbg'> " & vbCrLf
    Response.Write "              <td width='20%' height='30' align='right'><font color='#FF0000'>※</font><strong>按科目查询：</strong></td>" & vbCrLf
    Response.Write "              <td width='25%' height='30'> <select name='Subject'>" & vbCrLf
    Response.Write "" & vbCrLf

    Dim Recordset2
    Dim Recordset2_numRows

    Set Recordset2 = Server.CreateObject("ADODB.Recordset")
    Recordset2.Open "SELECT * FROM Subject ORDER BY ID ASC", Conn_Sdms, 1, 3

    i = 0
    While (Not Recordset2.EOF)
        If i = 0 Then
            Response.Write "<option value='" & Recordset2.Fields.Item("SubjectName").value & "' selected>" & Recordset2.Fields.Item("SubjectName").value & "</option>"
        Else
            Response.Write "<option value='" & Recordset2.Fields.Item("SubjectName").value & "'>" & Recordset2.Fields.Item("SubjectName").value & "</option>"
        End If
        i = i + 1
        Recordset2.MoveNext
    Wend


    Response.Write "                </select> </td>" & vbCrLf
    Response.Write "              <td height='30'> <input type='submit' name='Submit2' value='下一步'> " & vbCrLf
    Response.Write "              </td>" & vbCrLf
    Response.Write "            </tr>" & vbCrLf
    Response.Write "            <tr valign='middle' class='tdbg'> " & vbCrLf
    Response.Write "              <td width='20%' height='30' align='right'>&nbsp;</td>" & vbCrLf
    Response.Write "              <td height='30' colspan='2'>查询指定科目的某一次或几次考试的成绩、达标、成绩升降等信息。此种方式便于科任老师掌握学生的学习情况。</td>" & vbCrLf
    Response.Write "            </tr>" & vbCrLf
    Response.Write "          </form>" & vbCrLf
    Response.Write "</TABLE>" & vbCrLf
    Response.Write "" & vbCrLf

    Recordset1.Close

    Recordset2.Close
    Set Recordset2 = Nothing
End Sub

Sub ScoreQueryStep1_1()
    Response.Write "<script language=""JavaScript"">" & vbCrLf
    Response.Write "function check()" & vbCrLf
    Response.Write "{" & vbCrLf
    Response.Write "var total=0;" & vbCrLf
    Response.Write "var intmax=document.form1.chkbox.length;" & vbCrLf
    Response.Write "if(intmax>1){" & vbCrLf
    Response.Write "  for(var idx=0;idx<intmax;idx++){" & vbCrLf
    Response.Write "    if(eval(""document.form1.chkbox["" + idx + ""].checked"")==true){" & vbCrLf
    Response.Write "      total+=1;" & vbCrLf
    Response.Write "    }" & vbCrLf
    Response.Write "  }" & vbCrLf
    Response.Write "  if(total==0){" & vbCrLf
    Response.Write "    alert(""您未选择任何科目！"");" & vbCrLf
    Response.Write "    document.form1.chkbox[0].focus();" & vbCrLf
    Response.Write "    return false;" & vbCrLf
    Response.Write "  }" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "else{" & vbCrLf
    Response.Write "  if(document.form1.chkbox.checked==false){" & vbCrLf
    Response.Write "    alert(""您未选择任何科目！"");" & vbCrLf
    Response.Write "    document.form1.chkbox.focus();" & vbCrLf
    Response.Write "    return false;" & vbCrLf
    Response.Write "  }" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "if(document.form1.ShowTarget.checked==true){" & vbCrLf
    Response.Write "    document.form1.action=""Admin_ScoreManage.asp?Action=ScoreQueryStep1_1_1"";" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "else{" & vbCrLf
    Response.Write "    document.form1.action=""Admin_ScoreManage.asp?Action=ScoreQueryStep1_1_2"";" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "</script>" & vbCrLf
    Response.Write "<script language=""JavaScript"" type=""text/JavaScript"">" & vbCrLf
    Response.Write "function ChangeClass(num)" & vbCrLf
    Response.Write "{" & vbCrLf
    Response.Write "    var i;" & vbCrLf
    Response.Write "    var j;" & vbCrLf
    Response.Write "    for(i=document.form1.ClassSelect.options.length-1;i>=0;i--)" & vbCrLf
    Response.Write "    {" & vbCrLf
    Response.Write "        document.form1.ClassSelect.options[i]=null;" & vbCrLf
    Response.Write "    }" & vbCrLf
    Response.Write "" & vbCrLf
    Response.Write "    for(j=0;j<document.Classes.all(""Grade""+num).options.length;j++)" & vbCrLf
    Response.Write "    {" & vbCrLf
    Response.Write "        document.form1.ClassSelect.options[j]=new Option(document.Classes.all(""Grade""+num).options[j].text,document.Classes.all(""Grade""+num).options[j].value);" & vbCrLf
    Response.Write "    }" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "</script>" & vbCrLf
    Dim strSheetName
    strSheetName = ReplaceBadChar(Trim(Request("SheetName")))
    If Request("SheetName") = "" Then
        Response.Write "<br><br>未选择任何考试,请先添加考试!!"
        Response.End
    End If
    Response.Write "<div id='Layer1' style='position:absolute; left:445px; top:220px; width:188px; height:64px; z-index:1; visibility: hidden;'> " & vbCrLf
    Response.Write GetClass_Option(0)
    Response.Write "</div>" & vbCrLf

    Response.Write "<br>" & vbCrLf
    Response.Write "<table width='100%' class='border' border='0' cellspacing='1' cellpadding='4' align='center'> " & vbCrLf
    Response.Write "  <tr>  " & vbCrLf
    Response.Write "    <td align='center' class='title' colspan='3'>  " & vbCrLf
    Response.Write "      <b>学 生 成 绩 查 询" & vbCrLf
    Response.Write "      </b> (第二步)----请输入查询条件并选择科目" & vbCrLf
    Response.Write "      </td> " & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "        <form Name='form1'  onSubmit=""return check()"" action='Admin_ScoreManage.asp?Action=ScoreQueryStep1_1_2' method='post'>" & vbCrLf
    Response.Write "            <tr class='tdbg'> " & vbCrLf
    Response.Write "              <td width='20%' align='right'>" & vbCrLf
    Response.Write "              <strong>考试名称：</strong>" & vbCrLf
    Response.Write "              </td>" & vbCrLf
    Response.Write "              <td colspan='2'>" & vbCrLf
    Dim Recordset2
    Set Recordset2 = Server.CreateObject("ADODB.Recordset")
    Recordset2.Open "SELECT * FROM TestName WHERE SheetName = '" & strSheetName & "'", Conn_Sdms, 1, 3
    Response.Write Recordset2("TestName")
    Recordset2.Close
    Set Recordset2 = Nothing
    Response.Write "              <input name='SheetName' type='hidden' id='SheetName2' value='" & strSheetName & "'>" & vbCrLf
    Response.Write "              </td>" & vbCrLf
    Response.Write "            </tr>" & vbCrLf
    Response.Write "            <tr class='tdbg'> " & vbCrLf
    Response.Write "              <td width='20%' align='right'>" & vbCrLf
    Response.Write "              <strong>请输入查询条件：</strong>" & vbCrLf
    Response.Write "              <br> " & vbCrLf
    Response.Write "                <br>" & vbCrLf
    Response.Write "              （可从学号或班级两种查询方法任选其一进行查询）</td>" & vbCrLf
    Response.Write "              <td nowrap>学号： " & vbCrLf
    Response.Write "                <input type='text' Name='StudentNum' maxlength='16' size='18'> " & vbCrLf
    Response.Write "                <br> <br>" & vbCrLf
    Response.Write "                班级： " & vbCrLf
    Response.Write "                <select name='Grade' onChange=""ChangeClass(this.value)"">" & vbCrLf
    Response.Write GetGrade_Option
    Response.Write "                </select> <select name='ClassSelect'>" & vbCrLf
    Response.Write "                  <option value='All' selected>全级</option>" & vbCrLf
    Response.Write "" & vbCrLf
    Dim RsFirst, FirstGradeID, Rsin, Sqlin
    Set RsFirst = Conn_Sdms.Execute("select top 1 GradeID from Grade order by OrderID asc")
    FirstGradeID = RsFirst("GradeID")
    Set RsFirst = Nothing
    Set Rsin = Server.CreateObject("ADODB.REcordset")
    Sqlin = "select * from Class where GradeID=" & FirstGradeID & " order by OrderID asc"
    Rsin.Open Sqlin, Conn_Sdms, 1, 3
    Do While Not Rsin.EOF
        Response.Write "<option value='" & Rsin("ClassID") & "' >" & Rsin("ClassName") & "</option>"
        Rsin.MoveNext
    Loop
    Set Rsin = Nothing

    Response.Write "                </select> </td>" & vbCrLf
    Response.Write "              <td><b>注：</b><br>" & vbCrLf
    Response.Write "                　　1 、若输入了学号，则优先按学号进行查询。 <br> " & vbCrLf
    Response.Write "                <font color='#FF0000'>　　2、支持模糊查询！</font><br>" & vbCrLf
    Response.Write "                例如：<br> &nbsp;&nbsp;&nbsp;&nbsp;在学号查询框中输入2001，则查询结果为学号中包含“2001”的学生</td>" & vbCrLf
    Response.Write "            </tr>" & vbCrLf
    Response.Write "            <tr class='tdbg'> " & vbCrLf
    Response.Write "              <td width='20%' align='right'><strong>请选择科目：</strong></td>" & vbCrLf
    Response.Write "              <td colspan='2'> <table border='0' cellspacing='5' cellpadding='0'>" & vbCrLf
    Response.Write "                  <tr class='tdbg'> " & vbCrLf
    Response.Write "" & vbCrLf
    Dim Recordset1, i

    Set Recordset1 = Server.CreateObject("ADODB.Recordset")
    Recordset1.Open "SELECT Top 1 * FROM " & strSheetName, Conn_Sdms, 1, 3
    For i = 5 To Recordset1.Fields.Count - 1
        Response.Write "<td width='80'><input Name='chkbox' type='checkbox' value='" & Recordset1.Fields(i).name & "'>" & Recordset1.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='chkbox' 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='chkbox' 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='chkbox' 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='chkbox' type='checkbox' value='班级排名'>班级排名</td>"
    Recordset1.Close
    Set Recordset1 = Nothing
    Response.Write "                  </tr>" & vbCrLf
    Response.Write "                </table></td>" & vbCrLf
    Response.Write "            </tr>" & vbCrLf
    Response.Write "            <tr class='tdbg'>" & vbCrLf
    Response.Write "              <td align='right'>&nbsp;</td>" & vbCrLf
    Response.Write "              <td colspan='2'><input name='ShowTarget' type='checkbox' id='ShowTarget' value='True'>" & vbCrLf
    Response.Write "                显示目标分及达标/跳格情况</td>" & vbCrLf
    Response.Write "            </tr>" & vbCrLf
    Response.Write "            <tr class='tdbg'>" & vbCrLf
    Response.Write "              <td align='right'><strong>排序方式：</strong></td>" & vbCrLf
    Response.Write "              <td colspan='2' align='left'><select name='OrderType' id='OrderType'>" & vbCrLf
    Response.Write "                <option value='1' selected>按学号排序" & vbCrLf
    Response.Write "                <option value='2'>按总分排序" & vbCrLf
    Response.Write "                <option value='3'>按全级名次排序" & vbCrLf
    Response.Write "                <option value='4'>按班级名次排序                " & vbCrLf
    Response.Write "              </select></td>" & vbCrLf
    Response.Write "            </tr>" & vbCrLf
    Response.Write "            <tr align='center' class='tdbg'> " & vbCrLf
    Response.Write "              <td height='43' colspan='3'><input type='submit' Name='Submit' value='下一步'></td>" & vbCrLf
    Response.Write "            </tr>" & vbCrLf
    Response.Write "        </form>" & vbCrLf
    Response.Write "</TABLE>" & vbCrLf
    Response.Write "" & vbCrLf
End Sub

Sub ScoreQueryStep1_1_1()
    Dim rsScore__MMColParam, rsScore, strSQL
    Dim strSheetName, strStudentNum, strName, strGrade, strClass, strSubjects
    strSheetName = ReplaceBadChar(Trim(Request("SheetName")))
    strSubjects = strSheetName & "." & Replace(Request("chkbox"), ", ", ", " & strSheetName & ".")
    Session("txtSheetName") = Request("SheetName")

    strStudentNum = Request("StudentNum")
    strName = Request("Name")
    strGrade = Request("Grade")
    strClass = Request("ClassSelect")

    Set rsScore = Server.CreateObject("ADODB.Recordset")
    strSQL = "Select " & strSheetName & ".StudentNum, StudentInfo.Name, " & strSubjects & " From " & strSheetName
    strSQL = strSQL & " LEFT JOIN StudentInfo ON " & strSheetName & ".StudentNum = StudentInfo.StudentNum"

    If (strStudentNum <> "") Then
        strSQL = strSQL & " Where " & strSheetName & ".StudentNum Like '%" & strStudentNum & "%'"
    ElseIf (strName <> "") Then
        strSQL = strSQL & " Where StudentInfo.Name Like '%" & strName & "%'"
    Else
        If strClass = "All" Then
            strSQL = strSQL & " Where StudentInfo.GradeID=" & CStr(strGrade) & ""
        Else
            strSQL = strSQL & " Where StudentInfo.ClassID=" & CStr(strClass) & " And StudentInfo.GradeID=" & CStr(strGrade) & ""
        End If
    End If
    Dim OrderType, rsScore_numRows
    OrderType = Trim(Request("OrderType"))
    If OrderType = "" Then
        OrderType = 1
    Else
        OrderType = CLng(OrderType)
    End If
    Select Case OrderType
    Case 1
        strSQL = strSQL & " ORDER BY " & strSheetName & ".StudentNum ASC"
    Case 2
        strSQL = strSQL & " ORDER BY " & strSheetName & ".总分 DESC"
    Case 3
        strSQL = strSQL & " ORDER BY " & strSheetName & ".全级排名 ASC"
    Case 4
        strSQL = strSQL & " ORDER BY " & strSheetName & ".班级排名 ASC"
    End Select
    rsScore.Open strSQL, Conn_Sdms, 1, 3
    rsScore_numRows = 0

    Dim Repeat1__numRows
    Repeat1__numRows = -1
    Dim Repeat1__index
    Repeat1__index = 0
    rsScore_numRows = rsScore_numRows + Repeat1__numRows

    Dim rsScore_total
    Dim rsScore_first
    Dim rsScore_last

    rsScore_total = rsScore.RecordCount

    If (rsScore_numRows < 0) Then
        rsScore_numRows = rsScore_total
    ElseIf (rsScore_numRows = 0) Then
        rsScore_numRows = 1
    End If

    rsScore_first = 1
    rsScore_last = rsScore_first + rsScore_numRows - 1

    If (rsScore_total <> -1) Then
        If (rsScore_first > rsScore_total) Then
            rsScore_first = rsScore_total
        End If
        If (rsScore_last > rsScore_total) Then
            rsScore_last = rsScore_total
        End If
        If (rsScore_numRows > rsScore_total) Then
            rsScore_numRows = rsScore_total
        End If
    End If

    If (rsScore_total = -1) Then

        rsScore_total = 0
        While (Not rsScore.EOF)
            rsScore_total = rsScore_total + 1
            rsScore.MoveNext
        Wend

        If (rsScore.CursorType > 0) Then
            rsScore.movefirst
        Else
            rsScore.Requery
        End If

        If (rsScore_numRows < 0 Or rsScore_numRows > rsScore_total) Then
            rsScore_numRows = rsScore_total
        End If

        rsScore_first = 1
        rsScore_last = rsScore_first + rsScore_numRows - 1

        If (rsScore_first > rsScore_total) Then
            rsScore_first = rsScore_total
        End If
        If (rsScore_last > rsScore_total) Then
            rsScore_last = rsScore_total
        End If

    End If

    Response.Write "<table width='100%' class='border' border='0' cellspacing='1' cellpadding='4' align='center'> " & vbCrLf
    Response.Write "  <tr>  " & vbCrLf
    Response.Write "    <td align='center' class='title'>  " & vbCrLf
    Response.Write "      <b>学 生 成 绩 查 询</b> " & vbCrLf
    Response.Write "    </td> " & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "</table>" & vbCrLf
    Response.Write "<TABLE cellSpacing=0 cellPadding=0 width=760 align=center border=0>" & vbCrLf
    Response.Write "  <TR> " & vbCrLf
    Response.Write "    <TD valign='top' ><font size='5'><strong>按考试查询方式</strong></font><br>" & vbCrLf
    Response.Write "      <br>" & vbCrLf
    Response.Write "      <b><font color='#FF0000'>" & vbCrLf
    Response.Write "            考试名称：</font></b>&nbsp;" & vbCrLf
    Response.Write "" & vbCrLf
    Dim rsTestName
    Set rsTestName = Server.CreateObject("ADODB.Recordset")
    rsTestName.Open "SELECT SheetName, TestName FROM TestName WHERE SheetName = '" & strSheetName & "'", Conn_Sdms, 1, 3
    Response.Write rsTestName("TestName")
    rsTestName.Close
    Set rsTestName = Nothing

    Response.Write "<font color='#FF0000'><b><font color='#0066cc'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font>" & vbCrLf
    Response.Write "</b></font><font color='#FF0000'><b>&nbsp;查询条件：</b>" & vbCrLf
    Response.Write "</font> " & vbCrLf


    If Request("StudentNum") <> "" Then
        Response.Write "学号中含有“" & strStudentNum & "”"
    ElseIf strName <> "" Then
        Response.Write "姓名中含有“" & strName & "”"
    Else
        If strClass <> "" Then
            Dim GradeName, strSearch, SearchResult
            If Trim(strClass) = "All" Then
                strClass = " 全级"
                Set GradeName = Conn_Sdms.Execute("Select GradeName From Grade Where GradeID=" & strGrade & "")
                strSearch = GradeName(0) & " " & strClass
                Set GradeName = Nothing
            Else
                Set SearchResult = Conn_Sdms.Execute("Select G.GradeName,C.ClassName From Class C Left join Grade G On C.GradeID= G.GradeID Where C.ClassID=" & CLng(strClass) & "")
                strSearch = SearchResult(0) & " " & SearchResult(1)
                Set SearchResult = Nothing
            End If

        End If
        Response.Write strSearch
    End If
    If rsScore.EOF Or rsScore.BOF Then
        Response.Write "<br><br><br>找不到符合条件的记录！<br><br><br>"
    Else
        Response.Write "      &nbsp;&nbsp;&nbsp;&nbsp;共找到&nbsp;<font color='#FF0000'>" & rsScore_total & "</font>&nbsp;条记录！ " & vbCrLf
        Response.Write "            " & vbCrLf
        Response.Write "      <table cellspacing=0 border=1 cellpadding='0' align='center'>" & vbCrLf
        Response.Write "        <tr align='center' valign='middle' bordercolor='#FFCC00'> " & vbCrLf
        Response.Write "          <td width='60' rowspan='2'><font color='#000000'><strong>学 号</strong>" & vbCrLf
        Response.Write "          </font></td>" & vbCrLf
        Response.Write "          <td width='50' rowspan='2'><font color='#000000'><strong>姓 名</strong>" & vbCrLf
        Response.Write "          </font></td>" & vbCrLf

        
        Dim ArrSubject, strSubject, SubjectCount, ScoreCount, TargetCount, strTemp, i, rsTarget__MMColParam
        Dim ArrPass(), ArrExcel(), ArrAttain(), ArrBeyond()
        strTemp = Request("chkbox")
        SubjectCount = 0
        ArrSubject = Split(strTemp, ",")
        ReDim ArrPass(UBound(ArrSubject) + 1)
        ReDim ArrExcel(UBound(ArrSubject) + 1)
        ReDim ArrAttain(UBound(ArrSubject) + 1)
        ReDim ArrBeyond(UBound(ArrSubject) + 1)

        For i = LBound(ArrSubject) To UBound(ArrSubject)
            strSubject = Trim(CStr(ArrSubject(i)))
            Response.Write "<td height='20' colspan='2'><font color='#000000'><b>" & strSubject & "</b></font></td>"
            ArrPass(i) = 0
            ArrExcel(i) = 0
            ArrAttain(i) = 0
            ArrBeyond(i) = 0
            If strSubject <> "总分" And strSubject <> "平均分" And strSubject <> "全级排名" And strSubject <> "班级排名" Then
                SubjectCount = SubjectCount + 1
            End If
        Next

        Response.Write "        </tr>" & vbCrLf
        Response.Write "        <tr align='center' valign='middle' bordercolor='#FFCC00'> " & vbCrLf

                                  
        For i = LBound(ArrSubject) To UBound(ArrSubject)
            strSubject = Trim(CStr(ArrSubject(i)))
            If strSubject <> "全级排名" And strSubject <> "班级排名" Then
                Response.Write "<td height='20' width='30'><font color='#000000'>成绩</font></td><td height='20' width='30'><font color='#000000'>目标</font></td>"
            Else
                Response.Write "<td height='20' width='30'><font color='#000000'>名次</font></td><td height='20' width='30'><font color='#000000'>目标</font></td>"
            End If
        Next

        Response.Write "        </tr>" & vbCrLf
        Dim rsTarget
        While ((Repeat1__numRows <> 0) And (Not rsScore.EOF))
            ScoreCount = 0
            TargetCount = 0
            strName = Trim(rsScore.Fields.Item("Name").value)
            If strName = "" Then strName = "&nbsp;"
            rsTarget__MMColParam = CStr(rsScore.Fields.Item("StudentNum").value)
            Set rsTarget = Server.CreateObject("ADODB.Recordset")
            rsTarget.Open "SELECT * FROM TargetScore WHERE StudentNum = '" + Replace(rsTarget__MMColParam, "'", "''") + "'", Conn_Sdms, 1, 3

            Response.Write "        <tr align='center' valign='middle'> " & vbCrLf
            Response.Write "          <td height='20' nowrap><font color='#000000'>" & rsScore.Fields.Item("StudentNum").value & "</font></td>" & vbCrLf
            Response.Write "          <td height='20' nowrap><font color='#000000'>" & strName & "</font></td>" & vbCrLf
            Response.Write "" & vbCrLf

            Dim strScore, strTarget
            For i = LBound(ArrSubject) To UBound(ArrSubject)
                strSubject = Trim(CStr(ArrSubject(i)))
                If strSubject = "总分" Then
                    strScore = ScoreCount
                    strTarget = TargetCount
                    If strScore < 60 * SubjectCount Then
                        If strScore >= strTarget Then      '达标
                            ArrAttain(i) = ArrAttain(i) + 1
                            strTarget = "<font color='#999999'>" & strTarget & "</font>"
                        Else        '不达标
                            strTarget = "<font color='#ff0000'>" & strTarget & "</font>"
                        End If
                        strScore = "<font color='#ff0000'>" & strScore & "</font>"
                    ElseIf strScore >= 60 * SubjectCount And strScore < 80 * SubjectCount Then
                        ArrPass(i) = ArrPass(i) + 1
                        If strScore >= strTarget Then
                            If strTarget < 60 * SubjectCount Then '跳格
                                ArrBeyond(i) = ArrBeyond(i) + 1
                                strTarget = "<font color='#009900'>" & strTarget & "</font>"
                            Else         '达标
                                ArrAttain(i) = ArrAttain(i) + 1
                                strTarget = "<font color='#999999'>" & strTarget & "</font>"
                            End If
                        Else         '不达标
                            strTarget = "<font color='#ff0000'>" & strTarget & "</font>"
                        End If
                        strScore = "<font color='#0000ff'>" & strScore & "</font>"
                    ElseIf strScore >= 80 * SubjectCount Then
                        ArrPass(i) = ArrPass(i) + 1
                        ArrExcel(i) = ArrExcel(i) + 1
                        If strScore >= strTarget Then
                            If strTarget < 80 Then '跳格
                                ArrBeyond(i) = ArrBeyond(i) + 1
                                strTarget = "<font color='#009900'>" & strTarget & "</font>"
                            Else    '达标
                                ArrAttain(i) = ArrAttain(i) + 1
                                strTarget = "<font color='#999999'>" & strTarget & "</font>"
                            End If
                        Else     '不达标
                            strTarget = "<font color='#ff0000'>" & strTarget & "</font>"
                        End If
                        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)
                        strTarget = Round(TargetCount / SubjectCount, 1)
                    Else
                        strScore = rsScore.Fields.Item(strSubject).value
                        If IsNull(strScore) Then strScore = 0
                        If rsTarget.BOF Or rsTarget.EOF Then
                            strTarget = 0
                        Else
                            strTarget = rsTarget.Fields.Item(strSubject).value
                            If IsNull(strTarget) Then strTarget = 0
                        End If
                        ScoreCount = ScoreCount + strScore
                        TargetCount = TargetCount + strTarget
                    End If
                    If strScore < 60 Then
                        If strScore >= strTarget Then      '达标
                            ArrAttain(i) = ArrAttain(i) + 1
                            strTarget = "<font color='#999999'>" & strTarget & "</font>"
                        Else        '不达标
                            strTarget = "<font color='#ff0000'>" & strTarget & "</font>"
                        End If
                        strScore = "<font color='#ff0000'>" & strScore & "</font>"
                    ElseIf strScore >= 60 And strScore < 80 Then
                        ArrPass(i) = ArrPass(i) + 1
                        If strScore >= strTarget Then
                            If strTarget < 60 Then '跳格
                                ArrBeyond(i) = ArrBeyond(i) + 1
                                strTarget = "<font color='#009900'>" & strTarget & "</font>"
                            Else         '达标
                                ArrAttain(i) = ArrAttain(i) + 1
                                strTarget = "<font color='#999999'>" & strTarget & "</font>"
                            End If
                        Else         '不达标
                            strTarget = "<font color='#ff0000'>" & strTarget & "</font>"
                        End If
                        strScore = "<font color='#0000ff'>" & strScore & "</font>"
                    ElseIf strScore >= 80 Then
                        ArrPass(i) = ArrPass(i) + 1
                        ArrExcel(i) = ArrExcel(i) + 1
                        If strScore >= strTarget Then
                            If strTarget < 80 Then '跳格
                                ArrBeyond(i) = ArrBeyond(i) + 1
                                strTarget = "<font color='#009900'>" & strTarget & "</font>"
                            Else    '达标
                                ArrAttain(i) = ArrAttain(i) + 1
                                strTarget = "<font color='#999999'>" & strTarget & "</font>"
                            End If
                        Else     '不达标
                            strTarget = "<font color='#ff0000'>" & strTarget & "</font>"
                        End If
                        strScore = "<font color='#009900'>" & strScore & "</font>"
                    End If
                End If
                Response.Write "<td height='20'>" & strScore & "</td>"
                Response.Write "<td height='20'>" & strTarget & "</td>"
            Next

            Response.Write "        </tr>" & vbCrLf

            rsTarget.Close
            Repeat1__index = Repeat1__index + 1
            Repeat1__numRows = Repeat1__numRows - 1
            rsScore.MoveNext
        Wend

        Response.Write "        <tr align='center' valign='middle'> " & vbCrLf
        Response.Write "          <td colspan='2' hight='20' align='right'><font color='#000000'>合格人数/达标人数：</font></td>" & vbCrLf


        For i = LBound(ArrSubject) To UBound(ArrSubject)
            strSubject = Trim(CStr(ArrSubject(i)))
            If strSubject = "全级排名" Or strSubject = "班级排名" Then
                Response.Write "<td height='20'>&nbsp;</td><td height='20'>&nbsp;</td>"
            Else
                Response.Write "<td height='20'>" & ArrPass(i) & "</td><td height='20'>" & ArrAttain(i) & "</td>"
            End If
        Next

        Response.Write "        </tr>" & vbCrLf
        Response.Write "        <tr align='center' valign='middle'> " & vbCrLf
        Response.Write "          <td colspan='2' hight='20' align='right'><font color='#000000'>合格率/达标率：</font></td>" & vbCrLf

        For i = LBound(ArrSubject) To UBound(ArrSubject)
            strSubject = Trim(CStr(ArrSubject(i)))
            If strSubject = "全级排名" Or strSubject = "班级排名" Then
                Response.Write "<td height='20'>&nbsp;</td><td height='20'>&nbsp;</td>"
            Else
                Response.Write "<td height='20'>" & Round(ArrPass(i) / (rsScore_total) * 100, 1) & "%</td><td height='20'>" & Round(ArrAttain(i) / (rsScore_total) * 100, 1) & "%</td>"
            End If
        Next
        Response.Write "        </tr>" & vbCrLf
        Response.Write "        <tr align='center' valign='middle'> " & vbCrLf
        Response.Write "          <td colspan='2' hight='20' align='right'><font color='#000000'>优秀人数/跳格人数：</font></td>" & vbCrLf
        Response.Write "" & vbCrLf

        For i = LBound(ArrSubject) To UBound(ArrSubject)
            strSubject = Trim(CStr(ArrSubject(i)))
            If strSubject = "全级排名" Or strSubject = "班级排名" Then
                Response.Write "<td height='20'>&nbsp;</td><td height='20'>&nbsp;</td>"
            Else
                Response.Write "<td height='20'>" & ArrExcel(i) & "</td><td height='20'>" & ArrBeyond(i) & "</td>"
            End If
        Next

        Response.Write "        </tr>" & vbCrLf
        Response.Write "        <tr align='center' valign='middle'> " & vbCrLf
        Response.Write "          <td colspan='2' hight='20' align='right'><font color='#000000'>优秀率/跳格率：</font></td>" & vbCrLf
        Response.Write "" & vbCrLf

        For i = LBound(ArrSubject) To UBound(ArrSubject)
            strSubject = Trim(CStr(ArrSubject(i)))
            If strSubject = "全级排名" Or strSubject = "班级排名" Then
                Response.Write "<td height='20'>&nbsp;</td><td height='20'>&nbsp;</td>"
            Else
                Response.Write "<td height='20'>" & Round(ArrExcel(i) / (rsScore_total) * 100, 1) & "%</td><td height='20'>" & Round(ArrBeyond(i) / (rsScore_total) * 100, 1) & "%</td>"
            End If
        Next
        Response.Write "        </tr>" & vbCrLf
        Response.Write "        <tr align='center' valign='middle'> " & vbCrLf
        Response.Write "          <td colspan='2' hight='20' align='right'><font color='#000000'>两率和：</font></td>" & vbCrLf
        Response.Write "" & vbCrLf

        For i = LBound(ArrSubject) To UBound(ArrSubject)
            strSubject = Trim(CStr(ArrSubject(i)))
            If strSubject = "全级排名" Or strSubject = "班级排名" Then
                Response.Write "<td height='20'>&nbsp;</td><td height='20'>&nbsp;</td>"
            Else
                Response.Write "<td height='20'>" & Round((ArrPass(i) + ArrExcel(i)) / (rsScore_total) * 100, 1) & "%</td><td height='20'>" & Round((ArrAttain(i) + ArrBeyond(i)) / (rsScore_total) * 100, 1) & "%</td>"
            End If
        Next
        Response.Write "        </tr>" & vbCrLf
        Response.Write "      </table>" & vbCrLf
        Response.Write "      <font color='#000000'><strong>说明：</strong><br>" & vbCrLf
        Response.Write "            成绩表示方法：60分以下用<font color='#FF0000'>红色</font>表示，60--79分用<font color='#0000FF'>蓝色" & vbCrLf
        Response.Write "            </font>表示，80分及以上用<font color='#009900'>绿色" & vbCrLf
        Response.Write "            </font>表示。<br>" & vbCrLf
        Response.Write "      达标表示方法：不达标用<font color='#FF0000'>红色</font>表示，达标用" & vbCrLf
        Response.Write "      </font><font color='#999999'>灰色</font><font color='#000000'>表示，跳格用<font color='#009900'>绿色" & vbCrLf
        Response.Write "      </font>表示。" & vbCrLf
        Response.Write "      <br>" & vbCrLf
        Response.Write "      这里显示的总分和平均分是按所选定的科目来计算的，而全级排名和班级排名是以本次考试的所有科目的总分来排名的。所以若没有显示所有科目，则两者之间可能会有出入，这是正常现象。</font>" & vbCrLf

    End If

    Response.Write "    </TD>" & vbCrLf
    Response.Write "  </TR>" & vbCrLf
    Response.Write "</TABLE>" & vbCrLf
    Response.Write "" & vbCrLf


    rsScore.Close
End Sub

Sub ScoreQueryStep1_1_2()
    Dim strSheetName, strStudentNum, strName, strGrade, strClass, strSubjects
    strSheetName = ReplaceBadChar(Trim(Request("SheetName")))
    strSubjects = strSheetName & "." & Replace(Request("chkbox"), ", ", ", " & strSheetName & ".")

    Session("txtSheetName") = Request("SheetName")

    strStudentNum = Request("StudentNum")
    strName = Request("Name")
    strGrade = Request("Grade")
    strClass = Request("ClassSelect")
    Dim rsScore, strSQL, OrderType
    Set rsScore = Server.CreateObject("ADODB.Recordset")

    strSQL = "Select " & strSheetName & ".StudentNum, StudentInfo.Name, " & strSubjects & " From " & strSheetName
    strSQL = strSQL & " LEFT JOIN StudentInfo ON " & strSheetName & ".StudentNum = StudentInfo.StudentNum"

    If (strStudentNum <> "") Then
        strSQL = strSQL & " Where " & strSheetName & ".StudentNum Like '%" & strStudentNum & "%'"
    ElseIf (strName <> "") Then
        strSQL = strSQL & " Where StudentInfo.Name Like '%" & strName & "%'"
    Else
        If strClass = "All" Then
            strSQL = strSQL & " Where GradeID=" & CStr(strGrade) & ""
        Else
            strSQL = strSQL & " Where ClassID=" & CStr(strClass) & " And GradeID=" & CStr(strGrade) & ""
        End If
    End If

    OrderType = Trim(Request("OrderType"))
    If OrderType = "" Then
        OrderType = 1
    Else
        OrderType = CLng(OrderType)
    End If
    Select Case OrderType
    Case 1
        strSQL = strSQL & " ORDER BY " & strSheetName & ".StudentNum ASC"
    Case 2
        strSQL = strSQL & " ORDER BY " & strSheetName & ".总分 DESC"
    Case 3
        strSQL = strSQL & " ORDER BY " & strSheetName & ".全级排名 ASC"
    Case 4
        strSQL = strSQL & " ORDER BY " & strSheetName & ".班级排名 ASC"
    End Select
    Dim rsScore_numRows
    rsScore.Open strSQL, Conn_Sdms, 1, 3
    rsScore_numRows = 0

    Dim Repeat1__numRows
    Repeat1__numRows = -1
    Dim Repeat1__index
    Repeat1__index = 0
    rsScore_numRows = rsScore_numRows + Repeat1__numRows

    Dim rsScore_total
    Dim rsScore_first
    Dim rsScore_last

    rsScore_total = rsScore.RecordCount

    If (rsScore_numRows < 0) Then
        rsScore_numRows = rsScore_total
    ElseIf (rsScore_numRows = 0) Then
        rsScore_numRows = 1
    End If

    rsScore_first = 1
    rsScore_last = rsScore_first + rsScore_numRows - 1

    If (rsScore_total <> -1) Then
        If (rsScore_first > rsScore_total) Then
            rsScore_first = rsScore_total
        End If
        If (rsScore_last > rsScore_total) Then
            rsScore_last = rsScore_total
        End If
        If (rsScore_numRows > rsScore_total) Then
            rsScore_numRows = rsScore_total
        End If
    End If

    If (rsScore_total = -1) Then
        rsScore_total = 0
        While (Not rsScore.EOF)
            rsScore_total = rsScore_total + 1
            rsScore.MoveNext
        Wend
        If (rsScore.CursorType > 0) Then
            rsScore.movefirst
        Else
            rsScore.Requery
        End If
        If (rsScore_numRows < 0 Or rsScore_numRows > rsScore_total) Then
            rsScore_numRows = rsScore_total
        End If
        rsScore_first = 1
        rsScore_last = rsScore_first + rsScore_numRows - 1
        If (rsScore_first > rsScore_total) Then
            rsScore_first = rsScore_total
        End If
        If (rsScore_last > rsScore_total) Then
            rsScore_last = rsScore_total
        End If

    End If

    Response.Write "<br>" & vbCrLf
    Response.Write "<table width='100%' class='border' border='0' cellspacing='1' cellpadding='4' align='center'> " & vbCrLf
    Response.Write "  <tr>  " & vbCrLf
    Response.Write "    <td align='center' class='title'>  " & vbCrLf
    Response.Write "      <b>学 生 成 绩 查 询</b> " & vbCrLf
    Response.Write "    </td> " & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "</table>" & vbCrLf
    Response.Write "<TABLE cellSpacing=0 cellPadding=0 width=760 align=center border=0>" & vbCrLf
    Response.Write "  <TR> " & vbCrLf
    Response.Write "    <TD valign='top' >" & vbCrLf
    Response.Write "      <br>" & vbCrLf
    Response.Write "      <b><font color='#FF0000'>" & vbCrLf
    Response.Write "            考试名称：</font></b>&nbsp;" & vbCrLf
    Response.Write "" & vbCrLf
    Dim rsTestName
    Set rsTestName = Server.CreateObject("ADODB.Recordset")
    rsTestName.Open "SELECT SheetName, TestName FROM TestName WHERE SheetName = '" & strSheetName & "'", Conn_Sdms, 1, 3
    Response.Write rsTestName("TestName")
    rsTestName.Close
    Set rsTestName = Nothing

    Response.Write "            <font color='#FF0000'><b><font color='#0066cc'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font>" & vbCrLf
    Response.Write "            </b></font>" & vbCrLf
    Response.Write "            <font color='#FF0000'><b>&nbsp;查询条件：</b>" & vbCrLf
    Response.Write "            </font> " & vbCrLf

                 'dim arrGrade
                 'arrGrade=split("一,二,三,四,五,六",",")
    If Request("StudentNum") <> "" Then
        Response.Write "学号中含有“" & strStudentNum & "”"
    ElseIf strName <> "" Then
        Response.Write "姓名中含有“" & strName & "”"
    Else
        If strClass <> "" Then
            Dim SearchResult, strSearch, GradeName
            If Trim(strClass) = "All" Then
                strClass = " 全级"
                Set GradeName = Conn_Sdms.Execute("Select GradeName From Grade Where GradeID=" & strGrade & "")
                strSearch = GradeName(0) & " " & strClass
                Set GradeName = Nothing
            Else
                Set SearchResult = Conn_Sdms.Execute("Select G.GradeName,C.ClassName From Class C Left join Grade G On C.GradeID= G.GradeID Where C.ClassID=" & CLng(strClass) & "")
                strSearch = SearchResult(0) & " " & SearchResult(1)
                Set SearchResult = Nothing
            End If

        End If
        Response.Write strSearch
    End If
    If rsScore.EOF Or rsScore.BOF Then
        Response.Write "<br><br><br>找不到符合条件的记录！<br><br><br>"
    Else

        Response.Write "      &nbsp;&nbsp;&nbsp;&nbsp;共找到&nbsp;<font color='#FF0000'>" & rsScore_total & "</font>&nbsp;条记录！ " & vbCrLf
        Response.Write "     <table class='border' border='0' cellspacing='1' cellpadding='4' align='center'>       " & vbCrLf
        Response.Write "        <tr class='title'> " & vbCrLf
        Response.Write "          <td width='50' align='center'>" & vbCrLf
        Response.Write "          <font color='#000000'><strong>学 号</strong>" & vbCrLf
        Response.Write "          </font></td>" & vbCrLf
        Response.Write "          <td width='45' align='center'>" & vbCrLf
        Response.Write "          <font color='#000000'><strong>姓 名</strong>" & vbCrLf
        Response.Write "          </font></td>" & vbCrLf
        Dim strTemp, i
        strTemp = Request("chkbox")
        Dim ArrSubject, strSubject, SubjectCount, ScoreCount
        Dim ArrPass(), ArrExcel(), ArrAttain(), ArrBeyond()
        ArrSubject = Split(strTemp, ",")
        ReDim ArrPass(UBound(ArrSubject) + 1)
        ReDim ArrExcel(UBound(ArrSubject) + 1)
        ReDim ArrAttain(UBound(ArrSubject) + 1)
        ReDim ArrBeyond(UBound(ArrSubject) + 1)

        For i = LBound(ArrSubject) To UBound(ArrSubject)
            strSubject = Trim(CStr(ArrSubject(i)))
            Response.Write "<td height='20' align='center'><font color='#000000'><b>" & strSubject & "</b></font></td>"
            ArrPass(i) = 0
            ArrExcel(i) = 0
            ArrAttain(i) = 0
            ArrBeyond(i) = 0
            If strSubject <> "总分" And strSubject <> "平均分" And strSubject <> "全级排名" And strSubject <> "班级排名" Then
            SubjectCount = SubjectCount + 1
            End If
        Next

        Response.Write "         </tr>"
        Dim strScore
        While ((Repeat1__numRows <> 0) And (Not rsScore.EOF))
            ScoreCount = 0
            strName = Trim(rsScore.Fields.Item("Name").value)
            If strName = "" Then strName = "&nbsp;"

            Response.Write "        <tr class='tdbg' onmouseout=this.style.backgroundColor='' onmouseover=this.style.backgroundColor='#BFDFFF'>   " & vbCrLf
            Response.Write "          <td height='20' align='center' nowrap><font color='#000000'>" & rsScore.Fields.Item("StudentNum").value & "</font></td>" & vbCrLf
            Response.Write "          <td height='20' align='center' nowrap><font color='#000000'>" & strName & "</font></td>" & vbCrLf

            For i = LBound(ArrSubject) To UBound(ArrSubject)
                strSubject = Trim(CStr(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
                        ArrPass(i) = ArrPass(i) + 1
                        strScore = "<font color='#0000ff'>" & strScore & "</font>"
                    ElseIf strScore >= 80 * SubjectCount Then
                        ArrPass(i) = ArrPass(i) + 1
                        ArrExcel(i) = ArrExcel(i) + 1
                        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
                        ArrPass(i) = ArrPass(i) + 1
                        strScore = "<font color='#0000ff'>" & strScore & "</font>"
                    ElseIf strScore >= 80 Then
                        ArrPass(i) = ArrPass(i) + 1
                        ArrExcel(i) = ArrExcel(i) + 1
                        strScore = "<font color='#009900'>" & strScore & "</font>"
                    End If
                End If
                Response.Write "<td height='20' align='center'>" & strScore & "</td>"
            Next
                                  

            Response.Write "        </tr>" & vbCrLf
            Response.Write "" & vbCrLf

            Repeat1__index = Repeat1__index + 1
            Repeat1__numRows = Repeat1__numRows - 1
            rsScore.MoveNext
        Wend

        Response.Write "        <tr align='center' valign='middle'> " & vbCrLf
        Response.Write "          <td colspan='2' hight='20' align='right'><font color='#000000'>合格人数：</font>" & vbCrLf
        Response.Write "          </td>" & vbCrLf

        For i = LBound(ArrSubject) To UBound(ArrSubject)
            strSubject = Trim(CStr(ArrSubject(i)))
            If strSubject = "全级排名" Or strSubject = "班级排名" Then
                Response.Write "<td height='20'>&nbsp;</td>"
            Else
                Response.Write "<td height='20'>" & ArrPass(i) & "</td>"
            End If
        Next

        Response.Write "        </tr>" & vbCrLf
        Response.Write "        <tr align='center' valign='middle'> " & vbCrLf
        Response.Write "          <td colspan='2' hight='20' align='right'><font color='#000000'>合格率：</font></td>" & vbCrLf


        For i = LBound(ArrSubject) To UBound(ArrSubject)
            strSubject = Trim(CStr(ArrSubject(i)))
            If strSubject = "全级排名" Or strSubject = "班级排名" Then
                Response.Write "<td height='20'>&nbsp;</td>"
            Else
                Response.Write "<td height='20'>" & Round(ArrPass(i) / (rsScore_total) * 100, 1) & "%</td>"
            End If
        Next
                                  

        Response.Write "        </tr>" & vbCrLf
        Response.Write "        <tr align='center' valign='middle'> " & vbCrLf
        Response.Write "          <td colspan='2' hight='20' align='right'><font color='#000000'>优秀人数：</font></td>" & vbCrLf
        Response.Write "" & vbCrLf

        For i = LBound(ArrSubject) To UBound(ArrSubject)
            strSubject = Trim(CStr(ArrSubject(i)))
            If strSubject = "全级排名" Or strSubject = "班级排名" Then
                Response.Write "<td height='20'>&nbsp;</td>"
            Else
                Response.Write "<td height='20'>" & ArrExcel(i) & "</td>"
            End If
        Next
                                  
        Response.Write "        </tr>" & vbCrLf
        Response.Write "        <tr align='center' valign='middle'> " & vbCrLf
        Response.Write "          <td colspan='2' hight='20' align='right'><font color='#000000'>优秀率：</font></td>" & vbCrLf
        Response.Write "" & vbCrLf

        For i = LBound(ArrSubject) To UBound(ArrSubject)
            strSubject = Trim(CStr(ArrSubject(i)))
            If strSubject = "全级排名" Or strSubject = "班级排名" Then
                Response.Write "<td height='20'>&nbsp;</td>"
            Else
                Response.Write "<td height='20'>" & Round(ArrExcel(i) / (rsScore_total) * 100, 1) & "%</td>"
            End If
        Next
                                  

        Response.Write "        </tr>" & vbCrLf
        Response.Write "        <tr align='center' valign='middle'> " & vbCrLf
        Response.Write "          <td colspan='2' hight='20' align='right'><font color='#000000'>两率和：</font></td>" & vbCrLf

        For i = LBound(ArrSubject) To UBound(ArrSubject)
            strSubject = Trim(CStr(ArrSubject(i)))
            If strSubject = "全级排名" Or strSubject = "班级排名" Then
                Response.Write "<td height='20'>&nbsp;</td>"
            Else
                Response.Write "<td height='20'>" & Round((ArrPass(i) + ArrExcel(i)) / (rsScore_total) * 100, 1) & "%</td>"
            End If
        Next
                                  

        Response.Write "        </tr>" & vbCrLf
        Response.Write "      </table>" & vbCrLf
        Response.Write "      <font color='#000000'><strong>说明：</strong><br>" & vbCrLf
        Response.Write "            　　成绩表示方法：60分以下用<font color='#FF0000'>红色" & vbCrLf
        Response.Write "            </font>表示，60--79分用<font color='#0000FF'>蓝色</font>表示，80分及以上用<font color='#009900'>绿色</font>表示。<br>" & vbCrLf
        Response.Write "      　　达标表示方法：不达标用<font color='#FF0000'>红色" & vbCrLf
        Response.Write "      </font>表示，达标用</font><font color='#999999'>灰色" & vbCrLf
        Response.Write "      </font><font color='#000000'>表示，跳格用<font color='#009900'>绿色" & vbCrLf
        Response.Write "      </font>表示。" & vbCrLf
        Response.Write "      <br>" & vbCrLf
        Response.Write "      　　这里显示的总分和平均分是按所选定的科目来计算的，而全级排名和班级排名是以本次考试的所有科目的总分来排名的。所以若没有显示所有科目，则两者之间可能会有出入，这是正常现象。</font>" & vbCrLf

    End If

    Response.Write "    </TD>" & vbCrLf
    Response.Write "  </TR>" & vbCrLf
    Response.Write "</TABLE>" & vbCrLf
    Response.Write "" & vbCrLf


    rsScore.Close
End Sub

Sub ScoreQueryStep1_2()
    Response.Write "<script language=""JavaScript"">" & vbCrLf
    Response.Write "function check()" & vbCrLf
    Response.Write "{" & vbCrLf
    Response.Write "var total=0;" & vbCrLf
    Response.Write "var intmax=document.form1.chkbox.length;" & vbCrLf
    Response.Write "if(intmax>1){" & vbCrLf
    Response.Write "  for(var idx=0;idx<intmax;idx++){" & vbCrLf
    Response.Write "    if(eval(""document.form1.chkbox["" + idx + ""].checked"")==true){" & vbCrLf
    Response.Write "      total+=1;" & vbCrLf
    Response.Write "    }" & vbCrLf
    Response.Write "  }" & vbCrLf
    Response.Write "  if(total==0){" & vbCrLf
    Response.Write "    alert(""您未选择任何考试！"");" & vbCrLf
    Response.Write "    document.form1.chkbox[0].focus();" & vbCrLf
    Response.Write "    return false;" & vbCrLf
    Response.Write "  }" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "else{" & vbCrLf
    Response.Write "  if(document.form1.chkbox.checked==false){" & vbCrLf
    Response.Write "    alert(""您未选择任何考试！"");" & vbCrLf
    Response.Write "    document.form1.chkbox.focus();" & vbCrLf
    Response.Write "    return false;" & vbCrLf
    Response.Write "  }" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "</script>" & vbCrLf
    Response.Write "<script language=""JavaScript"" type=""text/JavaScript"">" & vbCrLf
    Response.Write "function ChangeClass(num)" & vbCrLf
    Response.Write "{" & vbCrLf
    Response.Write "    var i;" & vbCrLf
    Response.Write "    var j;" & vbCrLf
    Response.Write "    for(i=document.form1.ClassSelect.options.length-1;i>=0;i--)" & vbCrLf
    Response.Write "    {" & vbCrLf
    Response.Write "        document.form1.ClassSelect.options[i]=null;" & vbCrLf
    Response.Write "    }" & vbCrLf
    Response.Write "" & vbCrLf
    Response.Write "    for(j=0;j<document.Classes.all(""Grade""+num).options.length;j++)" & vbCrLf
    Response.Write "    {" & vbCrLf
    Response.Write "        document.form1.ClassSelect.options[j]=new Option(document.Classes.all(""Grade""+num).options[j].text,document.Classes.all(""Grade""+num).options[j].value);" & vbCrLf
    Response.Write "    }" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "</script>" & vbCrLf
    Response.Write "" & vbCrLf

    Response.Write "<div id='Layer1' style='position:absolute; left:445px; top:220px; width:188px; height:64px; z-index:1; visibility: hidden;'> " & vbCrLf
    Response.Write GetClass_Option(0)
    Response.Write "</div>" & vbCrLf
    Dim Recordset1


    Set Recordset1 = Server.CreateObject("ADODB.Recordset")
    Recordset1.Open "SELECT * FROM TestName ORDER BY ID DESC", Conn_Sdms, 1, 3


    Dim Repeat1__numRows
    Dim Repeat1__index

    Repeat1__numRows = -1
    Repeat1__index = 0

    Response.Write "<br>" & vbCrLf
    Response.Write "<table width='100%' class='border' border='0' cellspacing='1' cellpadding='4' align='center'> " & vbCrLf
    Response.Write "  <tr>  " & vbCrLf
    Response.Write "    <td align='center' class='title' colspan='3'>  " & vbCrLf
    Response.Write "      <b>学 生 成 绩 查 询</b> (第二步)----请输入查询条件并选择考试</td> " & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "      <form Name='form1'  onSubmit='return check()' action='Admin_ScoreManage.asp?Action=ScoreQueryStep1_2_1' method='post'>" & vbCrLf
    Response.Write "                <tr class='tdbg'> " & vbCrLf
    Response.Write "                  <td width='25%' align='right'><strong>科目名称：</strong></td>" & vbCrLf
    Response.Write "                  <td colspan='2'>" & Request("Subject") & "" & vbCrLf
    Response.Write "                    <input name='Subject' type='hidden' id='Subject' value='" & Request("Subject") & "'> " & vbCrLf
    Response.Write "                  </td>" & vbCrLf
    Response.Write "                </tr>" & vbCrLf
    Response.Write "                <tr class='tdbg'> " & vbCrLf
    Response.Write "                  <td width='25%' align='right'><strong>请输入查询条件：</strong><br>" & vbCrLf
    Response.Write "                    <br>" & vbCrLf
    Response.Write "                  （可从学号或班级两种查询方法任选其一进行查询）</td>" & vbCrLf
    Response.Write "                  <td nowrap>学号： " & vbCrLf
    Response.Write "                    <input type='text' Name='StudentNum' maxlength='16' size='18'> " & vbCrLf
    Response.Write "                    <br> <br>" & vbCrLf
    Response.Write "                班级： " & vbCrLf
    Response.Write "                <select name='Grade' onChange='ChangeClass(this.value)'>" & vbCrLf
    Response.Write GetGrade_Option
    Response.Write "                </select> <select name='ClassSelect'>" & vbCrLf
    Response.Write "                  <option value='All' selected>全级</option>" & vbCrLf
    Response.Write "" & vbCrLf
    Dim RsFirst, FirstGradeID, Sqlin, Rsin
    Set RsFirst = Conn_Sdms.Execute("select top 1 GradeID from Grade order by OrderID asc")
    FirstGradeID = RsFirst("GradeID")
    Set RsFirst = Nothing
    Set Rsin = Server.CreateObject("ADODB.REcordset")
    Sqlin = "select * from Class where GradeID=" & FirstGradeID & " order by OrderID asc"
    Rsin.Open Sqlin, Conn_Sdms, 1, 3
    Do While Not Rsin.EOF
        Response.Write "<option value='" & Rsin("ClassID") & "' >" & Rsin("ClassName") & "</option>"
        Rsin.MoveNext
    Loop
    Set Rsin = Nothing

    Response.Write "                </select> </td>" & vbCrLf
    Response.Write "                  <td><b><font color='#0066cc'>注：</font></b><br>" & vbCrLf
    Response.Write "                    　　1 、若输入了学号，则优先按学号进行查询。 <br> " & vbCrLf
    Response.Write "                    <font color='#FF0000'>　　2、支持模糊查询！</font>" & vbCrLf
    Response.Write "                    <br>" & vbCrLf
    Response.Write "                    例如：<br> &nbsp;&nbsp;&nbsp;&nbsp;在学号查询框中输入2001，则查询结果为学号中包含“2001”的学生</td>" & vbCrLf
    Response.Write "                </tr>" & vbCrLf
    Response.Write "                <tr class='tdbg'> " & vbCrLf
    Response.Write "                  <td width='25%' align='right'><strong>请选择要查询成绩的考试：</strong>" & vbCrLf
    Response.Write "                  </td>" & vbCrLf
    Response.Write "                  <td colspan='2'>" & vbCrLf
    Response.Write "" & vbCrLf
    Dim strSheetName, rsTestName, ExistFlag, k
    While ((Repeat1__numRows <> 0) And (Not Recordset1.EOF))
        strSheetName = Recordset1.Fields.Item("SheetName").value
        Set rsTestName = Conn_Sdms.Execute("SELECT Top 1 * FROM " & strSheetName)

        ExistFlag = False
        For k = 0 To rsTestName.Fields.Count - 1
            If rsTestName.Fields.Item(k).name = CStr(Request("Subject")) Then ExistFlag = True
        Next
        If ExistFlag = True Then
            Response.Write "<input name='chkbox' type='checkbox' value='" & Recordset1.Fields.Item("SheetName").value & "'>"
            Response.Write Recordset1.Fields.Item("TestName").value & "<br>"
        End If
        rsTestName.Close
      Repeat1__index = Repeat1__index + 1
      Repeat1__numRows = Repeat1__numRows - 1
      Recordset1.MoveNext
    Wend
    Response.Write "</td>" & vbCrLf
    Response.Write "                </tr>" & vbCrLf
    Response.Write "                <tr align='center' class='tdbg'> " & vbCrLf
    Response.Write "                  <td height='43' colspan='3'><input type='submit' Name='Submit' value='下一步'></td>" & vbCrLf
    Response.Write "                </tr>" & vbCrLf
    Response.Write "  </form>" & vbCrLf
    Response.Write "</TABLE>" & vbCrLf
    Response.Write "" & vbCrLf


    Recordset1.Close
    Set Recordset1 = Nothing
End Sub

Sub ScoreQueryStep1_2_1()
    Dim strStudentNum, strName, strGrade, strClass, strSubject
    strSubject = ReplaceBadChar(Trim(Request("Subject")))
    strStudentNum = ReplaceBadChar(Trim(Request("StudentNum")))
    strName = ReplaceBadChar(Trim(Request("Name")))
    strGrade = PE_CLng(Trim(Request("Grade")))
    strClass = Request("ClassSelect")
    Dim Recordset1, Recordset1Sql, Recordset1_numRows
    Set Recordset1 = Server.CreateObject("ADODB.Recordset")

    If (strStudentNum <> "") Then
        Recordset1Sql = "SELECT StudentNum,Name FROM StudentInfo WHERE StudentNum like '%" & strStudentNum & "%'  ORDER BY StudentNum"
    Else
        If strClass = "All" Then
            Recordset1Sql = "SELECT StudentNum,Name FROM StudentInfo WHERE GradeID=" & strGrade & " ORDER BY StudentNum"
        Else
            strClass = PE_CLng(strClass)
            Recordset1Sql = "SELECT StudentNum,Name FROM StudentInfo WHERE ClassID=" & strClass & " And GradeID=" & strGrade & " ORDER BY StudentNum"
        End If
    End If
    Recordset1.Open Recordset1Sql, Conn_Sdms, 1, 3
    Recordset1_numRows = 0

    Dim Repeat1__numRows
    Repeat1__numRows = -1
    Dim Repeat1__index
    Repeat1__index = 0
    Recordset1_numRows = Recordset1_numRows + Repeat1__numRows

    Dim Recordset1_total
    Dim Recordset1_first
    Dim Recordset1_last

    Recordset1_total = Recordset1.RecordCount

    If (Recordset1_numRows < 0) Then
        Recordset1_numRows = Recordset1_total
    ElseIf (Recordset1_numRows = 0) Then
        Recordset1_numRows = 1
    End If

    Recordset1_first = 1
    Recordset1_last = Recordset1_first + Recordset1_numRows - 1

    If (Recordset1_total <> -1) Then
        If (Recordset1_first > Recordset1_total) Then
            Recordset1_first = Recordset1_total
        End If
        If (Recordset1_last > Recordset1_total) Then
            Recordset1_last = Recordset1_total
        End If
        If (Recordset1_numRows > Recordset1_total) Then
            Recordset1_numRows = Recordset1_total
        End If
    End If

    If (Recordset1_total = -1) Then

        Recordset1_total = 0
        While (Not Recordset1.EOF)
            Recordset1_total = Recordset1_total + 1
            Recordset1.MoveNext
        Wend

        If (Recordset1.CursorType > 0) Then
            Recordset1.movefirst
        Else
            Recordset1.Requery
        End If

        If (Recordset1_numRows < 0 Or Recordset1_numRows > Recordset1_total) Then
            Recordset1_numRows = Recordset1_total
        End If

        Recordset1_first = 1
        Recordset1_last = Recordset1_first + Recordset1_numRows - 1

        If (Recordset1_first > Recordset1_total) Then
            Recordset1_first = Recordset1_total
        End If
        If (Recordset1_last > Recordset1_total) Then
            Recordset1_last = Recordset1_total
        End If

    End If

    Response.Write "<br>" & vbCrLf
    Response.Write "<table width='100%' class='border' border='0' cellspacing='1' cellpadding='4' align='center'> " & vbCrLf
    Response.Write "  <tr>  " & vbCrLf
    Response.Write "    <td align='center' class='title'>  " & vbCrLf
    Response.Write "      <b>学 生 成 绩 查 询（按科目查询方式）</b> " & vbCrLf
    Response.Write "      </td> " & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "</table>" & vbCrLf
    Response.Write "<TABLE cellSpacing=0 cellPadding=0 width=760 align=center border=0>" & vbCrLf
    Response.Write "  <TR> " & vbCrLf
    Response.Write "    <TD valign='top' ><font size='5'>&nbsp;</font><br>" & vbCrLf
    Response.Write "      <b>" & vbCrLf
    Response.Write "      <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> " & vbCrLf
    Response.Write "" & vbCrLf


    If Request("StudentNum") <> "" Then
        Response.Write "学号中含有“" & strStudentNum & "”"
    ElseIf strName <> "" Then
        Response.Write "姓名中含有“" & strName & "”"
    Else
        If strClass <> "" Then
            Dim GradeName, strSearch, SearchResult
            If Trim(strClass) = "All" Then
                strClass = " 全级"
                Set GradeName = Conn_Sdms.Execute("Select GradeName From Grade Where GradeID=" & strGrade & "")
                strSearch = GradeName(0) & " " & strClass
                Set GradeName = Nothing
            Else
                Set SearchResult = Conn_Sdms.Execute("Select G.GradeName,C.ClassName From Class C Left join Grade G On C.GradeID= G.GradeID Where C.ClassID=" & CLng(strClass) & "")
                strSearch = SearchResult(0) & " " & SearchResult(1)
                Set SearchResult = Nothing
            End If

            End If
        Response.Write strSearch
    End If
    If Recordset1.EOF Or Recordset1.BOF Then
        Response.Write "<br><br><br>找不到符合条件的记录！<br><br><br>"
    Else

        Response.Write "      &nbsp;&nbsp;&nbsp;&nbsp;共找到&nbsp;<font color='#FF0000'>" & Recordset1_total & "</font>&nbsp;条记录！ " & vbCrLf
        Response.Write "            <table class='border' border='0' cellspacing='1' cellpadding='4' align='center'>" & vbCrLf
        Response.Write "              <tr valign='middle' class='title'>           " & vbCrLf
        Response.Write "                <td width='60' rowspan='2' align='center'>学 号</td>" & vbCrLf
        Response.Write "                <td width='50' rowspan='2' align='center'>姓 名</td>" & vbCrLf
        Response.Write "                <td width='50' rowspan='2' align='center'>目 标</td>" & vbCrLf

        Dim arrSheetName
        Dim strSheetName, strTemp, i
        Dim rsSubjects()
        Dim ArrPass(), ArrExcel(), ArrAttain(), ArrBeyond()
        strTemp = Request("chkbox")
        arrSheetName = Split(strTemp, ",")
        ReDim ArrPass(UBound(arrSheetName) + 1)
        ReDim ArrExcel(UBound(arrSheetName) + 1)
        ReDim ArrAttain(UBound(arrSheetName) + 1)
        ReDim ArrBeyond(UBound(arrSheetName) + 1)

        ReDim rsSubjects(UBound(arrSheetName) + 1)
        Dim rsTestName, strTestName
        For i = LBound(arrSheetName) To UBound(arrSheetName)
            strSheetName = Trim(CStr(arrSheetName(i)))
            Set rsTestName = Server.CreateObject("ADODB.Recordset")
            rsTestName.Open "SELECT SheetName, TestName FROM TestName WHERE SheetName = '" + Replace(strSheetName, "'", "''") + "'", Conn_Sdms, 1, 3

            strTestName = rsTestName.Fields.Item("TestName")
            strTestName = Left(strTestName, Len(strTestName) \ 2) & "<br>" & Mid(strTestName, Len(strTestName) \ 2 + 1, Len(strTestName))
            Response.Write "<td height='20' colspan='2' align='center'>" & strTestName & "</td>"
            rsTestName.Close
            Set rsTestName = Nothing
            ArrPass(i) = 0
            ArrExcel(i) = 0
            ArrAttain(i) = 0
            ArrBeyond(i) = 0
        Next

        Response.Write "              </tr>" & vbCrLf
        Response.Write "              <tr align='center' valign='middle' class='title'> " & vbCrLf
        Response.Write "" & vbCrLf

        For i = LBound(arrSheetName) To UBound(arrSheetName)
            If strSubject <> "全级排名" And strSubject <> "班级排名" Then
                Response.Write "<td height='20' align='center'>成绩</td><td height='20' align='center'>达标否</td>"
            Else
                Response.Write "<td height='20' align='center'>名次</td><td height='20' align='center'>达标否</td>"
            End If
        Next

        Response.Write "              </tr>" & vbCrLf
        Dim rsSubjects__MMColParam, rsTarget__MMColParam, rsTarget, Target, strScore, strTarget
        While ((Repeat1__numRows <> 0) And (Not Recordset1.EOF))

            For i = LBound(arrSheetName) To UBound(arrSheetName)
                strSheetName = Trim(CStr(arrSheetName(i)))
                Set rsSubjects(i) = Server.CreateObject("ADODB.Recordset")
                rsSubjects__MMColParam = CStr(Recordset1.Fields.Item("StudentNum"))
                rsSubjects(i).Open "SELECT " & strSubject & " FROM " & strSheetName & " WHERE StudentNum = '" + Replace(rsSubjects__MMColParam, "'", "''") + "'", Conn_Sdms, 1, 3
            Next

            rsTarget__MMColParam = CStr(Recordset1.Fields.Item("StudentNum").value)
            Set rsTarget = Server.CreateObject("ADODB.Recordset")
            rsTarget.Open "SELECT " & strSubject & " FROM TargetScore WHERE StudentNum = '" + Replace(rsTarget__MMColParam, "'", "''") + "'", Conn_Sdms, 1, 3

            If rsTarget.BOF Or rsTarget.EOF Then
                Target = 0
            Else
                Target = rsTarget.Fields.Item(strSubject).value
                If IsNull(Target) Then Target = 0
            End If

            Response.Write "            <tr class='tdbg' onmouseout=this.style.backgroundColor='' onmouseover=this.style.backgroundColor='#BFDFFF'>  " & vbCrLf
            Response.Write "                <td height='20' nowrap align='center'>" & Recordset1.Fields.Item("StudentNum").value & "</td>" & vbCrLf
            Response.Write "                <td height='20' nowrap align='center'>" & Recordset1.Fields.Item("Name").value & "</td>" & vbCrLf
            Response.Write "                <td height='20' align='center'>" & Target & "</td>" & vbCrLf
            Response.Write "" & vbCrLf

            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
                If strScore < 60 Then
                    If strScore >= Target Then      '达标
                        ArrAttain(i) = ArrAttain(i) + 1
                        strTarget = "<font color='#999999'>◇</font>"
                    Else        '不达标
                        strTarget = "<font color='#ff0000'>※</font>"
                    End If
                    strScore = "<font color='#ff0000'>" & strScore & "</font>"
                ElseIf strScore >= 60 And strScore < 80 Then
                    ArrPass(i) = ArrPass(i) + 1
                    If strScore >= Target Then
                        If Target < 60 Then '跳格
                            ArrBeyond(i) = ArrBeyond(i) + 1
                            strTarget = "<font color='#009900'>☆</font>"
                        Else         '达标
                            ArrAttain(i) = ArrAttain(i) + 1
                            strTarget = "<font color='#999999'>◇</font>"
                        End If
                    Else         '不达标
                        strTarget = "<font color='#ff0000'>※</font>"
                    End If
                    strScore = "<font color='#0000ff'>" & strScore & "</font>"
                ElseIf strScore >= 80 Then
                    ArrPass(i) = ArrPass(i) + 1
                    ArrExcel(i) = ArrExcel(i) + 1
                    If strScore >= Target Then
                        If Target < 80 Then '跳格
                            ArrBeyond(i) = ArrBeyond(i) + 1
                            strTarget = "<font color='#009900'>☆</font>"
                        Else    '达标
                            ArrAttain(i) = ArrAttain(i) + 1
                            strTarget = "<font color='#999999'>◇</font>"
                        End If
                    Else     '不达标
                        strTarget = "<font color='#ff0000'>※</font>"
                    End If
                    strScore = "<font color='#009900'>" & strScore & "</font>"
                End If
                Response.Write "<td height='20' align='center'>" & strScore & "</td>"
                Response.Write "<td height='20' align='center'>" & strTarget & "</td>"
            Next

            Response.Write "              </tr>" & vbCrLf

            Repeat1__index = Repeat1__index + 1
            Repeat1__numRows = Repeat1__numRows - 1
            Recordset1.MoveNext
        Wend

        Response.Write "              <tr align='center' valign='middle'> " & vbCrLf
        Response.Write "                <td colspan='3' hight='20' align='right'>合格人数/达标人数：</td>" & vbCrLf
        Response.Write "" & vbCrLf

        For i = LBound(arrSheetName) To UBound(arrSheetName)
            Response.Write "<td height='20'>" & ArrPass(i) & "</td><td height='20'>" & ArrAttain(i) & "</td>"
        Next

        Response.Write "              </tr>" & vbCrLf
        Response.Write "              <tr align='center' valign='middle'> " & vbCrLf
        Response.Write "                <td colspan='3' hight='20' align='right'>合格率/达标率：</td>" & vbCrLf
        Response.Write "" & vbCrLf

        For i = LBound(arrSheetName) To UBound(arrSheetName)
            Response.Write "<td height='20'>" & Round(ArrPass(i) / (Recordset1_total) * 100, 1) & "%</td><td height='20'>" & Round(ArrAttain(i) / (Recordset1_total) * 100, 1) & "%</td>"
        Next

        Response.Write "              </tr>" & vbCrLf
        Response.Write "              <tr align='center' valign='middle'> " & vbCrLf
        Response.Write "                <td colspan='3' hight='20' align='right'>优秀人数/跳格人数：</td>" & vbCrLf
        Response.Write "" & vbCrLf

        For i = LBound(arrSheetName) To UBound(arrSheetName)
            Response.Write "<td height='20'>" & ArrExcel(i) & "</td><td height='20'>" & ArrBeyond(i) & "</td>"
        Next

        Response.Write "              </tr>" & vbCrLf
        Response.Write "              <tr align='center' valign='middle'> " & vbCrLf
        Response.Write "                <td colspan='3' hight='20' align='right'>优秀率/跳格率：</td>" & vbCrLf

        For i = LBound(arrSheetName) To UBound(arrSheetName)
            Response.Write "<td height='20'>" & Round(ArrExcel(i) / (Recordset1_total) * 100, 1) & "%</td><td height='20'>" & Round(ArrBeyond(i) / (Recordset1_total) * 100, 1) & "%</td>"
        Next

        Response.Write "              </tr>" & vbCrLf
        Response.Write "              <tr align='center' valign='middle'> " & vbCrLf
        Response.Write "                <td height='26' colspan='3' align='right' hight='20'>两率和：</td>" & vbCrLf
        Response.Write "" & vbCrLf

        For i = LBound(arrSheetName) To UBound(arrSheetName)
            Response.Write "<td height='20'>" & Round((ArrPass(i) + ArrExcel(i)) / (Recordset1_total) * 100, 1) & "%</td><td height='20'>" & Round((ArrAttain(i) + ArrBeyond(i)) / (Recordset1_total) * 100, 1) & "%</td>"
        Next

        Response.Write "              </tr>" & vbCrLf
        Response.Write "            </table>" & vbCrLf
        Response.Write "            <font color='#000000'><strong>说明：</strong><br>" & vbCrLf
        Response.Write "            　　成绩表示方法：60分以下用<font color='#FF0000'>红色</font>表示，60--79分用<font color='#0000FF'>蓝色</font>表示，80分及以上用<font color='#009900'>绿色" & vbCrLf
        Response.Write "            </font>表示。<br>" & vbCrLf
        Response.Write "      　　达标表示方法：不达标用<font color='#FF0000'>※</font>表示，达标用" & vbCrLf
        Response.Write "      </font><font color='#999999'>◇</font><font color='#000000'>表示，跳格用" & vbCrLf
        Response.Write "      <font color='#009900'>☆</font>表示。" & vbCrLf
        Response.Write "      </font> " & vbCrLf
        Response.Write "" & vbCrLf

    End If
    Response.Write "</TD>" & vbCrLf
    Response.Write "  </TR>" & vbCrLf
    Response.Write "</TABLE>" & vbCrLf
    Response.Write "" & vbCrLf

    Recordset1.Close
End Sub

Sub ScoreModifyQuery()
    Response.Write "<script language=""JavaScript"" type=""text/JavaScript"">" & vbCrLf
    Response.Write "function ChangeClass(num)" & vbCrLf
    Response.Write "{" & vbCrLf
    Response.Write "    var i;" & vbCrLf
    Response.Write "    var j;" & vbCrLf
    Response.Write "    for(i=document.form1.ClassSelect.options.length-1;i>=0;i--)" & vbCrLf
    Response.Write "    {" & vbCrLf
    Response.Write "        document.form1.ClassSelect.options[i]=null;" & vbCrLf
    Response.Write "    }" & vbCrLf
    Response.Write "" & vbCrLf
    Response.Write "    for(j=0;j<document.Classes.all(""Grade""+num).options.length;j++)" & vbCrLf
    Response.Write "    {" & vbCrLf
    Response.Write "        document.form1.ClassSelect.options[j]=new Option(document.Classes.all(""Grade""+num).options[j].text,document.Classes.all(""Grade""+num).options[j].value);" & vbCrLf
    Response.Write "    }" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "</script>" & vbCrLf
    Response.Write "<div id=""Layer1"" style=""position:absolute; left:445px; top:220px; width:188px; height:64px; z-index:1; visibility: hidden;""> " & vbCrLf
    Response.Write GetClass_Option(0)
    Response.Write "</div>" & vbCrLf
    Response.Write "" & vbCrLf

    Response.Write "<br>" & vbCrLf
    Response.Write "<table width='100%' class='border' border='0' cellspacing='1' cellpadding='4' align='center'> " & vbCrLf
    Response.Write "  <tr>  " & vbCrLf
    Response.Write "    <td align='center' class='title' colspan='2'>  " & vbCrLf
    Response.Write "      <b>学 生 成 绩 修 改 / 删 除 (请先查询要修改或删除的记录)</b> " & vbCrLf
    Response.Write "    </td> " & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "        <form Name='form1' action='Admin_ScoreManage.asp?Action=ScoreModifyQueryResult' method='post'>" & vbCrLf
    Response.Write "            <tr class='tdbg'> " & vbCrLf
    Response.Write "              <td width='40%' align='right' nowrap><strong>请选择考试：</strong></td>" & vbCrLf
    Response.Write "              <td> <select Name='sheetName'>" & vbCrLf
    Response.Write "" & vbCrLf
    Dim Recordset1, i
    Set Recordset1 = Server.CreateObject("ADODB.Recordset")

    Recordset1.Open "SELECT * FROM TestName where Locked=False ORDER BY id DESC", Conn_Sdms, 1, 3
    i = 0
    While (Not Recordset1.EOF)
        If i = 0 Then
            Response.Write "<option value='" & Recordset1.Fields.Item("SheetName").value & "' selected>" & Recordset1.Fields.Item("TestName").value & "</option>"
        Else
            Response.Write "<option value='" & Recordset1.Fields.Item("SheetName").value & "'>" & Recordset1.Fields.Item("TestName").value & "</option>"
        End If
        i = i + 1
        Recordset1.MoveNext
    Wend
    If Not Recordset1.EOF And Recordset1.BOF Then
        If (Recordset1.CursorType > 0) Then
            Recordset1.movefirst
        Else
            Recordset1.Requery
        End If
    End If

    Response.Write "                </select> </td>" & vbCrLf
    Response.Write "            </tr>" & vbCrLf
    Response.Write "            <tr class='tdbg'> " & vbCrLf
    Response.Write "              <td width='40%' align='right' nowrap><strong>请输入学号：</strong></td>" & vbCrLf
    Response.Write "              <td> <input Name='StudentNum' type='text' size='18' maxlength='8'>                <b></td>" & vbCrLf
    Response.Write "            </tr>" & vbCrLf
    Response.Write "            <tr class='tdbg'> " & vbCrLf
    Response.Write "              <td width='40%' align='right' nowrap><strong>请选择班级：</strong></td>" & vbCrLf
    Response.Write "              <td nowrap> <select name='Grade' onChange=""ChangeClass(this.value)"">" & vbCrLf
    Response.Write GetGrade_Option
    Response.Write "                </select> <select name='ClassSelect'>" & vbCrLf
    Response.Write "                  <option value='All' selected>全级</option>" & vbCrLf
    Response.Write "" & vbCrLf
    Dim RsFirst, FirstGradeID, Rsin, Sqlin
    Set RsFirst = Conn_Sdms.Execute("select top 1 GradeID from Grade order by OrderID asc")
    FirstGradeID = RsFirst("GradeID")
    Set RsFirst = Nothing
    Set Rsin = Server.CreateObject("ADODB.REcordset")
    Sqlin = "select * from Class where GradeID=" & FirstGradeID & " order by OrderID asc"
    Rsin.Open Sqlin, Conn_Sdms, 1, 3
    Do While Not Rsin.EOF
        Response.Write "<option value='" & Rsin("ClassID") & "' >" & Rsin("ClassName") & "</option>"
        Rsin.MoveNext
    Loop
    Set Rsin = Nothing

                      
    Response.Write "                </select>" & vbCrLf
    Response.Write "              </td>" & vbCrLf
    Response.Write "            </tr>" & vbCrLf
    Response.Write "            <tr align='center' class='tdbg'> " & vbCrLf
    Response.Write "              <td colspan='2'><input name='Submit1' type='submit' id='Submit12' value='查询'></td>" & vbCrLf
    Response.Write "            </tr>" & vbCrLf
    Response.Write "        </form>" & vbCrLf
    Response.Write "</TABLE>" & vbCrLf
    Response.Write "注：<br>" & vbCrLf
    Response.Write "                　　1 、若输入了学号，则优先按学号进行查询。 <br> " & vbCrLf
    Response.Write "                <font color='#FF0000'>　　2、支持模糊查询！</font><br>" & vbCrLf
    Response.Write "                例如：<br> &nbsp;&nbsp;&nbsp;&nbsp;在学号查询框中输入2001，则查询结果为学号中包含“2001”的学生" & vbCrLf
End Sub

Sub ScoreModifyQueryResult()
    Response.Write "<SCRIPT language=javascript>" & vbCrLf
    Response.Write "" & vbCrLf
    Response.Write "function unselectall()" & vbCrLf
    Response.Write "{" & vbCrLf
    Response.Write "    if(document.del.chkAll.checked){" & vbCrLf
    Response.Write "    document.del.chkAll.checked = document.del.chkAll.checked&0;" & vbCrLf
    Response.Write "    }   " & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "" & vbCrLf
    Response.Write "function CheckAll(form)" & vbCrLf
    Response.Write "  {" & vbCrLf
    Response.Write "  for (var i=0;i<form.elements.length;i++)" & vbCrLf
    Response.Write "    {" & vbCrLf
    Response.Write "    var e = form.elements[i];" & vbCrLf
    Response.Write "    if (e.Name != 'chkAll')" & vbCrLf
    Response.Write "       e.checked = form.chkAll.checked;" & vbCrLf
    Response.Write "    }" & vbCrLf
    Response.Write "  }" & vbCrLf
    Response.Write "function ConfirmDel()" & vbCrLf
    Response.Write "{" & vbCrLf
    Response.Write "   if(confirm(""确定要删除选中的记录吗？一旦删除将不能恢复！""))" & vbCrLf
    Response.Write "     return true;" & vbCrLf
    Response.Write "   else" & vbCrLf
    Response.Write "     return false;" & vbCrLf
    Response.Write "     " & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "</SCRIPT>" & vbCrLf
    Dim strSheetName, strStudentNum, strName, strGrade, strClass, strSubjects
    strSheetName = ReplaceBadChar(Trim(Request("SheetName")))

    If Request("SheetName") = "" Then
        Response.Write "<br><br>未选择任何考试,请先添加考试!!"
        Response.End
    End If
    Session("txtSheetName") = Request("SheetName")
    Session("strQureyString") = Request.Form()
    If Session("strQureyString") = "" Then
        Session("strQureyString") = Request.QueryString()
    End If
    
    Dim rsSubjects, i, rsScore, strSQL
    Set rsSubjects = Server.CreateObject("ADODB.Recordset")
    rsSubjects.Open "SELECT Top 1 * FROM " & strSheetName, Conn_Sdms, 1, 3

    strSubjects = strSheetName & "." & rsSubjects.Fields.Item(5).name
    For i = 6 To rsSubjects.Fields.Count - 1
        strSubjects = strSubjects & "," & strSheetName & "." & rsSubjects.Fields.Item(i).name
    Next

    strStudentNum = ReplaceBadChar(Trim(Request("StudentNum")))
    strName = ReplaceBadChar(Trim(Request("Name")))
    strGrade = PE_CLng(Trim(Request("Grade")))
    strClass = Trim(Request("ClassSelect"))

    Set rsScore = Server.CreateObject("ADODB.Recordset")

    strSQL = "Select " & strSheetName & ".StudentNum, StudentInfo.Name, " & strSubjects & " From " & strSheetName
    strSQL = strSQL & " LEFT JOIN StudentInfo ON " & strSheetName & ".StudentNum = StudentInfo.StudentNum"

    If (strStudentNum <> "") Then
        strSQL = strSQL & " Where " & strSheetName & ".StudentNum Like '%" & strStudentNum & "%'"
    ElseIf (strName <> "") Then
        strSQL = strSQL & " Where StudentInfo.Name Like '%" & strName & "%'"
    Else
        If strClass = "All" Then
            strSQL = strSQL & " WHERE StudentInfo.GradeID=" & strGrade
        Else
            strSQL = strSQL & " WHERE StudentInfo.GradeID=" & strGrade & " and StudentInfo.ClassID=" & strClass
        End If

    End If
    strSQL = strSQL & " ORDER BY " & strSheetName & ".StudentNum"
    rsScore.Open strSQL, Conn_Sdms, 1, 3

    Dim Repeat1__numRows
    Repeat1__numRows = -1
    Dim Repeat1__index
    Repeat1__index = 0

    Response.Write "<br>" & vbCrLf
    Response.Write "<table width='100%' class='border' border='0' cellspacing='1' cellpadding='4' align='center'> " & vbCrLf
    Response.Write "  <tr>  " & vbCrLf
    Response.Write "    <td align='center' class='title'>  " & vbCrLf
    Response.Write "      <b>学 生 成 绩 修 改 / 删 除</b> " & vbCrLf
    Response.Write "    </td> " & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "</table><br>" & vbCrLf
    Response.Write "<TABLE cellSpacing=0 cellPadding=0 width='100%' align=center border=0>" & vbCrLf
    Response.Write "  <TBODY>" & vbCrLf
    Response.Write "    <TR> " & vbCrLf
    Response.Write "      <TD >" & vbCrLf
    Response.Write "" & vbCrLf
    If rsScore.EOF Or rsScore.BOF Then
        Response.Write " <br> <br> <br>" & vbCrLf
        Response.Write "                找不到符合条件的记录！<br> <br> <br> " & vbCrLf
        Response.Write "" & vbCrLf
    Else


        Response.Write "        <form Name='del' onsubmit=""return ConfirmDel()"" method='post' action='Admin_ScoreManage.asp?Action=BatchDelScore'>" & vbCrLf
        Response.Write "          <b><font color='#FF0000'>考试名称：</font></b>&nbsp;" & vbCrLf
        Response.Write "" & vbCrLf
        Dim rsTestName
        Set rsTestName = Server.CreateObject("ADODB.Recordset")
        rsTestName.Open "SELECT SheetName, TestName FROM TestName WHERE Locked=False and SheetName = '" & strSheetName & "'", Conn_Sdms, 1, 3
        Response.Write rsTestName.Fields.Item("TestName").value
        rsTestName.Close
        Set rsTestName = Nothing

        Response.Write "<font color='#FF0000'><b><font color='#0066cc'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font></b></font><font color='#FF0000'><b>查询条件：</b></font> " & vbCrLf
            
        If Request("StudentNum") <> "" Then
            Response.Write "学号中含有“" & strStudentNum & "”"
        ElseIf strName <> "" Then
            Response.Write "姓名中含有“" & strName & "”"
        Else
            If strClass <> "" Then
                Dim GradeName, strSearch, SearchResult
                If Trim(strClass) = "All" Then
                    strClass = " 全级"
                    Set GradeName = Conn_Sdms.Execute("Select GradeName From Grade Where GradeID=" & strGrade & "")
                    strSearch = GradeName(0) & " " & strClass
                    Set GradeName = Nothing
                Else
                    Set SearchResult = Conn_Sdms.Execute("Select G.GradeName,C.ClassName From Class C Left join Grade G On C.GradeID= G.GradeID Where C.ClassID=" & CLng(strClass) & "")
                    strSearch = SearchResult(0) & " " & SearchResult(1)
                    Set SearchResult = Nothing
                End If
            End If
            Response.Write strSearch
        End If

        Response.Write "     <table width='100%' class='border' border='0' cellspacing='1' cellpadding='4' align='center'>       " & vbCrLf
        Response.Write "        <tr class='title'> " & vbCrLf
        Response.Write "                      <td height='28' align='center'>" & vbCrLf
        Response.Write "                        删除</td>" & vbCrLf
        Response.Write "                      <td align='center'>学 号</td>" & vbCrLf
        Response.Write "                      <td align='center'>姓 名</td>" & vbCrLf

        For i = 2 To rsScore.Fields.Count - 1
            Response.Write "<td height='28' align='center'>" & rsScore.Fields.Item(i).name & "</td>"
        Next

        Response.Write "                      <td height='28' align='center'>操作</td>" & vbCrLf
        Response.Write "                    </tr>" & vbCrLf
        Response.Write "" & vbCrLf
        Dim tmpScore
        While ((Repeat1__numRows <> 0) And (Not rsScore.EOF))

            Response.Write "        <tr class='tdbg' onmouseout=""this.style.backgroundColor=''"" onmouseover=""this.style.backgroundColor='#BFDFFF'"">   " & vbCrLf
            Response.Write "" & vbCrLf
            Response.Write "                      <td height='22' align='center'> " & vbCrLf
            Response.Write "                        <input type='checkbox' value='" & rsScore.Fields.Item("StudentNum").value & "' onClick=""unselectall()"" Name='chkNum'>                      </td>" & vbCrLf
            Response.Write "" & vbCrLf

            For i = 0 To rsScore.Fields.Count - 1
                tmpScore = rsScore.Fields.Item(i).value
                If IsNull(tmpScore) Then tmpScore = "&nbsp;"
                Response.Write "<td height='20' align='center'>" & tmpScore & "</td>"
            Next

            Response.Write "                      <td height='22' align='center'><A HREF='Admin_ScoreManage.asp?Action=ScoreModify&SheetName=" & strSheetName & "&StudentNum=" & rsScore.Fields.Item("StudentNum").value & "'>修改</A> " & vbCrLf
            Response.Write "                        <A HREF='Admin_ScoreManage.asp?Action=DelScore&sheetName=" & strSheetName & "&StudentNum=" & rsScore.Fields.Item("StudentNum").value & "'>删除</A></td>" & vbCrLf
            Response.Write "                    </tr>" & vbCrLf
            Response.Write "" & vbCrLf

            Repeat1__index = Repeat1__index + 1
            Repeat1__numRows = Repeat1__numRows - 1
            rsScore.MoveNext
        Wend

        Response.Write "                    <tbody>" & vbCrLf
        Response.Write "                    </tbody>" & vbCrLf
        Response.Write "                  </table>" & vbCrLf
        Response.Write "                  <br>" & vbCrLf
        Response.Write "                  <table border='0' cellspacing='0' cellpadding='0' align='left'>" & vbCrLf
        Response.Write "                    <tr> " & vbCrLf
        Response.Write "                      <td width='104'> <input type='checkbox' Name='chkAll' value='1' onClick=""CheckAll(this.form)"">" & vbCrLf
        Response.Write "                        全部选定</td>" & vbCrLf
        Response.Write "                      <td width='104'><input name='SheetName' type='hidden' value='" & Request("SheetName") & "'> " & vbCrLf
        Response.Write "                      </td>" & vbCrLf
        Response.Write "                      <td width='46'> <input type='submit' Name='Submit' value='删除选定的记录'> " & vbCrLf
        Response.Write "                      </td>" & vbCrLf
        Response.Write "                    </tr>" & vbCrLf
        Response.Write "                  </table>" & vbCrLf
        Response.Write "                  <br>" & vbCrLf
        Response.Write "                  <br>" & vbCrLf
        Response.Write "                </form>" & vbCrLf
        Response.Write "" & vbCrLf

    End If
    Response.Write "        </TD>" & vbCrLf
    Response.Write "    </TR>" & vbCrLf
    Response.Write "  </TBODY>" & vbCrLf
    Response.Write "</TABLE>" & vbCrLf
    Response.Write "" & vbCrLf


    rsScore.Close

End Sub

Sub ScoreModify()
    Dim strSheetName, Recordset1, Recordset2, Recordset3
    strSheetName = Request("SheetName")

    Dim Recordset1__MMColParam, Recordset2__MMColParam, Recordset3__MMColParam
    Recordset1__MMColParam = Request.QueryString("StudentNum")
    Recordset2__MMColParam = Request.QueryString("SheetName")
    Recordset3__MMColParam = Request.QueryString("StudentNum")
    Call OpenSdmsConn
    Set Recordset1 = Server.CreateObject("ADODB.Recordset")
    Recordset1.Open "SELECT StudentNum, Name  FROM StudentInfo  WHERE StudentNum = '" + Replace(Recordset1__MMColParam, "'", "''") + "'", Conn_Sdms, 1, 3

    Set Recordset2 = Server.CreateObject("ADODB.Recordset")
    Recordset2.Open "SELECT SheetName, TestName FROM TestName WHERE SheetName = '" + Replace(Recordset2__MMColParam, "'", "''") + "'", Conn_Sdms, 1, 3

    Set Recordset3 = Server.CreateObject("ADODB.Recordset")
    Recordset3.Open "SELECT *  FROM " & strSheetName & " WHERE StudentNum = '" + Replace(Recordset3__MMColParam, "'", "''") + "'", Conn_Sdms, 1, 3

    Response.Write "<br>" & vbCrLf
    Response.Write "<table width='100%' class='border' border='0' cellspacing='1' cellpadding='4' align='center'> " & vbCrLf
    Response.Write "  <tr>  " & vbCrLf
    Response.Write "    <td align='center' class='title'>  " & vbCrLf
    Response.Write "      <b>学 生 成 绩 修 改</b> " & vbCrLf
    Response.Write "    </td> " & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "</table>" & vbCrLf
    Response.Write "<table width='100%' border=0 align='center' cellPadding=0 cellSpacing=0>" & vbCrLf
    Response.Write "  <TBODY>" & vbCrLf
    Response.Write "    <TR> " & vbCrLf
    Response.Write "      <TD > " & vbCrLf
    Response.Write "        <table width='100%' border='0' cellpadding='0' cellspacing='0'>" & vbCrLf
    Response.Write "          <tr> " & vbCrLf
    Response.Write "            <TD width='150' vAlign=top> <p> <br>" & vbCrLf
    Response.Write "                <strong>注：</strong><br>" & vbCrLf
    Response.Write "                <br>" & vbCrLf
    Response.Write "                1、输入信息后可直接按回车键保存修改结果<br>" & vbCrLf
    Response.Write "                <br>" & vbCrLf
    Response.Write "                2、输入过程中可用Tab键将光标在各输入框中切换<br>" & vbCrLf
    Response.Write "                <br>" & vbCrLf
    Response.Write "                3、保存修改结果后，系统会自动转入录入下一条记录页面或查询结果结果页面。</p></TD>" & vbCrLf
    Response.Write "            <td width='10' valign='top'> <table height='300' border='0' align='center' cellpadding='0' cellspacing='0'>" & vbCrLf
    Response.Write "                <tr> " & vbCrLf
    Response.Write "                   " & vbCrLf
    Response.Write "                </tr>" & vbCrLf
    Response.Write "              </table></td>" & vbCrLf
    Response.Write "            <TD valign='top'><form action='Admin_ScoreManage.asp' method='post' name='form1'>" & vbCrLf
    Response.Write "            <b><font color='#FF0000'>考试名称：</font></b>" & vbCrLf
    Response.Write (Recordset2.Fields.Item("TestName").value)
    Response.Write "            <br>" & vbCrLf
    Response.Write "              <table cellspacing=4 width='100%' border=0>" & vbCrLf
    Response.Write "                <tr> " & vbCrLf
    Response.Write "                  <td align=right width=60 height='20'>学号：</td>" & vbCrLf
    Response.Write "                  <td align=left width=373 height='20'>" & vbCrLf
    Response.Write (Recordset3.Fields.Item("StudentNum").value)
    Response.Write "                  </td>" & vbCrLf
    Response.Write "                </tr>" & vbCrLf
    Response.Write "                <tr> " & vbCrLf
    Response.Write "                  <td align=right width=60 height='20'>姓名：</td>" & vbCrLf
    Response.Write "                  <td align=left width=373 height='20'> " & vbCrLf
    Response.Write "" & vbCrLf
    If Not Recordset1.EOF Or Not Recordset1.BOF Then
        Response.Write (Recordset1.Fields.Item("Name").value)
    End If ' end Not Recordset1.EOF Or NOT Recordset1.BOF
    Response.Write "                    &nbsp;</td>" & vbCrLf
    Response.Write "                </tr>" & vbCrLf
    Response.Write "" & vbCrLf
    Dim strSubject, i
    strSubject = ""
    For i = 5 To Recordset3.Fields.Count - 1
        Response.Write "<tr>"
        Response.Write "<td align=right width=60 height='20'>" & Recordset3.Fields.Item(i).name & "：</td>"
        Response.Write "<td align=left width=373 height='20'><input maxlength=6 size=10 Name='" & Recordset3.Fields.Item(i).name & "' value='" & Recordset3.Fields.Item(i).value & "'>"
        Response.Write "</td></tr>"
        If strSubject = "" Then
            strSubject = Recordset3.Fields.Item(i).name
        Else
            strSubject = strSubject & "|" & Recordset3.Fields.Item(i).name
        End If
    Next

    Response.Write "              </table>" & vbCrLf
    Response.Write "              <input type='hidden' name='Action' value='SaveScoreModify'>" & vbCrLf
    Response.Write "              <input type='hidden' Name='MM_recordId' value='" & Recordset3.Fields.Item("StudentNum").value & "'> " & vbCrLf
    Response.Write "              <input type='hidden' name='Subject' value='" & strSubject & "'>" & vbCrLf
    Response.Write "              <input name='SheetName' type='hidden' id='SheetName' value='" & strSheetName & "'>" & vbCrLf
    Response.Write "              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " & vbCrLf
    Response.Write "              <input type='submit' Name='Submit' value='保存修改结果'></form></td>" & vbCrLf
    Response.Write "          </tr>" & vbCrLf
    Response.Write "        </table></td>" & vbCrLf
    Response.Write "       " & vbCrLf
    Response.Write "    </TR> " & vbCrLf
    Response.Write "  </TBODY>" & vbCrLf
    Response.Write "</TABLE>" & vbCrLf
    Response.Write "" & vbCrLf


    Recordset1.Close
    Recordset2.Close
    Recordset3.Close
End Sub

Sub SaveScoreModify()

    Dim rsScore, sqlScore, ArrSubject, i, rsScoreTemp
    Dim StudentNum, strSheetName, strSubject, total
    StudentNum = Trim(Request.Form("MM_recordId"))
    strSheetName = Request("SheetName")
    strSubject = Request.Form("Subject")
    
    If StudentNum = "" Then
        FoundErr = True
        ErrMsg = ErrMsg & "<br><li>学生学号不能为空！！！</li>"
        Exit Sub
    Else
        StudentNum = ReplaceBadChar(StudentNum)
    End If
    If strSheetName = "" Then
        FoundErr = True
        ErrMsg = ErrMsg & "<br><li>考试名称不能为空！！！</li>"
        Exit Sub
    Else
        strSheetName = ReplaceBadChar(strSheetName)
    End If
    If strSubject = "" Then
        FoundErr = True
        ErrMsg = ErrMsg & "<br><li>考试科目不能为空！！！</li>"
        Exit Sub
    Else
        strSubject = ReplaceBadChar(strSubject)
    End If
    total = 0
    Set rsScore = Server.CreateObject("adodb.recordset")
    sqlScore = "select * from " & strSheetName & " Where StudentNum='" & StudentNum & "'"
    rsScore.Open sqlScore, Conn_Sdms, 1, 3
    ArrSubject = Split(strSubject, "|")
    'response.write"strSubject="&strSubject
    'response.end
    For i = 0 To UBound(ArrSubject)
        rsScoreTemp = CStr(Request.Form(ArrSubject(i)))
        If rsScoreTemp = "" Then
            rsScore(ArrSubject(i)) = "0"
        Else
            rsScore(ArrSubject(i)) = rsScoreTemp
        End If

        ' 计算总分
        total = total + rsScore(ArrSubject(i))
    Next
    rsScore("总分") = total
    rsScore.Update
    rsScore.Close
    Set rsScore = Nothing
    If InStr(LCase(Session("strQureyString")), "action") <= 0 Then
        Response.Redirect "Admin_ScoreManage.asp?Action=ScoreModifyQueryResult&" & Session("strQureyString")
    Else
        Response.Redirect "Admin_ScoreManage.asp?" & Session("strQureyString")
    End If
    'if Session("strQureyString")<>"" then
        'response.redirect "Admin_ScoreManage.asp?Action=ScoreModifyQueryResult&" & Session("strQureyString")
    'end if

End Sub

Sub DelScore()
    Dim strStudentNum, strSheetName
    strSheetName = ReplaceBadChar(Trim(Request("SheetName")))
    strStudentNum = ReplaceBadChar(Trim(Request("StudentNum")))
    If strSheetName <> "" And strStudentNum <> "" Then
        Conn_Sdms.Execute "delete from " & strSheetName & " where StudentNum = '" & strStudentNum & "'"
    End If
    Response.Redirect "Admin_ScoreManage.asp?" & Session("strQureyString")
End Sub

Sub BatchDelScore()
    Dim strSheetName, strTemp, i
    strSheetName = Request("SheetName")

    Response.Write "<TABLE cellSpacing=0 cellPadding=0 width=750 align=center border=0>" & vbCrLf
    Response.Write "  <TBODY> " & vbCrLf
    Response.Write "  <TR> " & vbCrLf
    Response.Write "    <TD vAlign=top width=46 background=images/p_left_2.gif></TD>" & vbCrLf
    Response.Write "    <TD height='200' width='25' align='center'>&nbsp;</TD>" & vbCrLf
    Response.Write "      <TD height='200' width='679' valign='top' align='center'> <br>" & vbCrLf
    Response.Write "            <b><font size='5'>修改/删除学生成绩</font></b><br>" & vbCrLf
    Response.Write "            <br>" & vbCrLf
    Response.Write "            <br>" & vbCrLf
    Response.Write "            <br>" & vbCrLf
    Response.Write "" & vbCrLf

    If Not IsEmpty(Request("chkNum")) Then
        strTemp = Request("chkNum")
        If InStr(strTemp, ",") > 0 Then
            Dim arrStudentNum
            arrStudentNum = Split(strTemp, ",")
            Dim ID
            For i = LBound(arrStudentNum) To UBound(arrStudentNum)
                ID = CLng(arrStudentNum(i))
                Call DelScoreRecord(ID, strSheetName)
            Next
        Else
            Call DelScoreRecord(CLng(strTemp), strSheetName)
        End If
    Else
        Response.Write "没有选中任何记录！"
    End If

    Response.Write "            <br>" & vbCrLf
    Response.Write "            <br>" & vbCrLf
    Response.Write "            <br>" & vbCrLf
    Response.Write "" & vbCrLf
    If strSheetName <> "" Then
        Response.Write " <a href='Admin_ScoreManage.asp?" & Session("strQureyString") & "'>【返回查询结果页面】</a>" & vbCrLf
    End If
    Response.Write "            <br><br>" & vbCrLf
    Response.Write "    </TD>" & vbCrLf
    Response.Write "  </TR>" & vbCrLf
    Response.Write "  </TBODY> " & vbCrLf
    Response.Write "</TABLE>" & vbCrLf
    Response.Write "" & vbCrLf
End Sub

Sub DelScoreRecord(StudentNum, strSheetName)    '删除记录
    If strSheetName <> "" Then

        Conn_Sdms.Execute "delete from " & strSheetName & " where StudentNum = '" & CStr(StudentNum) & "'"

        If Err.Number <> 0 Then
            Err.Clear
            Response.Write "删除 " & CStr(StudentNum) & " 失败！<br>"
        Else
            Response.Write "删除 " & CStr(StudentNum) & " 成功！<br>"
        End If
    Else
        Response.Write "操作过时！<br>"
    End If
End Sub

Sub ScorePrintStep1()
    Dim Recordset1, i
    Set Recordset1 = Server.CreateObject("ADODB.Recordset")
    Recordset1.Open "SELECT * FROM TestName ORDER BY id DESC", Conn_Sdms, 1, 3

    Dim Recordset2
    Dim Recordset2_numRows

    Set Recordset2 = Server.CreateObject("ADODB.Recordset")
    Recordset2.Open "SELECT * FROM Subject ORDER BY ID ASC", Conn_Sdms, 1, 3

    Response.Write "<br>" & vbCrLf
    Response.Write "<table width='100%' class='border' border='0' cellspacing='1' cellpadding='4' align='center'> " & vbCrLf
    Response.Write "  <tr>  " & vbCrLf
    Response.Write "    <td align='center' class='title' colspan='3'>  " & vbCrLf
    Response.Write "    <b>学 生 成 绩 打 印 (第一步<b>)</b>----请选择查询方式</b></td> " & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "          <form Name='form1' action='Admin_ScoreManage.asp?Action=ScorePrintStep1_1' method='post'>" & vbCrLf
    Response.Write "            <tr valign='middle' class='tdbg'> " & vbCrLf
    Response.Write "              <td width='25%' height='30' align='right'><strong><font color='#FF0000'>※</font>按考试查询：</strong></td>" & vbCrLf
    Response.Write "              <td width='150' height='30'> <select Name='sheetName'>" & vbCrLf
    i = 0
    While (Not Recordset1.EOF)
        If i = 0 Then
            Response.Write "<option value='" & Recordset1.Fields.Item("SheetName").value & "' selected>" & Recordset1.Fields.Item("TestName").value & "</option>"
        Else
            Response.Write "<option value='" & Recordset1.Fields.Item("SheetName").value & "'>" & Recordset1.Fields.Item("TestName").value & "</option>"
        End If
        i = i + 1
        Recordset1.MoveNext
    Wend
    If Not Recordset1.EOF And Recordset1.BOF Then
        If (Recordset1.CursorType > 0) Then
            Recordset1.movefirst
        Else
            Recordset1.Requery
        End If
    End If

    Response.Write "                </select> </td>" & vbCrLf
    Response.Write "              <td width='200' height='30'> <input type='submit' name='Submit' value='下一步'> " & vbCrLf
    Response.Write "              </td>" & vbCrLf
    Response.Write "            </tr>" & vbCrLf
    Response.Write "            <tr valign='middle' class='tdbg'> " & vbCrLf
    Response.Write "              <td width='25%' height='30' align='right'>&nbsp;</td>" & vbCrLf
    Response.Write "              <td height='30' colspan='2'>查询指定考试中某一科或几科的成绩及总分、达标等信息。此种方式便于班任或科任掌握相应考试的考试情况。</td>" & vbCrLf
    Response.Write "            </tr>" & vbCrLf
    Response.Write "          </form>" & vbCrLf
    Response.Write "          <form Name='form2' action='Admin_ScoreManage.asp?Action=ScorePrintStep1_2' method='post'>" & vbCrLf
    Response.Write "            <tr valign='middle' class='tdbg'> " & vbCrLf
    Response.Write "              <td width='25%' height='30' align='right'><strong><font color='#FF0000'>※</font>按科目查询：</strong></td>" & vbCrLf
    Response.Write "              <td width='150' height='30'> <select name='Subject'>" & vbCrLf
    Response.Write "" & vbCrLf

    i = 0
    While (Not Recordset2.EOF)
        If i = 0 Then
            Response.Write "<option value='" & Recordset2.Fields.Item("SubjectName").value & "' selected>" & Recordset2.Fields.Item("SubjectName").value & "</option>"
        Else
            Response.Write "<option value='" & Recordset2.Fields.Item("SubjectName").value & "'>" & Recordset2.Fields.Item("SubjectName").value & "</option>"
        End If
        i = i + 1
        Recordset2.MoveNext
    Wend
    If Not Recordset1.EOF And Recordset1.BOF Then
        If (Recordset2.CursorType > 0) Then
            Recordset2.movefirst
        Else
            Recordset2.Requery
        End If
    End If

    Response.Write "                </select> </td>" & vbCrLf
    Response.Write "              <td width='200' height='30'> <input type='submit' name='Submit2' value='下一步'> " & vbCrLf
    Response.Write "              </td>" & vbCrLf
    Response.Write "            </tr>" & vbCrLf
    Response.Write "            <tr valign='middle' class='tdbg'> " & vbCrLf
    Response.Write "              <td width='25%' height='30' align='right'>&nbsp;</td>" & vbCrLf
    Response.Write "              <td height='30' colspan='2'>查询指定科目的某一次或几次考试的成绩、达标、成绩升降等信息。此种方式便于科任老师掌握学生的学习情况。</td>" & vbCrLf
    Response.Write "            </tr>" & vbCrLf
    Response.Write "          </form>" & vbCrLf
    Response.Write "</TABLE>" & vbCrLf
    Response.Write "<br>" & vbCrLf
    Response.Write "        <b><font color='#FF0000'>&nbsp;&nbsp;&nbsp;&nbsp;如果您还没有阅读<a href='InfoManage.asp?Action=PrintGuide'>《如何用IE打印网页》</a>一文，那么请首先阅读它，因为本系统只是对查询的结果进行简单的版面调整，真正的打印功能还必须使用IE的打印功能来实现。</font><br>" & vbCrLf
    Response.Write "        <br>" & vbCrLf
    Response.Write "        <a href='InfoManage.asp?Action=PrintGuide'>&nbsp;&nbsp;&nbsp;&nbsp;点此阅读《如何用IE打印网页》一文。</a>" & vbCrLf
    Response.Write "    </b><br>" & vbCrLf
    Response.Write "" & vbCrLf
    Recordset1.Close
    Recordset2.Close
    Set Recordset2 = Nothing
End Sub

Sub ScorePrintStep1_1()
    Response.Write "<script language=""JavaScript"">" & vbCrLf
    Response.Write "function check()" & vbCrLf
    Response.Write "{" & vbCrLf
    Response.Write "var total=0;" & vbCrLf
    Response.Write "var intmax=document.form1.chkbox.length;" & vbCrLf
    Response.Write "if(intmax>1){" & vbCrLf
    Response.Write "  for(var idx=0;idx<intmax;idx++){" & vbCrLf
    Response.Write "    if(eval(""document.form1.chkbox["" + idx + ""].checked"")==true){" & vbCrLf
    Response.Write "      total+=1;" & vbCrLf
    Response.Write "    }" & vbCrLf
    Response.Write "  }" & vbCrLf
    Response.Write "  if(total==0){" & vbCrLf
    Response.Write "    alert(""您未选择任何科目！"");" & vbCrLf
    Response.Write "    document.form1.chkbox[0].focus();" & vbCrLf
    Response.Write "    return false;" & vbCrLf
    Response.Write "  }" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "else{" & vbCrLf
    Response.Write "  if(document.form1.chkbox.checked==false){" & vbCrLf
    Response.Write "    alert(""您未选择任何科目！"");" & vbCrLf
    Response.Write "    document.form1.chkbox.focus();" & vbCrLf
    Response.Write "    return false;" & vbCrLf
    Response.Write "  }" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "if(document.form1.ShowTarget.checked==true){" & vbCrLf
    Response.Write "    document.form1.action=""Admin_ScoreManage.asp?Action=ScorePrintStep1_1_1"";" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "else{" & vbCrLf
    Response.Write "    document.form1.action=""Admin_ScoreManage.asp?Action=ScorePrintStep1_1_2"";" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "</script>" & vbCrLf
    Response.Write "<script language=""JavaScript"" type=""text/JavaScript"">" & vbCrLf
    Response.Write "function ChangeClass(num)" & vbCrLf
    Response.Write "{" & vbCrLf
    Response.Write "    var i;" & vbCrLf
    Response.Write "    var j;" & vbCrLf
    Response.Write "    for(i=document.form1.ClassSelect.options.length-1;i>=0;i--)" & vbCrLf
    Response.Write "    {" & vbCrLf
    Response.Write "        document.form1.ClassSelect.options[i]=null;" & vbCrLf
    Response.Write "    }" & vbCrLf
    Response.Write "" & vbCrLf
    Response.Write "    for(j=0;j<document.Classes.all(""Grade""+num).options.length;j++)" & vbCrLf
    Response.Write "    {" & vbCrLf
    Response.Write "        document.form1.ClassSelect.options[j]=new Option(document.Classes.all(""Grade""+num).options[j].text,document.Classes.all(""Grade""+num).options[j].value);" & vbCrLf
    Response.Write "    }" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "</script>" & vbCrLf
    Response.Write "" & vbCrLf

    Response.Write "<div id='Layer1' style='position:absolute; left:445px; top:220px; width:188px; height:64px; z-index:1; visibility: hidden;'> " & vbCrLf
    Response.Write GetClass_Option(0)
    Response.Write "</div>" & vbCrLf
    Response.Write "" & vbCrLf
    Dim Recordset1
    Dim strSheetName
    strSheetName = ReplaceBadChar(Trim(Request("SheetName")))
    If strSheetName = "" Then
        Response.Write "<br><br>未选择任何考试,请先添加考试!!"
        Response.End
    End If


    Response.Write "    <br>" & vbCrLf
    Response.Write "<table width='100%' class='border' border='0' cellspacing='1' cellpadding='4' align='center'> " & vbCrLf
    Response.Write "  <tr>  " & vbCrLf
    Response.Write "    <td align='center' class='title' colspan='3'>  " & vbCrLf
    Response.Write "      <b>学　生　成　绩　打　印(第二步)----请输入查询条件并选择科目</b></td> " & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "        <form Name='form1'  onSubmit=""return check()"" action='Admin_ScoreManage.asp?Action=ScorePrintStep1_1_2' method='post' target='_blank'>" & vbCrLf
    Response.Write "            <tr class='tdbg'> " & vbCrLf
    Response.Write "              <td width='25%' align='right'><strong>考试名称：</strong></td>" & vbCrLf
    Response.Write "              <td colspan='2'>" & vbCrLf

    Dim Recordset2
    Set Recordset2 = Server.CreateObject("ADODB.Recordset")
    Recordset2.Open "SELECT * FROM TestName WHERE SheetName = '" & strSheetName & "'", Conn_Sdms, 1, 3
    Response.Write Recordset2("TestName")
    Recordset2.Close
    Set Recordset2 = Nothing
     
    Response.Write "<input name='SheetName' type='hidden' id='SheetName2' value='" & strSheetName & "'></td>" & vbCrLf
    Response.Write "            </tr>" & vbCrLf
    Response.Write "            <tr class='tdbg'> " & vbCrLf
    Response.Write "              <td width='25%' align='right'><strong>请输入查询条件：</strong><br> " & vbCrLf
    Response.Write "                <br>" & vbCrLf
    Response.Write "              （可从学号或班级两种查询方法任选其一进行查询）</td>" & vbCrLf
    Response.Write "              <td nowrap>学号： " & vbCrLf
    Response.Write "                <input type='text' Name='StudentNum' maxlength='16' size='18'> " & vbCrLf
    Response.Write "                <br> <br>" & vbCrLf
    Response.Write "                班级： " & vbCrLf
    Response.Write "                <select name='Grade' onChange=""ChangeClass(this.value)"">" & vbCrLf
    Response.Write "" & vbCrLf
    Response.Write GetGrade_Option
    Response.Write "                </select> <select name='ClassSelect'>" & vbCrLf
    Response.Write "                  <option value='All' selected>全级</option>" & vbCrLf
    Response.Write "" & vbCrLf
    Dim RsFirst, FirstGradeID, Rsin, Sqlin, i
    Set RsFirst = Conn_Sdms.Execute("select top 1 GradeID from Grade order by OrderID asc")
    FirstGradeID = RsFirst("GradeID")
    Set RsFirst = Nothing
    Set Rsin = Server.CreateObject("ADODB.REcordset")
    Sqlin = "select * from Class where GradeID=" & FirstGradeID & " order by OrderID asc"
    Rsin.Open Sqlin, Conn_Sdms, 1, 3
    Do While Not Rsin.EOF
        Response.Write "<option value='" & Rsin("ClassID") & "' >" & Rsin("ClassName") & "</option>"
        Rsin.MoveNext
    Loop
    Rsin.Close
    Set Rsin = Nothing

    Response.Write "                </select> </td>" & vbCrLf
    Response.Write "              <td><b>注：</b><br>" & vbCrLf
    Response.Write "                　　1 、若输入了学号，则优先按学号进行查询。 <br> " & vbCrLf
    Response.Write "                <font color='#FF0000'>　　2、支持模糊查询！</font><br>" & vbCrLf
    Response.Write "                例如：<br> " & vbCrLf
    Response.Write "                &nbsp;&nbsp;&nbsp;&nbsp;　在学号查询框中输入2001，则查询结果为学号中包含“2001”的学生</td>" & vbCrLf
    Response.Write "            </tr>" & vbCrLf
    Response.Write "            <tr class='tdbg'> " & vbCrLf
    Response.Write "              <td width='25%' align='right'><strong>请选择科目：</strong></td>" & vbCrLf
    Response.Write "              <td colspan='2'> <table border='0' cellspacing='5' cellpadding='0'>" & vbCrLf
    Response.Write "                  <tr class='tdbg'>" & vbCrLf
    Set Recordset1 = Server.CreateObject("ADODB.Recordset")
    Recordset1.Open "SELECT Top 1 * FROM " & strSheetName, Conn_Sdms, 1, 3
    For i = 5 To Recordset1.Fields.Count - 1
        Response.Write "<td width='80'><input Name='chkbox' type='checkbox' value='" & Recordset1.Fields(i).name & "'>" & Recordset1.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='chkbox' 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='chkbox' 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='chkbox' 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='chkbox' type='checkbox' value='班级排名'>班级排名</td>"
    Recordset1.Close
    Set Recordset1 = Nothing
    Response.Write "                  </tr>" & vbCrLf
    Response.Write "                </table></td>" & vbCrLf
    Response.Write "            </tr>" & vbCrLf
    Response.Write "            <tr class='tdbg'>" & vbCrLf
    Response.Write "              <td align='right'>&nbsp;</td>" & vbCrLf
    Response.Write "              <td colspan='2'><input name='ShowTarget' type='checkbox' id='ShowTarget' value='True'>" & vbCrLf
    Response.Write "                显示目标分及达标/跳格情况</td>" & vbCrLf
    Response.Write "            </tr>" & vbCrLf
    Response.Write "            <tr class='tdbg'>" & vbCrLf
    Response.Write "              <td align='right'><strong>排序方式：</strong></td>" & vbCrLf
    Response.Write "              <td colspan='2' align='left'><select name='OrderType' id='OrderType'>" & vbCrLf
    Response.Write "                <option value='1' selected>按学号排序" & vbCrLf
    Response.Write "                <option value='2'>按总分排序" & vbCrLf
    Response.Write "                <option value='3'>按全级名次排序" & vbCrLf
    Response.Write "                <option value='4'>按班级名次排序                " & vbCrLf
    Response.Write "              </select></td>" & vbCrLf
    Response.Write "            </tr>" & vbCrLf
    Response.Write "            <tr class='tdbg'>" & vbCrLf
    Response.Write "              <td align='right'><strong>请输入每页要打印的记录数：</strong></td>" & vbCrLf
    Response.Write "              <td colspan='2' align='left'><input name='PageSize' type='text' id='PageSize' value='30' size='4' maxlength='4'>" & vbCrLf
    Response.Write "                &nbsp;&nbsp;&nbsp;&nbsp;请根据页面设置中的纸张大小、页边距等实际情况设定记录数</td>" & vbCrLf
    Response.Write "            </tr>" & vbCrLf
    Response.Write "            <tr align='center' class='tdbg'> " & vbCrLf
    Response.Write "              <td height='42' colspan='3'><input type='submit' Name='Submit' value='打印预览'></td>" & vbCrLf
    Response.Write "            </tr>" & vbCrLf
    Response.Write "        </form>" & vbCrLf
    Response.Write "</TABLE>" & vbCrLf
    Response.Write "" & vbCrLf

End Sub

Sub ScorePrintStep1_2()
    Response.Write "<script language=""JavaScript"">" & vbCrLf
    Response.Write "function check()" & vbCrLf
    Response.Write "{" & vbCrLf
    Response.Write "var total=0;" & vbCrLf
    Response.Write "var intmax=document.form1.chkbox.length;" & vbCrLf
    Response.Write "if(intmax>1){" & vbCrLf
    Response.Write "  for(var idx=0;idx<intmax;idx++){" & vbCrLf
    Response.Write "    if(eval(""document.form1.chkbox["" + idx + ""].checked"")==true){" & vbCrLf
    Response.Write "      total+=1;" & vbCrLf
    Response.Write "    }" & vbCrLf
    Response.Write "  }" & vbCrLf
    Response.Write "  if(total==0){" & vbCrLf
    Response.Write "    alert(""您未选择任何考试！"");" & vbCrLf
    Response.Write "    document.form1.chkbox[0].focus();" & vbCrLf
    Response.Write "    return false;" & vbCrLf
    Response.Write "  }" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "else{" & vbCrLf
    Response.Write "  if(document.form1.chkbox.checked==false){" & vbCrLf
    Response.Write "    alert(""您未选择任何考试！"");" & vbCrLf
    Response.Write "    document.form1.chkbox.focus();" & vbCrLf
    Response.Write "    return false;" & vbCrLf
    Response.Write "  }" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "</script>" & vbCrLf
    Response.Write "<script language=""JavaScript"" type=""text/JavaScript"">" & vbCrLf
    Response.Write "function ChangeClass(num)" & vbCrLf
    Response.Write "{" & vbCrLf
    Response.Write "    var i;" & vbCrLf
    Response.Write "    var j;" & vbCrLf
    Response.Write "    for(i=document.form1.ClassSelect.options.length-1;i>=0;i--)" & vbCrLf
    Response.Write "    {" & vbCrLf
    Response.Write "        document.form1.ClassSelect.options[i]=null;" & vbCrLf
    Response.Write "    }" & vbCrLf
    Response.Write "" & vbCrLf
    Response.Write "    for(j=0;j<document.Classes.all(""Grade""+num).options.length;j++)" & vbCrLf
    Response.Write "    {" & vbCrLf
    Response.Write "        document.form1.ClassSelect.options[j]=new Option(document.Classes.all(""Grade""+num).options[j].text,document.Classes.all(""Grade""+num).options[j].value);" & vbCrLf
    Response.Write "    }" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "</script>" & vbCrLf

    Dim Recordset1

    Set Recordset1 = Server.CreateObject("ADODB.Recordset")
    Recordset1.Open "SELECT * FROM TestName ORDER BY ID DESC", Conn_Sdms, 1, 3

    Dim Repeat1__numRows
    Dim Repeat1__index

    Repeat1__numRows = -1
    Repeat1__index = 0

    Response.Write "<div id='Layer1' style='position:absolute; left:445px; top:220px; width:188px; height:64px; z-index:1; visibility: hidden;'> " & vbCrLf
    Response.Write GetClass_Option(0)
    Response.Write "</div>" & vbCrLf
    Response.Write "<br>" & vbCrLf
    Response.Write "<table width='100%' class='border' border='0' cellspacing='1' cellpadding='4' align='center'>" & vbCrLf
    Response.Write "  <tr>" & vbCrLf
    Response.Write "    <td align='center' class='title' colspan='3'> <b>学　生　成　绩　打　印 (第二步<b>)</b>----请输入查询条件并选择考试</b></td>" & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "  <form name='form1'  onSubmit=""return check()"" action='Admin_ScoreManage.asp?Action=ScorePrintStep1_2_1' method='post' target='_blank'>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td width='25%' align='right'><strong>科目名称：</strong></td>" & vbCrLf
    Response.Write "      <td colspan='2'>" & vbCrLf
    Response.Write Request("Subject")
    Response.Write "          <input name='Subject' type='hidden' id='Subject' value='" & Request("Subject") & "'>" & vbCrLf
    Response.Write "      </td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr  class='tdbg'>" & vbCrLf
    Response.Write "      <td width='25%' align='right'><strong>请输入查询条件：</strong><br>" & vbCrLf
    Response.Write "          <br>" & vbCrLf
    Response.Write "        （可从学号或班级两种查询方法任选其一进行查询）</td>" & vbCrLf
    Response.Write "      <td nowrap>学号：" & vbCrLf
    Response.Write "          <input type='text' name='StudentNum' maxlength='16' size='18'>" & vbCrLf
    Response.Write "          <br>" & vbCrLf
    Response.Write "          <br>" & vbCrLf
    Response.Write "        班级：" & vbCrLf
    Response.Write "        <select name='Grade' onChange=""ChangeClass(this.value)"">" & vbCrLf
    Response.Write GetGrade_Option
    Response.Write "        </select>" & vbCrLf
    Response.Write "        <select name='ClassSelect'>" & vbCrLf
    Response.Write "          <option value='All' selected>全级</option>" & vbCrLf
    Response.Write "" & vbCrLf
    Dim RsFirst, FirstGradeID, Rsin, Sqlin
    Set RsFirst = Conn_Sdms.Execute("select top 1 GradeID from Grade order by OrderID asc")
    FirstGradeID = RsFirst("GradeID")
    Set RsFirst = Nothing
    Set Rsin = Server.CreateObject("ADODB.REcordset")
    Sqlin = "select * from Class where GradeID=" & FirstGradeID & " order by OrderID asc"
    Rsin.Open Sqlin, Conn_Sdms, 1, 3
    Do While Not Rsin.EOF
        Response.Write "<option value='" & Rsin("ClassID") & "' >" & Rsin("ClassName") & "</option>"
        Rsin.MoveNext
    Loop
    Set Rsin = Nothing

    Response.Write "        </select>" & vbCrLf
    Response.Write "      </td>" & vbCrLf
    Response.Write "      <td><b><font color='#0066cc'>注：</font></b><br>" & vbCrLf
    Response.Write "        　　1 、若输入了学号，则优先按学号进行查询。 <br>" & vbCrLf
    Response.Write "        <font color='#FF0000'>　　2、支持模糊查询！</font><br>" & vbCrLf
    Response.Write "        例如：<br>" & vbCrLf
    Response.Write "&nbsp;&nbsp;&nbsp;&nbsp;在学号查询框中输入2001，则查询结果为学号中包含“2001”的学生</td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td width='25%' align='right'><strong>请选择要查询成绩的考试：</strong></td>" & vbCrLf
    Response.Write "      <td colspan='2'>" & vbCrLf
    Response.Write "" & vbCrLf
    Dim strSheetName, rsTestName, ExistFlag, k
    While ((Repeat1__numRows <> 0) And (Not Recordset1.EOF))
        strSheetName = Recordset1.Fields.Item("SheetName").value
        Set rsTestName = Server.CreateObject("ADODB.Recordset")
        rsTestName.Open "SELECT Top 1 * FROM " & strSheetName, Conn_Sdms, 1, 3


        ExistFlag = False
        For k = 0 To rsTestName.Fields.Count - 1
            If rsTestName.Fields.Item(k).name = CStr(Request("Subject")) Then ExistFlag = True
        Next
        If ExistFlag = True Then
            Response.Write "<input name='chkbox' type='checkbox' value='" & Recordset1.Fields.Item("SheetName").value & "'>"
            Response.Write Recordset1.Fields.Item("TestName").value & "<br>"
        End If
        rsTestName.Close
      Repeat1__index = Repeat1__index + 1
      Repeat1__numRows = Repeat1__numRows - 1
      Recordset1.MoveNext
    Wend
    Recordset1.Close
    Set Recordset1 = Nothing
    Response.Write "      </td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr align='center' class='tdbg'>" & vbCrLf
    Response.Write "      <td height='43' colspan='3'><input type='submit' name='Submit' value='下一步'></td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "  </form>" & vbCrLf
    Response.Write "</table>" & vbCrLf
    Response.Write "<br>" & vbCrLf
    Response.Write "</form>" & vbCrLf
    Response.Write "" & vbCrLf
End Sub

Sub ScoreOrder()

    Response.Write "<script language=""JavaScript"" type=""text/JavaScript"">" & vbCrLf
    Response.Write "function ChangeClass(num)" & vbCrLf
    Response.Write "{" & vbCrLf
    Response.Write "    var i;" & vbCrLf
    Response.Write "    var j;" & vbCrLf
    Response.Write "    for(i=document.form1.ClassSelect.options.length-1;i>=0;i--)" & vbCrLf
    Response.Write "    {" & vbCrLf
    Response.Write "        document.form1.ClassSelect.options[i]=null;" & vbCrLf
    Response.Write "    }" & vbCrLf
    Response.Write "" & vbCrLf
    Response.Write "    for(j=0;j<document.Classes.all(""Grade""+num).options.length;j++)" & vbCrLf
    Response.Write "    {" & vbCrLf
    Response.Write "        document.form1.ClassSelect.options[j]=new Option(document.Classes.all(""Grade""+num).options[j].text,document.Classes.all(""Grade""+num).options[j].value);" & vbCrLf
    Response.Write "    }" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "</script>" & vbCrLf
    Response.Write "<div id='Layer1' style='position:absolute; left:445px; top:220px; width:188px; height:64px; z-index:1; visibility: hidden;'> " & vbCrLf
    Response.Write GetClass_Option(0)
    Response.Write "</div>" & vbCrLf
    Response.Write "" & vbCrLf
    Dim Recordset1, i
    Set Recordset1 = Server.CreateObject("ADODB.Recordset")
    Recordset1.Open "SELECT * FROM TestName ORDER BY id Desc", Conn_Sdms, 1, 3

    Response.Write "<br>" & vbCrLf
    Response.Write "<table width='100%' class='border' border='0' cellspacing='1' cellpadding='4' align='center'> " & vbCrLf
    Response.Write "  <tr>  " & vbCrLf
    Response.Write "    <td align='center' class='title' colspan='2'>  " & vbCrLf
    Response.Write "      <b>计 算 总 分 与 排 名</b> " & vbCrLf
    Response.Write "    </td> " & vbCrLf
    Response.Write "  </tr>        " & vbCrLf
    Response.Write "  <form Name='form1' action='Admin_ScoreManage.asp?Action=ScoreOrderCalculate' method='post'>" & vbCrLf
    Response.Write "  <tr class='tdbg'>" & vbCrLf
    Response.Write "    <td width='30%' align='right'><strong>请选择考试：</strong></td>" & vbCrLf
    Response.Write "    <td><select name='SheetName'>" & vbCrLf
    Response.Write "" & vbCrLf

    i = 0
    While (Not Recordset1.EOF)
        If i = 0 Then
            Response.Write "<option value='" & Recordset1.Fields.Item("SheetName").value & "' selected >" & Recordset1.Fields.Item("TestName").value & "</option>"
        Else
            Response.Write "<option value='" & Recordset1.Fields.Item("SheetName").value & "'>" & Recordset1.Fields.Item("TestName").value & "</option>"
        End If
        i = i + 1
        Recordset1.MoveNext
    Wend
    If Not Recordset1.EOF And Recordset1.BOF Then
        If (Recordset1.CursorType > 0) Then
            Recordset1.movefirst
        Else
            Recordset1.Requery
        End If
    End If

    Response.Write "    </select>" & vbCrLf
    Response.Write "      <font color='#FF0000'>*</font></td>" & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "  <tr class='tdbg'>" & vbCrLf
    Response.Write "    <td width='30%' align='right'><strong>请选择班级：</strong></td>" & vbCrLf
    Response.Write "    <td><select name='Grade' onChange=""ChangeClass(this.value)"">" & vbCrLf
    Response.Write "" & vbCrLf
    Response.Write GetGrade_Option
    Response.Write "    </select>" & vbCrLf
    Response.Write "      <select name='ClassSelect'>" & vbCrLf
    Response.Write "        <option value='All' selected>全级</option>" & vbCrLf
    Response.Write "" & vbCrLf
    Dim RsFirst, FirstGradeID, Rsin, Sqlin
    Set RsFirst = Conn_Sdms.Execute("select top 1 GradeID from Grade order by OrderID asc")
    FirstGradeID = RsFirst("GradeID")
    Set RsFirst = Nothing
    Set Rsin = Server.CreateObject("ADODB.REcordset")
    Sqlin = "select * from Class where GradeID=" & FirstGradeID & " order by OrderID asc"
    Rsin.Open Sqlin, Conn_Sdms, 1, 3
    Do While Not Rsin.EOF
        Response.Write "<option value='" & Rsin("ClassID") & "' >" & Rsin("ClassName") & "</option>"
        Rsin.MoveNext
    Loop
    Set Rsin = Nothing
                     
    Response.Write "      </select></td>" & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "  <tr class='tdbg'>" & vbCrLf
    Response.Write "    <td width='30%' align='right'><strong>请选择查询记录的排序字段：</strong></td>" & vbCrLf
    Response.Write "    <td><select name='OrderField'>" & vbCrLf
    Response.Write "      <option value='StudentNum' selected>学号</option>" & vbCrLf
    Response.Write "      <option value='总分'>总分</option>" & vbCrLf
    Response.Write "    </select></td>" & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "  <tr align='center' class='tdbg'>" & vbCrLf
    Response.Write "    <td colspan='2'><input type='submit' name='Submit3' value='确定'></td>" & vbCrLf
    Response.Write "  </tr>  </form>" & vbCrLf
    Response.Write "</TABLE>" & vbCrLf
End Sub

Sub ScoreOrderCalculate()
    Dim strSheetName, strStudentNum, strGrade, strClass, strOrderField, rsSum, rsSumSql
    Dim intTotal, i
    strSheetName = CStr(Trim(Request("SheetName")))
    If Request("SheetName") = "" Then
        Response.Write "<br><br>未选择任何考试,请先添加考试!!"
        Response.End
    End If
    strGrade = Request("Grade")
    strClass = Request("ClassSelect")
    strOrderField = Request("OrderField")

    Set rsSum = Server.CreateObject("ADODB.Recordset")
    If strClass = "All" Then
        rsSumSql = "SELECT *  FROM " & strSheetName & " WHERE StudentNum In (Select StudentNum From StudentInfo Where GradeID=" & strGrade & ") Order By StudentNum"
    Else
        rsSumSql = "SELECT *  FROM " & strSheetName & " WHERE StudentNum In (Select StudentNum From StudentInfo Where GradeID=" & strGrade & " and ClassID=" & strClass & ") Order By StudentNum"
    End If
    rsSum.Open rsSumSql, Conn_Sdms, 1, 3

    '计算总分
    If (Not rsSum.BOF Or Not rsSum.EOF) Then
        rsSum.movefirst
    End If
    While Not rsSum.EOF
        intTotal = 0
        For i = 5 To rsSum.Fields.Count - 1
            If Not IsNull(rsSum.Fields.Item(i).value) Then
              intTotal = intTotal + rsSum.Fields.Item(i).value
              'response.write "intTotal="&intTotal&"<br>"
              'response.write "rsSum.Fields.Item(i).Value="&rsSum.Fields.Item(i).Value&"<br>"
              'response.end
            End If
        Next
        rsSum.Fields.Item("总分").value = intTotal
        rsSum.Fields.Item("平均分").value = Round(intTotal / (rsSum.Fields.Count - 5), 2)
        rsSum.Update
        rsSum.MoveNext
    Wend
    rsSum.Close
    Dim rsOrder, OrderNum, tmpTotal
    '进行级排名
    Set rsOrder = Server.CreateObject("ADODB.Recordset")
    'rsOrder.Open "SELECT *  FROM " & strSheetName & " WHERE StudentNum like '" & Left(strStudentNum, 4) & "%'  ORDER BY 总分 DESC", Conn_Sdms, 1, 3
    rsOrder.Open "SELECT * FROM " & strSheetName & " S left join StudentInfo I on S.StudentNum=I.StudentNum WHERE I.GradeID=" & strGrade & "  ORDER BY S.总分 DESC", Conn_Sdms, 1, 3
    If (Not rsOrder.BOF Or Not rsOrder.EOF) Then
        OrderNum = 1
        i = 1
        rsOrder.movefirst
        tmpTotal = rsOrder.Fields.Item("总分")
        rsOrder.Fields.Item("全级排名") = OrderNum
        rsOrder.Update
        rsOrder.MoveNext
        While Not rsOrder.EOF
            i = i + 1
            If rsOrder.Fields.Item("总分") = tmpTotal Then
                rsOrder.Fields.Item("全级排名") = OrderNum
            Else
                rsOrder.Fields.Item("全级排名") = i
            End If
            tmpTotal = rsOrder.Fields.Item("总分")
            rsOrder.Update
            OrderNum = rsOrder.Fields.Item("全级排名")

            rsOrder.MoveNext
        Wend
    End If
    rsOrder.Close

    '对每个班的学生进行班排名
    Dim rsClass__MMColParam
    Dim rsClass
    Dim rsClass_numRows, tmpClass
    '先查询出班级
    rsClass__MMColParam = strGrade
    Set rsClass = Server.CreateObject("ADODB.Recordset")
    rsClass.Open "SELECT * FROM Class WHERE GradeID = " + Replace(rsClass__MMColParam, "'", "''") + " ORDER BY OrderID ASC", Conn_Sdms, 1, 3
    rsClass_numRows = 0
    While (Not rsClass.EOF)
        tmpClass = rsClass.Fields.Item("ClassID").value
        'If Len(CStr(tmpClass)) = 1 Then
            'tmpClass = "0" & CStr(tmpClass)
        'End If
        Set rsOrder = Server.CreateObject("ADODB.Recordset")
        'rsOrder.Open "SELECT *  FROM " & strSheetName & " WHERE StudentNum like '" & Left(strStudentNum, 4) & tmpClass & "%'  ORDER BY 总分 DESC", Conn_Sdms, 1, 3
        rsOrder.Open "SELECT *  FROM " & strSheetName & " S left join StudentInfo I on S.StudentNum=I.StudentNum WHERE I.GradeID=" & strGrade & " and I.ClassID=" & tmpClass & " ORDER BY S.总分 DESC", Conn_Sdms, 1, 3

        If Not rsOrder.EOF Or Not rsOrder.BOF Then
            OrderNum = 1
            i = 1
            rsOrder.movefirst
            tmpTotal = rsOrder.Fields.Item("总分")
            rsOrder.Fields.Item("班级排名") = OrderNum
            rsOrder.Update
            rsOrder.MoveNext
            While Not rsOrder.EOF
                i = i + 1
                If rsOrder.Fields.Item("总分") = tmpTotal Then
                    rsOrder.Fields.Item("班级排名") = OrderNum
                Else
                    rsOrder.Fields.Item("班级排名") = i
                End If
                tmpTotal = rsOrder.Fields.Item("总分")
                rsOrder.Update
                OrderNum = rsOrder.Fields.Item("班级排名")

                rsOrder.MoveNext
            Wend
        End If
        rsOrder.Close
        rsClass.MoveNext
    Wend

    Response.Redirect ("Admin_ScoreManage.asp?Action=ScoreOrderResult&sheetName=" & strSheetName & "&grade=" & strGrade & "&classselect=" & strClass & "&OrderField=" & strOrderField)
End Sub

Sub ScoreOrderResult()
    Dim strSheetName, strStudentNum, strName, strGrade, strClass, strSubjects, strOrderField
    Dim rsSubjects, i, rsScore, strSQL, rsScore_numRows
    strSheetName = ReplaceBadChar(Trim(Request("SheetName")))

    strOrderField = Request("OrderField")
    If strOrderField = "" Then strOrderField = "StudentNum"
    If strOrderField = "总分" Then strOrderField = strOrderField & " DESC"

    Set rsSubjects = Server.CreateObject("ADODB.Recordset")
    rsSubjects.Open "SELECT Top 1 * FROM " & strSheetName, Conn_Sdms, 1, 3

    strSubjects = strSheetName & "." & rsSubjects.Fields.Item(5).name
    For i = 6 To rsSubjects.Fields.Count - 1
      strSubjects = strSubjects & "," & strSheetName & "." & rsSubjects.Fields.Item(i).name
    Next
    strSubjects = strSubjects & ",总分,平均分,全级排名,班级排名"


    strStudentNum = Trim(Request("StudentNum"))
    strName = Trim(Request("Name"))
    strGrade = Trim(Request("Grade"))
    strClass = Trim(Request("ClassSelect"))
    Set rsScore = Server.CreateObject("ADODB.Recordset")

    strSQL = "Select " & strSheetName & ".StudentNum, StudentInfo.Name, " & strSubjects & " From " & strSheetName
    strSQL = strSQL & " LEFT JOIN StudentInfo ON " & strSheetName & ".StudentNum = StudentInfo.StudentNum"

    If (strStudentNum <> "") Then
        strSQL = strSQL & " Where " & strSheetName & ".StudentNum Like '%" & strStudentNum & "%'"
    ElseIf (strName <> "") Then
        strSQL = strSQL & " Where StudentInfo.Name Like '%" & strName & "%'"
    Else
        If strClass = "All" Then
            strSQL = strSQL & " Where StudentInfo.GradeID=" & CLng(strGrade) & ""
        Else
            strSQL = strSQL & " Where StudentInfo.ClassID=" & CLng(strClass) & " And StudentInfo.GradeID=" & CLng(strGrade) & ""
        End If
    End If
    strSQL = strSQL & " ORDER BY " & strSheetName & "." & strOrderField
    rsScore.Open strSQL, Conn_Sdms, 1, 3
    rsScore_numRows = 0

    Dim Repeat1__numRows
    Repeat1__numRows = -1
    Dim Repeat1__index
    Repeat1__index = 0
    rsScore_numRows = rsScore_numRows + Repeat1__numRows

    Dim rsScore_total
    Dim rsScore_first
    Dim rsScore_last

    ' set the record count
    rsScore_total = rsScore.RecordCount

    If (rsScore_numRows < 0) Then
        rsScore_numRows = rsScore_total
    ElseIf (rsScore_numRows = 0) Then
        rsScore_numRows = 1
    End If

    rsScore_first = 1
    rsScore_last = rsScore_first + rsScore_numRows - 1

    If (rsScore_total <> -1) Then
        If (rsScore_first > rsScore_total) Then
            rsScore_first = rsScore_total
        End If
        If (rsScore_last > rsScore_total) Then
            rsScore_last = rsScore_total
        End If
        If (rsScore_numRows > rsScore_total) Then
            rsScore_numRows = rsScore_total
        End If
    End If


    If (rsScore_total = -1) Then

        rsScore_total = 0
        While (Not rsScore.EOF)
            rsScore_total = rsScore_total + 1
            rsScore.MoveNext
        Wend

        If (rsScore.CursorType > 0) Then
            rsScore.movefirst
        Else
            rsScore.Requery
        End If

        If (rsScore_numRows < 0 Or rsScore_numRows > rsScore_total) Then
            rsScore_numRows = rsScore_total
        End If

        rsScore_first = 1
        rsScore_last = rsScore_first + rsScore_numRows - 1

        If (rsScore_first > rsScore_total) Then
            rsScore_first = rsScore_total
        End If
        If (rsScore_last > rsScore_total) Then
            rsScore_last = rsScore_total
        End If

    End If

    Response.Write "    <BR>" & vbCrLf
    Response.Write "<table width='100%' class='border' border='0' cellspacing='1' cellpadding='4' align='center'> " & vbCrLf
    Response.Write "  <tr>  " & vbCrLf
    Response.Write "    <td class='title'>  " & vbCrLf
    Response.Write "      <div align='center'><b>计 算 总 分 与 排 名 结 果</b></div> " & vbCrLf
    Response.Write "    </td> " & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "</table>" & vbCrLf
    Response.Write "<TABLE cellSpacing=0 cellPadding=0 width='100%' align=center border=0>" & vbCrLf
    Response.Write "  <TBODY>" & vbCrLf
    Response.Write "    <TR> " & vbCrLf
    Response.Write "      <TD>" & vbCrLf
    Response.Write "        <b> 考试名称：</b>&nbsp;" & vbCrLf
    Response.Write "" & vbCrLf
    Dim rsTestName
    Set rsTestName = Server.CreateObject("ADODB.Recordset")
    rsTestName.Open "SELECT SheetName, TestName FROM TestName WHERE SheetName = '" & strSheetName & "'", Conn_Sdms, 1, 3
    Response.Write rsTestName("TestName")
    rsTestName.Close
    Set rsTestName = Nothing

    Response.Write "<font color='#FF0000'><b>" & vbCrLf
    Response.Write "<font color='#0066cc'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font></b></font><b>查询条件：</b> " & vbCrLf
    Response.Write "" & vbCrLf

    If Request("StudentNum") <> "" Then
        Response.Write "学号中含有“" & strStudentNum & "”"
    ElseIf strName <> "" Then
        Response.Write "姓名中含有“" & strName & "”"
    Else
        'if strClass<>"" then strClass=strClass & "班"
        'response.write "初" & strGrade+1 & "级" & strClass
        If strClass <> "" Then
            Dim GradeName, strSearch, SearchResult
            If Trim(strClass) = "All" Then
                strClass = " 全级"
                Set GradeName = Conn_Sdms.Execute("Select GradeName From Grade Where GradeID=" & strGrade & "")
                strSearch = GradeName(0) & " " & strClass
                Set GradeName = Nothing
            Else
                Set SearchResult = Conn_Sdms.Execute("Select G.GradeName,C.ClassName From Class C Left join Grade G On C.GradeID= G.GradeID Where C.ClassID=" & CLng(strClass) & "")
                strSearch = SearchResult(0) & " " & SearchResult(1)
                Set SearchResult = Nothing
            End If
        End If
        Response.Write strSearch
    End If
    If rsScore.EOF Or rsScore.BOF Then
        Response.Write "                <br> " & vbCrLf
        Response.Write "                <br> <br>" & vbCrLf
        Response.Write "                找不到符合条件的记录！<br> " & vbCrLf
        Response.Write "                <br> <br> " & vbCrLf
    Else

        Response.Write "        <form Name='del' onsubmit='return ConfirmDel()' method='post' action='ScoreDel2.asp'>" & vbCrLf
        Response.Write "                  共找到&nbsp;<font color='#FF0000'>" & rsScore_total & "</font>&nbsp;条记录！ " & vbCrLf
        Response.Write "                  <table width='100%' class='border' border='0' cellspacing='1' cellpadding='4' align='center'>" & vbCrLf
        Response.Write "                    <tr class='title'> " & vbCrLf
        Response.Write "                      <td height='28'><font color='#000000'>学 号</font></td>" & vbCrLf
        Response.Write "                      <td height='28'><font color='#000000'>姓 名</font></td>" & vbCrLf
        Response.Write "" & vbCrLf

        For i = 2 To rsScore.Fields.Count - 1
            Response.Write "<td height='28'><font color='#000000'>" & rsScore.Fields.Item(i).name & "</font></td>"
        Next

        Response.Write "                    </tr>" & vbCrLf
        Dim tmpScore
        While ((Repeat1__numRows <> 0) And (Not rsScore.EOF))

            Response.Write "          <tr class='tdbg' onmouseout=""this.style.backgroundColor=''"" onmouseover=""this.style.backgroundColor='#BFDFFF'"">  " & vbCrLf
            Response.Write "" & vbCrLf

            For i = 0 To rsScore.Fields.Count - 1
                tmpScore = rsScore.Fields.Item(i).value
                If IsNull(tmpScore) Then tmpScore = "&nbsp;"
                Response.Write "<td height='20'>" & tmpScore & "</td>"
            Next

            Response.Write "                    </tr>" & vbCrLf
             
            Repeat1__index = Repeat1__index + 1
            Repeat1__numRows = Repeat1__numRows - 1
            rsScore.MoveNext
        Wend

        Response.Write "                  </table>" & vbCrLf
        Response.Write "                </form>" & vbCrLf
    End If
    Response.Write "        </TD>" & vbCrLf
    Response.Write "    </TR>" & vbCrLf
    Response.Write "  </TBODY>" & vbCrLf
    Response.Write "</TABLE>" & vbCrLf

    rsScore.Close
End Sub

Sub TargetManage()
    Response.Write "<script language=""JavaScript"">" & vbCrLf
    Response.Write "function check()" & vbCrLf
    Response.Write "{" & vbCrLf
    Response.Write "var total=0;" & vbCrLf
    Response.Write "var intmax=document.form1.chkbox.length;" & vbCrLf
    Response.Write "if(intmax>1){" & vbCrLf
    Response.Write "  for(var idx=0;idx<intmax;idx++){" & vbCrLf
    Response.Write "    if(eval(""document.form1.chkbox["" + idx + ""].checked"")==true){" & vbCrLf
    Response.Write "      total+=1;" & vbCrLf
    Response.Write "    }" & vbCrLf
    Response.Write "  }" & vbCrLf
    Response.Write "  if(total==0){" & vbCrLf
    Response.Write "    alert(""您未选择任何科目！"");" & vbCrLf
    Response.Write "    document.form1.chkbox[0].focus();" & vbCrLf
    Response.Write "    return false;" & vbCrLf
    Response.Write "  }" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "else{" & vbCrLf
    Response.Write "  if(document.form1.chkbox.checked==false){" & vbCrLf
    Response.Write "    alert(""您未选择任何科目！"");" & vbCrLf
    Response.Write "    document.form1.chkbox.focus();" & vbCrLf
    Response.Write "    return false;" & vbCrLf
    Response.Write "  }" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "</script>" & vbCrLf
    Response.Write "<script language=""JavaScript"" type=""text/JavaScript"">" & vbCrLf
    Response.Write "function ChangeClass(num)" & vbCrLf
    Response.Write "{" & vbCrLf
    Response.Write "    var i;" & vbCrLf
    Response.Write "    var j;" & vbCrLf
    Response.Write "    for(i=document.form1.ClassSelect.options.length-1;i>=0;i--)" & vbCrLf
    Response.Write "    {" & vbCrLf
    Response.Write "        document.form1.ClassSelect.options[i]=null;" & vbCrLf
    Response.Write "    }" & vbCrLf
    Response.Write "" & vbCrLf
    Response.Write "    for(j=0;j<document.Classes.all(""Grade""+num).options.length;j++)" & vbCrLf
    Response.Write "    {" & vbCrLf
    Response.Write "        document.form1.ClassSelect.options[j]=new Option(document.Classes.all(""Grade""+num).options[j].text,document.Classes.all(""Grade""+num).options[j].value);" & vbCrLf
    Response.Write "    }" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "</script>" & vbCrLf
    Response.Write "<div id='Layer1' style='position:absolute; left:445px; top:220px; width:188px; height:64px; z-index:1; visibility: hidden;'> " & vbCrLf
    Response.Write GetClass_Option(0)
    Response.Write "</div>" & vbCrLf
    Response.Write "" & vbCrLf
    Dim Recordset1

    Set Recordset1 = Server.CreateObject("ADODB.Recordset")
    Recordset1.Open "SELECT * FROM TargetScore", Conn_Sdms, 1, 3

    Response.Write "<br>" & vbCrLf
    Response.Write "<table width='100%' class='border' border='0' cellspacing='1' cellpadding='4' align='center'> " & vbCrLf
    Response.Write "  <tr>  " & vbCrLf
    Response.Write "    <td align='center' class='title' colspan='3'>  " & vbCrLf
    Response.Write "      <b><b>目 标 分</b> 管 理(第一步)----请输入查询条件并选择要进行目标分管理的科目</b> " & vbCrLf
    Response.Write "    </td> " & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "        <form Name='form1'  onSubmit='return check()' action='Admin_ScoreManage.asp?Action=TargetManageMain' method='post'>" & vbCrLf
    Response.Write "            <tr class='tdbg'> " & vbCrLf
    Response.Write "              <td width='20%' align='right'><strong>请输入查询条件：</strong>" & vbCrLf
    Response.Write "              <br> " & vbCrLf
    Response.Write "                <br>" & vbCrLf
    Response.Write "              （可从学号或班级两种查询方法任选其一进行查询）</td>" & vbCrLf
    Response.Write "              <td nowrap>学号： " & vbCrLf
    Response.Write "                <input type='text' Name='StudentNum' maxlength='8' size='18'> " & vbCrLf
    Response.Write "                <br> <br>" & vbCrLf
    Response.Write "                班级： " & vbCrLf
    Response.Write "                <select name='Grade' onChange=""ChangeClass(this.value)"">" & vbCrLf
    Response.Write GetGrade_Option
    Response.Write "                </select> <select name='ClassSelect'>" & vbCrLf
    Response.Write "                  <option value='All' selected>全级</option>" & vbCrLf
    Response.Write "" & vbCrLf
    Dim RsFirst, FirstGradeID, Rsin, Sqlin, i
    Set RsFirst = Conn_Sdms.Execute("select top 1 GradeID from Grade order by OrderID asc")
    FirstGradeID = RsFirst("GradeID")
    Set RsFirst = Nothing
    Set Rsin = Server.CreateObject("ADODB.REcordset")
    Sqlin = "select * from Class where GradeID=" & FirstGradeID & " order by OrderID asc"
    Rsin.Open Sqlin, Conn_Sdms, 1, 3
    Do While Not Rsin.EOF
        Response.Write "<option value='" & Rsin("ClassID") & "' >" & Rsin("ClassName") & "</option>"
        Rsin.MoveNext
    Loop
    Set Rsin = Nothing

    Response.Write "                </select> </td>" & vbCrLf
    Response.Write "              <td><b><font color='#0066cc'>注：</font></b><br>" & vbCrLf
    Response.Write "                　　1 、若输入了学号，则优先按学号进行查询。 <br> " & vbCrLf
    Response.Write "                <font color='#FF0000'>　　2、支持模糊查询！</font>" & vbCrLf
    Response.Write "                <br>" & vbCrLf
    Response.Write "                例如：<br> &nbsp;&nbsp;&nbsp;&nbsp;在学号查询框中输入2001，则查询结果为学号中包含“2001”的学生</td>" & vbCrLf
    Response.Write "            </tr>" & vbCrLf
    Response.Write "            <tr class='tdbg'> " & vbCrLf
    Response.Write "              <td width='20%' align='right'><strong>请选择科目：</strong></td>" & vbCrLf
    Response.Write "              <td colspan='2'> <table border='0' cellspacing='5' cellpadding='0'>" & vbCrLf
    Response.Write "                  <tr class='tdbg'> " & vbCrLf
    Response.Write "" & vbCrLf

    For i = 5 To Recordset1.Fields.Count - 1
        Response.Write "<td width='80'><input Name='chkbox' type='checkbox' value='" & Recordset1.Fields(i).name & "'>" & Recordset1.Fields(i).name & "</td>"
        If (i + 1 - 5) > 0 And ((i + 1 - 5) Mod 5 = 0) Then Response.Write "</tr><tr class='tdbg'>"
    Next
    Response.Write "<td><input Name='chkbox' type='checkbox' value='总分'>总分</td>"
    If (i + 1 - 5) > 0 And ((i + 1 - 5) Mod 5 = 0) Then Response.Write "</tr><tr class='tdbg'>"
    i = i + 1
    Response.Write "<td><input Name='chkbox' type='checkbox' value='平均分'>平均分</td>"
    If (i + 1 - 5) > 0 And ((i + 1 - 5) Mod 5 = 0) Then Response.Write "</tr><tr class='tdbg'>"
    i = i + 1
    Response.Write "<td><input Name='chkbox' type='checkbox' value='全级排名'>全级排名</td>"
    If (i + 1 - 5) > 0 And ((i + 1 - 5) Mod 5 = 0) Then Response.Write "</tr><tr class='tdbg'>"
    Response.Write "<td><input Name='chkbox' type='checkbox' value='班级排名'>班级排名</td>"

    Response.Write "                  </tr>" & vbCrLf
    Response.Write "                </table></td>" & vbCrLf
    Response.Write "            </tr>" & vbCrLf
    Response.Write "            <tr align='center' class='tdbg'> " & vbCrLf
    Response.Write "              <td height='43' colspan='3'><input type='submit' Name='Submit' value='下一步'></td>" & vbCrLf
    Response.Write "            </tr>" & vbCrLf
    Response.Write "        </form>" & vbCrLf
    Response.Write "</TABLE>" & vbCrLf
    Response.Write "" & vbCrLf
    Recordset1.Close
End Sub

Sub TargetManageMain()
    Dim MM_editAction, MM_editTable, MM_editQuery, MM_editRedirectUrl
    Dim strStudentNum, strName, strGrade, strClass, Recordset1, Recordset1Sql
    Dim strTemp, i, Recordset5__MMColParam, Recordset5, Recordset5Sql
    Dim Recordset4__MMColParam, Recordset4, Recordset4Sql, tmpScore
    
    MM_editAction = CStr(Request("URL"))
    If (Request.QueryString <> "") Then
        MM_editAction = MM_editAction & "?" & Request.QueryString
    End If
    Dim arrStudentNum, arrEditType, ArrSubject, intTemp, EditType
    Dim MM_fieldsStr, MM_columnsStr, MM_fields, MM_columns, arrTemp, MM_tableValues, MM_dbValues
    Dim FormVal, MM_typeArray, Delim, AltVal, EmptyVal, j
    Dim MM_recordId
    If (Trim(Request.Form("InputScore")) <> "" And Trim(Request.Form("StudentNum")) <> "") Then
        MM_editTable = "TargetScore"
        MM_editRedirectUrl = "Admin_ScoreManage.asp?Action=TargetManageMain&" & Session("strQureyString")
        MM_editQuery = ""
        If InStr(Request.Form("StudentNum"), ",") > 0 Then     '需要对多条记录进行操作
            arrStudentNum = Split(Replace(Request.Form("StudentNum"), " ", ""), ",")
            arrEditType = Split(Replace(Request.Form("EditType"), " ", ""), ",")
            ArrSubject = Split(Replace(Request.Form("Subject"), "|value", ""), "|")
            Dim arrScore()
            ReDim arrScore(UBound(ArrSubject) + 1)
            For intTemp = LBound(ArrSubject) To UBound(ArrSubject)
                arrScore(intTemp) = Replace(Replace(Request.Form(ArrSubject(intTemp)), " ", ""), ",", "|")
            Next
            EditType = "Insert"
            For intTemp = LBound(arrStudentNum) To UBound(arrStudentNum)     '对每一条记录进行插入或更新操作
                EditType = CheckExist(CStr(arrStudentNum(intTemp)), MM_editTable)
                If EditType = "Insert" Then  '插入记录
                    MM_fieldsStr = "StudentNum|value|" & Request.Form("Subject")
                    MM_columnsStr = "StudentNum|',none,''|" & Replace(Request.Form("Subject"), "value", "none,none,NULL")
                    MM_fields = Split(MM_fieldsStr, "|")
                    MM_columns = Split(MM_columnsStr, "|")
                    MM_fields(1) = arrStudentNum(intTemp)
                    For j = 2 To UBound(MM_fields) Step 2
                        arrTemp = Split(arrScore((j - 2) / 2), "|")
                        MM_fields(j + 1) = arrTemp(intTemp) & ""
                        If MM_fields(j + 1) = "" Then MM_fields(j + 1) = "0"
                    Next
                    'InsertRecord
                    '--------------
                    MM_tableValues = ""
                    MM_dbValues = ""
                    
                    For i = LBound(MM_fields) To UBound(MM_fields) Step 2
                        FormVal = MM_fields(i + 1)
                        MM_typeArray = Split(MM_columns(i + 1), ",")
                        Delim = MM_typeArray(0)
                        If (Delim = "none") Then Delim = ""
                        AltVal = MM_typeArray(1)
                        If (AltVal = "none") Then AltVal = ""
                        EmptyVal = MM_typeArray(2)
                        If (EmptyVal = "none") Then EmptyVal = ""
                        If (FormVal = "") Then
                          FormVal = EmptyVal
                        Else
                          If (AltVal <> "") Then
                            FormVal = AltVal
                          ElseIf (Delim = "'") Then  ' escape quotes
                            FormVal = "'" & Replace(FormVal, "'", "''") & "'"
                          Else
                            FormVal = Delim + FormVal + Delim
                          End If
                        End If
                        If (i <> LBound(MM_fields)) Then
                          MM_tableValues = MM_tableValues & ","
                          MM_dbValues = MM_dbValues & ","
                        End If
                        MM_tableValues = MM_tableValues & MM_columns(i)
                        MM_dbValues = MM_dbValues & FormVal
                    Next

                    MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & ") values (" & MM_dbValues & ")"
                    '--------------
                End If
                If EditType = "Update" Then  '更新记录
                    MM_recordId = "'" & arrStudentNum(intTemp) & "'"
                    MM_fieldsStr = Request.Form("Subject")
                    MM_columnsStr = Replace(Request.Form("Subject"), "value", "',none,''")
                    MM_fields = Split(MM_fieldsStr, "|")
                    MM_columns = Split(MM_columnsStr, "|")
                    For j = LBound(MM_fields) To UBound(MM_fields) Step 2
                        arrTemp = Split(arrScore(j / 2), "|")
                        MM_fields(j + 1) = arrTemp(intTemp) & ""
                        If MM_fields(j + 1) = "" Then MM_fields(j + 1) = "0"
                    Next
                    'UpdateRecord
                    '--------------------
                    MM_editQuery = "update " & MM_editTable & " set "
                    For i = LBound(MM_fields) To UBound(MM_fields) Step 2
                        FormVal = MM_fields(i + 1)
                        MM_typeArray = Split(MM_columns(i + 1), ",")
                        Delim = MM_typeArray(0)
                        If (Delim = "none") Then Delim = ""
                        AltVal = MM_typeArray(1)
                        If (AltVal = "none") Then AltVal = ""
                        EmptyVal = MM_typeArray(2)
                        If (EmptyVal = "none") Then EmptyVal = ""
                        If (FormVal = "") Then
                            FormVal = EmptyVal
                        Else
                            If (AltVal <> "") Then
                                FormVal = AltVal
                            ElseIf (Delim = "'") Then  ' escape quotes
                                FormVal = "'" & Replace(FormVal, "'", "''") & "'"
                            Else
                                FormVal = Delim + FormVal + Delim
                            End If
                        End If
                        If (i <> LBound(MM_fields)) Then
                            MM_editQuery = MM_editQuery & ","
                        End If
                        MM_editQuery = MM_editQuery & MM_columns(i) & " = " & FormVal
                    Next
                    MM_editQuery = MM_editQuery & " where StudentNum = " & MM_recordId
                    '---------------------
                End If
                Conn_Sdms.Execute MM_editQuery
            Next
        Else             '只有一条记录时
            EditType = ReplaceBadChar(Trim(Request.Form("EditType")))
            strStudentNum = Trim(Request.Form("StudentNum"))
            EditType = CheckExist(strStudentNum, MM_editTable)
            If EditType = "" Then
                Response.Write "<br><br>条件不足，操作失败！"
                Response.End
            End If
            If EditType = "Insert" Then '插入记录
                MM_fieldsStr = "StudentNum|value|" & Request.Form("Subject")
                MM_columnsStr = "StudentNum|',none,''|" & Replace(Request.Form("Subject"), "value", "none,none,NULL")
                MM_fields = Split(MM_fieldsStr, "|")
                MM_columns = Split(MM_columnsStr, "|")
                
                MM_fields(1) = strStudentNum
                For intTemp = 2 To UBound(MM_fields) Step 2
                    MM_fields(intTemp + 1) = CStr(Request.Form(MM_fields(intTemp)))
                    If MM_fields(intTemp + 1) = "" Then MM_fields(intTemp + 1) = "0"
                Next
                'InsertRecord
                '-----------------
                MM_tableValues = ""
                MM_dbValues = ""
                For i = LBound(MM_fields) To UBound(MM_fields) Step 2
                    FormVal = MM_fields(i + 1)
                    MM_typeArray = Split(MM_columns(i + 1), ",")
                    Delim = MM_typeArray(0)
                    If (Delim = "none") Then Delim = ""
                    AltVal = MM_typeArray(1)
                    If (AltVal = "none") Then AltVal = ""
                    EmptyVal = MM_typeArray(2)
                    If (EmptyVal = "none") Then EmptyVal = ""
                    If (FormVal = "") Then
                      FormVal = EmptyVal
                    Else
                      If (AltVal <> "") Then
                        FormVal = AltVal
                      ElseIf (Delim = "'") Then  ' escape quotes
                        FormVal = "'" & Replace(FormVal, "'", "''") & "'"
                      Else
                        FormVal = Delim + FormVal + Delim
                      End If
                    End If
                    If (i <> LBound(MM_fields)) Then
                      MM_tableValues = MM_tableValues & ","
                      MM_dbValues = MM_dbValues & ","
                    End If
                    MM_tableValues = MM_tableValues & MM_columns(i)
                    MM_dbValues = MM_dbValues & FormVal
                Next

                MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & ") values (" & MM_dbValues & ")"
                '-----------------
            End If
            If EditType = "Update" Then  '更新记录
                MM_recordId = "'" & strStudentNum & "'"
                MM_fieldsStr = Request.Form("Subject")
                MM_columnsStr = Replace(Request.Form("Subject"), "value", "',none,''")
                MM_fields = Split(MM_fieldsStr, "|")
                MM_columns = Split(MM_columnsStr, "|")
                For intTemp = LBound(MM_fields) To UBound(MM_fields) Step 2
                    MM_fields(intTemp + 1) = CStr(Request.Form(MM_fields(intTemp)))
                    If MM_fields(intTemp + 1) = "" Then MM_fields(intTemp + 1) = "0"
                Next
                '编译时通不过，先注释掉了
                'UpdateRecord
            End If
            Conn_Sdms.Execute MM_editQuery
        End If

        Response.Redirect (MM_editRedirectUrl)
    End If

    strStudentNum = Trim(Request("StudentNum"))
    strGrade = Request("Grade")
    strClass = Request("ClassSelect")
    Session("txtStudentNum") = strStudentNum
    Session("txtGrade") = strGrade
    Session("txtClass") = strClass
    If Request.Form("chkbox") <> "" Then Session("strQureyString") = Request.Form

    Set Recordset1 = Server.CreateObject("ADODB.Recordset")
    If (strStudentNum <> "") Then
        Recordset1Sql = "SELECT StudentNum, Name FROM StudentInfo WHERE StudentNum like '" & strStudentNum & "%'  ORDER BY StudentNum asc"
    Else
        If strClass = "All" Then
            Recordset1Sql = "SELECT StudentNum, Name FROM StudentInfo WHERE GradeID=" & strGrade & " ORDER BY StudentNum asc"
        Else
            Recordset1Sql = "SELECT StudentNum, Name FROM StudentInfo WHERE ClassID=" & strClass & " And GradeID=" & strGrade & " ORDER BY StudentNum asc"
        End If
    End If
    Recordset1.Open Recordset1Sql, Conn_Sdms, 1, 3
    Dim Repeat1__numRows
    Repeat1__numRows = -1
    Dim Repeat1__index
    Repeat1__index = 0

    Response.Write "<br>" & vbCrLf
    Response.Write "<table width='100%' class='border' border='0' cellspacing='1' cellpadding='4' align='center'> " & vbCrLf
    Response.Write "  <tr>  " & vbCrLf
    Response.Write "    <td align='center' class='title'>  " & vbCrLf
    Response.Write "    <b>目 标 分 管 理</b> <b>(第二步)</b>----输入目标分</td> " & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "</table>" & vbCrLf
    Response.Write "<table width='100%' border=0 align='center' cellPadding=0 cellSpacing=0>" & vbCrLf
    Response.Write "  <TBODY>" & vbCrLf
    Response.Write "    <TR> " & vbCrLf
    Response.Write "      <TD >" & vbCrLf
    Response.Write "        <form Name='form1' action='" & MM_editAction & "' method='POST'>" & vbCrLf
    Response.Write "          <font color='#FF0000'><b>查询条件：</b></font> " & vbCrLf
                
    If Request("StudentNum") <> "" Then
        Response.Write "学号中含有“" & strStudentNum & "”"
    ElseIf strName <> "" Then
        Response.Write "姓名中含有“" & strName & "”"
    Else
        If strClass <> "" Then
            Dim SearchResult, GradeName, strSearch
            If Trim(strClass) = "All" Then
                Set GradeName = Conn_Sdms.Execute("Select GradeName From Grade Where GradeID=" & strGrade & "")
                strSearch = GradeName(0) & "  全级"
                Set GradeName = Nothing
            Else
                Set SearchResult = Conn_Sdms.Execute("Select G.GradeName,C.ClassName From Class C Left join Grade G On C.GradeID= G.GradeID Where C.ClassID=" & CLng(strClass) & "")
                strSearch = SearchResult(0) & " " & SearchResult(1)
                Set SearchResult = Nothing
            End If
        End If
        Response.Write strSearch
    End If

    Response.Write "          <br>" & vbCrLf
    Response.Write "          <br>" & vbCrLf
    Response.Write "          <b><font color='#FF0000'>未录入目标分的学生名单：</font>" & vbCrLf
    Response.Write "          </b><br>" & vbCrLf
    Response.Write "" & vbCrLf

    If Recordset1.EOF Or Recordset1.BOF Then
        Response.Write ("找不到学生，请先在学生信息管理中录入相应的学生信息！")
    Else
        Response.Write "        <table class='border' border='0' cellspacing='1' cellpadding='4' align='center'>" & vbCrLf
        Response.Write "            <tr class='title'>  " & vbCrLf
        Response.Write "              <td width='60' height='25' align='center'>学号</td>" & vbCrLf
        Response.Write "              <td width='60' align='center'>姓名</td>" & vbCrLf

        strTemp = Request("chkbox")
        If InStr(strTemp, ",") > 0 Then
            ArrSubject = Split(strTemp, ",")
            For i = LBound(ArrSubject) To UBound(ArrSubject)
                Response.Write "<td align='center'>" & Trim(ArrSubject(i)) & "</td>"
            Next
        Else
            Response.Write "<td align='center'>" & strTemp & "</td>"
        End If
        Response.Write "               </tr>" & vbCrLf
        Response.Write (vbCrLf)
        i = 0
        Dim UpdateFlag
        While (Not Recordset1.EOF)
            Recordset5__MMColParam = CStr(Recordset1.Fields.Item("StudentNum").value)
            Set Recordset5 = Server.CreateObject("ADODB.Recordset")
            Recordset5Sql = "SELECT StudentNum," & Request("chkbox") & " FROM TargetScore WHERE StudentNum = '" + Replace(Recordset5__MMColParam, "'", "''") + "'"

            Recordset5.Open Recordset5Sql, Conn_Sdms, 1, 3
            If Recordset5.BOF Or Recordset5.EOF Then
                i = i + 1
                Response.Write "    <tr class='tdbg' onmouseout=""this.className='tdbg'"" onmouseover=""this.className='tdbgmouseover'"">"
                Response.Write ("<td height='25' align='center'>" & Recordset1.Fields.Item("StudentNum").value & "</td>")
                Response.Write ("<input name='StudentNum' type='hidden' value='" & Recordset1.Fields.Item("StudentNum").value & "'>")
                Response.Write ("<input name='EditType' type='hidden' value='Insert'>")
                Response.Write ("<td align='center'>" & Recordset1.Fields.Item("Name").value & "</td>")
                strTemp = Request("chkbox")
                If InStr(strTemp, ",") > 0 Then
                    ArrSubject = Split(strTemp, ",")
                    For i = LBound(ArrSubject) To UBound(ArrSubject)
                        Response.Write "<td align='center'><input type='text' maxlength=6 size=6 Name='" & Trim(ArrSubject(i)) & "'></td>"
                    Next
                Else
                    Response.Write "<td align='center'><input type='text' maxlength=6 size=6 Name='" & strTemp & "'></td>"
                End If
                Response.Write ("</tr>" & vbCrLf)
            Else
                strTemp = CStr(Request("chkbox"))
                UpdateFlag = False
                If InStr(strTemp, ",") > 0 Then
                    ArrSubject = Split(strTemp, ",")
                    For j = LBound(ArrSubject) To UBound(ArrSubject)
                        If IsNull(Recordset5.Fields.Item(Trim(ArrSubject(j))).value) Or Recordset5.Fields.Item(Trim(ArrSubject(j))).value = 0 Then
                            UpdateFlag = True
                        End If
                    Next
                    If UpdateFlag = True Then
                        i = i + 1
                        Response.Write ("<tr valign='middle'>")
                        Response.Write ("<td height='25' align='center'>" & Recordset1.Fields.Item("StudentNum").value & "</td>")
                        Response.Write ("<input name='StudentNum' type='hidden' value='" & Recordset1.Fields.Item("StudentNum").value & "'>")
                        Response.Write ("<input name='EditType' type='hidden' value='Update'>")
                        Response.Write ("<td align='center'>" & Recordset1.Fields.Item("Name").value & "</td>")
                        For j = LBound(ArrSubject) To UBound(ArrSubject)
                            tmpScore = Recordset5.Fields.Item(Trim(ArrSubject(j))).value
                            Response.Write "<td align='center'><input type='text' maxlength=6 size=6 Name='" & Trim(ArrSubject(j)) & "' value='" & tmpScore & "'></td>"
                        Next
                        Response.Write ("</tr>" & vbCrLf)
                    End If
                Else
                    If IsNull(Recordset5.Fields.Item(strTemp).value) Or Recordset5.Fields.Item(strTemp).value = 0 Then
                        i = i + 1
                        Response.Write ("<tr valign='middle'>")
                        Response.Write ("<td height='25' align='center'>" & Recordset1.Fields.Item("StudentNum").value & "</td>")
                        Response.Write ("<input name='StudentNum' type='hidden' value='" & Recordset1.Fields.Item("StudentNum").value & "'>")
                        Response.Write ("<input name='EditType' type='hidden' value='Update'>")
                        Response.Write ("<td align='center'>" & Recordset1.Fields.Item("Name").value & "</td>")
                        Response.Write ("<td align='center'><input type='text' maxlength=6 size=6 Name='" & strTemp & "'></td>")
                        Response.Write ("</tr>" & vbCrLf)
                    End If
                End If
            End If
            Recordset5.Close
            Recordset1.MoveNext
        Wend
        If (Recordset1.CursorType > 0) Then
            Recordset1.movefirst
        Else
            Recordset1.Requery
        End If
        Recordset1.Close
        Set Recordset1 = Nothing
        If i = 0 Then
            Response.Write "全部成绩都已经录入"
        End If
        Response.Write "          </table>" & vbCrLf
        Response.Write "          <br>" & vbCrLf

        If i > 0 Then
            Response.Write "          <input type='hidden' Name='Action' value='TargetManageMain'>" & vbCrLf
            Response.Write "          <input type='hidden' Name='InputScore' value='True'>" & vbCrLf
            Response.Write "          <input type='hidden' Name='Subject' value='" & Replace(Replace(Request("chkbox"), ",", "|value|") & "|value", " ", "") & "'>" & vbCrLf
            Response.Write "          <input type='submit' Name='Submit2' value='保存已录入的学生成绩'>" & vbCrLf
            Response.Write "" & vbCrLf
        End If
    End If
    Response.Write "        </form>" & vbCrLf
    Response.Write "        <b><font color='#FF0000'>已经录入目标分的学生：</font>" & vbCrLf
    Response.Write "        </b> " & vbCrLf
    Response.Write "" & vbCrLf
    Dim Recordset3, Recordset3Sql
    Set Recordset3 = Server.CreateObject("ADODB.Recordset")
    If (strStudentNum <> "") Then
        Recordset3Sql = "SELECT * FROM TargetScore WHERE StudentNum like '" & strStudentNum & "%'  ORDER BY StudentNum asc"
    Else
        If strClass = "All" Then
            Recordset3Sql = "SELECT * FROM TargetScore T Left Join StudentInfo S On T.StudentNum=S.StudentNum WHERE S.GradeID=" & CLng(strGrade) & " ORDER BY T.StudentNum asc"
        Else
            Recordset3Sql = "SELECT * FROM TargetScore T Left Join StudentInfo S On T.StudentNum=S.StudentNum WHERE S.ClassID=" & CLng(strClass) & " And S.GradeID=" & CLng(strGrade) & " ORDER BY T.StudentNum asc"
        End If
    End If
    Recordset3.Open Recordset3Sql, Conn_Sdms, 1, 3
    If Recordset3.EOF Or Recordset3.BOF Then
        Response.Write "<br><br>还没有录入任何学生的目标分！<br> <br> <br> "
    Else
        Response.Write "        <table width='100%' class='border' border='0' cellspacing='1' cellpadding='4' align='center'>" & vbCrLf
        Response.Write "          <tr class='title'> " & vbCrLf
        Response.Write "            <td height='30'><font color='#000000'>学 号</font></td>" & vbCrLf
        Response.Write "            <td height='30'><font color='#000000'>姓 名</font></td>" & vbCrLf
        Response.Write "" & vbCrLf

        For i = 5 To 18
            Response.Write "<td height='28'><font color='#000000'>" & Recordset3.Fields.Item(i).name & "</font></td>"
        Next

        Response.Write "            <td height='30'><font color='#000000'>操作</font>" & vbCrLf
        Response.Write "            </td>" & vbCrLf
        Response.Write "          </tr>" & vbCrLf
        Response.Write "" & vbCrLf
        
        While ((Repeat1__numRows <> 0) And (Not Recordset3.EOF))
            Recordset4__MMColParam = CStr(Recordset3.Fields.Item("StudentNum").value)
            Set Recordset4 = Server.CreateObject("ADODB.Recordset")
            Recordset4Sql = "SELECT StudentNum, Name  FROM StudentInfo WHERE StudentNum = '" + Replace(Recordset4__MMColParam, "'", "''") + "'"
            Recordset4.Open Recordset4Sql, Conn_Sdms, 1, 3
            If Not Recordset4.BOF Or Not Recordset4.EOF Then
                strName = CStr(Recordset4.Fields.Item("Name").value)
                If strName = "" Then strName = "&nbsp;"
            Else
                strName = "&nbsp;"
            End If
            Response.Write "              <tr class='tdbg' onmouseout=""this.style.backgroundColor=''"" onmouseover=""this.style.backgroundColor='#BFDFFF'"">  " & vbCrLf
            Response.Write "                <td height='20'>" & Recordset3.Fields.Item("StudentNum").value & "</td>" & vbCrLf
            Response.Write "                <td height='20'>" & strName & "</td>" & vbCrLf
            Response.Write "" & vbCrLf
            For i = 5 To 18
                tmpScore = Recordset3.Fields.Item(i).value
                If IsNull(tmpScore) Then tmpScore = "&nbsp;"
                Response.Write "<td height='20'>" & tmpScore & "</td>"
            Next
            Response.Write "                <td height='20'><A HREF='Admin_ScoreManage.asp?Action=TargetModify&StudentNum=" & Recordset3.Fields.Item("StudentNum").value & "'>修改</A> " & vbCrLf
            Response.Write "                  <A HREF='Admin_ScoreManage.asp?Action=TargetDel&StudentNum=" & Recordset3.Fields.Item("StudentNum").value & "'>删除</A></td>" & vbCrLf
            Response.Write "              </tr>" & vbCrLf
            Response.Write "" & vbCrLf
            Recordset4.Close
            Repeat1__index = Repeat1__index + 1
            Repeat1__numRows = Repeat1__numRows - 1
            Recordset3.MoveNext
        Wend
        Recordset3.Close
        Set Recordset3 = Nothing
        Response.Write "          <tbody>" & vbCrLf
        Response.Write "          </tbody>" & vbCrLf
        Response.Write "        </table>" & vbCrLf
        Response.Write "" & vbCrLf
    End If
    Response.Write "      </td>" & vbCrLf
    Response.Write "       " & vbCrLf
    Response.Write "    </TR> " & vbCrLf
    Response.Write "  </TBODY>" & vbCrLf
    Response.Write "</TABLE>" & vbCrLf
End Sub


Sub TargetModify()
    Dim strStudentNum, Recordset3
    strStudentNum = Request.QueryString("StudentNum")
    Set Recordset3 = Server.CreateObject("ADODB.Recordset")
    Recordset3.Open "SELECT *  FROM TargetScore WHERE StudentNum = '" & strStudentNum & "'", Conn_Sdms, 1, 3
    Response.Write "<br>" & vbCrLf
    Response.Write "<table width='100%' class='border' border='0' cellspacing='1' cellpadding='4' align='center'> " & vbCrLf
    Response.Write "  <tr>  " & vbCrLf
    Response.Write "    <td align='center' class='title'>  " & vbCrLf
    Response.Write "      <b>目 标 分 管 理</b> " & vbCrLf
    Response.Write "    </td> " & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "</table>" & vbCrLf
    Response.Write "<table width='100%' border=0 align='center' cellPadding=0 cellSpacing=0>" & vbCrLf
    Response.Write "  <TBODY>" & vbCrLf
    Response.Write "    <TR> " & vbCrLf
    Response.Write "      <TD>" & vbCrLf
    Response.Write "        <table width='100%' border='0' cellpadding='0' cellspacing='0'>" & vbCrLf
    Response.Write "          <tr> " & vbCrLf
    Response.Write "            <TD width='25%' vAlign=top> <p> <br>" & vbCrLf
    Response.Write "                <strong>注：</strong><br>" & vbCrLf
    Response.Write "                <br>" & vbCrLf
    Response.Write "                1、输入成绩后可直接按回车键保存修改结果<br>" & vbCrLf
    Response.Write "                <br>" & vbCrLf
    Response.Write "                2、输入过程中可用Tab键将光标在各输入框中切换<br>" & vbCrLf
    Response.Write "                <br>" & vbCrLf
    Response.Write "                3、保存修改结果后，系统会自动转入录入下一条记录页面或查询结果结果页面。</p>" & vbCrLf
    Response.Write "                </TD>" & vbCrLf
    Response.Write "            <td width='2%' valign='top'> " & vbCrLf
    Response.Write "            </td>" & vbCrLf
    Response.Write "            <TD valign='top'>" & vbCrLf
    Response.Write "            <form action='Admin_ScoreManage.asp' method='post' name='form1'>" & vbCrLf
    Response.Write "<table cellspacing=4 width='100%' border=0>" & vbCrLf
    Response.Write "                <tr> " & vbCrLf
    Response.Write "                  <td align=right width=60 height='20'>学号：</td>" & vbCrLf
    Response.Write "                 <td align=left width=373 height='20'>" & vbCrLf
    Response.Write Recordset3.Fields.Item("StudentNum").value
    Response.Write "                  </td>" & vbCrLf
    Response.Write "                </tr>" & vbCrLf
    Response.Write "                <tr> " & vbCrLf
    Response.Write "                  <td align=right width=60 height='20'>姓名：</td>" & vbCrLf
    Response.Write "                  <td align=left width=373 height='20'>" & vbCrLf
    Dim Recordset1, i, strSubject
    Set Recordset1 = Server.CreateObject("ADODB.Recordset")
    Recordset1.Open "SELECT StudentNum, Name FROM StudentInfo WHERE StudentNum = '" & strStudentNum & "'", Conn_Sdms, 1, 3
    If Not Recordset1.EOF Or Not Recordset1.BOF Then
        Response.Write Recordset1.Fields.Item("Name").value
    End If
    Recordset1.Close
    Response.Write "                    &nbsp;</td>" & vbCrLf
    Response.Write "                </tr>" & vbCrLf
    Response.Write "" & vbCrLf
    strSubject = ""
    For i = 5 To Recordset3.Fields.Count - 1
        Response.Write "<tr>"
        Response.Write "<td align=right width=60 height='20'>" & Recordset3.Fields.Item(i).name & "：</td>"
        Response.Write "<td align=left width=373 height='20'><input maxlength=6 size=10 Name='" & Recordset3.Fields.Item(i).name & "' value='" & Recordset3.Fields.Item(i).value & "'>"
        Response.Write "</td></tr>"
        If strSubject = "" Then
            strSubject = Recordset3.Fields.Item(i).name
        Else
            strSubject = strSubject & "|" & Recordset3.Fields.Item(i).name
        End If
    Next
    Response.Write "              </table>" & vbCrLf
    Response.Write "              <input type='hidden' name='Action' value='SaveTargetModify'>" & vbCrLf
    Response.Write "              <input Name='MM_recordId' type='hidden' id='MM_recordId' value='" & Recordset3.Fields.Item("StudentNum").value & "'> " & vbCrLf
    Response.Write "              <input name='Subject' type='hidden' id='Subject' value='" & strSubject & "'> " & vbCrLf
    Response.Write "              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " & vbCrLf
    Response.Write "              <input type='submit' Name='Submit2' value='保存修改结果'></form></td>" & vbCrLf
    Response.Write "          </tr>" & vbCrLf
    Response.Write "        </table></td>" & vbCrLf
    Response.Write "       " & vbCrLf
    Response.Write "    </TR> " & vbCrLf
    Response.Write "  </TBODY>" & vbCrLf
    Response.Write "</TABLE>" & vbCrLf
    Response.Write "" & vbCrLf
    Recordset3.Close
End Sub


Sub SaveTargetModify()
    Dim rsScore, sqlScore, ArrSubject, rsScoreTemp, i
    Dim StudentNum, strSheetName, strSubject, total
    StudentNum = Trim(Request.Form("MM_recordId"))
    strSubject = Request.Form("Subject")
    If StudentNum = "" Then
        FoundErr = True
        ErrMsg = ErrMsg & "<br><li>学生学号不能为空！！！</li>"
        Exit Sub
    Else
        StudentNum = ReplaceBadChar(StudentNum)
    End If

    If strSubject = "" Then
        FoundErr = True
        ErrMsg = ErrMsg & "<br><li>科目不能为空！！！</li>"
        Exit Sub
    Else
        strSubject = ReplaceBadChar(strSubject)
    End If
    total = 0
    Set rsScore = Server.CreateObject("adodb.recordset")
    sqlScore = "select * from TargetScore Where StudentNum='" & StudentNum & "'"
    rsScore.Open sqlScore, Conn_Sdms, 1, 3
    ArrSubject = Split(strSubject, "|")
    'response.write"strSubject="&strSubject
    'response.end
    For i = 0 To UBound(ArrSubject)
        rsScoreTemp = CStr(Request.Form(ArrSubject(i)))
        If rsScoreTemp = "" Then
            rsScore(ArrSubject(i)) = "0"
        Else
            rsScore(ArrSubject(i)) = rsScoreTemp
        End If

        ' 计算总分
        total = total + rsScore(ArrSubject(i))
    Next
    rsScore("总分") = total
    rsScore.Update
    rsScore.Close
    Set rsScore = Nothing

    If Session("strQureyString") <> "" Then
        Response.Redirect "Admin_ScoreManage.asp?Action=TargetManageMain&" & Session("strQureyString")
    End If

End Sub

Sub TargetDel()
    Dim strStudentNum, MM_editQuery
    strStudentNum = Trim(Request("StudentNum"))
    If strStudentNum <> "" Then
        MM_editQuery = "delete from TargetScore where StudentNum = '" & CStr(strStudentNum) & "'"
        Conn_Sdms.Execute MM_editQuery
        Response.Redirect "Admin_ScoreManage.asp?Action=TargetManageMain&" & Session("strQureyString")

    End If
End Sub

Sub ScorePrintStep1_1_1()
    Dim rsTestName__MMColParam, rsScore__MMColParam, intPageSize, rsTestName, rsScore, strSQL
    Dim strSheetName, strStudentNum, strName, strGrade, strClass, strSubjects
    strSheetName = Request("SheetName")
    strSubjects = strSheetName & "." & Replace(Request("chkbox"), ", ", ", " & strSheetName & ".")
    rsTestName__MMColParam = Request("SheetName")

    intPageSize = Request("PageSize")
    If intPageSize = "" Then intPageSize = 30

    Set rsTestName = Conn_Sdms.Execute("SELECT SheetName, TestName FROM TestName WHERE SheetName = '" + Replace(rsTestName__MMColParam, "'", "''") + "'")

    strStudentNum = Request("StudentNum")
    strName = Request("Name")
    strGrade = Request("Grade")
    strClass = Request("ClassSelect")

    Set rsScore = Server.CreateObject("ADODB.Recordset")

    strSQL = "Select " & strSheetName & ".StudentNum, StudentInfo.Name, " & strSubjects & " From " & strSheetName
    strSQL = strSQL & " LEFT JOIN StudentInfo ON " & strSheetName & ".StudentNum = StudentInfo.StudentNum"

    If (strStudentNum <> "") Then
        strSQL = strSQL & " Where " & strSheetName & ".StudentNum Like '%" & strStudentNum & "%'"
    ElseIf (strName <> "") Then
        strSQL = strSQL & " Where StudentInfo.Name Like '%" & strName & "%'"
    Else
        If strClass = "All" Then
            strSQL = strSQL & " Where StudentInfo.GradeID=" & CStr(strGrade) & ""
        Else
            strSQL = strSQL & " Where StudentInfo.ClassID=" & CStr(strClass) & " And StudentInfo.GradeID=" & CStr(strGrade) & ""
        End If
    End If
    Dim OrderType, rsScore_numRows
    OrderType = Trim(Request("OrderType"))
    If OrderType = "" Then
        OrderType = 1
    Else
        OrderType = CLng(OrderType)
    End If
    Select Case OrderType
    Case 1
        strSQL = strSQL & " ORDER BY " & strSheetName & ".StudentNum ASC"
    Case 2
        strSQL = strSQL & " ORDER BY " & strSheetName & ".总分 DESC"
    Case 3
        strSQL = strSQL & " ORDER BY " & strSheetName & ".全级排名 ASC"
    Case 4
        strSQL = strSQL & " ORDER BY " & strSheetName & ".班级排名 ASC"
    End Select
    rsScore.Open strSQL, Conn_Sdms, 1, 3
    rsScore_numRows = 0

    Dim Repeat1__numRows
    Repeat1__numRows = -1
    Dim Repeat1__index
    Repeat1__index = 0
    rsScore_numRows = rsScore_numRows + Repeat1__numRows

    '  *** Recordset Stats, Move To Record, and Go To Record: declare stats variables

    Dim rsScore_total
    Dim rsScore_first
    Dim rsScore_last

    ' set the record count
    rsScore_total = rsScore.RecordCount

    ' set the number of rows displayed on this page
    If (rsScore_numRows < 0) Then
        rsScore_numRows = rsScore_total
    ElseIf (rsScore_numRows = 0) Then
        rsScore_numRows = 1
    End If

    ' set the first and last displayed record
    rsScore_first = 1
    rsScore_last = rsScore_first + rsScore_numRows - 1

    ' if we have the correct record count, check the other stats
    If (rsScore_total <> -1) Then
        If (rsScore_first > rsScore_total) Then
            rsScore_first = rsScore_total
        End If
        If (rsScore_last > rsScore_total) Then
            rsScore_last = rsScore_total
        End If
        If (rsScore_numRows > rsScore_total) Then
            rsScore_numRows = rsScore_total
        End If
    End If

    ' *** Recordset Stats: if we don't know the record count, manually count them

    If (rsScore_total = -1) Then

        ' count the total records by iterating through the recordset
        rsScore_total = 0
        While (Not rsScore.EOF)
            rsScore_total = rsScore_total + 1
            rsScore.MoveNext
        Wend

        ' reset the cursor to the beginning
        If (rsScore.CursorType > 0) Then
            rsScore.movefirst
        Else
            rsScore.Requery
        End If

        ' set the number of rows displayed on this page
        If (rsScore_numRows < 0 Or rsScore_numRows > rsScore_total) Then
            rsScore_numRows = rsScore_total
        End If

        ' set the first and last displayed record
        rsScore_first = 1
        rsScore_last = rsScore_first + rsScore_numRows - 1

        If (rsScore_first > rsScore_total) Then
            rsScore_first = rsScore_total
        End If
        If (rsScore_last > rsScore_total) Then
            rsScore_last = rsScore_total
        End If

    End If



    Response.Write "<HTML>" & vbCrLf
    Response.Write "<HEAD>" & vbCrLf
    Response.Write "<TITLE>学生成绩打印预览</TITLE>" & vbCrLf
    Response.Write "<META http-equiv=Content-Type content='text/html; charset=gb2312'>" & vbCrLf
    Response.Write "<META content='MSHTML 6.00.2600.0' Name=GENERATOR>" & vbCrLf
    Response.Write "<style type='text/css'>" & vbCrLf
    Response.Write "<!--" & vbCrLf
    Response.Write "TABLE {" & vbCrLf
    Response.Write "    font-size: 12px;" & vbCrLf
    Response.Write "    text-decoration: none;" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "-->" & vbCrLf
    Response.Write "</style>" & vbCrLf
    Response.Write "</HEAD>" & vbCrLf
    Response.Write "<BODY text=#000000 bgColor=#ffffff leftMargin=5 topMargin=5>" & vbCrLf
    Response.Write "<TABLE cellSpacing=0 cellPadding=0 border=0>" & vbCrLf
    Response.Write "  <TR> " & vbCrLf
    Response.Write "    <TD align='center' valign='top'>" & vbCrLf
    Dim strTitle
    If Request("StudentNum") <> "" Then
        strTitle = "学号中含有“" & strStudentNum & "”"
    ElseIf strName <> "" Then
        strTitle = "姓名中含有“" & strName & "”"
    Else
        If strClass <> "" Then
            Dim GradeName, strSearch, SearchResult
            If Trim(strClass) = "All" Then
                strClass = " 全级"
                Set GradeName = Conn_Sdms.Execute("Select GradeName From Grade Where GradeID=" & strGrade & "")
                strSearch = GradeName(0) & " " & strClass
                Set GradeName = Nothing
            Else
                Set SearchResult = Conn_Sdms.Execute("Select G.GradeName,C.ClassName From Class C Left join Grade G On C.GradeID= G.GradeID Where C.ClassID=" & CLng(strClass) & "")
                strSearch = SearchResult(0) & " " & SearchResult(1)
                Set SearchResult = Nothing
            End If

        End If
        Response.Write strSearch
    End If


    Dim ArrSubject, strSubject, SubjectCount, ScoreCount, TargetCount, strTemp, i
    Dim ArrPass(), ArrExcel(), ArrAttain(), ArrBeyond()
    strTemp = Request("chkbox")
    SubjectCount = 0
    ArrSubject = Split(strTemp, ",")
    ReDim ArrPass(UBound(ArrSubject) + 1)
    ReDim ArrExcel(UBound(ArrSubject) + 1)
    ReDim ArrAttain(UBound(ArrSubject) + 1)
    ReDim ArrBeyond(UBound(ArrSubject) + 1)
    For i = LBound(ArrSubject) To UBound(ArrSubject)
        ArrPass(i) = 0
        ArrExcel(i) = 0
        ArrAttain(i) = 0
        ArrBeyond(i) = 0
    Next
            
    If Not rsScore.EOF Or Not rsScore.BOF Then
        rsScore.movefirst
        While Not rsScore.EOF
            Response.Write "<font size='6'><b>" & strTitle & rsTestName.Fields.Item("TestName").value & "成绩表</b></font><br>"
            Repeat1__numRows = intPageSize

            Response.Write "      <table cellspacing=0 border=1 cellpadding='0' bordercolor='#666666'>" & vbCrLf
            Response.Write "        <tr align='center' valign='middle'> " & vbCrLf
            Response.Write "          <td width='60' rowspan='2'>" & vbCrLf
            Response.Write "          <font color='#000000'>" & vbCrLf
            Response.Write "          <strong>学 号</strong>" & vbCrLf
            Response.Write "          </font>" & vbCrLf
            Response.Write "          </td>" & vbCrLf
            Response.Write "          <td width='60' rowspan='2'>" & vbCrLf
            Response.Write "          <font color='#000000'>" & vbCrLf
            Response.Write "          <strong>姓 名</strong>" & vbCrLf
            Response.Write "          </font>" & vbCrLf
            Response.Write "          </td>" & vbCrLf
            Response.Write "" & vbCrLf

            For i = LBound(ArrSubject) To UBound(ArrSubject)
                strSubject = Trim(CStr(ArrSubject(i)))
                Response.Write "<td height='20' colspan='2'><font color='#000000'><b>" & strSubject & "</b></font></td>"
                If strSubject <> "总分" And strSubject <> "平均分" And strSubject <> "全级排名" And strSubject <> "班级排名" Then
                    SubjectCount = SubjectCount + 1
                End If
            Next
            For i = UBound(ArrSubject) + 1 To 6
                Response.Write "<td height='20' colspan='2'>&nbsp;</td>"
            Next

            Response.Write "        </tr>" & vbCrLf
            Response.Write "        <tr align='center' valign='middle'> " & vbCrLf

            For i = LBound(ArrSubject) To UBound(ArrSubject)
                strSubject = Trim(CStr(ArrSubject(i)))
                If strSubject <> "全级排名" And strSubject <> "班级排名" Then
                    Response.Write "<td height='20' width='30'><font color='#000000'>成绩</font></td><td height='20' width='30'><font color='#000000'>目标</font></td>"
                Else
                    Response.Write "<td height='20' width='30'><font color='#000000'>名次</font></td><td height='20' width='30'><font color='#000000'>目标</font></td>"
                End If
            Next
            For i = UBound(ArrSubject) + 1 To 6
                Response.Write "<td height='20' width='30'>&nbsp;</td><td height='20' width='30'>&nbsp;</td>"
            Next

            Response.Write "        </tr>" & vbCrLf
            Dim rsTarget__MMColParam, rsTarget
            While ((Repeat1__numRows <> 0) And (Not rsScore.EOF))
                ScoreCount = 0
                TargetCount = 0
                strName = CStr(rsScore.Fields.Item("Name").value)
                If strName = "" Then strName = "&nbsp;"
                rsTarget__MMColParam = CStr(rsScore.Fields.Item("StudentNum").value)
                Set rsTarget = Server.CreateObject("ADODB.Recordset")
                rsTarget.Open "SELECT * FROM TargetScore WHERE StudentNum = '" + Replace(rsTarget__MMColParam, "'", "''") + "'", Conn_Sdms, 1, 3


                Response.Write "        <tr align='center' valign='middle'> " & vbCrLf
                Response.Write "          <td height='28' nowrap>" & vbCrLf
                Response.Write "          <font color='#000000'>" & vbCrLf
                Response.Write "" & vbCrLf

                Response.Write rsScore.Fields.Item("StudentNum").value
                Response.Write "          </font>" & vbCrLf
                Response.Write "          </td>" & vbCrLf
                Response.Write "          <td height='20' nowrap>" & vbCrLf
                Response.Write "          <font color='#000000'>" & vbCrLf
                Response.Write strName
                Response.Write "          </font>" & vbCrLf
                Response.Write "          </td>" & vbCrLf

                Dim strScore, strTarget
                For i = LBound(ArrSubject) To UBound(ArrSubject)
                    strSubject = Trim(CStr(ArrSubject(i)))
                    If strSubject = "总分" Then
                        strScore = ScoreCount
                        strTarget = TargetCount
                        If strScore < 60 * SubjectCount Then
                            If strScore >= strTarget Then      '达标
                                ArrAttain(i) = ArrAttain(i) + 1
                                strTarget = "<font color='#999999'>" & strTarget & "</font>"
                            Else        '不达标
                                strTarget = "<font color='#ff0000'>" & strTarget & "</font>"
                            End If
                            strScore = "<font color='#ff0000'>" & strScore & "</font>"
                        ElseIf strScore >= 60 * SubjectCount And strScore < 80 * SubjectCount Then
                            ArrPass(i) = ArrPass(i) + 1
                            If strScore >= strTarget Then
                                If strTarget < 60 * SubjectCount Then '跳格
                                    ArrBeyond(i) = ArrBeyond(i) + 1
                                    strTarget = "<font color='#009900'>" & strTarget & "</font>"
                                Else         '达标
                                    ArrAttain(i) = ArrAttain(i) + 1
                                    strTarget = "<font color='#999999'>" & strTarget & "</font>"
                                End If
                            Else         '不达标
                                strTarget = "<font color='#ff0000'>" & strTarget & "</font>"
                            End If
                            strScore = "<font color='#0000ff'>" & strScore & "</font>"
                        ElseIf strScore >= 80 * SubjectCount Then
                            ArrPass(i) = ArrPass(i) + 1
                            ArrExcel(i) = ArrExcel(i) + 1
                            If strScore >= strTarget Then
                                If strTarget < 80 Then '跳格
                                    ArrBeyond(i) = ArrBeyond(i) + 1
                                    strTarget = "<font color='#009900'>" & strTarget & "</font>"
                                Else    '达标
                                    ArrAttain(i) = ArrAttain(i) + 1
                                    strTarget = "<font color='#999999'>" & strTarget & "</font>"
                                End If
                            Else     '不达标
                                strTarget = "<font color='#ff0000'>" & strTarget & "</font>"
                            End If
                            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)
                            strTarget = Round(TargetCount / SubjectCount, 1)
                        Else
                            strScore = rsScore.Fields.Item(strSubject).value
                            If IsNull(strScore) Then strScore = 0
                            If rsTarget.BOF Or rsTarget.EOF Then
                                strTarget = 0
                            Else
                                strTarget = rsTarget.Fields.Item(strSubject).value
                                If IsNull(strTarget) Then strTarget = 0
                            End If
                            ScoreCount = ScoreCount + strScore
                            TargetCount = TargetCount + strTarget
                        End If
                        If strScore < 60 Then
                            If strScore >= strTarget Then      '达标
                                ArrAttain(i) = ArrAttain(i) + 1
                                strTarget = "<font color='#999999'>" & strTarget & "</font>"
                            Else        '不达标
                                strTarget = "<font color='#ff0000'>" & strTarget & "</font>"
                            End If
                            strScore = "<font color='#ff0000'>" & strScore & "</font>"
                        ElseIf strScore >= 60 And strScore < 80 Then
                            ArrPass(i) = ArrPass(i) + 1
                            If strScore >= strTarget Then
                                If strTarget < 60 Then '跳格
                                    ArrBeyond(i) = ArrBeyond(i) + 1
                                    strTarget = "<font color='#009900'>" & strTarget & "</font>"
                                Else         '达标
                                    ArrAttain(i) = ArrAttain(i) + 1
                                    strTarget = "<font color='#999999'>" & strTarget & "</font>"
                                End If
                            Else         '不达标
                                strTarget = "<font color='#ff0000'>" & strTarget & "</font>"
                            End If
                            strScore = "<font color='#0000ff'>" & strScore & "</font>"
                        ElseIf strScore >= 80 Then
                            ArrPass(i) = ArrPass(i) + 1
                            ArrExcel(i) = ArrExcel(i) + 1
                            If strScore >= strTarget Then
                                If strTarget < 80 Then '跳格
                                    ArrBeyond(i) = ArrBeyond(i) + 1
                                    strTarget = "<font color='#009900'>" & strTarget & "</font>"
                                Else    '达标
                                    ArrAttain(i) = ArrAttain(i) + 1
                                    strTarget = "<font color='#999999'>" & strTarget & "</font>"
                                End If
                            Else     '不达标
                                strTarget = "<font color='#ff0000'>" & strTarget & "</font>"
                            End If
                            strScore = "<font color='#009900'>" & strScore & "</font>"
                        End If
                    End If
                    Response.Write "<td height='20'>" & strScore & "</td>"
                    Response.Write "<td height='20'>" & strTarget & "</td>"
                Next
                Response.Write "</tr>"

                rsTarget.Close

                Repeat1__index = Repeat1__index + 1
                Repeat1__numRows = Repeat1__numRows - 1
                rsScore.MoveNext
            Wend
            If rsScore.EOF Then

                Response.Write "        <tr align='center' valign='middle'> " & vbCrLf
                Response.Write "          <td height='28' colspan='2' align='right' hight='20'>" & vbCrLf
                Response.Write "          <font color='#000000'>合格人数/达标人数：</font>" & vbCrLf
                Response.Write "          </td>" & vbCrLf

                For i = LBound(ArrSubject) To UBound(ArrSubject)
                    strSubject = Trim(CStr(ArrSubject(i)))
                    If strSubject = "全级排名" Or strSubject = "班级排名" Then
                        Response.Write "<td height='20'>&nbsp;</td><td height='20'>&nbsp;</td>"
                    Else
                        Response.Write "<td height='20'>" & ArrPass(i) & "</td><td height='20'>" & ArrAttain(i) & "</td>"
                    End If
                Next

                Response.Write "        </tr>" & vbCrLf
                Response.Write "        <tr align='center' valign='middle'> " & vbCrLf
                Response.Write "          <td height='28' colspan='2' align='right' hight='20'>" & vbCrLf
                Response.Write "          <font color='#000000'>合格率/达标率：</font>" & vbCrLf
                Response.Write "          </td>" & vbCrLf

                For i = LBound(ArrSubject) To UBound(ArrSubject)
                    strSubject = Trim(CStr(ArrSubject(i)))
                    If strSubject = "全级排名" Or strSubject = "班级排名" Then
                        Response.Write "<td height='20'>&nbsp;</td><td height='20'>&nbsp;</td>"
                    Else
                        Response.Write "<td height='20'>" & Round(ArrPass(i) / (rsScore_total) * 100, 1) & "%</td><td height='20'>" & Round(ArrAttain(i) / (rsScore_total) * 100, 1) & "%</td>"
                    End If
                Next

                Response.Write "        </tr>" & vbCrLf
                Response.Write "        <tr align='center' valign='middle'> " & vbCrLf
                Response.Write "          <td height='28' colspan='2' align='right' hight='20'>" & vbCrLf
                Response.Write "          <font color='#000000'>优秀人数/跳格人数：</font>" & vbCrLf
                Response.Write "          </td>" & vbCrLf
                Response.Write "" & vbCrLf

                For i = LBound(ArrSubject) To UBound(ArrSubject)
                    strSubject = Trim(CStr(ArrSubject(i)))
                    If strSubject = "全级排名" Or strSubject = "班级排名" Then
                        Response.Write "<td height='20'>&nbsp;</td><td height='20'>&nbsp;</td>"
                    Else
                        Response.Write "<td height='20'>" & ArrExcel(i) & "</td><td height='20'>" & ArrBeyond(i) & "</td>"
                    End If
                Next

                Response.Write "        </tr>" & vbCrLf
                Response.Write "        <tr align='center' valign='middle'> " & vbCrLf
                Response.Write "          <td height='28' colspan='2' align='right' hight='20'>" & vbCrLf
                Response.Write "          <font color='#000000'>优秀率/跳格率：</font>" & vbCrLf
                Response.Write "          </td>" & vbCrLf
                Response.Write "" & vbCrLf

                For i = LBound(ArrSubject) To UBound(ArrSubject)
                    strSubject = Trim(CStr(ArrSubject(i)))
                    If strSubject = "全级排名" Or strSubject = "班级排名" Then
                        Response.Write "<td height='20'>&nbsp;</td><td height='20'>&nbsp;</td>"
                    Else
                        Response.Write "<td height='20'>" & Round(ArrExcel(i) / (rsScore_total) * 100, 1) & "%</td><td height='20'>" & Round(ArrBeyond(i) / (rsScore_total) * 100, 1) & "%</td>"
                    End If
                Next

                Response.Write "        </tr>" & vbCrLf
                Response.Write "        <tr align='center' valign='middle'> " & vbCrLf
                Response.Write "          <td height='28' colspan='2' align='right' hight='20'>" & vbCrLf
                Response.Write "          <font color='#000000'>两率和：</font>" & vbCrLf
                Response.Write "          </td>" & vbCrLf

                For i = LBound(ArrSubject) To UBound(ArrSubject)
                    strSubject = Trim(CStr(ArrSubject(i)))
                    If strSubject = "全级排名" Or strSubject = "班级排名" Then
                        Response.Write "<td height='20'>&nbsp;</td><td height='20'>&nbsp;</td>"
                    Else
                        Response.Write "<td height='20'>" & Round((ArrPass(i) + ArrExcel(i)) / (rsScore_total) * 100, 1) & "%</td><td height='20'>" & Round((ArrAttain(i) + ArrBeyond(i)) / (rsScore_total) * 100, 1) & "%</td>"
                    End If
                Next

                Response.Write "          </tr>" & vbCrLf

            End If
            Response.Write "      </table>" & vbCrLf
            Response.Write "      <br>" & vbCrLf

        Wend
    Else
        Response.Write "<br><br><br>找不到符合条件的记录！<br><br><br>"
    End If

    Response.Write "    </TD>" & vbCrLf
    Response.Write "  </TR>" & vbCrLf
    Response.Write "</TABLE>" & vbCrLf

    rsTestName.Close
    rsScore.Close
End Sub

Sub ScorePrintStep1_1_2()
    Dim rsTestName__MMColParam, rsScore__MMColParam, intPageSize, rsTestName, rsScore, strSQL
    Dim strSheetName, strStudentNum, strName, strGrade, strClass, strSubjects
    strSheetName = Request("SheetName")
    strSubjects = strSheetName & "." & Replace(Request("chkbox"), ", ", ", " & strSheetName & ".")
    rsTestName__MMColParam = Request("SheetName")
    Session("txtSheetName") = Request("SheetName")

    intPageSize = Request("PageSize")
    If intPageSize = "" Then intPageSize = 30

    Set rsTestName = Server.CreateObject("ADODB.Recordset")
    rsTestName.Open "SELECT SheetName, TestName FROM TestName WHERE SheetName = '" + Replace(rsTestName__MMColParam, "'", "''") + "'", Conn_Sdms, 1, 3


    strStudentNum = Trim(Request("StudentNum"))
    strName = Trim(Request("Name"))
    strGrade = Trim(Request("Grade"))
    strClass = Trim(Request("ClassSelect"))

    Set rsScore = Server.CreateObject("ADODB.Recordset")

    strSQL = "Select " & strSheetName & ".StudentNum, StudentInfo.Name, " & strSubjects & " From " & strSheetName
    strSQL = strSQL & " LEFT JOIN StudentInfo ON " & strSheetName & ".StudentNum = StudentInfo.StudentNum"

    If (strStudentNum <> "") Then
        strSQL = strSQL & " Where " & strSheetName & ".StudentNum Like '%" & strStudentNum & "%'"
    ElseIf (strName <> "") Then
        strSQL = strSQL & " Where StudentInfo.Name Like '%" & strName & "%'"
    Else
        If strClass = "All" Then
            strSQL = strSQL & " Where StudentInfo.GradeID=" & CLng(strGrade) & ""
        Else
            strSQL = strSQL & " Where StudentInfo.ClassID=" & CLng(strClass) & " And StudentInfo.GradeID=" & CLng(strGrade) & ""
        End If
    End If
    Dim OrderType, rsScore_numRows
    OrderType = Trim(Request("OrderType"))
    If OrderType = "" Then
        OrderType = 1
    Else
        OrderType = CLng(OrderType)
    End If
    Select Case OrderType
    Case 1
        strSQL = strSQL & " ORDER BY " & strSheetName & ".StudentNum ASC"
    Case 2
        strSQL = strSQL & " ORDER BY " & strSheetName & ".总分 DESC"
    Case 3
        strSQL = strSQL & " ORDER BY " & strSheetName & ".全级排名 ASC"
    Case 4
        strSQL = strSQL & " ORDER BY " & strSheetName & ".班级排名 ASC"
    End Select
    rsScore.Open strSQL, Conn_Sdms, 1, 3
    rsScore_numRows = 0

    Dim Repeat1__numRows
    Repeat1__numRows = -1
    Dim Repeat1__index
    Repeat1__index = 0
    rsScore_numRows = rsScore_numRows + Repeat1__numRows

    '  *** Recordset Stats, Move To Record, and Go To Record: declare stats variables

    Dim rsScore_total
    Dim rsScore_first
    Dim rsScore_last

    ' set the record count
    rsScore_total = rsScore.RecordCount

    ' set the number of rows displayed on this page
    If (rsScore_numRows < 0) Then
        rsScore_numRows = rsScore_total
    ElseIf (rsScore_numRows = 0) Then
        rsScore_numRows = 1
    End If

    ' set the first and last displayed record
    rsScore_first = 1
    rsScore_last = rsScore_first + rsScore_numRows - 1

    ' if we have the correct record count, check the other stats
    If (rsScore_total <> -1) Then
        If (rsScore_first > rsScore_total) Then
            rsScore_first = rsScore_total
        End If
        If (rsScore_last > rsScore_total) Then
            rsScore_last = rsScore_total
        End If
        If (rsScore_numRows > rsScore_total) Then
            rsScore_numRows = rsScore_total
        End If
    End If

    ' *** Recordset Stats: if we don't know the record count, manually count them

    If (rsScore_total = -1) Then

        ' count the total records by iterating through the recordset
        rsScore_total = 0
        While (Not rsScore.EOF)
            rsScore_total = rsScore_total + 1
            rsScore.MoveNext
        Wend

        ' reset the cursor to the beginning
        If (rsScore.CursorType > 0) Then
            rsScore.movefirst
        Else
            rsScore.Requery
        End If

        ' set the number of rows displayed on this page
        If (rsScore_numRows < 0 Or rsScore_numRows > rsScore_total) Then
            rsScore_numRows = rsScore_total
        End If

        ' set the first and last displayed record
        rsScore_first = 1
        rsScore_last = rsScore_first + rsScore_numRows - 1

        If (rsScore_first > rsScore_total) Then
            rsScore_first = rsScore_total
        End If
        If (rsScore_last > rsScore_total) Then
            rsScore_last = rsScore_total
        End If

    End If


    Response.Write "<HTML>" & vbCrLf
    Response.Write "<HEAD>" & vbCrLf
    Response.Write "<TITLE>学生成绩打印预览</TITLE>" & vbCrLf
    Response.Write "<META http-equiv=Content-Type content='text/html; charset=gb2312'>" & vbCrLf
    Response.Write "<META content='MSHTML 6.00.2600.0' Name=GENERATOR>" & vbCrLf
    Response.Write "<style type='text/css'>" & vbCrLf
    Response.Write "<!--" & vbCrLf
    Response.Write "TABLE {" & vbCrLf
    Response.Write "    font-size: 12px;" & vbCrLf
    Response.Write "    text-decoration: none;" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "-->" & vbCrLf
    Response.Write "</style>" & vbCrLf
    Response.Write "</HEAD>" & vbCrLf
    Response.Write "<BODY text=#000000 bgColor=#ffffff leftMargin=0 topMargin=0>" & vbCrLf
    Response.Write "<TABLE cellSpacing=0 cellPadding=0 border=0>" & vbCrLf
    Response.Write "  <TR> " & vbCrLf
    Response.Write "    <TD align='center' valign='top'>" & vbCrLf
    Dim strTitle, strTemp, i
    If Request("StudentNum") <> "" Then
        strTitle = "学号中含有“" & strStudentNum & "”"
    ElseIf strName <> "" Then
        strTitle = "姓名中含有“" & strName & "”"
    Else
        If strClass <> "" Then
            Dim GradeName, strSearch, SearchResult
            If Trim(strClass) = "All" Then
                strClass = " 全级"
                Set GradeName = Conn_Sdms.Execute("Select GradeName From Grade Where GradeID=" & strGrade & "")
                strSearch = GradeName(0) & " " & strClass
                Set GradeName = Nothing
            Else
                Set SearchResult = Conn_Sdms.Execute("Select G.GradeName,C.ClassName From Class C Left join Grade G On C.GradeID= G.GradeID Where C.ClassID=" & CLng(strClass) & "")
                strSearch = SearchResult(0) & " " & SearchResult(1)
                Set SearchResult = Nothing
            End If

         End If
         strTitle = strSearch
    End If
            
    strTemp = Request("chkbox")
    Dim ArrSubject, strSubject
    Dim ArrPass(), ArrExcel(), ArrAttain(), ArrBeyond()
    ArrSubject = Split(strTemp, ",")
    ReDim ArrPass(UBound(ArrSubject) + 1)
    ReDim ArrExcel(UBound(ArrSubject) + 1)
    ReDim ArrAttain(UBound(ArrSubject) + 1)
    ReDim ArrBeyond(UBound(ArrSubject) + 1)
    For i = LBound(ArrSubject) To UBound(ArrSubject)
        ArrPass(i) = 0
        ArrExcel(i) = 0
        ArrAttain(i) = 0
        ArrBeyond(i) = 0
    Next

    If Not rsScore.EOF Or Not rsScore.BOF Then
        rsScore.movefirst
        While Not rsScore.EOF
            Response.Write "<font size='5'><b>" & strTitle & rsTestName.Fields.Item("TestName").value & "成绩表</b></font><br><br>"
            Repeat1__numRows = intPageSize

            Response.Write "        <table border=1 cellpadding='2' cellspacing=0 bordercolor='#000000'>" & vbCrLf
            Response.Write "        <tr valign='middle'> " & vbCrLf
            Response.Write "          <td width='50' align='center'>" & vbCrLf
            Response.Write "          <font color='#000000'><strong>学 号</strong>" & vbCrLf
            Response.Write "          </font></td>" & vbCrLf
            Response.Write "          <td width='50' align='center'>" & vbCrLf
            Response.Write "          <font color='#000000'><strong>姓 名</strong>" & vbCrLf
            Response.Write "          </font></td>" & vbCrLf
            Dim SubjectCount
            For i = LBound(ArrSubject) To UBound(ArrSubject)
                strSubject = Trim(CStr(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
            For i = UBound(ArrSubject) + 1 To 6
                Response.Write "<td width='60' height='20' align='center'>&nbsp;</td>"
            Next

            Response.Write "        </tr>" & vbCrLf
            Dim ScoreCount, strScore
            While ((Repeat1__numRows <> 0) And (Not rsScore.EOF))
                ScoreCount = 0
                strName = Trim(rsScore.Fields.Item("Name").value)
                If strName = "" Then strName = "&nbsp;"
                Response.Write "        <tr valign='middle'> " & vbCrLf
                Response.Write "          <td height='28' align='center' nowrap>" & vbCrLf
                Response.Write "          <font color='#000000'>" & vbCrLf
                Response.Write rsScore.Fields.Item("StudentNum").value
                Response.Write "          </font></td>" & vbCrLf
                Response.Write "          <td height='20' align='center' nowrap>" & vbCrLf
                Response.Write "          <font color='#000000'>" & vbCrLf
                Response.Write strName
                Response.Write "          </font></td>" & vbCrLf
                For i = LBound(ArrSubject) To UBound(ArrSubject)
                    strSubject = Trim(CStr(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
                            ArrPass(i) = ArrPass(i) + 1
                            strScore = "<font color='#0000ff'>" & strScore & "</font>"
                        ElseIf strScore >= 80 * SubjectCount Then
                            ArrPass(i) = ArrPass(i) + 1
                            ArrExcel(i) = ArrExcel(i) + 1
                            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
                            ArrPass(i) = ArrPass(i) + 1
                            strScore = "<font color='#0000ff'>" & strScore & "</font>"
                        ElseIf strScore >= 80 Then
                            ArrPass(i) = ArrPass(i) + 1
                            ArrExcel(i) = ArrExcel(i) + 1
                            strScore = "<font color='#009900'>" & strScore & "</font>"
                        End If
                    End If
                    Response.Write "<td height='20' align='center'>" & strScore & "</td>"
                Next
                For i = UBound(ArrSubject) + 1 To 6
                    Response.Write "<td width='60' height='20' align='center'>&nbsp;</td>"
                Next

                Response.Write "        </tr>"

                Repeat1__index = Repeat1__index + 1
                Repeat1__numRows = Repeat1__numRows - 1
                rsScore.MoveNext
            Wend
            Response.Write " </table><br>"

        Wend

        Response.Write "    <table border=1 cellpadding='2' cellspacing=0 bordercolor='#000000'>" & vbCrLf
        Response.Write "         <tr valign='middle'> " & vbCrLf
        Response.Write "          <td width='50' align='center'>" & vbCrLf
        Response.Write "          <font color='#000000'>" & vbCrLf
        Response.Write "          <strong>统 计</strong>" & vbCrLf
        Response.Write "          </font></td>" & vbCrLf
        Response.Write "          <td width='50' align='center'>" & vbCrLf
        Response.Write "          <font color='#000000'>" & vbCrLf
        Response.Write "          <strong>分 析</strong>" & vbCrLf
        Response.Write "          </font></td>" & vbCrLf
        For i = LBound(ArrSubject) To UBound(ArrSubject)
            strSubject = Trim(CStr(ArrSubject(i)))
            If strSubject = "全级排名" Or strSubject = "班级排名" Then
            Else
                Response.Write "<td height='20' align='center'><font color='#000000'><b>" & strSubject & "</b></font></td>"
            End If
        Next

        Response.Write "        </tr>" & vbCrLf
        Response.Write "        <tr valign='middle'> " & vbCrLf
        Response.Write "          <td width='100' height='28' colspan='2' align='center'>" & vbCrLf
        Response.Write "          <font color='#000000'>合格人数：</font>" & vbCrLf
        Response.Write "          </td>" & vbCrLf

        For i = LBound(ArrSubject) To UBound(ArrSubject)
            strSubject = Trim(CStr(ArrSubject(i)))
            If strSubject = "全级排名" Or strSubject = "班级排名" Then
                'response.write "<td height='20' align='center'>&nbsp;</td>"
            Else
                Response.Write "<td height='20' align='center'>" & ArrPass(i) & "</td>"
            End If
        Next
        Response.Write "        </tr>" & vbCrLf
        Response.Write "        <tr valign='middle'> " & vbCrLf
        Response.Write "          <td width='100' height='28' colspan='2' align='center'>" & vbCrLf
        Response.Write "          <font color='#000000'>合格率：</font>" & vbCrLf
        Response.Write "          </td>" & vbCrLf
        For i = LBound(ArrSubject) To UBound(ArrSubject)
            strSubject = Trim(CStr(ArrSubject(i)))
            If strSubject = "全级排名" Or strSubject = "班级排名" Then
                'response.write "<td height='20' align='center'>&nbsp;</td>"
            Else
                Response.Write "<td height='20' align='center'>" & Round(ArrPass(i) / (rsScore_total) * 100, 1) & "%</td>"
            End If
        Next
        Response.Write "" & vbCrLf

        Response.Write "        </tr>" & vbCrLf
        Response.Write "        <tr valign='middle'> " & vbCrLf
        Response.Write "          <td width='100' height='28' colspan='2' align='center'>" & vbCrLf
        Response.Write "          <font color='#000000'>优秀人数：</font" & vbCrLf
        Response.Write "          ></td>" & vbCrLf

        For i = LBound(ArrSubject) To UBound(ArrSubject)
            strSubject = Trim(CStr(ArrSubject(i)))
            If strSubject = "全级排名" Or strSubject = "班级排名" Then
                'response.write "<td height='20' align='center'>&nbsp;</td>"
            Else
                Response.Write "<td height='20' align='center'>" & ArrExcel(i) & "</td>"
            End If
        Next

        Response.Write "        </tr>" & vbCrLf
        Response.Write "        <tr valign='middle'> " & vbCrLf
        Response.Write "          <td width='100' height='28' colspan='2' align='center'>" & vbCrLf
        Response.Write "          <font color='#000000'>优秀率：</font>" & vbCrLf
        Response.Write "          </td>" & vbCrLf

        For i = LBound(ArrSubject) To UBound(ArrSubject)
            strSubject = Trim(CStr(ArrSubject(i)))
            If strSubject = "全级排名" Or strSubject = "班级排名" Then
                'response.write "<td height='20' align='center'>&nbsp;</td>"
            Else
                Response.Write "<td height='20' align='center'>" & Round(ArrExcel(i) / (rsScore_total) * 100, 1) & "%</td>"
            End If
        Next

        Response.Write "        </tr>" & vbCrLf
        Response.Write "        <tr valign='middle'> " & vbCrLf
        Response.Write "          <td height='28' colspan='2' width='100' align='center'>" & vbCrLf
        Response.Write "          <font color='#000000'>两率和：</font>" & vbCrLf
        Response.Write "          </td>" & vbCrLf
        Response.Write "" & vbCrLf
        For i = LBound(ArrSubject) To UBound(ArrSubject)
            strSubject = Trim(CStr(ArrSubject(i)))
            If strSubject = "全级排名" Or strSubject = "班级排名" Then
                'response.write "<td height='20' align='center'>&nbsp;</td>"
            Else
                Response.Write "<td height='20' align='center'>" & Round((ArrPass(i) + ArrExcel(i)) / (rsScore_total) * 100, 1) & "%</td>"
            End If
        Next
        Response.Write "        </tr>" & vbCrLf
        Response.Write "        </table>" & vbCrLf
        Response.Write "        <br>" & vbCrLf
    Else
        Response.Write "<br><br><br>找不到符合条件的记录！<br><br><br>"
    End If
    Response.Write "    </TD>" & vbCrLf
    Response.Write "  </TR>" & vbCrLf
    Response.Write "</TABLE>" & vbCrLf
    rsTestName.Close
    rsScore.Close
End Sub

Sub ScorePrintStep1_2_1()
    Dim strStudentNum, strName, strGrade, strClass, strSubject, intPageSize, Recordset1, Recordset1_numRows, Recordset1Sql
    strSubject = Trim(Request("Subject"))
    strStudentNum = Request("StudentNum")
    strName = Request("Name")
    strGrade = Request("Grade")
    strClass = Request("ClassSelect")

    intPageSize = Request("PageSize")
    If intPageSize = "" Then intPageSize = 30

    Dim Recordset1__MMColParam

    Set Recordset1 = Server.CreateObject("ADODB.Recordset")
    If (strStudentNum <> "") Then
        Recordset1__MMColParam = strStudentNum
        Recordset1Sql = "SELECT StudentNum,Name FROM StudentInfo WHERE StudentNum like '%" & Recordset1__MMColParam & "%'  ORDER BY StudentNum"
    ElseIf (strName <> "") Then
        Recordset1__MMColParam = strName
        Recordset1Sql = "SELECT StudentNum,Name FROM StudentInfo WHERE StudentNum like '%" & Recordset1__MMColParam & "%'  ORDER BY StudentNum"
    Else
        If strClass = "All" Then
            Recordset1Sql = "SELECT StudentNum,Name FROM StudentInfo WHERE GradeID=" & CLng(strGrade) & "  ORDER BY StudentNum"
        Else
            Recordset1Sql = "SELECT StudentNum,Name FROM StudentInfo WHERE ClassID=" & CLng(strClass) & " And GradeID=" & CLng(strGrade) & "  ORDER BY StudentNum"
        End If
    End If
    Recordset1.Open Recordset1Sql, Conn_Sdms, 1, 3
    Recordset1_numRows = 0

    Dim Repeat1__numRows
    Repeat1__numRows = -1
    Dim Repeat1__index
    Repeat1__index = 0
    Recordset1_numRows = Recordset1_numRows + Repeat1__numRows

    '  *** Recordset Stats, Move To Record, and Go To Record: declare stats variables

    Dim Recordset1_total
    Dim Recordset1_first
    Dim Recordset1_last

    ' set the record count
    Recordset1_total = Recordset1.RecordCount

    ' set the number of rows displayed on this page
    If (Recordset1_numRows < 0) Then
      Recordset1_numRows = Recordset1_total
    ElseIf (Recordset1_numRows = 0) Then
      Recordset1_numRows = 1
    End If

    ' set the first and last displayed record
    Recordset1_first = 1
    Recordset1_last = Recordset1_first + Recordset1_numRows - 1

    ' if we have the correct record count, check the other stats
    If (Recordset1_total <> -1) Then
      If (Recordset1_first > Recordset1_total) Then
        Recordset1_first = Recordset1_total
      End If
      If (Recordset1_last > Recordset1_total) Then
        Recordset1_last = Recordset1_total
      End If
      If (Recordset1_numRows > Recordset1_total) Then
        Recordset1_numRows = Recordset1_total
      End If
    End If

    ' *** Recordset Stats: if we don't know the record count, manually count them

    If (Recordset1_total = -1) Then

        ' count the total records by iterating through the recordset
        Recordset1_total = 0
        While (Not Recordset1.EOF)
            Recordset1_total = Recordset1_total + 1
            Recordset1.MoveNext
        Wend

        ' reset the cursor to the beginning
        If (Recordset1.CursorType > 0) Then
            Recordset1.movefirst
        Else
            Recordset1.Requery
        End If

        ' set the number of rows displayed on this page
        If (Recordset1_numRows < 0 Or Recordset1_numRows > Recordset1_total) Then
            Recordset1_numRows = Recordset1_total
        End If

        ' set the first and last displayed record
        Recordset1_first = 1
        Recordset1_last = Recordset1_first + Recordset1_numRows - 1

        If (Recordset1_first > Recordset1_total) Then
            Recordset1_first = Recordset1_total
        End If
        If (Recordset1_last > Recordset1_total) Then
            Recordset1_last = Recordset1_total
        End If

    End If



    Response.Write "<HTML>" & vbCrLf
    Response.Write "<HEAD>" & vbCrLf
    Response.Write "<TITLE>学生成绩查询</TITLE>" & vbCrLf
    Response.Write "<META http-equiv=Content-Type content='text/html; charset=gb2312'>" & vbCrLf
    Response.Write "<META content='MSHTML 6.00.2600.0' Name=GENERATOR>" & vbCrLf
    Response.Write "<style type='text/css'>" & vbCrLf
    Response.Write "<!--" & vbCrLf
    Response.Write "TABLE {" & vbCrLf
    Response.Write "    font-size: 12px;" & vbCrLf
    Response.Write "    text-decoration: none;" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "-->" & vbCrLf
    Response.Write "</style>" & vbCrLf
    Response.Write "</HEAD>" & vbCrLf
    Response.Write "<BODY text=#000000 bgColor=#ffffff leftMargin=5 topMargin=5>" & vbCrLf
    Response.Write "" & vbCrLf
    Response.Write "<TABLE cellSpacing=0 cellPadding=0 border=0　align='center'>" & vbCrLf
    Response.Write "  <TR> " & vbCrLf
    Response.Write "    <TD align='center' valign='top'>" & vbCrLf
    Response.Write "" & vbCrLf

    Dim strTitle, strTemp, i
    If Request("StudentNum") <> "" Then
        strTitle = "学号中含有“" & strStudentNum & "”"
    ElseIf strName <> "" Then
        strTitle = "姓名中含有“" & strName & "”"
    Else
        If strClass <> "" Then strClass = strClass & "班"
        strTitle = "初" & strGrade + 1 & "级" & strClass
    End If
    strTitle = strTitle & strSubject & "成绩表"
    Dim arrSheetName
    Dim strSheetName
    Dim rsSubjects()
    Dim ArrPass(), ArrExcel(), ArrAttain(), ArrBeyond()
    strTemp = Request("chkbox")
    arrSheetName = Split(strTemp, ",")
    ReDim ArrPass(UBound(arrSheetName) + 1)
    ReDim ArrExcel(UBound(arrSheetName) + 1)
    ReDim ArrAttain(UBound(arrSheetName) + 1)
    ReDim ArrBeyond(UBound(arrSheetName) + 1)

    ReDim rsSubjects(UBound(arrSheetName) + 1)

    For i = LBound(arrSheetName) To UBound(arrSheetName)
        ArrPass(i) = 0
        ArrExcel(i) = 0
        ArrAttain(i) = 0
        ArrBeyond(i) = 0
    Next

    If Not Recordset1.EOF Or Not Recordset1.BOF Then
        Recordset1.movefirst
        While Not Recordset1.EOF
            Response.Write "<font size='6'><b>" & strTitle & "</b></font><br>"
            Repeat1__numRows = intPageSize
            Response.Write "            <table border=1 cellpadding='2' cellspacing=0 bordercolor='#000000'>" & vbCrLf
            Response.Write "              <tr align='center' valign='middle'> " & vbCrLf
            Response.Write "                <td width='60' rowspan='2'>" & vbCrLf
            Response.Write "                <font color='#000000'>学 号</font>" & vbCrLf
            Response.Write "                </td>" & vbCrLf
            Response.Write "                <td width='50' rowspan='2'>" & vbCrLf
            Response.Write "                <font color='#000000'>姓 名</font>" & vbCrLf
            Response.Write "                </td>" & vbCrLf
            Response.Write "                <td width='50' rowspan='2'>" & vbCrLf
            Response.Write "                <font color='#000000'>目 标</font>" & vbCrLf
            Response.Write "                </td>" & vbCrLf
            Dim rsTestName, rsTestName__MMColParam, strTestName
            For i = LBound(arrSheetName) To UBound(arrSheetName)
                strSheetName = Trim(CStr(arrSheetName(i)))
                rsTestName__MMColParam = strSheetName
                Set rsTestName = Server.CreateObject("ADODB.Recordset")
                rsTestName.Open "SELECT SheetName, TestName FROM TestName WHERE SheetName = '" + Replace(rsTestName__MMColParam, "'", "''") + "'", Conn_Sdms, 1, 3
                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' colspan='2'><font color='#000000'>" & strTestName & "</font></td>"
            Next
            Response.Write "              </tr>" & vbCrLf
            Response.Write "              <tr align='center' valign='middle'> " & vbCrLf
            Response.Write "" & vbCrLf

            For i = LBound(arrSheetName) To UBound(arrSheetName)
                If strSubject <> "全级排名" And strSubject <> "班级排名" Then
                    Response.Write "<td height='20'><font color='#000000'>成绩</font></td><td height='20'><font color='#000000'>达标否</font></td>"
                Else
                    Response.Write "<td height='20'><font color='#000000'>名次</font></td><td height='20'><font color='#000000'>达标否/font></td>"
                End If
            Next
            Response.Write "              </tr>" & vbCrLf
            Dim rsTarget__MMColParam, rsTarget, Target, strScore, strTarget
            While ((Repeat1__numRows <> 0) And (Not Recordset1.EOF))

                For i = LBound(arrSheetName) To UBound(arrSheetName)
                    strSheetName = Trim(CStr(arrSheetName(i)))
                    Set rsSubjects(i) = Server.CreateObject("ADODB.Recordset")
                    
                    rsSubjects(i).Open "SELECT " & strSubject & " FROM " & strSheetName & " WHERE StudentNum = '" + Replace(CStr(Recordset1.Fields.Item("StudentNum")), "'", "''") + "'", Conn_Sdms, 1, 3
                Next

                rsTarget__MMColParam = CStr(Recordset1.Fields.Item("StudentNum").value)
                Set rsTarget = Server.CreateObject("ADODB.Recordset")
                rsTarget.Open "SELECT " & strSubject & " FROM TargetScore WHERE StudentNum = '" + Replace(rsTarget__MMColParam, "'", "''") + "'", Conn_Sdms, 1, 3


                If rsTarget.BOF Or rsTarget.EOF Then
                    Target = 0
                Else
                    Target = rsTarget.Fields.Item(strSubject).value
                    If IsNull(Target) Then Target = 0
                End If

                Response.Write "              <tr align='center' valign='middle'> " & vbCrLf
                Response.Write "                <td height='20' nowrap>" & vbCrLf
                Response.Write Recordset1.Fields.Item("StudentNum").value
                Response.Write "                </td>" & vbCrLf
                Response.Write "                <td height='20' nowrap>" & vbCrLf
                Response.Write Recordset1.Fields.Item("Name").value
                Response.Write "                </td>" & vbCrLf
                Response.Write "                <td height='20'>" & vbCrLf
                Response.Write Target
                Response.Write "                </td>" & vbCrLf

                Response.Write "" & vbCrLf
                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
                    If strScore < 60 Then
                        If strScore >= Target Then      '达标
                            ArrAttain(i) = ArrAttain(i) + 1
                            strTarget = "<font color='#999999'>◇</font>"
                        Else        '不达标
                            strTarget = "<font color='#ff0000'>※</font>"
                        End If
                        strScore = "<font color='#ff0000'>" & strScore & "</font>"
                    ElseIf strScore >= 60 And strScore < 80 Then
                        ArrPass(i) = ArrPass(i) + 1
                        If strScore >= Target Then
                            If Target < 60 Then '跳格
                                ArrBeyond(i) = ArrBeyond(i) + 1
                                strTarget = "<font color='#009900'>☆</font>"
                            Else         '达标
                                ArrAttain(i) = ArrAttain(i) + 1
                                strTarget = "<font color='#999999'>◇</font>"
                            End If
                        Else         '不达标
                            strTarget = "<font color='#ff0000'>※</font>"
                        End If
                        strScore = "<font color='#0000ff'>" & strScore & "</font>"
                    ElseIf strScore >= 80 Then
                        ArrPass(i) = ArrPass(i) + 1
                        ArrExcel(i) = ArrExcel(i) + 1
                        If strScore >= Target Then
                            If Target < 80 Then '跳格
                                ArrBeyond(i) = ArrBeyond(i) + 1
                                strTarget = "<font color='#009900'>☆</font>"
                            Else    '达标
                                ArrAttain(i) = ArrAttain(i) + 1
                                strTarget = "<font color='#999999'>◇</font>"
                            End If
                        Else     '不达标
                            strTarget = "<font color='#ff0000'>※</font>"
                        End If
                        strScore = "<font color='#009900'>" & strScore & "</font>"
                    End If
                    Response.Write "<td height='20'>" & strScore & "</td>"
                    Response.Write "<td height='20'>" & strTarget & "</td>"
                Next
                Response.Write "              </tr>" & vbCrLf
                Repeat1__index = Repeat1__index + 1
                Repeat1__numRows = Repeat1__numRows - 1
                Recordset1.MoveNext
            Wend
            If Recordset1.EOF Then

                Response.Write "              <tr align='center' valign='middle'> " & vbCrLf
                Response.Write "                <td colspan='3' hight='20' align='right'>合格人数/达标人数：</td>" & vbCrLf
                Response.Write "" & vbCrLf

                For i = LBound(arrSheetName) To UBound(arrSheetName)
                    Response.Write "<td height='20'>" & ArrPass(i) & "</td><td height='20'>" & ArrAttain(i) & "</td>"
                Next
                Response.Write "              </tr>" & vbCrLf
                Response.Write "              <tr align='center' valign='middle'> " & vbCrLf
                Response.Write "                <td colspan='3' hight='20' align='right'>合格率/达标率：</td>" & vbCrLf
                Response.Write "" & vbCrLf
                For i = LBound(arrSheetName) To UBound(arrSheetName)
                    Response.Write "<td height='20'>" & Round(ArrPass(i) / (Recordset1_total) * 100, 1) & "%</td><td height='20'>" & Round(ArrAttain(i) / (Recordset1_total) * 100, 1) & "%</td>"
                Next

                Response.Write "              </tr>" & vbCrLf
                Response.Write "              <tr align='center' valign='middle'> " & vbCrLf
                Response.Write "                <td colspan='3' hight='20' align='right'>优秀人数/跳格人数：</td>" & vbCrLf
                Response.Write "" & vbCrLf
                For i = LBound(arrSheetName) To UBound(arrSheetName)
                    Response.Write "<td height='20'>" & ArrExcel(i) & "</td><td height='20'>" & ArrBeyond(i) & "</td>"
                Next

                Response.Write "              </tr>" & vbCrLf
                Response.Write "              <tr align='center' valign='middle'> " & vbCrLf
                Response.Write "                <td colspan='3' hight='20' align='right'>优秀率/跳格率：</td>" & vbCrLf

                For i = LBound(arrSheetName) To UBound(arrSheetName)
                    Response.Write "<td height='20'>" & Round(ArrExcel(i) / (Recordset1_total) * 100, 1) & "%</td><td height='20'>" & Round(ArrBeyond(i) / (Recordset1_total) * 100, 1) & "%</td>"
                Next

                Response.Write "              </tr>" & vbCrLf
                Response.Write "              <tr align='center' valign='middle'> " & vbCrLf
                Response.Write "                <td colspan='3' hight='20' align='right'>两率和：</td>" & vbCrLf
                Response.Write "" & vbCrLf

                For i = LBound(arrSheetName) To UBound(arrSheetName)
                    Response.Write "<td height='20'>" & Round((ArrPass(i) + ArrExcel(i)) / (Recordset1_total) * 100, 1) & "%</td><td height='20'>" & Round((ArrAttain(i) + ArrBeyond(i)) / (Recordset1_total) * 100, 1) & "%</td>"
                Next

                Response.Write "              </tr>" & vbCrLf

            End If
            Response.Write "      </table><br>" & vbCrLf

        Wend
    Else
        Response.Write "<br><br><br>找不到符合条件的记录！<br><br><br>"
    End If

    Response.Write "    </TD>" & vbCrLf
    Response.Write "  </TR>" & vbCrLf
    Response.Write "</TABLE>" & vbCrLf
    Response.Write "" & vbCrLf

    Recordset1.Close
End Sub
%>
