<!--#include file="Admin_Common.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 = "Equipment"   '其他权限

Dim rsa, sqla, rs, sql, intID, Status
Dim strSort, Man, UsedTpye, StartDay
Dim ClassroomID, lessonYear, lessonMonth, lessonDay, lessonNumber
StartDay="2008-2-25" '室场登记时间初始化，当每学期开学时修改此设置

Man = CStr(Request("Man"))
Status = Trim(Request("Status"))
UsedTpye = PE_CLng(Request("UsedTpye"))
ClassroomID = PE_CLng(Request("ClassroomID"))
lessonYear = PE_CLng(Request("lessonYear"))
lessonMonth = PE_CLng(Request("lessonMonth"))
lessonDay = PE_CLng(Request("lessonDay"))
lessonNumber = PE_CLng(Request("lessonNumber"))
strSort = ClassroomID
Call getSort(ClassroomID)
If Status = "" Then
    Status = Session("Status")
End If
Session("Status") = Status
If Request("page") <> "" Then
    CurrentPage = PE_CLng(Request("page"))
Else
    CurrentPage = 1
End If
strFileName = " Admin_ManageRecord.asp?Man=" & Man & "&ClassroomID=" & ClassroomID & "&lessonYear=" & lessonYear & "&lessonMonth=" & lessonMonth & "&lessonDay=" & lessonDay & "&lessonNumber=" & lessonNumber
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 "</head>" & vbCrLf
Response.Write "<body leftmargin='2' topmargin='0' marginwidth='0' marginheight='0'>" & vbCrLf
Response.Write "<table width='100%' border='0' align='center' cellpadding='1' cellspacing='1' class='border'>" & vbCrLf
Call ShowPageTitle("专 用 教 室 管 理", 10193)
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_ClassroomSort.asp?Action=Add'>室场添加</a>&nbsp;|&nbsp;<a href='Admin_ClassroomSort.asp'>室场管理</a>&nbsp;|&nbsp;<a href='Admin_Equipment.asp?Action=Add'>设备添加</a>&nbsp;|&nbsp;<a href='Admin_Equipment.asp'>设备管理</a>&nbsp;|&nbsp;<a href='Admin_ManageRecord.asp?Action=AdminEnrol'>固定排课</a>&nbsp;|&nbsp;<a href='Admin_ManageRecord.asp?Status=All'>使用登记管理</a>&nbsp;|&nbsp;<a href='Admin_SearchHistory.asp'>使用记录查询</a>" & vbCrLf
Response.Write "    </td>" & vbCrLf
Response.Write "  </tr>" & vbCrLf
If Action = "" Then
    Response.Write "<form name='form' method='Post' action='Admin_ManageRecord.asp'><tr class='tdbg'>"
    Response.Write "      <td width='70' height='30' ><strong>管理选项：</strong></td><td>"
    Response.Write "  <input name='Status' type='radio' value='All' onclick='submit();'"
    If Status = "All" Then Response.Write " checked"
    Response.Write ">所有记录&nbsp;&nbsp;&nbsp;&nbsp;<input name='Status' type='radio' value='0' onclick='submit();'"
    If Status = "0" Then Response.Write " checked"
    Response.Write ">待确认登记的记录&nbsp;&nbsp;&nbsp;&nbsp;<input name='Status' type='radio' value='1' onclick='submit();'"
    If Status = "1" Then Response.Write " checked"
    Response.Write ">待确认使用的记录&nbsp;&nbsp;&nbsp;&nbsp;<input name='Status' type='radio' value='2' onclick='submit();'"
    If Status = "2" Then Response.Write " checked"
    Response.Write ">已使用的记录</td></tr></form>" & vbCrLf
End If
Response.Write "</table>" & vbCrLf
Select Case Action
Case "UsedDetail"
    Call UsedDetail
Case "Del", "SetEnrol", "SetUsed"
    Call SetProperty
Case "AdminEnrol"
    Call AdminEnrol
Case "ShowEnrolResult"
    Call ShowEnrolResult
Case Else
    Call main
End Select
If FoundErr = True Then
    Call WriteErrMsg(ErrMsg, ComeUrl)
End If
Response.Write "</body></html>"
Call CloseConn


Sub main()
    If UsedTpye <> "" Then
        If UsedTpye = "1" Then
            Conn.Execute ("update PE_UsedDetail set Used=1 where id=" & PE_CLng(Request("id")) & "")
            Dim sqlSame, rsSame
            Set rsSame = Server.CreateObject("adodb.recordset")
            sqlSame = "select * from PE_UsedDetail where id<>" & PE_CLng(Request("id")) & " and lessonYear=" & PE_Clng(Request("ilessonYear")) & " and lessonMonth=" & PE_Clng(Request("ilessonMonth")) & " and lessonDay=" & PE_Clng(Request("ilessonDay")) & " and lessonNumber=" & PE_Clng(Request("ilessonNumber")) & " and EquipmentID =" & PE_CLng(Request("EquipmentID"))
            'Response.Write sqlSame
            rsSame.Open sqlSame, Conn, 1, 3
            Do While Not rsSame.EOF
                rsSame.Delete
                rsSame.Update
                rsSame.MoveNext
            Loop
            rsSame.Close
            Set rsSame = Nothing
        End If
        If UsedTpye = "2" Then
            Conn.Execute ("update PE_UsedDetail set Used=2 where id=" & PE_CLng(Request("id")) & "")
        End If
    End If
    Call ShowJS_Main("记录")
    Response.Write "<br><table width='100%'><tr><td align='left'>您现在的位置：专用教室管理 &nbsp;&gt;&gt;&nbsp;使用登记管理"
    Response.Write "</td><td align='right'>"
    Set rs = Server.CreateObject("adodb.recordset")
    sql = "select D.ID, D.EquipmentID, D.UserName, D.lessonMonth, D.lessonDay, D.lessonNumber, D.lessonYear, D.UserClass, D.UserType, D.RegisterTime,D.Used, F.ClassroomID, F.EquipmentName, C.ClassroomName from PE_UsedDetail D left join ( PE_Equipment F left join  PE_Classroom C on F.ClassroomID = C.ID ) on D.EquipmentID = F.ID where 1=1"
    If Status = "0" Then
        sql = sql & " and Used=0"
    ElseIf Status = "1" Then
        sql = sql & " and Used=1"
    ElseIf Status = "2" Then
        sql = sql & " and Used=2"
    End If
    If Not (Man = "" Or IsEmpty(Man)) Then
        sql = sql & " and D.UserName like '%" & ReplaceBadChar(Man) & "%'"
    End If
    If ClassroomID > 0 Then
        sql = sql & " and F.ClassroomID in (" & strSort & ")"
    End If
    If lessonMonth > 0 Then
        sql = sql & " and D.lessonMonth=" & lessonMonth
    End If
    If lessonDay > 0 Then
        sql = sql & " and D.lessonDay=" & lessonDay
    End If
    If lessonNumber > 0 Then
        sql = sql & " and D.lessonNumber= " & lessonNumber
    End If
    If lessonYear > 0 Then
        sql = sql & " and D.lessonYear=" & lessonYear
    End If
    sql = sql & " order by D.id asc"
    rs.Open sql, Conn, 1, 1
    rs.pagesize = MaxPerPage
    If rs.BOF And rs.EOF Then
        Response.Write "共找到 <font color=red>0</font> 条记录</td></tr></table>"
    Else
        totalPut = rs.RecordCount
        'If lessonYear = 0 Then
            'Response.Write "没有指定查询条件!</td></tr></table>"
        'Else
            Response.Write "共找到 <font color=red>" & totalPut & "</font> 条记录</td></tr></table>"
        'End If
    End If
    If CurrentPage < 1 Then
        CurrentPage = 1
    End If
    If (CurrentPage - 1) * MaxPerPage > totalPut Then
        If (totalPut Mod MaxPerPage) = 0 Then
            CurrentPage = totalPut \ MaxPerPage
        Else
            CurrentPage = totalPut \ MaxPerPage + 1
        End If
    End If
    If CurrentPage > 1 Then
        If (CurrentPage - 1) * MaxPerPage < totalPut Then
            rs.Move (CurrentPage - 1) * MaxPerPage
        Else
            CurrentPage = 1
        End If
    End If
    Response.Write "    <table width='100%' class='border' border='0' cellspacing='1' cellpadding='1' align='center'>" & vbCrLf
    Response.Write "  <form name='myform' method='Post' action='Admin_ManageRecord.asp' onsubmit='return ConfirmDel();'>"
    Response.Write "      <tr class='title'>" & vbCrLf
    Response.Write "        <td width='5%' nowrap> " & vbCrLf
    Response.Write "          <div align='center'><b>选中</b></div>" & vbCrLf
    Response.Write "        </td>" & vbCrLf
    Response.Write "        <td width='10%' nowrap> " & vbCrLf
    Response.Write "          <div align='center'><b>设备名称</b></div>" & vbCrLf
    Response.Write "        </td>" & vbCrLf
    Response.Write "        <td width='11%' nowrap> " & vbCrLf
    Response.Write "          <div align='center'><b>使用日期</b></div>" & vbCrLf
    Response.Write "        </td>" & vbCrLf

    Response.Write "        <td width='6%' nowrap> " & vbCrLf
    Response.Write "          <div align='center'><b>节次</b></div>" & vbCrLf
    Response.Write "        </td>" & vbCrLf
    Response.Write "        <td width='10%' nowrap> " & vbCrLf
    Response.Write "          <div align='center'><b>所属教室</b></div>" & vbCrLf
    Response.Write "        </td>" & vbCrLf

    Response.Write "        <td width='8%' nowrap> " & vbCrLf
    Response.Write "          <div align='center'><b>使用人</b></div>" & vbCrLf
    Response.Write "        </td>" & vbCrLf
    Response.Write "        <td width='8%' nowrap> " & vbCrLf
    Response.Write "          <div align='center'><b>班级</b></div>" & vbCrLf
    Response.Write "        </td>" & vbCrLf
    Response.Write "        <td width='16%' nowrap> " & vbCrLf
    Response.Write "          <div align='center'><b>登记时间</b></div>" & vbCrLf
    Response.Write "        </td>" & vbCrLf
    Response.Write "        <td width='6%' nowrap> " & vbCrLf
    Response.Write "          <div align='center'><b>已确认</b></div>" & vbCrLf
    Response.Write "        </td>" & vbCrLf
    Response.Write "        <td width='6%' nowrap> " & vbCrLf
    Response.Write "          <div align='center'><b>已使用</b></div>" & vbCrLf
    Response.Write "        </td>" & vbCrLf
    Response.Write "        <td width='14%' nowrap> " & vbCrLf
    Response.Write "          <div align='center'><b>管理操作</b></div>" & vbCrLf
    Response.Write "        </td>" & vbCrLf
    Response.Write "      </tr>" & vbCrLf
    If rs.RecordCount = 0 Then
        Response.Write "<tr class='tdbg'><td colspan='11' align='center'>没有满足条件的登记记录!</td><tr>" & vbCrLf
    Else
        Dim rsID, i, Sort
        i = 0
        Do While Not rs.EOF
            Response.Write "    <tr class='tdbg' onmouseout=""this.className='tdbg'"" onmouseover=""this.className='tdbgmouseover'"">" & vbCrLf
            Response.Write "      <td width='5' align='center'><input name='ID' type='checkbox' onclick='unselectall()' value='" & rs("ID") & "'></td>"
            Response.Write "      <td width='10%' title='点击查看记录具体信息' align='center'><a href='Admin_ManageRecord.asp?Action=UsedDetail&id=" & rs("ID") & "'>" & rs("EquipmentName") & "</a></td>" & vbCrLf
            'Response.Write "      <td width='12%' align='center'>" & rs("lessonYear") & "/" & rs("lessonMonth") & "/" & rs("lessonDay") & "</td>" & vbCrLf
            Response.Write "      <td width='11%' align='center'>" & ShowWeek(rs("lessonYear") & "-" & rs("lessonMonth") & "-" & rs("lessonDay")) & "</td>" & vbCrLf
            Response.Write "      <td width='6%' align='center'>" & vbCrLf
            If rs("lessonNumber") = 0 Then Response.Write ("不限") Else Response.Write rs("lessonNumber") & "</td>" & vbCrLf
            Response.Write "      <td width='10%' align='center'>" & rs("ClassroomName") & "</td>" & vbCrLf

            Response.Write "      <td width='8%' align='center'>" & rs("UserName") & "</td>" & vbCrLf
            Response.Write "      <td width='8%' align='center'>" & vbCrLf
            'If rs("UserType") = 1 Then Response.Write ("教师") Else Response.Write ("学生") & "</td>" & vbCrLf
            If rs("UserClass") = "" Or IsNull(rs("UserClass")) Then
                    Response.Write "未填</td>" & vbCrLf
            Else
                    Response.Write rs("UserClass") & "</td>" & vbCrLf
            End If
            Response.Write "      <td width='16%' align='center'>" & rs("RegisterTime") & "</td>" & vbCrLf
            Response.Write "      <td width='6%' align='center'>" & vbCrLf
            If rs("Used") = 0 Then Response.Write ("×") Else Response.Write ("√") & "</td>" & vbCrLf
            Response.Write "      <td width='6%' align='center'>" & vbCrLf
            If rs("Used") = 2 Then Response.Write ("√") Else Response.Write ("×") & "</td>" & vbCrLf
            Response.Write "      <td width='14%' align='center'>" & vbCrLf
            'if rs("Used")= 1 then response.Write("2") else response.Write("3")
            Select Case rs("Used")
            Case "0"
                Response.Write "<a href='" & strFileName & "&page=" & CurrentPage & "&UsedTpye=1&id=" & rs("ID") & "&EquipmentID=" & rs("EquipmentID") & "&ilessonYear=" & rs("lessonYear") & "&ilessonMonth=" & rs("lessonMonth") & "&ilessonDay=" & rs("lessonDay") & "&ilessonNumber=" & rs("lessonNumber") & "' onClick=""return confirm('如果有其他用户同一时间想使用此设备的，将被删除！确定仅给此用户使用权吗？');"">确认</a> " & vbCrLf
                '如果有其他用户同一时间想使用此设备的，将被删除！可以改进在此列出其他用户。
            Case "1"
                Response.Write "<a href='" & strFileName & "&page=" & CurrentPage & "&UsedTpye=2&id=" & rs("ID") & "'>已使用</a> " & vbCrLf
            Case Else
                Response.Write ("&nbsp;&nbsp;&nbsp;&nbsp;")
            End Select
            Response.Write "<a href='Admin_ManageRecord.asp?Action=UsedDetail&id=" & rs("ID") & "'>查看</a> " & vbCrLf
            Response.Write "<a href='Admin_ManageRecord.asp?Action=Del&id=" & rs("ID") & "' onClick=""return confirm('确定要删除此项吗？');"">删除</a> " & vbCrLf
            Response.Write "      </td></tr>" & vbCrLf
            i = i + 1
            If i > MaxPerPage Then Exit Do
            rs.MoveNext
        Loop
    End If
    Response.Write "  </table>" & vbCrLf
    Response.Write "<table width='100%' border='0' cellpadding='0' cellspacing='0'>"
    Response.Write "  <tr>"
    Response.Write "    <td width='130' height='30'><input name='chkAll' type='checkbox' id='chkAll' onclick='CheckAll(this.form)' value='checkbox'>选中所有的记录</td><td>"
    
    Response.Write "<input name='submit2' type='submit' id='submit2' onClick=""document.myform.Action.value='SetEnrol'"" value='确认选定的登记记录' "
    Response.Write ">&nbsp;&nbsp;"
        
    Response.Write "<input name='submit1' type='submit' id='submit1' onClick=""document.myform.Action.value='SetUsed'"" value='确认选定的使用记录' "
    Response.Write ">&nbsp;&nbsp;"
    
    Response.Write "<input type='submit' value='删除选定的记录' name='submit' onClick=""document.myform.Action.value='Del'"" "
    Response.Write ">"
    Response.Write "<input name='Action' type='hidden' id='Action' value=''>"
    Response.Write "  </td></tr>"
    Response.Write "</form>"
    Response.Write "</table>"
    If totalPut > 0 Then
        Response.Write ShowPage(strFileName, totalPut, MaxPerPage, CurrentPage, True, True, "条记录", True)
    End If
    Response.Write ShowSearch()
End Sub

Function ShowWeek(ByVal strDay)
    Dim DatediffNum, arrWeek
    If Not IsDate(strDay) Then
        ShowWeek = "错误的日期"
        Exit Function
    End If
    DatediffNum = DateDiff("w", StartDay, strDay)
    If DatediffNum < 0 Then
        ShowWeek = "错误的日期"
        Exit Function
    End If
    If Weekday(StartDay) < 7 And (Weekday(StartDay) > Weekday(strDay) Or Weekday(strDay) = 7) Then
        DatediffNum = DatediffNum + 1
    End If
    arrWeek = Split("一,二,三,四,五,六,日", ",")
    ShowWeek = "<div title='" & strDay & "'>第" & DatediffNum + 1 & "周 星期" & arrWeek(Weekday(strDay) - 1) & "</div>"
End Function

Sub SetProperty()
    Dim sqlProperty, rsProperty, ID
    ID = Trim(Request("ID"))
    If IsValidID(ID) = False Then
        ID = ""
    End If

    If ID = "" Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>请指定记录ID</li>"
    End If
    If Action = "" Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>参数不足！</li>"
    End If
    If FoundErr = True Then
        Exit Sub
    End If
    If InStr(ID, ",") > 0 Then
        sqlProperty = "select * from PE_UsedDetail where ID in (" & ID & ")"
    Else
        sqlProperty = "select * from PE_UsedDetail where ID=" & ID
    End If
    Set rsProperty = Server.CreateObject("ADODB.Recordset")
    rsProperty.Open sqlProperty, Conn, 1, 3
    Dim ReplyNumCount, rsReplyNum
    Do While Not rsProperty.EOF
        Select Case Action
        Case "Del"
            '已使用记录也将被删除
            rsProperty.Delete
        Case "SetEnrol"
            If rsProperty("Used") = 0 Then rsProperty("Used") = 1
            'Conn.Execute ("update PE_UsedDetail set Used=1 where id=" & rsProperty("ID") & " and Used=0")
            Dim sqlSame, rsSame
            Set rsSame = Server.CreateObject("adodb.recordset")
            sqlSame = "select * from PE_UsedDetail where id<>" & rsProperty("ID") & " and Used=0 and lessonYear=" & rsProperty("lessonYear") & " and lessonMonth=" & rsProperty("lessonMonth") & " and lessonDay=" & rsProperty("lessonDay") & " and lessonNumber=" & rsProperty("lessonNumber") & " and EquipmentID =" & rsProperty("EquipmentID")
            rsSame.Open sqlSame, Conn, 1, 3
            Do While Not rsSame.EOF
                rsSame.Delete
                '此处可以提示被删除的记录列表
                rsSame.Update
                rsSame.MoveNext
            Loop
            rsSame.Close
            Set rsSame = Nothing
        Case "SetUsed"
            If rsProperty("Used") = 1 Then rsProperty("Used") = 2
            'Conn.Execute ("update PE_UsedDetail set Used=2 where id=" & PE_CLng(Request("id")) & "")
        End Select
        
        rsProperty.Update
        rsProperty.MoveNext
    Loop
    rsProperty.Close
    Set rsProperty = Nothing
    

    Call CloseConn
    If FoundErr = True Then
        Exit Sub
    End If
    Response.Redirect ComeUrl
End Sub

Function ShowSearch()
    Response.Write "    <form method='post' action='Admin_ManageRecord.asp' name='form1'>" & vbCrLf
    Response.Write "      <table width='100%' border='0' cellspacing='1' cellpadding='1' class='border' align='center'>" & vbCrLf
    Response.Write "        <tr class='tdbg'>     " & vbCrLf
    Response.Write "          <td colspan='10'> " & vbCrLf
    Response.Write "            <div align='left'>使用人名字关键字：" & vbCrLf
    Response.Write "              <input type='text' name='Man' size='12' value='" & Man & "'>&nbsp;使用时间：  " & vbCrLf
    Response.Write "              <select name='lessonYear'>" & vbCrLf
    Dim i
    For i = 2005 To 2012
        If i = Year(Date) Then
            Response.Write "<option value='" & i & "' selected>" & i & "</option>"
        Else
            Response.Write "<option value='" & i & "'>" & i & "</option>"
        End If
    Next
    Response.Write "              </select>年" & vbCrLf
    Response.Write "              <select name='lessonMonth'>" & vbCrLf
    Response.Write "                <option value='0' selected>不限</option>" & vbCrLf
    For i = 1 To 12
        Response.Write "<option value='" & i & "'>" & i & "</option>"
    Next
    Response.Write "              </select>月" & vbCrLf
    Response.Write "              <select name='lessonDay'>" & vbCrLf
    Response.Write "                <option value='0'>不限</option>" & vbCrLf
    For i = 1 To 31
        Response.Write "<option value='" & i & "'>" & i & "</option>"
    Next
    Response.Write "              </select>" & vbCrLf
    Response.Write "              日　第          " & vbCrLf
    Response.Write "              <select name='lessonNumber'>" & vbCrLf
    Response.Write "                <option value='0'>不限</option>" & vbCrLf
    Response.Write "                <option value='1'>1</option>" & vbCrLf
    Response.Write "                <option value='2'>2</option>" & vbCrLf
    Response.Write "                <option value='3'>3</option>" & vbCrLf
    Response.Write "                <option value='4'>4</option>" & vbCrLf
    Response.Write "                <option value='5'>5</option>" & vbCrLf
    Response.Write "                <option value='6'>6</option>" & vbCrLf
    Response.Write "                <option value='7'>7</option>" & vbCrLf
    Response.Write "                <option value='8'>8</option>" & vbCrLf
    Response.Write "              </select>" & vbCrLf
    Response.Write "              节课　使用教室：" & vbCrLf
    Response.Write "              <select name='ClassroomID'>" & vbCrLf
    Response.Write "                <option value='0'>全部分类</option>" & vbCrLf
    Response.Write "Response.Write '' & vbCrLf" & vbCrLf
    Response.Write "" & vbCrLf
    Call selectTreeList(0, 0)
    Response.Write "              </select>" & vbCrLf
    Response.Write "              <input type='submit' name='Submit' value='搜索'>" & vbCrLf
    Response.Write "            </div>" & vbCrLf
    Response.Write "          </td>" & vbCrLf
    Response.Write "        " & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "      </table>" & vbCrLf
    Response.Write "    </form>" & vbCrLf
End Function

Sub UsedDetail()
    Dim rs, sql
    Set rs = Server.CreateObject("adodb.recordset")
    sql = "select D.UserName,D.UserType,D.UserYear,D.LessonInfo,D.UserClass,D.lessonYear, D.lessonMonth, D.lessonDay, D.lessonNumber, D.RegisterTime,D.RegisterIP, F.EquipmentName, F.EquipmentSituation, C.ClassroomName from PE_UsedDetail D left join ( PE_Equipment F left join  PE_Classroom C on F.ClassroomID = C.ID ) on D.EquipmentID = F.ID where D.id=" & PE_CLng(Request("id"))
    rs.Open sql, Conn, 1, 1
    Response.Write "    <br><table width='100%' class='border' border='0' cellspacing='1' cellpadding='1' align='center'>" & vbCrLf
    Response.Write "      <tr class='title'> " & vbCrLf
    Response.Write "        <td colspan='2' class='title'> " & vbCrLf
    Response.Write "          <div align='center'><b>记 录 详 情 显 示</b></div>" & vbCrLf
    Response.Write "        </td>" & vbCrLf
    Response.Write "      </tr>" & vbCrLf
    Response.Write "      <tr class='tdbg'> " & vbCrLf
    Response.Write "        <td width='30%' nowrap align='left'> " & vbCrLf
    Response.Write "          <div align='left'><b>使用人：</b></div>" & vbCrLf
    Response.Write "        </td>" & vbCrLf
    Response.Write "        <td width='70%'>" & rs("UserName") & "</td>" & vbCrLf
    Response.Write "      </tr>" & vbCrLf
    Response.Write "      <tr class='tdbg'> " & vbCrLf
    Response.Write "        <td width='30%' nowrap align='left'> " & vbCrLf
    Response.Write "          <b>身份：</b></td><td width='70%'>" & vbCrLf
    If rs("UserType") = 1 Then Response.Write ("教师") Else Response.Write ("学生")
    Response.Write "          　</td>" & vbCrLf
    Response.Write "      </tr>" & vbCrLf
    Response.Write "      <tr class='tdbg'> " & vbCrLf
    Response.Write "        <td width='30%' nowrap align='left'> " & vbCrLf
    Response.Write "          <b>班级：</b></td>" & vbCrLf
    Response.Write "        <td width='70%'>" & vbCrLf
    If rs("UserType") = 1 Then Response.Write ("教师") Else Response.Write rs("UserYear") & "届/" & rs("UserClass") & "班"
    Response.Write "        </td>" & vbCrLf
    Response.Write "      </tr>" & vbCrLf
    Response.Write "      <tr class='tdbg'> " & vbCrLf
    Response.Write "        <td width='30%' nowrap align='left'> " & vbCrLf
    Response.Write "          <b>使用具体时间：</b></td>" & vbCrLf
    Response.Write "        <td width='70%'>" & rs("lessonYear") & "年" & rs("lessonMonth") & "月" & rs("lessonDay") & "日 第" & rs("lessonNumber") & "节课" & vbCrLf
    Response.Write "         </td>" & vbCrLf
    Response.Write "      </tr>" & vbCrLf
    Response.Write "      <tr class='tdbg'> " & vbCrLf
    Response.Write "        <td width='30%' nowrap align='left'> " & vbCrLf
    Response.Write "          <b>使用设备名：</b></td>" & vbCrLf
    Response.Write "        <td width='70%'>" & rs("EquipmentName") & "</td>" & vbCrLf
    Response.Write "      </tr>" & vbCrLf
    Response.Write "      <tr class='tdbg'> " & vbCrLf
    Response.Write "        <td width='30%' nowrap align='left'> " & vbCrLf
    Response.Write "          <b>使用设备所属教室：</b></td>" & vbCrLf
    Response.Write "        <td width='70%'>" & rs("ClassroomName") & "</td></tr>" & vbCrLf
    Response.Write "      <tr class='tdbg'> " & vbCrLf
    Response.Write "        <td width='30%' nowrap align='left'> " & vbCrLf
    Response.Write "          <b>设备状态：</b></td>" & vbCrLf
    Response.Write "        <td width='70%'>" & vbCrLf
    If rs("EquipmentSituation") = 1 Then Response.Write ("正常") Else Response.Write ("不正常")
    Response.Write "          　</td>" & vbCrLf
    Response.Write "      </tr>" & vbCrLf
    Response.Write "      <tr class='tdbg'> " & vbCrLf
    Response.Write "        <td width='30%' nowrap align='left'> " & vbCrLf
    Response.Write "          <b>课程信息：</b></td>" & vbCrLf
    If rs("LessonInfo") <> "" Then
        Response.Write "        <td width='70%'>" & rs("LessonInfo") & "</td>" & vbCrLf
    Else
        Response.Write "        <td width='70%'>未填</td>" & vbCrLf
    End If
    Response.Write "      </tr>" & vbCrLf
    Response.Write "      <tr class='tdbg'> " & vbCrLf
    Response.Write "        <td width='30%' nowrap align='left'> " & vbCrLf
    Response.Write "          <b>登记时间：</b></td>" & vbCrLf
    Response.Write "        <td width='70%'>" & rs("RegisterTime") & "</td>" & vbCrLf
    Response.Write "      </tr>" & vbCrLf
    Response.Write "      <tr class='tdbg'> " & vbCrLf
    Response.Write "        <td width='30%' nowrap align='left'> " & vbCrLf
    Response.Write "          <b>登记IP：</b></td>" & vbCrLf
    Response.Write "        <td width='70%'>" & rs("RegisterIP") & "</td>" & vbCrLf
    Response.Write "      </tr>" & vbCrLf
    Response.Write "      <tr class='tdbg'> " & vbCrLf
    Response.Write "        <td colspan='2' nowrap> " & vbCrLf
    Response.Write "          <div align='center'>" & vbCrLf
    Response.Write "            <input type='button' name='Submit2' value='返回' onClick=""window.location='Admin_ManageRecord.asp';"">" & vbCrLf
    Response.Write "          </div>" & vbCrLf
    Response.Write "        </td>" & vbCrLf
    Response.Write "      </tr>" & vbCrLf
    Response.Write "    </table>" & vbCrLf
End Sub


Function selectTreeList(i, deep)
    Dim sql
    Dim rs
    Dim tempi
    Dim rsID, rsName
    Set rs = Server.CreateObject("adodb.recordset")
    sql = "select * from PE_Classroom where fatherID=" & i
    rs.Open sql, Conn, 1, 1
    If rs.EOF Then
        Exit Function
    Else
        Do While Not rs.EOF
            rsID = rs("id")
            rsName = rs("ClassroomName")
            Response.Write "<option value=" & rsID
            If rsID = ClassroomID Then Response.Write " selected"
            Response.Write ">"
            For tempi = 1 To deep
                Response.Write "&nbsp;"
            Next
            Response.Write rsName & "</option>"
            Call selectTreeList(rsID, deep + 1)
            rs.MoveNext
        Loop
    End If
End Function

Function getSort(i)
    Dim rs, sql
    Set rs = Server.CreateObject("adodb.recordset")
    sql = "select * from PE_Classroom where fatherID=" & i
    rs.Open sql, Conn, 1, 1
    Do While Not rs.EOF
        strSort = strSort & "," & rs("id")
        Call getSort(rs("id"))
        rs.MoveNext
    Loop
End Function

Sub AdminEnrol()
    Response.Write "<form name='myform' method='post' action='Admin_ManageRecord.asp?action=ShowEnrolResult'>" & vbCrLf
    Dim str1, str2, str3, str4, str5, str6, str7
    Dim str11, str22, str33, str44, str55, str66, str77
    Dim i, j, Num
    If Weekday(StartDay) < 7 Then
        Num = 7 - Weekday(StartDay)
    Else
        Num = 7
    End If
    i = 2
    Select Case Weekday(StartDay)
        Case 2
            str1 = "<td align='center' id='sstr" & TransformDay(StartDay, 1) & "' onmouseout=""this.className='tdbg'"" onmouseover=""this.className='tdbgmouseover'"" width='70' height='25'><a class='Date' href='#' onclick=""window.open('Admin_SelectTime.asp?ShowStyle=0&DaySelect=str" & TransformDay(StartDay, 1) & "', 'strLesson', 'width=400,height=100,toolbar=no,menubar=no, scrollbars=no, resizable=no, location=no, status=no');"">" & TransformDay(StartDay, 2) & "</a></td>"
            str11 = TransformDay(StartDay, 1)
            str22 = TransformDay(DateAdd("d", 1, CDate(StartDay)), 1)
            str2 = "<td align='center' id='sstr" & TransformDay(DateAdd("d", 1, CDate(StartDay)), 1) & "' onmouseout=""this.className='tdbg'"" onmouseover=""this.className='tdbgmouseover'"" width='70' height='25'><a class='Date' href='#' onclick=""window.open('Admin_SelectTime.asp?ShowStyle=0&DaySelect=str" & TransformDay(DateAdd("d", 1, CDate(StartDay)), 1) & "', 'strLesson', 'width=400,height=100,toolbar=no,menubar=no, scrollbars=no, resizable=no, location=no, status=no');"">" & TransformDay(DateAdd("d", 1, CDate(StartDay)), 2) & "</a></td>"
            str33 = TransformDay(DateAdd("d", 2, CDate(StartDay)), 1)
            str3 = "<td align='center' id='sstr" & TransformDay(DateAdd("d", 2, CDate(StartDay)), 1) & "' onmouseout=""this.className='tdbg'"" onmouseover=""this.className='tdbgmouseover'"" width='70' height='25'><a class='Date' href='#' onclick=""window.open('Admin_SelectTime.asp?ShowStyle=0&DaySelect=str" & TransformDay(DateAdd("d", 2, CDate(StartDay)), 1) & "', 'strLesson', 'width=400,height=100,toolbar=no,menubar=no, scrollbars=no, resizable=no, location=no, status=no');"">" & TransformDay(DateAdd("d", 2, CDate(StartDay)), 2) & "</a></td>"
            str44 = TransformDay(DateAdd("d", 3, CDate(StartDay)), 1)
            str4 = "<td align='center' id='sstr" & TransformDay(DateAdd("d", 3, CDate(StartDay)), 1) & "' onmouseout=""this.className='tdbg'"" onmouseover=""this.className='tdbgmouseover'"" width='70' height='25'><a class='Date' href='#' onclick=""window.open('Admin_SelectTime.asp?ShowStyle=0&DaySelect=str" & TransformDay(DateAdd("d", 3, CDate(StartDay)), 1) & "', 'strLesson', 'width=400,height=100,toolbar=no,menubar=no, scrollbars=no, resizable=no, location=no, status=no');"">" & TransformDay(DateAdd("d", 3, CDate(StartDay)), 2) & "</a></td>"
            str55 = TransformDay(DateAdd("d", 4, CDate(StartDay)), 1)
            str5 = "<td align='center' id='sstr" & TransformDay(DateAdd("d", 4, CDate(StartDay)), 1) & "' onmouseout=""this.className='tdbg'"" onmouseover=""this.className='tdbgmouseover'"" width='70' height='25'><a class='Date' href='#' onclick=""window.open('Admin_SelectTime.asp?ShowStyle=0&DaySelect=str" & TransformDay(DateAdd("d", 4, CDate(StartDay)), 1) & "', 'strLesson', 'width=400,height=100,toolbar=no,menubar=no, scrollbars=no, resizable=no, location=no, status=no');"">" & TransformDay(DateAdd("d", 4, CDate(StartDay)), 2) & "</a></td>"
            str66 = TransformDay(DateAdd("d", 5, CDate(StartDay)), 1)
            str6 = "<td align='center' id='sstr" & TransformDay(DateAdd("d", 5, CDate(StartDay)), 1) & "' onmouseout=""this.className='tdbg'"" onmouseover=""this.className='tdbgmouseover'"" width='70' height='25'><a class='Date' href='#' onclick=""window.open('Admin_SelectTime.asp?ShowStyle=0&DaySelect=str" & TransformDay(DateAdd("d", 5, CDate(StartDay)), 1) & "', 'strLesson', 'width=400,height=100,toolbar=no,menubar=no, scrollbars=no, resizable=no, location=no, status=no');"">" & TransformDay(DateAdd("d", 5, CDate(StartDay)), 2) & "</a></td>"
            str77 = ""
            str7 = "<td>&nbsp;&nbsp;</td>"
        Case 3
            str11 = ""
            str1 = "<td>&nbsp;&nbsp;</td>"
            str2 = "<td align='center' id='sstr" & TransformDay(StartDay, 1) & "' onmouseout=""this.className='tdbg'"" onmouseover=""this.className='tdbgmouseover'"" width='70' height='25'><a class='Date' href='#' onclick=""window.open('Admin_SelectTime.asp?ShowStyle=0&DaySelect=str" & TransformDay(StartDay, 1) & "', 'strLesson', 'width=400,height=100,toolbar=no,menubar=no, scrollbars=no, resizable=no, location=no, status=no');"">" & TransformDay(StartDay, 2) & "</a></td>"
            str22 = TransformDay(StartDay, 1)
            str33 = TransformDay(DateAdd("d", 1, CDate(StartDay)), 1)
            str3 = "<td align='center' id='sstr" & TransformDay(DateAdd("d", 1, CDate(StartDay)), 1) & "' onmouseout=""this.className='tdbg'"" onmouseover=""this.className='tdbgmouseover'"" width='70' height='25'><a class='Date' href='#' onclick=""window.open('Admin_SelectTime.asp?ShowStyle=0&DaySelect=str" & TransformDay(DateAdd("d", 1, CDate(StartDay)), 1) & "', 'strLesson', 'width=400,height=100,toolbar=no,menubar=no, scrollbars=no, resizable=no, location=no, status=no');"">" & TransformDay(DateAdd("d", 1, CDate(StartDay)), 2) & "</a></td>"
            str44 = TransformDay(DateAdd("d", 2, CDate(StartDay)), 1)
            str4 = "<td align='center' id='sstr" & TransformDay(DateAdd("d", 2, CDate(StartDay)), 1) & "' onmouseout=""this.className='tdbg'"" onmouseover=""this.className='tdbgmouseover'"" width='70' height='25'><a class='Date' href='#' onclick=""window.open('Admin_SelectTime.asp?ShowStyle=0&DaySelect=str" & TransformDay(DateAdd("d", 2, CDate(StartDay)), 1) & "', 'strLesson', 'width=400,height=100,toolbar=no,menubar=no, scrollbars=no, resizable=no, location=no, status=no');"">" & TransformDay(DateAdd("d", 2, CDate(StartDay)), 2) & "</a></td>"
            str55 = TransformDay(DateAdd("d", 3, CDate(StartDay)), 1)
            str5 = "<td align='center' id='sstr" & TransformDay(DateAdd("d", 3, CDate(StartDay)), 1) & "' onmouseout=""this.className='tdbg'"" onmouseover=""this.className='tdbgmouseover'"" width='70' height='25'><a class='Date' href='#' onclick=""window.open('Admin_SelectTime.asp?ShowStyle=0&DaySelect=str" & TransformDay(DateAdd("d", 3, CDate(StartDay)), 1) & "', 'strLesson', 'width=400,height=100,toolbar=no,menubar=no, scrollbars=no, resizable=no, location=no, status=no');"">" & TransformDay(DateAdd("d", 3, CDate(StartDay)), 2) & "</a></td>"
            str66 = TransformDay(DateAdd("d", 4, CDate(StartDay)), 1)
            str6 = "<td align='center' id='sstr" & TransformDay(DateAdd("d", 4, CDate(StartDay)), 1) & "' onmouseout=""this.className='tdbg'"" onmouseover=""this.className='tdbgmouseover'"" width='70' height='25'><a class='Date' href='#' onclick=""window.open('Admin_SelectTime.asp?ShowStyle=0&DaySelect=str" & TransformDay(DateAdd("d", 4, CDate(StartDay)), 1) & "', 'strLesson', 'width=400,height=100,toolbar=no,menubar=no, scrollbars=no, resizable=no, location=no, status=no');"">" & TransformDay(DateAdd("d", 4, CDate(StartDay)), 2) & "</a></td>"
            str77 = ""
            str7 = "<td>&nbsp;&nbsp;</td>"
            
        Case 4
            str11 = ""
            str1 = "<td>&nbsp;&nbsp;</td>"
            str22 = ""
            str2 = "<td>&nbsp;&nbsp;</td>"
            str3 = "<td align='center' id='sstr" & TransformDay(StartDay, 1) & "' onmouseout=""this.className='tdbg'"" onmouseover=""this.className='tdbgmouseover'"" width='70' height='25'><a class='Date' href='#' onclick=""window.open('Admin_SelectTime.asp?ShowStyle=0&DaySelect=str" & TransformDay(StartDay, 1) & "', 'strLesson', 'width=400,height=100,toolbar=no,menubar=no, scrollbars=no, resizable=no, location=no, status=no');"">" & TransformDay(StartDay, 2) & "</a></td>"
            str33 = TransformDay(StartDay, 1)
            str44 = TransformDay(DateAdd("d", 1, CDate(StartDay)), 1)
            str4 = "<td align='center' id='sstr" & TransformDay(DateAdd("d", 1, CDate(StartDay)), 1) & "' onmouseout=""this.className='tdbg'"" onmouseover=""this.className='tdbgmouseover'"" width='70' height='25'><a class='Date' href='#' onclick=""window.open('Admin_SelectTime.asp?ShowStyle=0&DaySelect=str" & TransformDay(DateAdd("d", 1, CDate(StartDay)), 1) & "', 'strLesson', 'width=400,height=100,toolbar=no,menubar=no, scrollbars=no, resizable=no, location=no, status=no');"">" & TransformDay(DateAdd("d", 1, CDate(StartDay)), 2) & "</a></td>"
            str55 = TransformDay(DateAdd("d", 2, CDate(StartDay)), 1)
            str5 = "<td align='center' id='sstr" & TransformDay(DateAdd("d", 2, CDate(StartDay)), 1) & "' onmouseout=""this.className='tdbg'"" onmouseover=""this.className='tdbgmouseover'"" width='70' height='25'><a class='Date' href='#' onclick=""window.open('Admin_SelectTime.asp?ShowStyle=0&DaySelect=str" & TransformDay(DateAdd("d", 2, CDate(StartDay)), 1) & "', 'strLesson', 'width=400,height=100,toolbar=no,menubar=no, scrollbars=no, resizable=no, location=no, status=no');"">" & TransformDay(DateAdd("d", 2, CDate(StartDay)), 2) & "</a></td>"
            str66 = TransformDay(DateAdd("d", 3, CDate(StartDay)), 1)
            str6 = "<td align='center' id='sstr" & TransformDay(DateAdd("d", 3, CDate(StartDay)), 1) & "' onmouseout=""this.className='tdbg'"" onmouseover=""this.className='tdbgmouseover'"" width='70' height='25'><a class='Date' href='#' onclick=""window.open('Admin_SelectTime.asp?ShowStyle=0&DaySelect=str" & TransformDay(DateAdd("d", 3, CDate(StartDay)), 1) & "', 'strLesson', 'width=400,height=100,toolbar=no,menubar=no, scrollbars=no, resizable=no, location=no, status=no');"">" & TransformDay(DateAdd("d", 3, CDate(StartDay)), 2) & "</a></td>"
            str77 = ""
            str7 = "<td>&nbsp;&nbsp;</td>"
        Case 5
            str11 = ""
            str1 = "<td>&nbsp;&nbsp;</td>"
            str22 = ""
            str2 = "<td>&nbsp;&nbsp;</td>"
            str33 = ""
            str3 = "<td>&nbsp;&nbsp;</td>"
            str4 = "<td align='center' id='sstr" & TransformDay(StartDay, 1) & "' onmouseout=""this.className='tdbg'"" onmouseover=""this.className='tdbgmouseover'"" width='70' height='25'><a class='Date' href='#' onclick=""window.open('Admin_SelectTime.asp?ShowStyle=0&DaySelect=str" & TransformDay(StartDay, 1) & "', 'strLesson', 'width=400,height=100,toolbar=no,menubar=no, scrollbars=no, resizable=no, location=no, status=no');"">" & TransformDay(StartDay, 2) & "</a></td>"
            str44 = TransformDay(StartDay, 1)
            str55 = TransformDay(DateAdd("d", 1, CDate(StartDay)), 1)
            str5 = "<td align='center' id='sstr" & TransformDay(DateAdd("d", 1, CDate(StartDay)), 1) & "' onmouseout=""this.className='tdbg'"" onmouseover=""this.className='tdbgmouseover'"" width='70' height='25'><a class='Date' href='#' onclick=""window.open('Admin_SelectTime.asp?ShowStyle=0&DaySelect=str" & TransformDay(DateAdd("d", 1, CDate(StartDay)), 1) & "', 'strLesson', 'width=400,height=100,toolbar=no,menubar=no, scrollbars=no, resizable=no, location=no, status=no');"">" & TransformDay(DateAdd("d", 1, CDate(StartDay)), 2) & "</a></td>"
            str66 = TransformDay(DateAdd("d", 2, CDate(StartDay)), 1)
            str6 = "<td align='center' id='sstr" & TransformDay(DateAdd("d", 2, CDate(StartDay)), 1) & "' onmouseout=""this.className='tdbg'"" onmouseover=""this.className='tdbgmouseover'"" width='70' height='25'><a class='Date' href='#' onclick=""window.open('Admin_SelectTime.asp?ShowStyle=0&DaySelect=str" & TransformDay(DateAdd("d", 2, CDate(StartDay)), 1) & "', 'strLesson', 'width=400,height=100,toolbar=no,menubar=no, scrollbars=no, resizable=no, location=no, status=no');"">" & TransformDay(DateAdd("d", 2, CDate(StartDay)), 2) & "</a></td>"
            str77 = ""
            str7 = "<td>&nbsp;&nbsp;</td>"
        Case 6
            str11 = ""
            str1 = "<td>&nbsp;&nbsp;</td>"
            str22 = ""
            str2 = "<td>&nbsp;&nbsp;</td>"
            str33 = ""
            str3 = "<td>&nbsp;&nbsp;</td>"
            str44 = ""
            str4 = "<td>&nbsp;&nbsp;</td>"
            str5 = "<td align='center' id='sstr" & TransformDay(StartDay, 1) & "' onmouseout=""this.className='tdbg'"" onmouseover=""this.className='tdbgmouseover'"" width='70' height='25'><a class='Date' href='#' onclick=""window.open('Admin_SelectTime.asp?ShowStyle=0&DaySelect=str" & TransformDay(StartDay, 1) & "', 'strLesson', 'width=400,height=100,toolbar=no,menubar=no, scrollbars=no, resizable=no, location=no, status=no');"">" & TransformDay(StartDay, 2) & "</a></td>"
            str55 = TransformDay(StartDay, 1)
            str66 = TransformDay(DateAdd("d", 1, CDate(StartDay)), 1)
            str6 = "<td align='center' id='sstr" & TransformDay(DateAdd("d", 1, CDate(StartDay)), 1) & "' onmouseout=""this.className='tdbg'"" onmouseover=""this.className='tdbgmouseover'"" width='70' height='25'><a class='Date' href='#' onclick=""window.open('Admin_SelectTime.asp?ShowStyle=0&DaySelect=str" & TransformDay(DateAdd("d", 1, CDate(StartDay)), 1) & "', 'strLesson', 'width=400,height=100,toolbar=no,menubar=no, scrollbars=no, resizable=no, location=no, status=no');"">" & TransformDay(DateAdd("d", 1, CDate(StartDay)), 2) & "</a></td>"
            str77 = ""
            str7 = "<td>&nbsp;&nbsp;</td>"
        Case 7
            str11 = ""
            str1 = "<td>&nbsp;&nbsp;</td>"
            str22 = ""
            str2 = "<td>&nbsp;&nbsp;</td>"
            str33 = ""
            str3 = "<td>&nbsp;&nbsp;</td>"
            str44 = ""
            str4 = "<td>&nbsp;&nbsp;</td>"
            str55 = ""
            str5 = "<td>&nbsp;&nbsp;</td>"
            str6 = "<td align='center' id='sstr" & TransformDay(StartDay, 1) & "' onmouseout=""this.className='tdbg'"" onmouseover=""this.className='tdbgmouseover'"" width='70' height='25'><a class='Date' href='#' onclick=""window.open('Admin_SelectTime.asp?ShowStyle=0&DaySelect=str" & TransformDay(StartDay, 1) & "', 'strLesson', 'width=400,height=100,toolbar=no,menubar=no, scrollbars=no, resizable=no, location=no, status=no');"">" & TransformDay(StartDay, 2) & "</a></td>"
            str66 = TransformDay(StartDay, 1)
            str77 = ""
            str7 = "<td>&nbsp;&nbsp;</td>"
        Case 1
            str11 = TransformDay(DateAdd("d", 1, CDate(StartDay)), 1)
            str1 = "<td align='center' id='sstr" & TransformDay(DateAdd("d", 1, CDate(StartDay)), 1) & "' onmouseout=""this.className='tdbg'"" onmouseover=""this.className='tdbgmouseover'"" width='70' height='25'><a class='Date' href='#' onclick=""window.open('Admin_SelectTime.asp?ShowStyle=0&DaySelect=str" & TransformDay(DateAdd("d", 1, CDate(StartDay)), 1) & "', 'strLesson', 'width=400,height=100,toolbar=no,menubar=no, scrollbars=no, resizable=no, location=no, status=no');"">" & TransformDay(DateAdd("d", 1, CDate(StartDay)), 2) & "</a></td>"
            str22 = TransformDay(DateAdd("d", 2, CDate(StartDay)), 1)
            str2 = "<td align='center' id='sstr" & TransformDay(DateAdd("d", 2, CDate(StartDay)), 1) & "' onmouseout=""this.className='tdbg'"" onmouseover=""this.className='tdbgmouseover'"" width='70' height='25'><a class='Date' href='#' onclick=""window.open('Admin_SelectTime.asp?ShowStyle=0&DaySelect=str" & TransformDay(DateAdd("d", 2, CDate(StartDay)), 1) & "', 'strLesson', 'width=400,height=100,toolbar=no,menubar=no, scrollbars=no, resizable=no, location=no, status=no');"">" & TransformDay(DateAdd("d", 2, CDate(StartDay)), 2) & "</a></td>"
            str33 = TransformDay(DateAdd("d", 3, CDate(StartDay)), 1)
            str3 = "<td align='center' id='sstr" & TransformDay(DateAdd("d", 3, CDate(StartDay)), 1) & "' onmouseout=""this.className='tdbg'"" onmouseover=""this.className='tdbgmouseover'"" width='70' height='25'><a class='Date' href='#' onclick=""window.open('Admin_SelectTime.asp?ShowStyle=0&DaySelect=str" & TransformDay(DateAdd("d", 3, CDate(StartDay)), 1) & "', 'strLesson', 'width=400,height=100,toolbar=no,menubar=no, scrollbars=no, resizable=no, location=no, status=no');"">" & TransformDay(DateAdd("d", 3, CDate(StartDay)), 2) & "</a></td>"
            str44 = TransformDay(DateAdd("d", 4, CDate(StartDay)), 1)
            str4 = "<td align='center' id='sstr" & TransformDay(DateAdd("d", 4, CDate(StartDay)), 1) & "' onmouseout=""this.className='tdbg'"" onmouseover=""this.className='tdbgmouseover'"" width='70' height='25'><a class='Date' href='#' onclick=""window.open('Admin_SelectTime.asp?ShowStyle=0&DaySelect=str" & TransformDay(DateAdd("d", 4, CDate(StartDay)), 1) & "', 'strLesson', 'width=400,height=100,toolbar=no,menubar=no, scrollbars=no, resizable=no, location=no, status=no');"">" & TransformDay(DateAdd("d", 4, CDate(StartDay)), 2) & "</a></td>"
            str55 = TransformDay(DateAdd("d", 5, CDate(StartDay)), 1)
            str5 = "<td align='center' id='sstr" & TransformDay(DateAdd("d", 5, CDate(StartDay)), 1) & "' onmouseout=""this.className='tdbg'"" onmouseover=""this.className='tdbgmouseover'"" width='70' height='25'><a class='Date' href='#' onclick=""window.open('Admin_SelectTime.asp?ShowStyle=0&DaySelect=str" & TransformDay(DateAdd("d", 5, CDate(StartDay)), 1) & "', 'strLesson', 'width=400,height=100,toolbar=no,menubar=no, scrollbars=no, resizable=no, location=no, status=no');"">" & TransformDay(DateAdd("d", 5, CDate(StartDay)), 2) & "</a></td>"
            str66 = TransformDay(DateAdd("d", 6, CDate(StartDay)), 1)
            str6 = "<td align='center' id='sstr" & TransformDay(DateAdd("d", 6, CDate(StartDay)), 1) & "' onmouseout=""this.className='tdbg'"" onmouseover=""this.className='tdbgmouseover'"" width='70' height='25'><a class='Date' href='#' onclick=""window.open('Admin_SelectTime.asp?ShowStyle=0&DaySelect=str" & TransformDay(DateAdd("d", 6, CDate(StartDay)), 1) & "', 'strLesson', 'width=400,height=100,toolbar=no,menubar=no, scrollbars=no, resizable=no, location=no, status=no');"">" & TransformDay(DateAdd("d", 6, CDate(StartDay)), 2) & "</a></td>"
            str7 = "<td align='center' id='sstr" & TransformDay(StartDay, 1) & "' onmouseout=""this.className='tdbg'"" onmouseover=""this.className='tdbgmouseover'"" width='70' height='25'><a class='Date' href='#' onclick=""window.open('Admin_SelectTime.asp?ShowStyle=0&DaySelect=str" & TransformDay(StartDay, 1) & "', 'strLesson', 'width=400,height=100,toolbar=no,menubar=no, scrollbars=no, resizable=no, location=no, status=no');"">" & TransformDay(StartDay, 2) & "</a></td>"
            str77 = TransformDay(StartDay, 1)
    End Select

    'Response.Write "<form name='myform' method='post' action='test6.asp'>" & vbCrLf
    Response.Write "<table align='center' width='740' border='0' align='center' cellpadding='1' cellspacing='1' class='border'>" & vbCrLf
    Response.Write "  <tr class='title'>" & vbCrLf
    Response.Write "    <td colspan='2' align='center'>" & vbCrLf
    Response.Write "      <strong>固定排课给单个老师使用</strong>" & vbCrLf
    Response.Write "    </td>" & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "  <tr class='tdbg'>" & vbCrLf
    Response.Write "    <td width='150'>" & vbCrLf
    Response.Write "        <strong>使用老师：</strong>" & vbCrLf
    Response.Write "    </td>" & vbCrLf
    Response.Write "    <td>" & vbCrLf
    Response.Write "      <input type='text' name='EnrolUserName'>" & vbCrLf
    Response.Write "    </td>" & vbCrLf
    Response.Write "  </tr>" & vbCrLf

    Response.Write "  <tr class='tdbg2'>" & vbCrLf
    Response.Write "    <td width='150'>" & vbCrLf
    Response.Write "        <strong>使用班级：</strong>" & vbCrLf
    Response.Write "    </td>" & vbCrLf
    Response.Write "    <td>" & vbCrLf
    Response.Write "      <input type='text' name='EnrolClass'>" & vbCrLf
    Response.Write "    </td>" & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "  <tr class='tdbg'>" & vbCrLf
    Response.Write "    <td width='150'>" & vbCrLf
    Response.Write "        <strong>课程信息：</strong>" & vbCrLf
    Response.Write "    </td>" & vbCrLf
    Response.Write "    <td>" & vbCrLf
    Response.Write "     <textarea name='LessonInfo' rows='4' cols='70'></textarea>" & vbCrLf
    Response.Write "    </td>" & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "  <tr class='tdbg2'>" & vbCrLf
    Response.Write "    <td width='150'>" & vbCrLf
    Response.Write "        <strong>使用设备：</strong>" & vbCrLf
    Response.Write "    </td>" & vbCrLf
    Response.Write "    <td>" & vbCrLf
    Response.Write "            <div align='left'>" & vbCrLf
    Response.Write "              <select name='EquipmentID'>" & vbCrLf
    Dim sql
    Dim rs
    Dim rsID, rsName
    Set rs = Server.CreateObject("adodb.recordset")
    sql = "select E.ID,E.EquipmentName,C.ClassroomName from PE_Equipment E left join PE_Classroom C on E.ClassroomID=C.ID  order by E.ClassroomID asc,E.id asc"
    rs.Open sql, Conn, 1, 1
    If rs.EOF Then
            Response.Write "<option value=''>请先添加室场设备"
            Response.Write "</option>"
    Else
        Do While Not rs.EOF
            rsID = rs("id")
            rsName = rs("EquipmentName")
            Response.Write "<option value=" & rsID
            Response.Write ">"
            Response.Write rsName & "(" & rs("ClassroomName") & ")</option>"
            rs.MoveNext
        Loop
    End If
    Response.Write "              </select>" & vbCrLf
    Response.Write "            </div>" & vbCrLf
    Response.Write "    </td>" & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "  <tr class='tdbg'>" & vbCrLf
    Response.Write "    <td width='150'>" & vbCrLf
    Response.Write "       <strong> 指定时间：</strong>" & vbCrLf
    Response.Write "        <br><div align='left'><font color='#006600'>注：<br>&nbsp;&nbsp;1、点击单个的日期可以选取当天的课时，支持多选；<br>&nbsp;&nbsp;2、点击左边的周次会选中此周所有日期选取课时；<br>&nbsp;&nbsp;3、点击顶部的星期将选中所有周次的这个星期选取课时；<br>&nbsp;&nbsp;4、选中后皆支持再修改。</font></div>" & vbCrLf
    Response.Write "    </td>" & vbCrLf
    Response.Write "    <td align='left'>" & vbCrLf

    Response.Write "<table align='center' width='580'  border='1' cellspacing='0' cellpadding='0' style='WORD-BREAK: break-all;' class='Date_border'>" & vbCrLf
    Response.Write "  <tr align='center' class='Date_title' height='30'>" & vbCrLf
    Response.Write "    <td>周次</td>" & vbCrLf
    Response.Write "    <td><a class='title' href='#' onclick=""window.open('Admin_SelectTime.asp?ShowStyle=1&DaySelect=str" & TransformDay(DateAdd("d", Num + 1, CDate(StartDay)), 1) & "', 'strLesson', 'width=400,height=100,toolbar=no,menubar=no, scrollbars=no, resizable=no, location=no, status=no');"">日</a></td>" & vbCrLf
    Response.Write "    <td><a class='title' href='#' onclick=""window.open('Admin_SelectTime.asp?ShowStyle=1&DaySelect=str" & TransformDay(DateAdd("d", Num + 2, CDate(StartDay)), 1) & "', 'strLesson', 'width=400,height=100,toolbar=no,menubar=no, scrollbars=no, resizable=no, location=no, status=no');"">一</a></td>" & vbCrLf
    Response.Write "    <td><a class='title' href='#' onclick=""window.open('Admin_SelectTime.asp?ShowStyle=1&DaySelect=str" & TransformDay(DateAdd("d", Num + 3, CDate(StartDay)), 1) & "', 'strLesson', 'width=400,height=100,toolbar=no,menubar=no, scrollbars=no, resizable=no, location=no, status=no');"">二</a></td>" & vbCrLf
    Response.Write "    <td><a class='title' href='#' onclick=""window.open('Admin_SelectTime.asp?ShowStyle=1&DaySelect=str" & TransformDay(DateAdd("d", Num + 4, CDate(StartDay)), 1) & "', 'strLesson', 'width=400,height=100,toolbar=no,menubar=no, scrollbars=no, resizable=no, location=no, status=no');"">三</a></td>" & vbCrLf
    Response.Write "    <td><a class='title' href='#' onclick=""window.open('Admin_SelectTime.asp?ShowStyle=1&DaySelect=str" & TransformDay(DateAdd("d", Num + 5, CDate(StartDay)), 1) & "', 'strLesson', 'width=400,height=100,toolbar=no,menubar=no, scrollbars=no, resizable=no, location=no, status=no');"">四</a></td>" & vbCrLf
    Response.Write "    <td><a class='title' href='#' onclick=""window.open('Admin_SelectTime.asp?ShowStyle=1&DaySelect=str" & TransformDay(DateAdd("d", Num + 6, CDate(StartDay)), 1) & "', 'strLesson', 'width=400,height=100,toolbar=no,menubar=no, scrollbars=no, resizable=no, location=no, status=no');"">五</a></td>" & vbCrLf
    Response.Write "    <td><a class='title' href='#' onclick=""window.open('Admin_SelectTime.asp?ShowStyle=1&DaySelect=str" & TransformDay(DateAdd("d", Num + 7, CDate(StartDay)), 1) & "', 'strLesson', 'width=400,height=100,toolbar=no,menubar=no, scrollbars=no, resizable=no, location=no, status=no');"">六</a></td>" & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "  <tr>" & vbCrLf
    Response.Write "    <td align='center' class='Date_tdbg'>1</td>" & vbCrLf
    Response.Write str7 & vbCrLf
    Response.Write str1 & vbCrLf
    Response.Write str2 & vbCrLf
    Response.Write str3 & vbCrLf
    Response.Write str4 & vbCrLf
    Response.Write str5 & vbCrLf
    Response.Write str6 & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    For i = 2 To 22

        Response.Write "  <tr>" & vbCrLf
        Response.Write "    <td align='center' class='Date_tdbg' id='s" & i & "str" & TransformDay(DateAdd("d", Num + 1 + 7 * (i - 2), CDate(StartDay)), 1) & "'>" & vbCrLf
        Response.Write "      <a class='lefts' href='#' onclick=""window.open('Admin_SelectTime.asp?ShowStyle=2&DaySelect=str" & TransformDay(DateAdd("d", Num + 1 + 7 * (i - 2), CDate(StartDay)), 1) & "', 'strLesson', 'width=400,height=100,toolbar=no,menubar=no, scrollbars=no, resizable=no, location=no, status=no');"">" & i & "</a>" & vbCrLf
        Response.Write "    </td>" & vbCrLf
        For j = 1 To 7
            Response.Write "        <td align='center' id='sstr" & TransformDay(DateAdd("d", Num + j + 7 * (i - 2), CDate(StartDay)), 1) & "' onmouseout=""this.className='tdbg'"" onmouseover=""this.className='tdbgmouseover'"" onclick="""" width='70' height='25'>" & vbCrLf
            Response.Write "          <a class='Date' href='#' onclick=""window.open('Admin_SelectTime.asp?ShowStyle=0&DaySelect=str" & TransformDay(DateAdd("d", Num + j + 7 * (i - 2), CDate(StartDay)), 1) & "', 'strLesson', 'width=400,height=100,toolbar=no,menubar=no, scrollbars=no, resizable=no, location=no, status=no');"">" & vbCrLf
            Response.Write TransformDay(DateAdd("d", Num + j + 7 * (i - 2), CDate(StartDay)), 2)
            Response.Write " " & vbCrLf
            Response.Write "          </a>" & vbCrLf
            Response.Write "        </td>" & vbCrLf
        Next
        Response.Write "  </tr>" & vbCrLf
      
    Next


    Response.Write "</table>" & vbCrLf
    Response.Write "    </td>" & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "  <tr class='tdbg2'>" & vbCrLf
    Response.Write "    <td colspan='2' align='center'>" & vbCrLf
    Response.Write "      <input type='submit' name='Submit' value='提交'>" & vbCrLf
    Response.Write "    </td>" & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Response.Write "" & vbCrLf
    Response.Write "</table>" & vbCrLf
    Response.Write "" & vbCrLf
    Response.Write "<table width='60%'  border='1' cellspacing='0' cellpadding='0' style='display:none'>" & vbCrLf
    Response.Write "  <tr>" & vbCrLf
    Response.Write "    <td align='center'>1</td>" & vbCrLf
    Response.Write "    <td><input type='text' name='str" & str77 & "' value=''></td>" & vbCrLf
    Response.Write "    <td><input type='text' name='str" & str11 & "' value=''></td>" & vbCrLf
    Response.Write "    <td><input type='text' name='str" & str22 & "' value=''></td>" & vbCrLf
    Response.Write "    <td><input type='text' name='str" & str33 & "' value=''></td>" & vbCrLf
    Response.Write "    <td><input type='text' name='str" & str44 & "' value=''></td>" & vbCrLf
    Response.Write "    <td><input type='text' name='str" & str55 & "' value=''></td>" & vbCrLf
    Response.Write "    <td><input type='text' name='str" & str66 & "' value=''></td>" & vbCrLf
    Response.Write "  </tr>" & vbCrLf

    i = 2
    For i = 2 To 22

        Response.Write "  <tr>" & vbCrLf
        Response.Write "    <td align='center'>" & i & "</td>" & vbCrLf
        For j = 1 To 7
            Response.Write "        <td>" & vbCrLf
            Response.Write "          <input type='text' name='str" & TransformDay(DateAdd("d", Num + j + 7 * (i - 2), CDate(StartDay)), 1) & "' id='str" & TransformDay(DateAdd("d", Num + j + 7 * (i - 2), CDate(StartDay)), 1) & "' value=''>" & vbCrLf
            Response.Write "        </td>" & vbCrLf
        Next
        Response.Write "  </tr>" & vbCrLf
      
    Next


    Response.Write "</table>" & vbCrLf
    Response.Write "</form>" & vbCrLf
End Sub

Function TransResult(ByVal strDay, ByVal strRequest)
    Dim arrHour, strTemp, i
    arrHour = Split(strRequest, ",")
    For i = 0 To UBound(arrHour)
        If i = 0 Then
            strTemp = strDay & "$" & arrHour(i)
        Else
            If arrHour(i) > arrHour(i - 1) Then
                strTemp = strTemp & "|||" & strDay & "$" & arrHour(i)
            Else
                strTemp = strDay & "$" & arrHour(i) & "|||" & strTemp
            End If
        End If
    Next
    TransResult = strTemp
End Function

Sub ShowEnrolResult()
    Dim i, j, strNum, EquipmentID, CollectionDay, arrCollectionDay, rs1, sql1, EnrolUserName, EnrolClass, LessonInfo
    EquipmentID = Trim(Request("EquipmentID"))
    EnrolUserName = ReplaceBadChar(Trim(Request("EnrolUserName")))
    EnrolClass = Trim(Request("EnrolClass"))
    LessonInfo = Trim(Request("LessonInfo"))
    If EnrolUserName = "" Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>请指定要使用人的姓名！</li>"
        Exit Sub
    End If
    If EnrolClass = "" Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>请指定要使用的班级！</li>"
        Exit Sub
    'else
        'EnrolClass=PE_clng(EnrolClass)
    End If
    If EquipmentID = "" Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>请指定要使用的设备ID！</li>"
        Exit Sub
    Else
        EquipmentID = PE_CLng(EquipmentID)
    End If
    If Weekday(StartDay) < 7 Then
        strNum = Weekday(StartDay) - 1
    Else
        strNum = -1
    End If
    j = 0
    CollectionDay = Trim(Request("CollectionDay"))
    If CollectionDay = "" Then
        For i = 0 To 22 * 7 - strNum
            Dim tempDay
            tempDay = TransformDay(DateAdd("d", i, CDate(StartDay)), 1)
            If Request("str" & tempDay) <> "" Then
                If CollectionDay = "" Then
                    CollectionDay = TransResult(tempDay, Request("str" & tempDay))
                Else
                    CollectionDay = CollectionDay & "|||" & TransResult(tempDay, Request("str" & tempDay))
                End If
            End If
        Next
    End If
    If CollectionDay = "" Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>请指定要搜索的时间！</li>"
        Exit Sub
    End If

    Dim strlessonDate, arrEnrolDate
    strlessonDate = CollectionDay

    If strlessonDate = "" Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>请指定时间</li>"
    End If
    If Not (InStr(strlessonDate, "$") > 0) Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>参数不足！</li>"
    End If


    If FoundErr = True Then
        Exit Sub
    End If
    Dim strTempDate0, strTempDate1, strTempDate2, strTempDate3
    strTempDate0 = ""   '未登记+已登记的时间
    strTempDate1 = ""   '已登记的ID
    strTempDate2 = ""   '已确认的ID
    strTempDate3 = ""   '已使用的ID
    arrEnrolDate = Split(strlessonDate, "|||")
    For i = 0 To UBound(arrEnrolDate)
        strlessonDate = Split(arrEnrolDate(i), "$")
        Set rs1 = Server.CreateObject("adodb.recordset")
        sql1 = "select * from PE_UsedDetail where lessonYear=" & Year(strlessonDate(0)) & " and lessonMonth=" & Month(strlessonDate(0)) & " and lessonDay=" & Day(strlessonDate(0)) & " and lessonNumber=" & PE_Clng(strlessonDate(1)) & " and EquipmentID =" & EquipmentID
        rs1.Open sql1, Conn, 1, 1
        If rs1.EOF Then
            If strTempDate0 = "" Then
                strTempDate0 = arrEnrolDate(i)
            Else
                strTempDate0 = strTempDate0 & "," & arrEnrolDate(i)
            End If
        Else
            If rs1.RecordCount = 1 Then
                If rs1("Used") = 0 Then
                    If strTempDate0 = "" Then
                        strTempDate0 = arrEnrolDate(i)
                    Else
                        strTempDate0 = strTempDate0 & "," & arrEnrolDate(i)
                    End If
                    If strTempDate1 = "" Then
                        strTempDate1 = rs1("ID")
                    Else
                        strTempDate1 = strTempDate1 & "," & rs1("ID")
                    End If
                ElseIf rs1("Used") = 1 Then
                    If strTempDate2 = "" Then
                        strTempDate2 = rs1("ID")
                    Else
                        strTempDate2 = strTempDate2 & "," & rs1("ID")
                    End If
                Else
                    If strTempDate3 = "" Then
                        strTempDate3 = rs1("ID")
                    Else
                        strTempDate3 = strTempDate3 & "," & rs1("ID")
                    End If
                End If
            Else
                If strTempDate0 = "" Then
                    strTempDate0 = arrEnrolDate(i)
                Else
                    strTempDate0 = strTempDate0 & "," & arrEnrolDate(i)
                End If
                Do While Not rs1.EOF
                    If strTempDate1 = "" Then
                        strTempDate1 = rs1("ID")
                    Else
                        strTempDate1 = strTempDate1 & "," & rs1("ID")
                    End If
                    rs1.MoveNext
                Loop
            End If
        End If
    Next

'0. 成功录入结果
    Dim EnrolSuccess, TempEnrolSuccess, EnrolSuccess0, TempEnrolSuccess0
    EnrolSuccess = Split(strTempDate0, ",")
    Set rs = Server.CreateObject("ADODB.Recordset")
    
    rs.Open "SELECT * FROM PE_UsedDetail", Conn, 1, 3
    For i = 0 To UBound(EnrolSuccess)
        TempEnrolSuccess = Split(EnrolSuccess(i), "$")
        rs.addnew
        rs("EquipmentID") = EquipmentID
        rs("lessonYear") = Year(TempEnrolSuccess(0))
        rs("lessonMonth") = Month(TempEnrolSuccess(0))
        rs("lessonDay") = Day(TempEnrolSuccess(0))
        rs("lessonNumber") = TempEnrolSuccess(1)
        'rs("UserName") = Session("db_User_TureName")
        rs("UserName") = EnrolUserName
        'rs("UserType") = Session("db_User_Type")
        'rs("UserYear") = Session("db_User_Year")
        rs("UserClass") = EnrolClass
        rs("LessonInfo") = LessonInfo
        rs("RegisterTime") = Now()
        rs("Used") = 1
        rs("RegisterIP") = UserTrueIP
        rs.Update
    Next

    rs.Close
    Set rs = Nothing

    Dim InsertCursor
    Set InsertCursor = Server.CreateObject("ADODB.Recordset")
    sql = "SELECT F.EquipmentName,F.EquipmentSituation,C.ClassroomName FROM PE_Equipment F left join PE_Classroom C on F.ClassroomID = C.ID WHERE F.id=" & EquipmentID
    InsertCursor.Open sql, Conn, 1, 3
    Response.Write "<br><table width='100%'><tr><td align='left'>专用室场设备使用 &nbsp;&gt;&gt;&nbsp;登记结果如下："
    Response.Write "</td></tr></table>" & vbCrLf
    Response.Write "      <table width='100%' class='border' border='0' cellspacing='1' cellpadding='1' align='center'>" & vbCrLf
    Response.Write "        <tr height='22' class='title'><td align='center' width='100%' colspan='2'><b>登  记  结  果</b></td></tr>" & vbCrLf
    Response.Write "        <tr class='tdbg'>" & vbCrLf
    Response.Write "          <td width='30%'><b>使用人：</b></td>" & vbCrLf
    Response.Write "          <td width='70%'>" & EnrolUserName & "    </td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf

    Response.Write "        <tr class='tdbg'>" & vbCrLf
    Response.Write "          <td width='30%'><b>班级：</b></td>" & vbCrLf
    Response.Write "          <td width='70%'>" & EnrolClass & "    </td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr class='tdbg'>" & vbCrLf
    Response.Write "          <td width='30%'><b>课程信息：</b></td>" & vbCrLf
    Response.Write "          <td width='70%'>" & LessonInfo & "    </td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf

    Response.Write "         <tr class='tdbg'>" & vbCrLf
    Response.Write "           <td width='30%'><b>室场：</b></td>" & vbCrLf
    Response.Write "           <td width='70%'>" & InsertCursor("ClassroomName") & "</td>" & vbCrLf
    Response.Write "         </tr>" & vbCrLf
    Response.Write "         <tr class='tdbg'>" & vbCrLf
    Response.Write "           <td width='30%'><b>设备：</b></td>" & vbCrLf
    Response.Write "           <td width='70%'>" & InsertCursor("EquipmentName") & "</td>" & vbCrLf
    Response.Write "         </tr>" & vbCrLf
    Response.Write "         <tr class='tdbg'>" & vbCrLf
    Response.Write "           <td width='30%'><b>设备情况：</b></td>" & vbCrLf
    Response.Write "           <td width='70%'>" & vbCrLf
    If InsertCursor("EquipmentSituation") = 1 Then Response.Write ("正常") Else Response.Write ("不正常")
    Response.Write "        </td></tr>" & vbCrLf

    Response.Write "        <tr class='tdbg'>" & vbCrLf
    Response.Write "          <td width='30%'><b>使用时间：</b></td>" & vbCrLf
    Response.Write "          <td width='70%'>" & vbCrLf
    Response.Write "            <table  width='100%' class='border' border='0' cellspacing='1' cellpadding='1' align='center'><tr>" & vbCrLf
    If strTempDate0 = "" Then
        Response.Write "<td align='center'><font color='#0000ff'>无记录录入到数据库！</font></td><tr>"
    Else
        EnrolSuccess0 = Split(strTempDate0, ",")
        For i = 1 To UBound(EnrolSuccess0) + 1
            TempEnrolSuccess0 = Split(EnrolSuccess0(i - 1), "$")
            Response.Write "<td align='center'>&nbsp;&nbsp;" & TempEnrolSuccess0(0) & "  第" & TempEnrolSuccess0(1) & "节课</td>"
            'if i<>0 then
                If i Mod 4 = 0 Then Response.Write "</tr><tr>"
            'end if
        Next
    End If
    Response.Write "            </table>" & vbCrLf
    Response.Write "          </td>" & vbCrLf
    Response.Write "         </tr>" & vbCrLf

    Response.Write "        <tr class='tdbg'><td colspan='2' align='center'><font color='#0000ff'>请通知 " & EnrolUserName & " 记清登记结果，准时使用该室场！</font></td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "      </table>" & vbCrLf
    InsertCursor.Close
    Set InsertCursor = Nothing

    If strTempDate3 <> "" Or strTempDate3 <> "" Or strTempDate3 <> "" Then
        Response.Write "<br><strong><font color='red'>固定排课过程中，发生以下与数据库中已有记录冲突情况：</font></strong>"
    End If
'1.数据库中处于已使用状态的记录，意外情况。
    If strTempDate3 <> "" Then
        Response.Write "<br><table width='100%'><tr><td align='left'>数据库中相冲突，处于<font color='red'>已使用</font>状态的记录如下："
        Response.Write "</td><td align='right'>"

        Set rs = Server.CreateObject("adodb.recordset")
        sql = "select D.ID, D.EquipmentID, D.UserName, D.lessonMonth, D.lessonDay, D.lessonNumber, D.lessonYear, D.UserType, D.RegisterTime,D.Used, F.ClassroomID, F.EquipmentName, C.ClassroomName from PE_UsedDetail D left join ( PE_Equipment F left join  PE_Classroom C on F.ClassroomID = C.ID ) on D.EquipmentID = F.ID where D.id in (" & strTempDate3 & ")"
        rs.Open sql, Conn, 1, 1
        
        Response.Write "共 <font color=red>" & rs.RecordCount & "</font> 条记录</td></tr></table>"
        Response.Write "    <table width='100%' class='border' border='0' cellspacing='1' cellpadding='1' align='center'>" & vbCrLf
        Response.Write "      <tr class='title' height='22'>" & vbCrLf
        Response.Write "        <td width='12%' height='22'> " & vbCrLf
        Response.Write "          <div align='center'><b>设备名称</b></div>" & vbCrLf
        Response.Write "        </td>" & vbCrLf
        Response.Write "        <td width='8%' nowrap> " & vbCrLf
        Response.Write "          <div align='center'><b>日期</b></div>" & vbCrLf
        Response.Write "        </td>" & vbCrLf

        Response.Write "        <td width='6%' nowrap> " & vbCrLf
        Response.Write "          <div align='center'><b>节次</b></div>" & vbCrLf
        Response.Write "        </td>" & vbCrLf
        Response.Write "        <td width='12%' nowrap> " & vbCrLf
        Response.Write "          <div align='center'><b>所属教室</b></div>" & vbCrLf
        Response.Write "        </td>" & vbCrLf

        Response.Write "        <td width='10%' nowrap> " & vbCrLf
        Response.Write "          <div align='center'><b>使用人</b></div>" & vbCrLf
        Response.Write "        </td>" & vbCrLf
        'Response.Write "        <td width='6%' nowrap> " & vbCrLf
        'Response.Write "          <div align='center'><b>身份</b></div>" & vbCrLf
        'Response.Write "        </td>" & vbCrLf
        Response.Write "        <td width='16%' nowrap> " & vbCrLf
        Response.Write "          <div align='center'><b>登记时间</b></div>" & vbCrLf
        Response.Write "        </td>" & vbCrLf
        Response.Write "        <td width='6%' nowrap> " & vbCrLf
        Response.Write "          <div align='center'><b>已确认</b></div>" & vbCrLf
        Response.Write "        </td>" & vbCrLf
        Response.Write "        <td width='6%' nowrap> " & vbCrLf
        Response.Write "          <div align='center'><b>已使用</b></div>" & vbCrLf
        Response.Write "        </td>" & vbCrLf
        Response.Write "        <td width='18%' nowrap> " & vbCrLf
        Response.Write "          <div align='center'><b>当前状态</b></div>" & vbCrLf
        Response.Write "        </td>" & vbCrLf
        Response.Write "      </tr>" & vbCrLf
        If rs.RecordCount = 0 Then
            Response.Write "<tr class='tdbg'><td colspan='10' align='center'>没有满足条件的登记记录!</td><tr>" & vbCrLf
        Else
            Do While Not rs.EOF
                Response.Write "    <tr class='tdbg' onmouseout=""this.className='tdbg'"" onmouseover=""this.className='tdbgmouseover'"">" & vbCrLf
                Response.Write "      <td width='12%' align='center'>" & rs("EquipmentName") & "</td>" & vbCrLf
                Response.Write "      <td width='8%' align='center'>" & rs("lessonYear") & "/" & rs("lessonMonth") & "/" & rs("lessonDay") & "</td>" & vbCrLf

                Response.Write "      <td width='6%' align='center'>" & vbCrLf
                If rs("lessonNumber") = 0 Then Response.Write ("不限") Else Response.Write rs("lessonNumber") & "</td>" & vbCrLf
                Response.Write "      <td width='12%' align='center'>" & rs("ClassroomName") & "</td>" & vbCrLf

                Response.Write "      <td width='10%' align='center'>" & rs("UserName") & "</td>" & vbCrLf
                'Response.Write "      <td width='6%' align='center'>" & vbCrLf
                'If rs("UserType") = 1 Then Response.Write ("教师") Else Response.Write ("学生") & "</td>" & vbCrLf
                Response.Write "      <td width='16%' align='center'>" & rs("RegisterTime") & "</td>" & vbCrLf
                Response.Write "      <td width='6%' align='center'>" & vbCrLf
                If rs("Used") = 0 Then Response.Write ("×") Else Response.Write ("√") & "</td>" & vbCrLf
                Response.Write "      <td width='6%' align='center'>" & vbCrLf
                If rs("Used") = 2 Then Response.Write ("√") Else Response.Write ("×") & "</td>" & vbCrLf
                Response.Write "      <td width='18%' align='center'>" & vbCrLf
                'if rs("Used")= 1 then response.Write("2") else response.Write("3")

                Response.Write "已经确认" & vbCrLf
                Response.Write "      </td></tr>" & vbCrLf
                rs.MoveNext
            Loop
        End If
        Response.Write "  </table>" & vbCrLf
        Set rs = Nothing
    End If

'2.***时间设备的使用权限已给，操作忽略。
'3.数据库中处于已确认状态的记录，若要给***用，请先删除现在的记录，然后安排给他用
    
    If strTempDate2 <> "" Then
        Response.Write "<br><table width='100%'><tr><td align='left'>数据库中相冲突，处于<font color=red>已确认</font>状态的记录如下："
        Response.Write "</td><td align='right'>"

        Set rs = Server.CreateObject("adodb.recordset")
        sql = "select D.ID, D.EquipmentID, D.UserName, D.lessonMonth, D.lessonDay, D.lessonNumber, D.lessonYear, D.UserType, D.RegisterTime,D.Used, F.ClassroomID, F.EquipmentName, C.ClassroomName from PE_UsedDetail D left join ( PE_Equipment F left join  PE_Classroom C on F.ClassroomID = C.ID ) on D.EquipmentID = F.ID where D.id in (" & strTempDate2 & ")"
        rs.Open sql, Conn, 1, 1
        
        Response.Write "共 <font color=red>" & rs.RecordCount & "</font> 条记录</td></tr></table>"
        Response.Write "<font color='#0000ff'>（注：请去使用登记管理中先删除以下处于已确认状态的记录，然后安排给" & EnrolUserName & "用！）"
        Response.Write "    <table width='100%' class='border' border='0' cellspacing='1' cellpadding='1' align='center'>" & vbCrLf
        Response.Write "      <tr class='title' height='22'>" & vbCrLf
        Response.Write "        <td width='12%' height='22'> " & vbCrLf
        Response.Write "          <div align='center'><b>设备名称</b></div>" & vbCrLf
        Response.Write "        </td>" & vbCrLf
        Response.Write "        <td width='8%' nowrap> " & vbCrLf
        Response.Write "          <div align='center'><b>日期</b></div>" & vbCrLf
        Response.Write "        </td>" & vbCrLf

        Response.Write "        <td width='6%' nowrap> " & vbCrLf
        Response.Write "          <div align='center'><b>节次</b></div>" & vbCrLf
        Response.Write "        </td>" & vbCrLf
        Response.Write "        <td width='12%' nowrap> " & vbCrLf
        Response.Write "          <div align='center'><b>所属教室</b></div>" & vbCrLf
        Response.Write "        </td>" & vbCrLf

        Response.Write "        <td width='10%' nowrap> " & vbCrLf
        Response.Write "          <div align='center'><b>使用人</b></div>" & vbCrLf
        Response.Write "        </td>" & vbCrLf
        'Response.Write "        <td width='6%' nowrap> " & vbCrLf
        'Response.Write "          <div align='center'><b>身份</b></div>" & vbCrLf
        'Response.Write "        </td>" & vbCrLf
        Response.Write "        <td width='16%' nowrap> " & vbCrLf
        Response.Write "          <div align='center'><b>登记时间</b></div>" & vbCrLf
        Response.Write "        </td>" & vbCrLf
        Response.Write "        <td width='6%' nowrap> " & vbCrLf
        Response.Write "          <div align='center'><b>已确认</b></div>" & vbCrLf
        Response.Write "        </td>" & vbCrLf
        Response.Write "        <td width='6%' nowrap> " & vbCrLf
        Response.Write "          <div align='center'><b>已使用</b></div>" & vbCrLf
        Response.Write "        </td>" & vbCrLf
        Response.Write "        <td width='18%' nowrap> " & vbCrLf
        Response.Write "          <div align='center'><b>当前状态</b></div>" & vbCrLf
        Response.Write "        </td>" & vbCrLf
        Response.Write "      </tr>" & vbCrLf
        If rs.RecordCount = 0 Then
            Response.Write "<tr class='tdbg'><td colspan='10' align='center'>没有满足条件的登记记录!</td><tr>" & vbCrLf
        Else
            Do While Not rs.EOF
                Response.Write "    <tr class='tdbg' onmouseout=""this.className='tdbg'"" onmouseover=""this.className='tdbgmouseover'"">" & vbCrLf
                Response.Write "      <td width='12%' align='center'>" & rs("EquipmentName") & "</td>" & vbCrLf
                Response.Write "      <td width='8%' align='center'>" & rs("lessonYear") & "/" & rs("lessonMonth") & "/" & rs("lessonDay") & "</td>" & vbCrLf

                Response.Write "      <td width='6%' align='center'>" & vbCrLf
                If rs("lessonNumber") = 0 Then Response.Write ("不限") Else Response.Write rs("lessonNumber") & "</td>" & vbCrLf
                Response.Write "      <td width='12%' align='center'>" & rs("ClassroomName") & "</td>" & vbCrLf

                Response.Write "      <td width='10%' align='center'>" & rs("UserName") & "</td>" & vbCrLf
                'Response.Write "      <td width='6%' align='center'>" & vbCrLf
                'If rs("UserType") = 1 Then Response.Write ("教师") Else Response.Write ("学生") & "</td>" & vbCrLf
                Response.Write "      <td width='16%' align='center'>" & rs("RegisterTime") & "</td>" & vbCrLf
                Response.Write "      <td width='6%' align='center'>" & vbCrLf
                If rs("Used") = 0 Then Response.Write ("×") Else Response.Write ("√") & "</td>" & vbCrLf
                Response.Write "      <td width='6%' align='center'>" & vbCrLf
                If rs("Used") = 2 Then Response.Write ("√") Else Response.Write ("×") & "</td>" & vbCrLf
                Response.Write "      <td width='18%' align='center'>" & vbCrLf
                'if rs("Used")= 1 then response.Write("2") else response.Write("3")

                Response.Write "已经确认" & vbCrLf
                Response.Write "      </td></tr>" & vbCrLf
                rs.MoveNext
            Loop
        End If
        Response.Write "  </table>" & vbCrLf
        Set rs = Nothing
    End If

'4. 已经删除处于登记状态的记录
    If strTempDate1 <> "" Then
        Response.Write "<br><table width='100%'><tr><td align='left'>数据库中相冲突，处于<font color='red'>已登记</font>状态的记录如下："
        Response.Write "</td><td align='right'>"
        Set rs = Server.CreateObject("adodb.recordset")
        sql = "select D.ID, D.EquipmentID, D.UserName, D.lessonMonth, D.lessonDay, D.lessonNumber, D.lessonYear, D.UserType, D.RegisterTime,D.Used, F.ClassroomID, F.EquipmentName, C.ClassroomName from PE_UsedDetail D left join ( PE_Equipment F left join  PE_Classroom C on F.ClassroomID = C.ID ) on D.EquipmentID = F.ID where D.id in (" & strTempDate1 & ")"
        rs.Open sql, Conn, 1, 1
    
        Response.Write "共删除了 <font color=red>" & rs.RecordCount & "</font> 条记录</td></tr></table>"
        Response.Write "    <table width='100%' class='border' border='0' cellspacing='1' cellpadding='1' align='center'>" & vbCrLf
        Response.Write "      <tr class='title' height='22'>" & vbCrLf
        Response.Write "        <td width='12%' height='22'> " & vbCrLf
        Response.Write "          <div align='center'><b>设备名称</b></div>" & vbCrLf
        Response.Write "        </td>" & vbCrLf
        Response.Write "        <td width='8%' nowrap> " & vbCrLf
        Response.Write "          <div align='center'><b>日期</b></div>" & vbCrLf
        Response.Write "        </td>" & vbCrLf

        Response.Write "        <td width='6%' nowrap> " & vbCrLf
        Response.Write "          <div align='center'><b>节次</b></div>" & vbCrLf
        Response.Write "        </td>" & vbCrLf
        Response.Write "        <td width='12%' nowrap> " & vbCrLf
        Response.Write "          <div align='center'><b>所属教室</b></div>" & vbCrLf
        Response.Write "        </td>" & vbCrLf

        Response.Write "        <td width='10%' nowrap> " & vbCrLf
        Response.Write "          <div align='center'><b>使用人</b></div>" & vbCrLf
        Response.Write "        </td>" & vbCrLf
        'Response.Write "        <td width='6%' nowrap> " & vbCrLf
        'Response.Write "          <div align='center'><b>身份</b></div>" & vbCrLf
        'Response.Write "        </td>" & vbCrLf
        Response.Write "        <td width='16%' nowrap> " & vbCrLf
        Response.Write "          <div align='center'><b>登记时间</b></div>" & vbCrLf
        Response.Write "        </td>" & vbCrLf
        Response.Write "        <td width='6%' nowrap> " & vbCrLf
        Response.Write "          <div align='center'><b>已确认</b></div>" & vbCrLf
        Response.Write "        </td>" & vbCrLf
        Response.Write "        <td width='6%' nowrap> " & vbCrLf
        Response.Write "          <div align='center'><b>已使用</b></div>" & vbCrLf
        Response.Write "        </td>" & vbCrLf
        Response.Write "        <td width='18%' nowrap> " & vbCrLf
        Response.Write "          <div align='center'><b>当前状态</b></div>" & vbCrLf
        Response.Write "        </td>" & vbCrLf
        Response.Write "      </tr>" & vbCrLf
        If rs.RecordCount = 0 Then
            Response.Write "<tr class='tdbg'><td colspan='10' align='center'>没有满足条件的登记记录!</td><tr>" & vbCrLf
        Else
            Do While Not rs.EOF
                Response.Write "    <tr class='tdbg' onmouseout=""this.className='tdbg'"" onmouseover=""this.className='tdbgmouseover'"">" & vbCrLf
                Response.Write "      <td width='12%' align='center'>" & rs("EquipmentName") & "</td>" & vbCrLf
                Response.Write "      <td width='8%' align='center'>" & rs("lessonYear") & "/" & rs("lessonMonth") & "/" & rs("lessonDay") & "</td>" & vbCrLf

                Response.Write "      <td width='6%' align='center'>" & vbCrLf
                If rs("lessonNumber") = 0 Then Response.Write ("不限") Else Response.Write rs("lessonNumber") & "</td>" & vbCrLf
                Response.Write "      <td width='12%' align='center'>" & rs("ClassroomName") & "</td>" & vbCrLf

                Response.Write "      <td width='10%' align='center'>" & rs("UserName") & "</td>" & vbCrLf
                'Response.Write "      <td width='6%' align='center'>" & vbCrLf
                'If rs("UserType") = 1 Then Response.Write ("教师") Else Response.Write ("学生") & "</td>" & vbCrLf
                Response.Write "      <td width='16%' align='center'>" & rs("RegisterTime") & "</td>" & vbCrLf
                Response.Write "      <td width='6%' align='center'>" & vbCrLf
                If rs("Used") = 0 Then Response.Write ("×") Else Response.Write ("√") & "</td>" & vbCrLf
                Response.Write "      <td width='6%' align='center'>" & vbCrLf
                If rs("Used") = 2 Then Response.Write ("√") Else Response.Write ("×") & "</td>" & vbCrLf
                Response.Write "      <td width='18%' align='center'>" & vbCrLf
                'if rs("Used")= 1 then response.Write("2") else response.Write("3")

                Response.Write "已经删除" & vbCrLf
                Response.Write "      </td></tr>" & vbCrLf
                rs.MoveNext
            Loop
        End If
        Response.Write "  </table>" & vbCrLf
        Set rs = Nothing
        sql = "delete from PE_UsedDetail where id in (" & strTempDate1 & ")"
        Conn.Execute (sql)
    End If

    
End Sub



    '1---2005-08-15
    '2---8-15
    '3---15
    '4---2005-8-15
Function TransformDay(ByVal strDay, ByVal Num)
    Dim strTemp, strNum
    strNum = CInt(Num)
    If Not IsDate(strDay) Then
        TransformDay = ""
        Exit Function
    End If
    If strNum = 2 Then
        If Day(strDay) = 1 Then
            strTemp = Month(strDay) & "/" & Day(strDay)
        Else
            strTemp = Day(strDay)
        End If
    ElseIf strNum = 4 Then
        strTemp = Year(strDay) & "-" & Right("0" & Month(strDay), 2) & "-" & Right("0" & Day(strDay), 2)
    Else
        strTemp = Year(strDay) & "-" & Month(strDay) & "-" & Day(strDay)
    End If
    TransformDay = strTemp
End Function
%>
