<!--#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 = "TestManage"   '其他权限

Response.Write "<html><head><title>考 试 管 理</title>" & vbCrLf
Response.Write "<meta http-equiv='Content-Type' content='text/html; charset=gb2312'>" & 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("考 试 管 理", 10303)
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_TestManage.asp'>考试管理主界面</a>&nbsp;|&nbsp;<a href='Admin_TestManage.asp'>添加考试 </a>&nbsp;|&nbsp;<a href='Admin_TestManage.asp'>修改考试信息 </a>&nbsp;|&nbsp;<a href='Admin_TestManage.asp'>删除考试 </a>&nbsp;|&nbsp;<a href='Admin_TestManage.asp?Action=SubjectManage'>考试科目管理</a>" & vbCrLf
Response.Write "    </td>" & vbCrLf
Response.Write "  </tr>" & vbCrLf
Response.Write "</table>" & vbCrLf
Call OpenSdmsConn
Select Case Action
Case "LockTest"
    Call LockTest
Case "TestDel"
    Call TestDel
Case "TestModify"
    Call TestModify
Case "SubjectManage"
    Call SubjectManage
    
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()
    Dim rsSubject, i
    Dim MM_qsChar, MM_editTable, MM_editRedirectUrl, MM_fieldsStr, MM_columnsStr, MM_fields, MM_columns
    Dim MM_tableValues, MM_dbValues, MM_CreateTableQuery
    Dim FormVal, MM_typeArray, Delim, AltVal, EmptyVal
    Dim strSubject, strTemp
    
    
    
    Response.Write "<script language=""JavaScript"">" & vbCrLf
    Response.Write "    function checktest(){" & vbCrLf
    Response.Write "        var total=0;" & vbCrLf
    Response.Write "        var intmax=document.form1.chkbox.length;" & vbCrLf
    Response.Write "        var strSheetName=document.form1.SheetName.value;" & 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 "        if(document.form1.TestName.value=="""")" & vbCrLf
    Response.Write "          {" & vbCrLf
    Response.Write "           alert(""考试名称不能为空！"");" & vbCrLf
    Response.Write "           document.form1.TestName.focus();" & vbCrLf
    Response.Write "           return false;" & vbCrLf
    Response.Write "           }" & vbCrLf
    Response.Write "        if(document.form1.TestName.value==""2002学年上学期"")" & vbCrLf
    Response.Write "          {" & vbCrLf
    Response.Write "           alert(""请不要偷懒！请录入完整的考试名称后再点“添加考试”按钮。"");" & vbCrLf
    Response.Write "           document.form1.TestName.focus();" & vbCrLf
    Response.Write "           return false;" & vbCrLf
    Response.Write "           }" & vbCrLf
    Response.Write "" & vbCrLf
    Response.Write "        if(strSheetName=="""")" & vbCrLf
    Response.Write "          {" & vbCrLf
    Response.Write "           alert(""数据库对应表名不能为空！"");" & vbCrLf
    Response.Write "           document.form1.SheetName.focus();" & vbCrLf
    Response.Write "           return false;" & vbCrLf
    Response.Write "           }" & vbCrLf
    Response.Write "        if(strSheetName==""CQZX2002A"")" & vbCrLf
    Response.Write "          {" & vbCrLf
    Response.Write "           alert(""请不要偷懒！请录入完整的数据库表名后再点“添加考试”按钮。"");" & vbCrLf
    Response.Write "           document.form1.SheetName.focus();" & vbCrLf
    Response.Write "           return false;" & vbCrLf
    Response.Write "           }" & vbCrLf
    Response.Write "" & vbCrLf
    Response.Write "        if(isNaN(strSheetName.substr(0,1))==false)" & vbCrLf
    Response.Write "          {" & vbCrLf
    Response.Write "           alert(""数据库对应表名不能以数字开头！"");" & vbCrLf
    Response.Write "           document.form1.SheetName.focus();" & vbCrLf
    Response.Write "           return false;" & vbCrLf
    Response.Write "          }" & vbCrLf
    Response.Write "        }" & vbCrLf
    Response.Write "" & vbCrLf
    Response.Write "    function ConfirmDel(){" & 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 "</script>" & vbCrLf
    Dim MM_editAction, MM_flag, strSheetName, MM_dupKeyRedirect, MM_dupKeyUsernameValue
    Dim MM_rsKey, MM_dupKeySQL, MM_editQuery
    MM_editAction = CStr(Request("URL"))
    MM_editQuery = ""

    MM_flag = "MM_insert"
    If (ReplaceBadChar(Request(MM_flag)) <> "") Then
        strSheetName = Request("SheetName") & ""
        If InStr(strSheetName, "!") > 0 Or InStr(strSheetName, "@") > 0 Or InStr(strSheetName, "#") > 0 Or InStr(strSheetName, "$") > 0 Or InStr(strSheetName, "%") > 0 Or InStr(strSheetName, "^") > 0 Or InStr(strSheetName, "&") > 0 Or InStr(strSheetName, "*") > 0 Or InStr(strSheetName, "(") > 0 Or InStr(strSheetName, ")") > 0 Or InStr(strSheetName, "-") > 0 Or InStr(strSheetName, "=") > 0 Or InStr(strSheetName, "\") > 0 Or InStr(strSheetName, ",") > 0 Or InStr(strSheetName, ".") > 0 Or InStr(strSheetName, "/") > 0 Or InStr(strSheetName, "?") > 0 Or InStr(strSheetName, "<") > 0 Or InStr(strSheetName, ">") > 0 Or InStr(strSheetName, "[") > 0 Or InStr(strSheetName, "]") > 0 Or InStr(strSheetName, "{") > 0 Or InStr(strSheetName, "}") > 0 Or InStr(strSheetName, "|") > 0 Or InStr(strSheetName, "+") > 0 Or InStr(strSheetName, "~") > 0 Or ReplaceBadChar(strSheetName) = "" Then
            Response.Redirect "Admin_TestManage.asp?Err=Char"
        End If
        MM_dupKeyRedirect = "Admin_TestManage.asp?Action=TestModify"

        MM_dupKeyUsernameValue = ReplaceBadChar(Request.Form("SheetName"))
        MM_dupKeySQL = "SELECT SheetName FROM TestName WHERE SheetName='" & MM_dupKeyUsernameValue & "'"
        Set MM_rsKey = Server.CreateObject("ADODB.Recordset")
        MM_rsKey.Open MM_dupKeySQL, Conn_Sdms, 1, 3
        If Not MM_rsKey.EOF Or Not MM_rsKey.BOF Then
        ' the userName was found - can not add the requested userName
            MM_qsChar = "?"
            If (InStr(1, MM_dupKeyRedirect, "?") >= 1) Then MM_qsChar = "&"
            MM_dupKeyRedirect = MM_dupKeyRedirect & MM_qsChar & "SheetName=" & MM_dupKeyUsernameValue
            Response.Redirect (MM_dupKeyRedirect)
            End If
        MM_rsKey.Close
    End If


    If (ReplaceBadChar(Request("MM_insert")) <> "") Then
        MM_editTable = "TestName"
        MM_editRedirectUrl = "Admin_TestManage.asp"
        MM_fieldsStr = "TestName|value|SheetName|value"
        MM_columnsStr = "TestName|',none,''|SheetName|',none,''"

        MM_fields = Split(MM_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)))
        Next

        If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
            If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
                MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
            Else
                MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
            End If
        End If

        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 & ")"

        Conn_Sdms.Execute MM_editQuery
        ' 在DW代码的基础上用SQL语句实现向数据库中添加表

        strSubject = "(StudentNum TEXT (16) CONSTRAINT MyFieldConstraint PRIMARY KEY,总分 SINGLE,平均分 SINGLE,全级排名 LONG,班级排名 LONG,"
        strTemp = Request("chkbox")
        If ReplaceBadChar(strTemp) = "" Then
            Response.Write "输入有错误！没有操作被完成，请重新进入考试管理添加。"
            Response.End
        End If
        If InStr(strTemp, ",") > 0 Then
            strSubject = strSubject & Replace(strTemp, ",", " SINGLE,") & " SINGLE)"
        Else
            strSubject = strSubject & strTemp & " SINGLE)"
        End If
        strSheetName = MM_dupKeyUsernameValue
        MM_CreateTableQuery = "Create Table " & strSheetName & strSubject
        Conn_Sdms.Execute MM_CreateTableQuery

        If (MM_editRedirectUrl <> "") Then
            Response.Redirect (MM_editRedirectUrl)
        End If
    End If


    Dim Recordset1
    Set Recordset1 = Server.CreateObject("ADODB.Recordset")

    Recordset1.Open "SELECT * FROM TestName ORDER BY id DESC", Conn_Sdms, 1, 3
    Dim Recordset2

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

    Dim Repeat1__numRows
    Repeat1__numRows = -1
    Dim Repeat1__index
    Repeat1__index = 0

    Dim Repeat2__numRows
    Dim Repeat2__index

    Repeat2__numRows = -1
    Repeat2__index = 0

    If Request("Err") = "Char" Then
        Response.Write "<script language=""JavaScript"" type=""text/JavaScript"">" & vbCrLf
        Response.Write "alert(""考试名称中含有“!@#$%^&*()-+=,./?<>[]{}\|~“等非法字符，操作被取消！"");" & vbCrLf
        Response.Write "</script>" & vbCrLf
    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'> <b>考 试 管 理 (添加新考试)</b> " & vbCrLf
    Response.Write "    </td>" & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "  <form name='form1' onSubmit='return checktest()' method='POST' action='" & MM_editAction & "'>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td width='117' height='30' align='right'><strong>考试名称： </strong>" & vbCrLf
    Response.Write "      </td>" & vbCrLf
    Response.Write "      <td height='30'>" & vbCrLf
    Response.Write "        <input name='TestName' type='text' value='2002学年上学期' maxlength='18'>" & vbCrLf
    Response.Write "      </td>" & vbCrLf
    Response.Write "      <td>例如：2002学年上学期第五次统测 </td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td height='30' align='right'><strong>数据库对应的表名：</strong>" & vbCrLf
    Response.Write "      </td>" & vbCrLf
    Response.Write "      <td height='30'>" & vbCrLf
    Response.Write "        <input name='SheetName' type='text' value='CQZX2002A' maxlength='18'>" & vbCrLf
    Response.Write "      </td>" & vbCrLf
    Response.Write "      <td height='30'><font color='#0000FF'>※</font>" & vbCrLf
    Response.Write "      <font color='#FF0000'>表名不能以数字或符号开头，必须以字母开头。<br>" & vbCrLf
    Response.Write "            <font color='#0000FF'>※</font>表名中不能含有符号或“!@#$%^&amp;*()-+=|\,./?[]{}”等字符，为减少错误，请只用“字母+数字”的组合。</font><strong>" & vbCrLf
    Response.Write "            <br>" & vbCrLf
    Response.Write "            <br>" & vbCrLf
    Response.Write "        推荐命名规则：</strong><font color='#0000FF'>学校名+学年+学期+考试名</font>" & vbCrLf
    Response.Write "        <br>" & vbCrLf
    Response.Write "        例如：CQZX2002BTC5<br>" & vbCrLf
    Response.Write "&nbsp;&nbsp;&nbsp; &nbsp;其中，“CQZX”表示城区中学，“2002”表示2002学年，“B”表示下学期，TC5表示第五次统测</td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td align='right' valign='middle'><strong>考试科目：</strong>" & vbCrLf
    Response.Write "      </td>" & vbCrLf
    Response.Write "      <td colspan='2'>" & vbCrLf
    If Not Recordset2.EOF Or Not Recordset2.BOF Then
        Response.Write "<table border='0' cellspacing='0' cellpadding='3'><tr>"
        While ((Repeat2__numRows <> 0) And (Not Recordset2.EOF))
            Response.Write ("<td><input name='chkbox' type='checkbox' value='" & Recordset2.Fields.Item("SubjectName").value & "' checked>")
            Response.Write (Recordset2.Fields.Item("SubjectName").value)
            If Repeat2__numRows Mod 8 = 0 Then Response.Write "</tr><tr>"
            Repeat2__index = Repeat2__index + 1
            Repeat2__numRows = Repeat2__numRows - 1
            Recordset2.MoveNext
        Wend
        Response.Write ("</tr></table>")
        If (Recordset2.CursorType > 0) Then
            Recordset2.movefirst
        Else
            Recordset2.Requery
        End If
        Response.Write "        <br>" & vbCrLf
        Response.Write "        <a href='Admin_TestManage.asp?Action=SubjectManage'>考试科目管理&gt;&gt;&gt;</a>" & vbCrLf
    Else
        Response.Write "        找不到任何考试科目，请首先进入“<a href='Admin_TestManage.asp?Action=SubjectManage'>考试科目管理</a>”模块添加考试科目！" & vbCrLf
    End If
    Response.Write "      </td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr align='center' class='tdbg'>" & vbCrLf
    Response.Write "      <td height='30' colspan='3'>" & vbCrLf
    Response.Write "      <input type='hidden' name='MM_insert' value='true'>" & vbCrLf
    Response.Write "          <input type='submit' name='Submit' value='添加考试' " & vbCrLf
    If Recordset2.EOF And Recordset2.BOF Then Response.Write "disabled>"
    Response.Write "      </td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "  </form>" & vbCrLf
    Response.Write "</table>" & vbCrLf
    Response.Write "</form>" & vbCrLf
    Response.Write "<strong>已有的考试：</strong>" & vbCrLf
    Response.Write "<br>" & vbCrLf
    Response.Write "" & vbCrLf

    If Recordset1.EOF And Recordset1.BOF Then
        Response.Write "        <p align='center'>" & vbCrLf
        Response.Write "        找不到任何考试，请添加考试！<br>" & vbCrLf
        Response.Write "          <br>" & vbCrLf
        Response.Write "        </p>" & vbCrLf
    Else
        Response.Write "<table width='100%' class='border' border='0' cellspacing='1' cellpadding='4' align='center'>" & vbCrLf
        Response.Write "" & vbCrLf
        Response.Write "          <tr class='title'> " & vbCrLf
        Response.Write "            <td  width='5%' align='center' >序号</td>" & vbCrLf
        Response.Write "            <td width='25%' align='center'>考试名称</td>" & vbCrLf
        Response.Write "            <td width='10%' align='center'>数据库表名</td>" & vbCrLf
        Response.Write "            <td align='center'>已有的考试科目</td>" & vbCrLf
        Response.Write "            <td width='6%' align='center'>状态</td>" & vbCrLf
        Response.Write "            <td width='12%' align='center'>操作</td>" & vbCrLf
        Response.Write "          </tr>" & vbCrLf
        Response.Write "" & vbCrLf

        While ((Repeat1__numRows <> 0) And (Not Recordset1.EOF))

            Response.Write "          <tr class='tdbg' onmouseout=""this.style.backgroundColor=''"" onmouseover=""this.style.backgroundColor='#BFDFFF'""> " & vbCrLf
            Response.Write "            <td width='5%' align='center'>" & vbCrLf
            Response.Write Recordset1.Fields.Item("id").value
            Response.Write "</td>" & vbCrLf
            Response.Write "            <td width='25%' align='center'>" & vbCrLf
            Response.Write Recordset1.Fields.Item("TestName").value
            Response.Write "</td>" & vbCrLf
            Response.Write "            <td width='10%' align='center'>" & vbCrLf
            Response.Write Recordset1.Fields.Item("SheetName").value
            Response.Write "</td>" & vbCrLf
            Response.Write "            <td>" & vbCrLf
            Response.Write "" & vbCrLf

            Set rsSubject = Server.CreateObject("ADODB.Recordset")
            rsSubject.Open "SELECT * FROM " & Recordset1.Fields.Item("SheetName").value, Conn_Sdms, 1, 3
            Response.Write ("<table border='0' cellspacing='0' cellpadding='3'><tr>")
            For i = 5 To rsSubject.Fields.Count - 1
                Response.Write "<td>" & rsSubject.Fields(i).name & "</td>"
                If (i + 1 - 5) > 0 And ((i + 1 - 5) Mod 8 = 0) Then Response.Write "</tr><tr>"
            Next
            Response.Write ("</tr></table>")
            rsSubject.Close
            Set rsSubject = Nothing

            Response.Write "            </td>" & vbCrLf
            Response.Write "            <td width='6%'>" & vbCrLf
            Response.Write "" & vbCrLf

            If Recordset1("Locked") = False Then
                Response.Write "正常"
            Else
                Response.Write "已锁定"
            End If
            Response.Write "            </td>" & vbCrLf
            Response.Write "            <td width='12%' align='center'>" & vbCrLf
            Response.Write "            <A HREF='Admin_TestManage.asp?Action=TestModify&id=" & Recordset1.Fields.Item("id").value & "'>修改</A>&nbsp;" & vbCrLf
            Response.Write "            <A HREF='Admin_TestManage.asp?Action=TestDel&id=" & Recordset1.Fields.Item("id").value & "&SheetName=" & Recordset1.Fields.Item("SheetName").value & "'  onClick=""return ConfirmDel()"">删除</A>" & vbCrLf
            Response.Write "" & vbCrLf

            If Recordset1("Locked") = False Then
                Response.Write "<A href='Admin_TestManage.asp?Action=LockTest&Locktype=Lock&ID=" & Recordset1("ID") & "'>锁定</a>"
            Else
                Response.Write "<A href='Admin_TestManage.asp?Action=LockTest&Locktype=UnLock&ID=" & Recordset1("ID") & "'>解锁</a>"
            End If
            Response.Write "</td>" & vbCrLf
            Response.Write "          </tr>" & vbCrLf

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

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

    End If

    Recordset1.Close
    Recordset2.Close
    Set Recordset1 = Nothing
    Set Recordset2 = Nothing
End Sub

Sub LockTest()
    Dim ID, LockType, MM_editQuery
    LockType = Trim(Request("LockType"))
    ID = Trim(Request("ID"))
    If ID = "" Then
        Response.Write "请指定ID"
        Response.End
    Else
        ID = PE_CLng(ID)
    End If
    If LockType = "Lock" Then
        MM_editQuery = "update TestName set Locked=True where ID=" & ID
    ElseIf LockType = "UnLock" Then
        MM_editQuery = "update TestName set Locked=False where ID=" & ID
    Else
        Response.Write "错误的参数"
        Response.End
    End If
    Conn_Sdms.Execute MM_editQuery
    Response.Redirect "Admin_TestManage.asp"
End Sub

Sub TestDel()
    Dim MM_editQuery, MM_SheetName, MM_DelQuery
    If Request("SheetName") <> "" And Request("ID") <> "" Then
        '删除记录
        MM_editQuery = "delete from TestName where ID = " & Request("ID") & ""
        ' 删除表
        MM_SheetName = Request("SheetName")
        MM_DelQuery = "Drop Table " & MM_SheetName

        Conn_Sdms.Execute MM_editQuery
        Conn_Sdms.Execute MM_DelQuery

        Response.Redirect "Admin_TestManage.asp"
    End If
End Sub

Sub TestModify()
    Dim rsSubject, Recordset1, Recordset2
    Dim strTemp, i
    Dim EditAction, MM_editQuery, strSheetName, strSubject, MM_AppendFieldQuery, MM_editRedirectUrl
    Dim MM_editTable, MM_editColumn, MM_recordId, MM_fieldsStr, MM_columnsStr, MM_fields, MM_columns
    Dim FormVal, MM_typeArray, Delim, AltVal, EmptyVal
    
    Response.Write "<script language=""JavaScript"">" & vbCrLf
    Response.Write "function checktest(){" & vbCrLf
    Response.Write "    if(document.form1.TestName.value=="""")" & vbCrLf
    Response.Write "      {" & vbCrLf
    Response.Write "       alert(""考试名称不能为空！"");" & vbCrLf
    Response.Write "       document.form1.TestName.focus();" & vbCrLf
    Response.Write "       return false;" & vbCrLf
    Response.Write "       }" & 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 "</script>" & vbCrLf

    EditAction = CStr(Request("URL"))
    If (Request.QueryString <> "") Then
        EditAction = EditAction & "?" & Request.QueryString
    End If

    ' query string to execute
    MM_editQuery = ""

    ' *** 向表中添加字段
    If (ReplaceBadChar(Request("AppendField")) <> "" And ReplaceBadChar(Request("Subject")) <> "" And ReplaceBadChar(Request("SheetName")) <> "") Then
        strSheetName = ReplaceBadChar(Request("SheetName"))
        strSubject = ReplaceBadChar(Request("Subject")) & " SINGLE"
        MM_AppendFieldQuery = "ALTER TABLE " & strSheetName & " ADD COLUMN " & strSubject
        Conn_Sdms.Execute MM_AppendFieldQuery
        If (MM_editRedirectUrl <> "") Then
          Response.Redirect (EditAction)
        End If
    End If

    ' *** 从表中删除字段
    If (ReplaceBadChar(Request("DeleteField")) <> "" And ReplaceBadChar(Request("Subject")) <> "" And ReplaceBadChar(Request("SheetName")) <> "") Then
        strSheetName = ReplaceBadChar(Request("SheetName"))
        strSubject = ReplaceBadChar(Request("Subject"))
        
        Conn_Sdms.Execute ("ALTER TABLE " & strSheetName & " DROP COLUMN " & strSubject & "")
        If (MM_editRedirectUrl <> "") Then
          Response.Redirect (EditAction)
        End If
    End If

    If (ReplaceBadChar(Request("MM_update")) <> "" And ReplaceBadChar(Request("MM_recordId")) <> "") Then
        MM_editTable = "TestName"
        MM_editColumn = "id"
        MM_recordId = "" + Request.Form("MM_recordId") + ""
        MM_editRedirectUrl = "Admin_TestManage.asp"
        MM_fieldsStr = "TestName|value"
        MM_columnsStr = "TestName|',none,''"

        MM_fields = Split(MM_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)))
        Next

        If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
            If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
                MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
            Else
                MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
            End If
        End If

        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
                    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 " & MM_editColumn & " = " & MM_recordId

        Conn_Sdms.Execute MM_editQuery

        If (MM_editRedirectUrl <> "") Then
            Response.Redirect (MM_editRedirectUrl)
        End If
    End If

    Dim Recordset1__MMColParam, Recordset1Sql, Recordset2Sql
    Recordset1__MMColParam = "1"

    Set Recordset1 = Server.CreateObject("ADODB.Recordset")
    If (Request.QueryString("id") <> "") Then
        Recordset1__MMColParam = Request.QueryString("id")
        Recordset1Sql = "SELECT * FROM TestName WHERE ID = " + Replace(Recordset1__MMColParam, "'", "''") + ""
    ElseIf (Request.QueryString("SheetName") <> "") Then
        strSheetName = Request.QueryString("SheetName")
        Recordset1__MMColParam = Request.QueryString("SheetName")
        Recordset1Sql = "SELECT * FROM TestName WHERE SheetName = '" + Replace(Recordset1__MMColParam, "'", "''") + "'"
    End If
    Recordset1.Open Recordset1Sql, Conn_Sdms, 1, 3

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


    Set rsSubject = Server.CreateObject("ADODB.Recordset")
    rsSubject.Open "SELECT * FROM " & Recordset1.Fields.Item("SheetName").value, Conn_Sdms, 1, 3
    strSubject = ""
    For i = 5 To rsSubject.Fields.Count - 1
        strSubject = strSubject & rsSubject.Fields(i).name & ","
    Next

    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 align='center' >" & vbCrLf
    Response.Write "      <br>" & vbCrLf
    If Not Recordset1.EOF Or Not Recordset1.BOF Then
        If Request.QueryString("SheetName") <> "" Then
            Response.Write "<br><br>错误！已经存在此考试！请在此修改考试信息！<br><br>"
        End If
        Response.Write "        <form onsubmit='return checktest()' ACTION='" & EditAction & "' METHOD='POST' Name='form1'>" & vbCrLf
        Response.Write "        <font color='#FF0000'><b>修改考试名称：</b></font> " & vbCrLf
        Response.Write "          <table width='60%' border='0' align='center' cellpadding='0' cellspacing='0'>" & vbCrLf
        Response.Write "            <tr> " & vbCrLf
        Response.Write "              <td width='20%' height='25' align='right'>考试名称： </td>" & vbCrLf
        Response.Write "              <td width='30%' height='25'> <input Name='TestName' type='text' value='" & (Recordset1.Fields.Item("TestName").value) & "' size='50'> " & vbCrLf
        Response.Write "              </td>" & vbCrLf
        Response.Write "            </tr>" & vbCrLf
        Response.Write "            <tr> " & vbCrLf
        Response.Write "              <td height='25' align='right'>数据库对应的表名：</td>" & vbCrLf
        Response.Write "              <td height='25'> " & Recordset1.Fields.Item("SheetName").value & "</td>" & vbCrLf
        Response.Write "            </tr>" & vbCrLf
        Response.Write "            <tr align='center'> " & vbCrLf
        Response.Write "              <td height='25' colspan='2'> <input type='hidden' name='MM_update' value='true'> " & vbCrLf
        Response.Write "                <input type='hidden' name='MM_recordId' value='" & Recordset1.Fields.Item("id").value & "'> " & vbCrLf
        Response.Write "                <input type='submit' Name='Submit' value='保存修改结果'> </td>" & vbCrLf
        Response.Write "            </tr>" & vbCrLf
        Response.Write "          </table>" & vbCrLf
        Response.Write "        </form>" & vbCrLf
        Response.Write "        ======================================================================================== " & vbCrLf
        Response.Write "        <form name='form2' method='post' action='" & EditAction & "'>" & vbCrLf
        Response.Write "          <font color='#FF0000'><b>添加考试科目：</b>" & vbCrLf
        Response.Write "          </font> " & vbCrLf
        Response.Write "          <select name='Subject'>" & vbCrLf

        i = 0
        While (Not Recordset2.EOF)
            strTemp = Recordset2.Fields.Item("SubjectName").value
            If InStr(strSubject, strTemp) <= 0 Then
                Response.Write "            <option value='" & Recordset2.Fields.Item("SubjectName").value & "'>" & vbCrLf
                Response.Write Recordset2.Fields.Item("SubjectName").value
                Response.Write "</option>" & vbCrLf
                i = i + 1
            End If
            Recordset2.MoveNext
        Wend
        If (Recordset2.CursorType > 0) Then
            Recordset2.movefirst
        Else
            Recordset2.Requery
        End If
        If i = 0 Then
            Response.Write "<option value=''>全部科目都已添加到考试中</option>"
        End If
        Response.Write "</select>" & vbCrLf
        If i > 0 Then
            Response.Write "<input type='submit' name='Submit2' value='添加'>"
        End If

        Response.Write "          <input type='hidden' name='AppendField' value='true'>" & vbCrLf
        Response.Write "          <input name='SheetName' type='hidden' id='SheetName2' value='" & Recordset1.Fields.Item("SheetName").value & "'>" & vbCrLf
        Response.Write "        </form>" & vbCrLf
        Response.Write "        ======================================================================================== " & vbCrLf
        Response.Write "        <form name='form3' onSubmit='return ConfirmDel()' method='post' action='" & EditAction & "'>" & vbCrLf
        Response.Write "          <b><font color='#FF0000'>删除已有的考试科目：</font>" & vbCrLf
        Response.Write "          </b> " & vbCrLf
        Response.Write "          <select name='Subject'>" & vbCrLf

        For i = 5 To rsSubject.Fields.Count - 1
            Response.Write "<option value=" & rsSubject.Fields(i).name & "' selected>" & rsSubject.Fields(i).name & "</option>"
        Next
        Response.Write "          </select>" & vbCrLf
        If i > 5 Then
            Response.Write "<input type='submit' name='Submit3' value='删除'>"
        End If
        Response.Write "          <input type='hidden' name='DeleteField' value='true'>" & vbCrLf
        Response.Write "          <input name='SheetName' type='hidden' id='SheetName2' value='" & (Recordset1.Fields.Item("SheetName").value) & "'>" & vbCrLf
        Response.Write "        </form>" & vbCrLf
        Response.Write "" & vbCrLf
    End If
    If Recordset1.EOF And Recordset1.BOF Then
        Response.Write "        <p align='center'>" & vbCrLf
        Response.Write "        <br>" & vbCrLf
        Response.Write "          <br>" & vbCrLf
        Response.Write "          找不到任何考试，请添加考试！<br>" & vbCrLf
        Response.Write "          <br>" & vbCrLf
        Response.Write "        </p>" & vbCrLf
    End If
    Response.Write "      <p align='right'><a href='Admin_TestManage.asp'>【返回考试管理主界面】</a>" & vbCrLf
    Response.Write "      </p>" & vbCrLf
    Response.Write "      <br>      </td>" & vbCrLf
    Response.Write "       " & vbCrLf
    Response.Write "    </TR> " & vbCrLf
    Response.Write "  </TBODY>" & vbCrLf
    Response.Write "</TABLE>" & vbCrLf

    Recordset1.Close
    Recordset2.Close
    rsSubject.Close
    Set Recordset1 = Nothing
    Set Recordset2 = Nothing
    Set rsSubject = Nothing
End Sub

Sub SubjectManage()
    Dim Recordset1
    Dim InsertFlag, i, k, intTemp
    Dim MM_editAction, MM_editQuery, MM_flag, strSubject, MM_dupKeyRedirect, MM_dupKeyUsernameValue
    Dim MM_rsKey, MM_qsChar
    Dim MM_editConnection, MM_editRedirectUrl, MM_editTable, MM_editColumn, MM_recordId, MM_fieldsStr, MM_columnsStr, MM_fields, MM_columns
    Dim MM_tableValues, MM_dbValues
    Dim FormVal, MM_typeArray, Delim, AltVal, EmptyVal
    
    MM_editAction = CStr(Request("URL"))
    MM_editQuery = ""
    MM_flag = "MM_insert"
    If (ReplaceBadChar(Request(MM_flag)) <> "") Then
        strSubject = Request("Subject") & ""
        If InStr(strSubject, "!") > 0 Or InStr(strSubject, "@") > 0 Or InStr(strSubject, "#") > 0 Or InStr(strSubject, "$") > 0 Or InStr(strSubject, "%") > 0 Or InStr(strSubject, "^") > 0 Or InStr(strSubject, "&") > 0 Or InStr(strSubject, "*") > 0 Or InStr(strSubject, "(") > 0 Or InStr(strSubject, ")") > 0 Or InStr(strSubject, "-") > 0 Or InStr(strSubject, "=") > 0 Or InStr(strSubject, "\") > 0 Or InStr(strSubject, ",") > 0 Or InStr(strSubject, ".") > 0 Or InStr(strSubject, "/") > 0 Or InStr(strSubject, "?") > 0 Or InStr(strSubject, "<") > 0 Or InStr(strSubject, ">") > 0 Or InStr(strSubject, "[") > 0 Or InStr(strSubject, "]") > 0 Or InStr(strSubject, "{") > 0 Or InStr(strSubject, "}") > 0 Or InStr(strSubject, "|") > 0 Or InStr(strSubject, "+") > 0 Or InStr(strSubject, "~") > 0 Or LCase(strSubject) = "as" Then
            Response.Redirect "Admin_TestManage.asp?Action=SubjectManage?Err=Char"
        End If

        MM_dupKeyRedirect = "Admin_TestManage.asp?Action=SubjectManage"
        
        MM_dupKeyUsernameValue = ReplaceBadChar(Request.Form("Subject"))
        Set MM_rsKey = Server.CreateObject("ADODB.Recordset")
        MM_rsKey.Open "SELECT SubjectName FROM Subject WHERE SubjectName='" & MM_dupKeyUsernameValue & "'", Conn_Sdms, 1, 3

        If Not MM_rsKey.EOF Or Not MM_rsKey.BOF Then
            MM_qsChar = "?"
            If (InStr(1, MM_dupKeyRedirect, "?") >= 1) Then MM_qsChar = "&"
            MM_dupKeyRedirect = MM_dupKeyRedirect & MM_qsChar & "Err=Exist"
            Response.Redirect (MM_dupKeyRedirect)
        End If
        MM_rsKey.Close
    End If

    If (ReplaceBadChar(Request("MM_insert")) = "form1") Then
        'MM_editConnection = MM_StudentConn_STRING
        MM_editTable = "Subject"
        MM_editRedirectUrl = "Admin_TestManage.asp?Action=SubjectManage"
        MM_fieldsStr = "Subject|value"
        MM_columnsStr = "SubjectName|',none,''"
        MM_fields = Split(MM_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)))
        Next
        Dim rsTarget
        Dim rsTarget_numRows

        Set rsTarget = Server.CreateObject("ADODB.Recordset")
        rsTarget.Open "SELECT * FROM TargetScore", Conn_Sdms, 1, 3
        InsertFlag = True
        For k = 0 To rsTarget.Fields.Count - 1
            If rsTarget.Fields.Item(k).name = ReplaceBadChar(Request.Form("Subject")) Then InsertFlag = False
        Next
        rsTarget.Close
        If InsertFlag = True Then
            If ReplaceBadChar(Request.Form("Subject")) = "" Then
                Response.Write "添加的考试科目输入有错误！没有操作被完成，请重新进入考试管理添加。"
                Response.End
            End If
            strSubject = ReplaceBadChar(Request.Form("Subject")) & " SINGLE"

            Conn_Sdms.Execute "ALTER TABLE TargetScore ADD COLUMN " & strSubject

        End If

        If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
            If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
                MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
            Else
                MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
            End If
        End If

    End If

    If (ReplaceBadChar(Request("MM_delete")) = "form2") Then
        'MM_editConnection = MM_StudentConn_STRING
        MM_editTable = "Subject"
        MM_editColumn = "ID"
        MM_recordId = "" + Request.Form("Subject") + ""
        MM_editRedirectUrl = "Admin_TestManage.asp?Action=SubjectManage"

        If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
            If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
                MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
            Else
                MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
            End If
        End If
      
    End If

    If (ReplaceBadChar(Request("MM_insert")) = "form1") Then
        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 & ")"

        Conn_Sdms.Execute MM_editQuery


        If (MM_editRedirectUrl <> "") Then
            Response.Redirect (MM_editRedirectUrl)
        End If

    End If


    If (ReplaceBadChar(Request("MM_delete")) <> "") Then
        MM_editQuery = "delete from " & MM_editTable & " where " & MM_editColumn & " = " & MM_recordId

        Conn_Sdms.Execute MM_editQuery

        If (MM_editRedirectUrl <> "") Then
            Response.Redirect (MM_editRedirectUrl)
        End If
    End If
    
    Set Recordset1 = Server.CreateObject("ADODB.Recordset")
    Recordset1.Open "SELECT * FROM Subject ORDER BY ID ASC", Conn_Sdms, 1, 3
    Response.Write "<script language=""JavaScript"">" & vbCrLf
    Response.Write "function checktest(){" & vbCrLf
    Response.Write "var strSubjectName=document.form1.Subject.value;" & vbCrLf
    Response.Write "if(strSubjectName=="""")" & vbCrLf
    Response.Write "  {" & vbCrLf
    Response.Write "   alert(""考试科目名不能为空！"");" & vbCrLf
    Response.Write "   document.form1.Subject.focus();" & vbCrLf
    Response.Write "   return false;" & vbCrLf
    Response.Write "   }" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "</script>" & vbCrLf
    Response.Write "" & vbCrLf
    If Request("Err") = "Char" Then
        Response.Write "<script language=""JavaScript"" type=""text/JavaScript"">" & vbCrLf
        Response.Write "alert(""科目名称中含有“!@#$%^&*()-+=,./?<>[]{}\|~“等非法字符，操作被取消！"");" & vbCrLf
        Response.Write "</script>" & vbCrLf
    End If
    If Request("Err") = "Exist" Then
        Response.Write "<script language=""JavaScript"" type=""text/JavaScript"">" & vbCrLf
        Response.Write "alert(""数据库中已存在此科目名称，操作被取消！"");" & vbCrLf
        Response.Write "</script>" & vbCrLf
    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 colspan='2' align='center' class='title'><b> 考 试 科 目 管 理 (</b><b>添加新考试科目)</b></td>" & vbCrLf
    Response.Write "  </tr> <form Name='form1' onsubmit='return checktest()' method='POST' action='" & MM_editAction & "'>" & vbCrLf
    Response.Write "  <tr class='tdbg'>" & vbCrLf
    Response.Write "    <td width='50%' align='right' ><b>添加新考试科目：</b></td>" & vbCrLf
    Response.Write "    <td align='left' ><font color='#FF0000'><b>" & vbCrLf
    Response.Write "      <input name='Subject' type='text' size='18' maxlength='16'>" & vbCrLf
    Response.Write "      <input type='hidden' name='MM_insert' value='form1'>" & vbCrLf
    Response.Write "      <input type='hidden' name='Action' value='SubjectManage'>" & vbCrLf
    Response.Write "    </b></font></td>" & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "  <tr align='center' class='tdbg'>  " & vbCrLf
    Response.Write "    <td colspan='2' ><font color='#FF0000'><b>" & vbCrLf
    Response.Write "      <input type='submit' name='Submit2' value='添加'>" & vbCrLf
    Response.Write "    </b></font>   " & vbCrLf
    Response.Write "   </td> " & vbCrLf
    Response.Write "  </tr></form>" & vbCrLf
    Response.Write "</table><br>       " & vbCrLf
    Response.Write "        <strong>已有的考试科目：</strong><br>" & vbCrLf
    If Not Recordset1.EOF Or Not Recordset1.BOF Then
        Response.Write "<table class='border' border='0' cellspacing='1' cellpadding='4' align='center'><tr class='tdbg'>"
        i = 1
        Recordset1.movefirst
        While (Not Recordset1.EOF)
            Response.Write "<td Width='50' Align='Center'>" & Recordset1.Fields.Item("SubjectName").value & "</td>"
            If (i) > 0 And (i Mod 8 = 0) Then Response.Write "</tr><tr class='tdbg'>"
            Recordset1.MoveNext
            i = i + 1
        Wend
        If (Recordset1.CursorType > 0) Then
            Recordset1.movefirst
        Else
            Recordset1.Requery
        End If
        Response.Write "</tr></table>"

        Response.Write "<form name='form2' method='POST' action='" & MM_editAction & "'>      " & vbCrLf
        Response.Write "<table width='100%' class='border' border='0' cellspacing='1' cellpadding='4' align='center'> " & vbCrLf
        Response.Write "  <tr>" & vbCrLf
        Response.Write "    <td colspan='2' align='center' class='title'><b> 考 试 科 目 管 理 (删除已有的考试科目)</b>" & vbCrLf
        Response.Write "    </td>" & vbCrLf
        Response.Write "  </tr>" & vbCrLf
        Response.Write "  <tr class='tdbg'>" & vbCrLf
        Response.Write "    <td width='50%' align='right' ><b>删除已有的考试科目：</b>" & vbCrLf
        Response.Write "    </td>" & vbCrLf
        Response.Write "    <td align='left' >          " & vbCrLf
        Response.Write "    <select name='Subject'>" & vbCrLf
        Response.Write "" & vbCrLf

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

        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' >  " & vbCrLf
        Response.Write "" & vbCrLf
        If intTemp > 0 Then
            Response.Write "      <input type='hidden' name='Action' value='SubjectManage'>" & vbCrLf
            Response.Write "          <input name='Submit' type='submit' value='删除'>" & vbCrLf
            Response.Write "          <input type='hidden' name='MM_delete' value='form2'>" & vbCrLf
            Response.Write "" & vbCrLf
        End If
        Response.Write "   </td> " & vbCrLf
        Response.Write "  </tr>" & vbCrLf
        Response.Write "</table>" & vbCrLf
        Response.Write "</form> " & vbCrLf
    End If
    If Recordset1.EOF And Recordset1.BOF Then
        Response.Write "        <p align='center'>找不到任何考试科目，请添加考试科目！<br>" & vbCrLf
        Response.Write "          <br>" & vbCrLf
        Response.Write "        </p>" & vbCrLf
        Response.Write "" & vbCrLf
    End If
    Recordset1.Close
End Sub

%>
