<!--#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
Dim strSort, Man
Dim ClassroomID, lessonYear, lessonMonth, lessonDay, lessonNumber


Man = Request("Man")
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)
strFileName = " Admin_SearchHistory.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("专 用 教 室 管 理", 10194)
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'>使用记录管理</a>&nbsp;|&nbsp;<a href='Admin_SearchHistory.asp'>使用记录查询</a>" & vbCrLf
Response.Write "    </td>" & vbCrLf
Response.Write "  </tr>" & vbCrLf
Response.Write "</table>" & vbCrLf
Select Case Action
Case "UsedDetail"
    Call UsedDetail
Case Else
    Call main
End Select
If FoundErr = True Then
    Call WriteErrMsg(ErrMsg, ComeUrl)
End If
Response.Write "</body></html>"
Call CloseConn

Sub 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, F.ClassroomID, 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.Used=2"
    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
    sql = sql & " and D.lessonYear=" & lessonYear
    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 "      <tr class='title'>" & 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='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='6%' 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='12%' 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 "    " & vbCrLf
    Response.Write "        <td width='9%' nowrap> " & vbCrLf
    Response.Write "          <div align='center'><b>使用人</b></div>" & vbCrLf
    Response.Write "        </td>" & vbCrLf
    Response.Write "        <td width='9%' 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
        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='12%' title='点击查看记录具体信息' align='center'><a href='Admin_SearchHistory.asp?Action=UsedDetail&id=" & rs("ID") & "'>" & rs("EquipmentName") & "</a></td>" & vbCrLf
            Response.Write "      <td width='6%' align='center'>" & rs("lessonYear") & "</td>" & vbCrLf
            Response.Write "      <td width='4%' align='center'>" & vbCrLf
            If rs("lessonMonth") = 0 Then Response.Write ("不限") Else Response.Write rs("lessonMonth") & "</td>" & vbCrLf
            Response.Write "      <td width='4%' align='center'>" & vbCrLf
            If rs("lessonDay") = 0 Then Response.Write ("不限") Else Response.Write rs("lessonDay") & "</td>" & vbCrLf
            Response.Write "      <td width='8%' 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='12%' align='center'>" & vbCrLf
            If rs("EquipmentSituation") = 1 Then Response.Write ("正常") Else Response.Write ("不正常") & "</td>" & vbCrLf
            Response.Write "      <td width='9%' align='center'>" & rs("UserName") & "</td>" & vbCrLf
            Response.Write "      <td width='9%' align='center'>" & vbCrLf
            'If rs("UserType") = 1 Then Response.Write ("教师") Else Response.Write ("学生") & "</td>" & vbCrLf
            Response.Write rs("UserClass") & "</td>" & vbCrLf
            Response.Write "      <td width='24%' align='center'>" & rs("RegisterTime") & "</td>" & vbCrLf
            Response.Write "    </tr>" & vbCrLf
            i = i + 1
            If i > MaxPerPage Then Exit Do
            rs.MoveNext
        Loop
    End If
    Response.Write "  </table>" & vbCrLf
    If totalPut > 0 Then
        Response.Write ShowPage(strFileName, totalPut, MaxPerPage, CurrentPage, True, True, "条记录", True)
    End If
    Response.Write ShowSearch()
End Sub

Function ShowSearch()
    Response.Write "    <form method='post' action='Admin_SearchHistory.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
    Response.Write "                <option value='2005'>2005</option>" & vbCrLf
    Response.Write "                <option value='2006'>2006</option>" & vbCrLf
    Response.Write "                <option value='2007'>2007</option>" & vbCrLf
    Response.Write "                <option value='2008'>2008</option>" & vbCrLf
    Response.Write "                <option value='2009'>2009</option>" & vbCrLf
    Response.Write "                <option value='2010'>2010</option>" & vbCrLf
    Response.Write "                <option value='2011'>2011</option>" & vbCrLf
    Response.Write "                <option value='2012'>2012</option>" & vbCrLf
    Response.Write "                <option value='2013'>2013</option>" & vbCrLf
    Response.Write "                <option value='2014'>2014</option>" & vbCrLf
    Response.Write "                <option value='2015'>2015</option>" & vbCrLf
    Response.Write "              </select>年" & vbCrLf
    Response.Write "              <select name='lessonMonth'>" & 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 "                <option value='9'>9</option>" & vbCrLf
    Response.Write "                <option value='10'>10</option>" & vbCrLf
    Response.Write "                <option value='11'>11</option>" & vbCrLf
    Response.Write "                <option value='12'>12</option>" & vbCrLf
    Response.Write "              </select>月" & vbCrLf
    Response.Write "              <select name='lessonDay'>" & 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 "                <option value='9'>9</option>" & vbCrLf
    Response.Write "                <option value='10'>10</option>" & vbCrLf
    Response.Write "                <option value='11'>11</option>" & vbCrLf
    Response.Write "                <option value='12'>12</option>" & vbCrLf
    Response.Write "                <option value='13'>13</option>" & vbCrLf
    Response.Write "                <option value='14'>14</option>" & vbCrLf
    Response.Write "                <option value='15'>15</option>" & vbCrLf
    Response.Write "                <option value='16'>16</option>" & vbCrLf
    Response.Write "                <option value='17'>17</option>" & vbCrLf
    Response.Write "                <option value='18'>18</option>" & vbCrLf
    Response.Write "                <option value='19'>19</option>" & vbCrLf
    Response.Write "                <option value='20'>20</option>" & vbCrLf
    Response.Write "                <option value='21'>21</option>" & vbCrLf
    Response.Write "                <option value='22'>22</option>" & vbCrLf
    Response.Write "                <option value='23'>23</option>" & vbCrLf
    Response.Write "                <option value='24'>24</option>" & vbCrLf
    Response.Write "                <option value='25'>25</option>" & vbCrLf
    Response.Write "                <option value='26'>26</option>" & vbCrLf
    Response.Write "                <option value='27'>27</option>" & vbCrLf
    Response.Write "                <option value='28'>28</option>" & vbCrLf
    Response.Write "                <option value='29'>29</option>" & vbCrLf
    Response.Write "                <option value='30'>30</option>" & vbCrLf
    Response.Write "                <option value='31'>31</option>" & vbCrLf
    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 "              </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' class='style1'><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_SearchHistory.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
%>
