<!--#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 rs, sql, ClassroomID, InsertCursor, cmdTemp, intID
Dim strSort '保留所选的类的所有子类
Dim myKeyword
Dim ClassroomIDDic, ClassroomIDRs
Dim tempName, tempID

Set ClassroomIDDic = Server.CreateObject("Scripting.Dictionary")
sql = "select * from PE_Classroom  where 1=1"
Set ClassroomIDRs = Conn.Execute(sql)
Do While Not (ClassroomIDRs.EOF Or Err)
    tempID = CStr(ClassroomIDRs("id"))
    tempName = ClassroomIDRs("ClassroomName")
    ClassroomIDDic.Add tempID, tempName
    ClassroomIDRs.MoveNext
Loop
myKeyword = Request("myKeyword")
ClassroomID = PE_CLng(Request("ClassroomID"))
strSort = ClassroomID
Call getSort(ClassroomID)
strFileName = "Admin_Equipment.asp?ClassroomID=" & ClassroomID & " & myKeyword=" & myKeyword

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("专 用 教 室 管 理", 10192)
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 "Add"
    Call AddEquipment
Case "SaveAdd"
    Call SaveAdd
Case "Modify"
    Call Modify
Case "SaveModify"
    Call SaveModify
Case "Del"
    Call DelEquipment
Case "Show"
    Call Show
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'>"
    If Request("page") <> "" Then
        CurrentPage = PE_CLng(Request("page"))
    Else
        CurrentPage = 1
    End If
    Set rs = Server.CreateObject("adodb.recordset")
    sql = "select * from PE_Equipment where 1=1"
    If Not (myKeyword = "" Or IsEmpty(myKeyword)) Then
        sql = sql & " and EquipmentName like '%" & ReplaceBadChar(myKeyword) & "%'"
    End If
    If ClassroomID > 0 Then
        sql = sql & " and ClassroomID in (" & strSort & ")"
    End If
    sql = sql & " order by 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
        Response.Write "共找到 <font color=red>" & totalPut & "</font> 台设备</td></tr></table>"
    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='6%' nowrap> " & vbCrLf
    Response.Write "              <div align='center'><strong>编号</strong></div>" & vbCrLf
    Response.Write "            </td>" & vbCrLf
    Response.Write "            <td width='20%' nowrap> " & vbCrLf
    Response.Write "              <div align='center'><strong>设备名称</strong></div>" & vbCrLf
    Response.Write "            </td>        " & vbCrLf
    Response.Write "            <td width='14%' nowrap> " & vbCrLf
    Response.Write "              <div align='center'><strong>所属教室</strong></div>" & vbCrLf
    Response.Write "            </td>" & vbCrLf
    Response.Write "            <td width='9%' nowrap> " & vbCrLf
    Response.Write "              <div align='center'><strong>设备价值(￥)</strong></div>" & vbCrLf
    Response.Write "            </td>" & vbCrLf
    Response.Write "            <td width='9%' nowrap> " & vbCrLf
    Response.Write "              <div align='center'><strong>设备状态</strong></div>" & vbCrLf
    Response.Write "            </td>" & vbCrLf
    Response.Write "            <td width='27%' nowrap> " & vbCrLf
    Response.Write "              <div align='center'><strong>设备简介</strong></div>" & vbCrLf
    Response.Write "            </td>" & vbCrLf
    Response.Write "            <td width='15%' nowrap> " & vbCrLf
    Response.Write "              <div align='center'><strong>常规管理操作</strong></div>" & vbCrLf
    Response.Write "            </td>" & vbCrLf
    Response.Write "          </tr>" & vbCrLf
    If rs.BOF And rs.EOF Then
        Response.Write "<tr class='tdbg'><td colspan='7' align='center'>您还没有添加任何设备!</td><tr></table>" & vbCrLf
    Else
        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
        Dim i, rsID, rsIntroduce
        i = 0
        Do While Not rs.EOF
            rsID = rs("id")
            Response.Write "    <tr class='tdbg' onmouseout=""this.className='tdbg'"" onmouseover=""this.className='tdbgmouseover'"">" & vbCrLf
            Response.Write "      <td width='6%' align='center'>" & rsID & "</td>" & vbCrLf
            Response.Write "     <td width='20%' style='cursor:hand' title='点击查看具体信息' onClick=""Javascript:window.location='Admin_Equipment.asp?Action=Show&id=" & rs("id") & "'"" align='center'>" & rs("EquipmentName") & "</td>" & vbCrLf
            Response.Write "                </td>" & vbCrLf
            Response.Write "                <td width='14%' align='center'> " & vbCrLf
            Response.Write ClassroomIDDic.Item(CStr(rs("ClassroomID")))
            Response.Write "                </td>" & vbCrLf
            Response.Write "                <td width='9%' align='center'>" & rs("EquipmentValue") & "</td>" & vbCrLf
            Response.Write "                <td width='9%' align='center'>" & vbCrLf
            If rs("EquipmentSituation") = 1 Then Response.Write ("正常") Else Response.Write ("不正常")
            Response.Write "                </td><td width='27%' align='center'>" & vbCrLf
            rsIntroduce = rs("EquipmentIntroduce")
            If LenB(rsIntroduce) > 40 Then
                rsIntroduce = LeftB(rsIntroduce, 30) & "……"
            End If
            Response.Write rsIntroduce
            Response.Write "</td><td width='15%' align='center'>" & vbCrLf
            Response.Write "<a href='Admin_Equipment.asp?Action=Show&id=" & rsID & "'>查看</a>&nbsp;" & vbCrLf
            Response.Write "<a href='Admin_Equipment.asp?Action=Modify&id=" & rsID & "'>修改</a>&nbsp;" & vbCrLf
            Response.Write "<a href='Admin_Equipment.asp?Action=Del&id=" & rsID & "' onClick=""return confirm('确定要删除此项吗？');"">删除</a>&nbsp;" & vbCrLf
            Response.Write "                </td>" & vbCrLf
            Response.Write "              </tr>" & vbCrLf
            i = i + 1
            If i >= MaxPerPage Then Exit Do
            rs.MoveNext
        Loop
        Response.Write " </table>" & vbCrLf
        If totalPut > 0 Then
            Response.Write ShowPage(strFileName, totalPut, MaxPerPage, CurrentPage, True, True, "台设备", True)
        End If
    End If
    Response.Write ShowSearch()
End Sub

Function ShowSearch()
    Response.Write "    <form name='form2' method='post' action='Admin_Equipment.asp'>" & 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 width='120'><strong>设备高级查询：</strong></td>" & vbCrLf
    Response.Write "          <td width='300'>" & vbCrLf
    Response.Write "            <select name='ClassroomID'>" & vbCrLf
    Response.Write "              <option value='0'>全部分类</option>" & vbCrLf
    Call selectTreeLists(0, 0)
    Response.Write "            </select>" & vbCrLf
    Response.Write "            <input name='myKeyword' type='text' id='myKeyword' size='20' maxlength='30'>" & vbCrLf
    Response.Write "            <input type='submit' name='Submit2' value=' 查 询 '>      " & vbCrLf
    Response.Write "          </td>" & vbCrLf
    Response.Write "          <td>若为空，则查询所有设备</td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "      </table>" & vbCrLf
    Response.Write "    </form>" & vbCrLf
End Function

Sub AddEquipment()
   
    If Request("ClassroomID") <> "" Then
        ClassroomID = PE_CLng(Request("ClassroomID"))
    Else
        ClassroomID = 0
    End If
    Response.Write "    <script language=Javascript>" & vbCrLf
    Response.Write "    <!--" & vbCrLf
    Response.Write "    function checkForm(){" & vbCrLf
    Response.Write "    if (form1.ClassroomID.value=='0'){" & vbCrLf
    Response.Write "        alert(""请选择设备所属教室"");" & vbCrLf
    Response.Write "        return false;" & vbCrLf
    Response.Write "        }" & vbCrLf
    Response.Write "    if (form1.EquipmentName.value==''){" & vbCrLf
    Response.Write "        alert(""请填写设备名称！！"");" & vbCrLf
    Response.Write "        return false;" & vbCrLf
    Response.Write "        }" & vbCrLf
    Response.Write "    return true;" & vbCrLf
    Response.Write "    }" & vbCrLf
    Response.Write "    //-->" & vbCrLf
    Response.Write "    </script>" & vbCrLf
    Response.Write "    <br>" & vbCrLf
    Response.Write "    <form method='post' action='Admin_Equipment.asp?Action=SaveAdd' name='form1' onSubmit='return checkForm()'>" & vbCrLf
    Response.Write "      <table width='100%' class='border' border='0' cellspacing='1' cellpadding='1' align='center'>" & vbCrLf
    Response.Write "        <tr> " & 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='20%' nowrap> " & vbCrLf
    Response.Write "            <div align='right'><b>设备所属教室</b></div>" & vbCrLf
    Response.Write "          </td>" & vbCrLf
    Response.Write "          <td width='80%'> " & vbCrLf
    Response.Write "            <select name='ClassroomID'>" & vbCrLf
    Call selectTreeList(0, 0)
    Response.Write "            </select>" & vbCrLf
    Response.Write "          </td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr class='tdbg'> " & vbCrLf
    Response.Write "          <td width='20%' nowrap> " & vbCrLf
    Response.Write "            <div align='right'><b>设备名称:</b></div>" & vbCrLf
    Response.Write "          </td>" & vbCrLf
    Response.Write "          <td width='80%'> " & vbCrLf
    Response.Write "            <input type='text' name='EquipmentName' maxlength='50' size='40'>" & vbCrLf
    Response.Write "          <font color='#ff0000'>*</font></td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr class='tdbg'> " & vbCrLf
    Response.Write "          <td width='20%' nowrap> " & vbCrLf
    Response.Write "            <div align='right'><b>设备价值:</b></div>" & vbCrLf
    Response.Write "          </td>" & vbCrLf
    Response.Write "          <td width='80%'> " & vbCrLf
    Response.Write "            <input type='text' maxlength='100' Name='EquipmentValue' size='12'>￥" & vbCrLf
    Response.Write "            </td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr class='tdbg'> " & vbCrLf
    Response.Write "          <td width='20%' nowrap> " & vbCrLf
    Response.Write "            <div align='right'><b>设备状态:</b></div>" & vbCrLf
    Response.Write "          </td>" & vbCrLf
    Response.Write "          <td width='80%'>" & vbCrLf
    Response.Write "            <select Name='EquipmentSituation'>" & vbCrLf
    Response.Write "              <option value='1'>正常</option>" & vbCrLf
    Response.Write "              <option value='0'>不正常</option>" & vbCrLf
    Response.Write "            </select> " & vbCrLf
    Response.Write "          </td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr class='tdbg'> " & vbCrLf
    Response.Write "          <td width='20%' nowrap> " & vbCrLf
    Response.Write "            <div align='right'><b>设备简介:</b></div>" & vbCrLf
    Response.Write "          </td>" & vbCrLf
    Response.Write "          <td width='80%'> " & vbCrLf
    Response.Write "            <textarea Name='EquipmentIntroduce' cols='60' rows='4'></textarea>" & vbCrLf
    Response.Write "          </td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr class='tdbg'> " & vbCrLf
    Response.Write "          <td width='20%' nowrap> " & vbCrLf
    Response.Write "            <div align='right'><b>备注:</b></div>" & vbCrLf
    Response.Write "          </td>" & vbCrLf
    Response.Write "          <td width='80%'> " & vbCrLf
    Response.Write "            <textarea Name='Explain' cols='60' rows='4'></textarea>" & vbCrLf
    Response.Write "          </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='submit' Name='Submit' value='添加'>" & vbCrLf
    Response.Write "              <input type='button' name='Submit2' value='清空'>" & vbCrLf
    Response.Write "            </div>" & vbCrLf
    Response.Write "          </td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "      </table>" & vbCrLf
    Response.Write "    </form>" & vbCrLf
End Sub

Sub SaveAdd()
    Dim sql, rscID
    rscID = PE_CLng(Request("ClassroomID"))
    Set InsertCursor = Server.CreateObject("ADODB.Recordset")
    cmdTemp = "SELECT top 1 * FROM PE_Equipment order by id desc"
    InsertCursor.Open cmdTemp, Conn, 1, 3
    InsertCursor.addnew
    InsertCursor("Explain") = Request("Explain")
    InsertCursor("EquipmentName") = PE_HTMLEncode(Request("EquipmentName"))
    InsertCursor("EquipmentValue") = PE_HTMLEncode(Request("EquipmentValue"))
    InsertCursor("EquipmentIntroduce") = Request("EquipmentIntroduce")
    InsertCursor("EquipmentSituation") = Request("EquipmentSituation")
    InsertCursor("ClassroomID") = rscID
    InsertCursor.Update
    InsertCursor.Close
    Conn.Close
    Set InsertCursor = Nothing
    Set Conn = Nothing
    Call WriteSuccessMsg("添加设备成功！", ComeUrl)

End Sub

Function wwselectTreeList(i, deep, ClassroomIDdd)
    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")
            If deep = 0 Then
                Response.Write "<option value='0'"
            Else
                Response.Write "<option value='" & rsID & "'"
            End If
            If rsID = ClassroomIDdd Then Response.Write " selected"
            Response.Write ">"
            For tempi = 1 To deep
                    Response.Write "&nbsp;"
            Next
            Response.Write rsName & "</option>"
            Call wwselectTreeList(rsID, deep + 1, ClassroomIDdd)
            rs.MoveNext
        Loop
    End If
End Function

Function selectTreeLists(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

Sub Modify()
    Dim rs, sql
    Dim ClassroomIDdd
    sql = "select * from PE_Equipment where id=" & PE_CLng(Request("id"))
    Set rs = Conn.Execute(sql)
    Response.Write "    <script language=Javascript>" & vbCrLf
    Response.Write "    <!--" & vbCrLf
    Response.Write "    function checkForm(){" & vbCrLf
    Response.Write "    if (form1.ClassroomID.value=='0'){" & vbCrLf
    Response.Write "        alert(""请选择设备所属教室"");" & vbCrLf
    Response.Write "        return false;" & vbCrLf
    Response.Write "        }" & vbCrLf
    Response.Write "    if (form1.EquipmentName.value==''){" & vbCrLf
    Response.Write "        alert(""请填写设备名称！！"");" & vbCrLf
    Response.Write "        return false;" & vbCrLf
    Response.Write "        }" & vbCrLf
    Response.Write "    return true;" & vbCrLf
    Response.Write "    }" & vbCrLf
    Response.Write "    //-->" & vbCrLf
    Response.Write "    </script>" & vbCrLf
    If rs.EOF And rs.BOF Then
        Response.Write "该设备已被删除,<a href=Javascript:window.history.go(-1)>返回</a>" & vbCrLf
    Else
        ClassroomIDdd = rs("ClassroomID")
        Response.Write "        <br>" & vbCrLf
        Response.Write "        <form method='post' action='Admin_Equipment.asp?Action=SaveModify' name='form1' onSubmit='return checkForm()'>" & vbCrLf
        Response.Write "          <table width='100%' class='border' border='0' cellspacing='1' cellpadding='1' align='center'>" & vbCrLf
        Response.Write "            <tr> " & vbCrLf
        Response.Write "              <td colspan='2' class='title'> " & vbCrLf
        Response.Write "                <div align='center'><strong>修 改 设 备</strong></div>" & vbCrLf
        Response.Write "              </td>" & vbCrLf
        Response.Write "            </tr>" & vbCrLf
        Response.Write "            <tr class='tdbg'> " & vbCrLf
        Response.Write "              <td width='20%' nowrap> " & vbCrLf
        Response.Write "                <div align='right'><strong>设备所属教室:</strong></div>" & vbCrLf
        Response.Write "              </td>" & vbCrLf
        Response.Write "              <td width='80%'>" & vbCrLf
        Response.Write "                <select name='ClassroomID'>" & vbCrLf
        Call wwselectTreeList(0, 0, ClassroomIDdd)
        Response.Write "                </select>" & vbCrLf
        Response.Write "                <input type='hidden' name='id' value='" & Request("id") & "'>" & vbCrLf
        Response.Write "              </td>" & vbCrLf
        Response.Write "            </tr>" & vbCrLf
        Response.Write "            <tr class='tdbg'> " & vbCrLf
        Response.Write "              <td width='20%' nowrap> " & vbCrLf
        Response.Write "                <div align='right'><strong>设备名称:</strong></div>" & vbCrLf
        Response.Write "              </td>" & vbCrLf
        Response.Write "              <td width='80%'> " & vbCrLf
        Response.Write "                <input type='text' name='EquipmentName' maxlength='50' size='40' value='" & rs("EquipmentName") & "'>" & vbCrLf
        Response.Write "                <font color='#ff0000'>*</font></td>" & vbCrLf
        Response.Write "            </tr>" & vbCrLf
        Response.Write "            <tr class='tdbg'> " & vbCrLf
        Response.Write "              <td width='20%' nowrap> " & vbCrLf
        Response.Write "                <div align='right'><strong>设备价值:</strong></div>" & vbCrLf
        Response.Write "              </td>" & vbCrLf
        Response.Write "              <td width='80%'> " & vbCrLf
        Response.Write "                <input type='text' name='EquipmentValue' maxlength='100' size='12' value='" & rs("EquipmentValue") & "'>" & vbCrLf
        Response.Write "                ￥</td>" & vbCrLf
        Response.Write "            </tr>" & vbCrLf
        Response.Write "            <tr class='tdbg'> " & vbCrLf
        Response.Write "              <td width='20%' nowrap> " & vbCrLf
        Response.Write "                <div align='right'><strong>设备状态:</strong></div>" & vbCrLf
        Response.Write "              </td>" & vbCrLf
        Response.Write "              <td width='80%'> " & vbCrLf
        Response.Write "                <select name='EquipmentSituation'>" & vbCrLf
        If rs("EquipmentSituation") = "1" Then
            Response.Write "                  <option value='1'>正常</option>" & vbCrLf
            Response.Write "                  <option value='0'>不正常</option>" & vbCrLf
        Else
            Response.Write "                  <option value='0'>不正常</option>" & vbCrLf
            Response.Write "                  <option value='1'>正常</option>" & vbCrLf
        End If
        Response.Write "                </select> " & vbCrLf
        Response.Write "              </td>" & vbCrLf
        Response.Write "            </tr>" & vbCrLf
        Response.Write "            <tr class='tdbg'> " & vbCrLf
        Response.Write "              <td width='20%' nowrap> " & vbCrLf
        Response.Write "                <div align='right'><strong>设备简介:</strong></div>" & vbCrLf
        Response.Write "              </td>" & vbCrLf
        Response.Write "              <td width='80%'>" & vbCrLf
        Response.Write "                <textarea name='EquipmentIntroduce' cols='60' rows='4'>" & rs("EquipmentIntroduce") & "</textarea>" & vbCrLf
        Response.Write "              </td>" & vbCrLf
        Response.Write "            </tr>" & vbCrLf
        Response.Write "            <tr class='tdbg'> " & vbCrLf
        Response.Write "              <td width='20%' nowrap> " & vbCrLf
        Response.Write "                <div align='right'><strong>备注:</strong></div>" & vbCrLf
        Response.Write "              </td>" & vbCrLf
        Response.Write "              <td width='80%'>" & vbCrLf
        Response.Write "                <textarea name='explain' cols='60' rows='4'>" & rs("Explain") & "</textarea>" & vbCrLf
        Response.Write "              </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='submit' name='Submit' value='修改'>" & vbCrLf
        Response.Write "                  <input type='button' name='Submit2' value='返回' onClick=""window.location.href='Admin_Equipment.asp';"">" & vbCrLf
        Response.Write "                </div>" & vbCrLf
        Response.Write "              </td>" & vbCrLf
        Response.Write "            </tr>" & vbCrLf
        Response.Write "          </table>" & vbCrLf
        Response.Write "        </form>" & vbCrLf
    End If
End Sub

Sub SaveModify()
    Dim sql
    Set cmdTemp = Server.CreateObject("ADODB.Command")
    Set InsertCursor = Server.CreateObject("ADODB.Recordset")
    cmdTemp.CommandText = "SELECT top 1 * FROM PE_Equipment where id=" & PE_CLng(Request("id"))
    cmdTemp.CommandType = 1
    Set cmdTemp.ActiveConnection = Conn
    InsertCursor.Open cmdTemp, , 1, 3
    If Request("ClassroomID") <> "" Then
        InsertCursor("ClassroomID") = Request("ClassroomID")
    End If
        InsertCursor("EquipmentName") = PE_HTMLEncode(Request("EquipmentName"))
    If Request("EquipmentValue") <> "" Then
        InsertCursor("EquipmentValue") = PE_HTMLEncode(Request("EquipmentValue"))
    End If
    If Request("EquipmentIntroduce") <> "" Then
        InsertCursor("EquipmentIntroduce") = Request("EquipmentIntroduce")
    End If
    InsertCursor("EquipmentSituation") = Request("EquipmentSituation")
    InsertCursor("Explain") = Request("Explain")
    InsertCursor.Update
    InsertCursor.Close
    Set InsertCursor = Nothing
    Call WriteSuccessMsg("修改设备成功！", "Admin_Equipment.asp")
End Sub

Sub Show()
    Dim rs, sql
    Dim ClassroomIDdd
    sql = "select * from PE_Equipment E inner join PE_Classroom C on  E.ClassroomID=C.id where E.id=" & PE_Clng(Request("id"))
    Set rs = Conn.Execute(sql)

    If rs.EOF And rs.BOF Then
        Response.Write "该设备已被删除,<a href=Javascript:window.history.go(-1)>返回</a>" & vbCrLf
    Else
        ClassroomIDdd = rs("ClassroomID")
        Response.Write "        <br>" & vbCrLf
        Response.Write "          <table width='100%' class='border' border='0' cellspacing='1' cellpadding='1' align='center'>" & vbCrLf
        Response.Write "            <tr> " & vbCrLf
        Response.Write "              <td colspan='2' class='title'> " & vbCrLf
        Response.Write "                <div align='center'><strong>查 看 设 备 信 息</strong></div>" & vbCrLf
        Response.Write "              </td>" & vbCrLf
        Response.Write "            </tr>" & vbCrLf
        Response.Write "            <tr class='tdbg'> " & vbCrLf
        Response.Write "              <td width='20%' nowrap> " & vbCrLf
        Response.Write "                <div align='right'><strong>设备所属教室:</strong></div>" & vbCrLf
        Response.Write "              </td>" & vbCrLf
        Response.Write "              <td width='80%'>" & rs("ClassroomName") & "</td>" & vbCrLf
        Response.Write "            </tr>" & vbCrLf
        Response.Write "            <tr class='tdbg'> " & vbCrLf
        Response.Write "              <td width='20%' nowrap> " & vbCrLf
        Response.Write "                <div align='right'><strong>设备名称:</strong></div>" & vbCrLf
        Response.Write "              </td>" & vbCrLf
        Response.Write "              <td width='80%'>" & rs("EquipmentName") & "</td>" & vbCrLf
        Response.Write "            </tr>" & vbCrLf
        Response.Write "            <tr class='tdbg'> " & vbCrLf
        Response.Write "              <td width='20%' nowrap> " & vbCrLf
        Response.Write "                <div align='right'><strong>设备价值:</strong></div>" & vbCrLf
        Response.Write "              </td>" & vbCrLf
        Response.Write "              <td width='80%'>" & rs("EquipmentValue") & "￥</td>" & vbCrLf
        Response.Write "            </tr>" & vbCrLf
        Response.Write "            <tr class='tdbg'> " & vbCrLf
        Response.Write "              <td width='20%' nowrap> " & vbCrLf
        Response.Write "                <div align='right'><strong>设备状态:</strong></div>" & vbCrLf
        Response.Write "              </td>" & vbCrLf
        Response.Write "              <td width='80%'> " & vbCrLf
        If rs("EquipmentSituation") = "1" Then
            Response.Write "正常" & vbCrLf
        Else
            Response.Write "不正常" & vbCrLf
        End If
        Response.Write "              </td>" & vbCrLf
        Response.Write "            </tr>" & vbCrLf
        Response.Write "            <tr class='tdbg'> " & vbCrLf
        Response.Write "              <td width='20%' nowrap> " & vbCrLf
        Response.Write "                <div align='right'><strong>设备简介:</strong></div>" & vbCrLf
        Response.Write "              </td>" & vbCrLf
        Response.Write "              <td width='80%'>" & rs("EquipmentIntroduce") & "</td>" & vbCrLf
        Response.Write "            </tr>" & vbCrLf
        Response.Write "            <tr class='tdbg'> " & vbCrLf
        Response.Write "              <td width='20%' nowrap> " & vbCrLf
        Response.Write "                <div align='right'><strong>备注:</strong></div>" & vbCrLf
        Response.Write "              </td>" & vbCrLf
        Response.Write "              <td width='80%'>" & rs("Explain") & " </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='submit' name='Submit' value='修改信息' onClick=""window.location.href='Admin_Equipment.asp?Action=Modify&id=" & Request("id") & "';"">" & vbCrLf
        Response.Write "                  <input type='button' name='Submit2' value='返回上页' onClick=""window.location.href='Admin_Equipment.asp';"">" & vbCrLf
        Response.Write "                </div>" & vbCrLf
        Response.Write "              </td>" & vbCrLf
        Response.Write "            </tr>" & vbCrLf
        Response.Write "          </table>" & vbCrLf
    End If
    Set rs = Nothing
End Sub

Sub DelEquipment()
    Dim ID
    Dim sql
    sql = "delete from PE_Equipment where id=" & PE_Clng(Request("id"))
    Conn.Execute (sql)
    Call WriteSuccessMsg("设备删除完毕！", ComeUrl)
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")
            If deep = 0 Then
                Response.Write "<option value='0'"
            Else
                Response.Write "<option value='" & rsID & "'"
            End If
            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
%>
