admin_equipment.asp 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. <!--#include file="Inc/common.asp"-->
  2. <!--#include file="Inc/MD5.asp"-->
  3. <!--#include file="Inc/Function.asp"-->
  4. <!--#include file="Admin_Common.asp"-->
  5. <!--#include file="CheckComeUrl.asp"-->
  6. <%
  7. Dim uid, rsRole, isAdmin, rsgan
  8. uid = trim(request("uid"))
  9. if trim(Lcase(AdminName)) = "admin" then
  10. isAdmin = true
  11. else
  12. isAdmin = false
  13. end if
  14. %>
  15. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  16. <html xmlns="http://www.w3.org/1999/xhtml">
  17. <head>
  18. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  19. <title><%=systemPageTitle%></title>
  20. <link href="bs2010.css" rel="stylesheet" type="text/css" />
  21. <script type="text/javascript" src="js/share.js"></script>
  22. <script type="text/javascript" src="js/prototype.js"></script>
  23. <script language="javascript">
  24. function GetData()
  25. {
  26. url="alarm.asp";//调用页面
  27. var xmlhttp=null;
  28. if(window.XMLHttpRequest)
  29. {
  30. xmlhttp=new XMLHttpRequest();
  31. }
  32. if(!xmlhttp&&window.ActiveXObject)
  33. {
  34. try
  35. {
  36. xmlhttp=new ActiveXObject("Msxml2.XMLHTTP.5.0")
  37. }
  38. catch(e)
  39. {
  40. try
  41. {
  42. xmlhttp=new ActiveXObject("Msxml2.XMLHTTP.4.0")
  43. }
  44. catch(e){
  45. try
  46. {
  47. new ActiveXObject("Msxml2.XMLHTTP")
  48. }
  49. catch(e)
  50. {
  51. try{
  52. new ActiveXObject("Microsoft.XMLHTTP")
  53. }catch(e)
  54. {
  55. }
  56. }
  57. }
  58. }
  59. }
  60. if(!xmlhttp){alert("XMLHTTP不可用,请升级安装。");location="support/msxml.msi"}
  61. xmlhttp.open("GET",url,false);
  62. xmlhttp.send();
  63. var str = xmlhttp.responseText;
  64. document.getElementById("loadcontent").innerHTML=str;
  65. setTimeout("GetData()",<%=refreshRate%>);
  66. }
  67. </script>
  68. <SCRIPT language=javascript>
  69. function unselectall(){
  70. if(document.myform.chkAll.checked){
  71. document.myform.chkAll.checked = document.myform.chkAll.checked&0;
  72. }
  73. }
  74. function CheckAll(form){
  75. for (var i=0;i<form.elements.length;i++){
  76. var e = form.elements[i];
  77. if (e.Name != "chkAll"&&e.disabled!=true)
  78. e.checked = form.chkAll.checked;
  79. }
  80. }
  81. </script>
  82. </head>
  83. <body onLoad="javascript:GetData();">
  84. <table width="100%" border="0" cellspacing="0" cellpadding="0">
  85. <tr>
  86. <td class="mainbg"><table width="760" border="0" cellspacing="0" cellpadding="0">
  87. <tr>
  88. <td valign="top">
  89. <div id="loadcontent">
  90. <p></p>
  91. 数据载入中……</div>
  92. <br />
  93. <table width="100%" border="0" cellspacing="0" cellpadding="0">
  94. <tr>
  95. <td width="20" height="40"><img src="images/arr1.gif" width="14" height="18" /></td>
  96. <td class="deviceName">设备管理</td>
  97. </tr>
  98. </table>
  99. <br />
  100. <%
  101. Action = request("Action")
  102. select case Action
  103. case "Modify"
  104. call Modify
  105. case "SaveModify"
  106. call SaveModify
  107. case "doMoveToClass"
  108. call doMoveToClass
  109. case else
  110. call main
  111. end select
  112. sub main()
  113. %>
  114. <form name='myform' method='Post' action='Admin_equipment.asp'>
  115. <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
  116. <tr>
  117. <td width="40" class="deviceTdTitle">选中</td>
  118. <td width="40" class="deviceTdTitle">ID</td>
  119. <td width="240" class="deviceTdTitle">所属区域 - <a href="admin_equipment.asp" style="font-weight:normal">显示全部</a></td>
  120. <td class="deviceTdTitle">设备名称</td>
  121. <td width="100" class="deviceTdTitle">操作</td>
  122. </tr>
  123. <%
  124. dim rse, sqle, t_classid
  125. t_classid = trim(request("t_classid"))
  126. if t_classid = "" then
  127. sqle = "select id, devicename, areaid from t_dev_property order by areaid, devicename"
  128. else
  129. sqle = "select id, devicename, areaid from t_dev_property where areaid = " & t_classid & " and uid in (select uid from t_dev_property where isuse = '1') order by devicename"
  130. end if
  131. set rse = server.CreateObject("adodb.recordset")
  132. rse.open sqle, conn, 1, 1
  133. if rse.bof and rse.eof then
  134. %>
  135. <tr class="deviceTd">
  136. <td colspan="5" align="center">没有设备</td>
  137. </tr>
  138. <%
  139. else
  140. do while not rse.eof
  141. %>
  142. <tr class="deviceTd">
  143. <td align="center"><input name='eid' type='checkbox' onclick='CheckItem(this)' id='eid' value='<%=rse("id")%>'></td>
  144. <td align="center"><%=rse("id")%></td>
  145. <td align="center"><a href="admin_equipment.asp?t_classid=<%=rse("areaid")%>">
  146. </a>
  147. <table border="0" cellspacing="0" cellpadding="0">
  148. <tr>
  149. <td align="left">
  150. <a href="admin_equipment.asp?t_classid=<%=rse("areaid")%>">
  151. <%
  152. set rsgan = conn.execute("select t_classid, parentpath from t_area where t_classid = " & rse("areaid"))
  153. response.write GetPath(rsgan(0), rsgan(1))
  154. %>
  155. </a> </td>
  156. </tr>
  157. </table> </td>
  158. <td align="center"><%=rse("devicename")%></td>
  159. <td align="center"><a href="admin_equipment.asp?Action=Modify&id=<%=rse("id")%>">修改</a></td>
  160. </tr>
  161. <%
  162. rse.movenext
  163. loop
  164. end if
  165. rse.close
  166. set rse = nothing
  167. %>
  168. <tr class="deviceTd">
  169. <td colspan="5" height="40"><table width="100%" border="0" cellspacing="0" cellpadding="0">
  170. <tr>
  171. <td><input name='chkAll' type='checkbox' id='chkAll' onclick='CheckAll(this.form)' value='checkbox' />
  172. 选中本页显示的所有设备</td>
  173. <td align="right">将选中的设备移动到
  174. <select name='areaid'>
  175. <%=GetClass_Option(1, 0)%>
  176. </select>
  177. <input type="hidden" id="Action" name="Action" value="doMoveToClass" />
  178. <input type='submit' name='Submit4' value=' 执行批量移动 '></td>
  179. </tr>
  180. </table> </td>
  181. </tr>
  182. </table>
  183. </form>
  184. <%
  185. end sub
  186. sub modify()
  187. dim rsem, id
  188. id = trim(request("id"))
  189. set rsem = conn.execute("select * from t_dev_property where id = " & id)
  190. if rsem.bof and rsem.eof then
  191. response.write "error"
  192. else
  193. %>
  194. <form name='form1' method='post' action='Admin_equipment.asp' onsubmit='return check()'>
  195. <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
  196. <tr class="deviceTd">
  197. <td width="40" align="center"><%=rsem("id")%></td>
  198. <td width="200" align="center"><select name='areaid'><%=GetClass_Option(1, rsem("areaid"))%></select></td>
  199. <td align="center"><%=rsem("devicename")%></td>
  200. <td width="120" align="center">
  201. <input name='Action' type='hidden' id='Action' value='SaveModify'>
  202. <input name="ID" type="hidden" id="ID" value="<%=rsem("id")%>" />
  203. <input name='Modify' type='submit' value=' 修改' style='cursor:hand;'>&nbsp;&nbsp;</td>
  204. </tr>
  205. </table>
  206. </form>
  207. <%
  208. end if
  209. end sub
  210. sub SaveModify()
  211. dim id, areaid, devicename, rssm, sqlsm
  212. id = trim(request("ID"))
  213. areaid = trim(request("areaid"))
  214. 'devicename = trim(request("devicename"))
  215. sqlsm = "select * from t_dev_property where id = " & id
  216. set rssm = server.CreateObject("adodb.recordset")
  217. rssm.open sqlsm, conn, 1, 3
  218. if rssm.bof and rssm.eof then
  219. FoundErr = True
  220. ErrMsg = ErrMsg & "<li>找不到指定的区域!</li>"
  221. rssm.Close
  222. Set rssm = Nothing
  223. Exit Sub
  224. end if
  225. 'rssm("devicename") = devicename
  226. rssm("areaid") = areaid
  227. rssm.update
  228. rssm.close
  229. set rssm = nothing
  230. If FoundErr = True Then Exit Sub
  231. Response.Redirect "Admin_equipment.asp"
  232. end sub
  233. sub doMoveToClass()
  234. dim BatchInfoID, areaid, rsar
  235. BatchInfoID = ReplaceBadChar(Request("Batcheid"))
  236. If BatchInfoID = "" Then
  237. BatchInfoID = ReplaceBadChar(Request("eid"))
  238. End If
  239. if BatchInfoID = "" then response.write "<script language='javascript'>alert('请至少选择一个设备!');window.history.go(-1);</script>"
  240. if BatchInfoID = "" then response.end
  241. areaid = trim(request("areaid"))
  242. set rsar = conn.execute("select child from t_area where t_classid = " & areaid)
  243. if rsar(0) <> 0 then response.write "<script language='javascript'>alert('所选区域不能含有子区域!');window.history.go(-1);</script>"
  244. if rsar(0) <> 0 then response.end
  245. conn.execute("update t_dev_property set areaid = " & areaid & " where id in (" & BatchInfoID & ")")
  246. response.redirect "admin_equipment.asp"
  247. end sub
  248. %> </td>
  249. </tr>
  250. </table></td>
  251. </tr>
  252. <tr>
  253. <td>&nbsp;</td>
  254. </tr>
  255. </table>
  256. </body>
  257. </html>
  258. <%
  259. Function GetClass_Option(iChannelID, CurrentID)
  260. Dim rsClass, sqlClass, strTemp, tmpDepth, i
  261. Dim arrShowLine(20)
  262. For i = 0 To UBound(arrShowLine)
  263. arrShowLine(i) = False
  264. Next
  265. sqlClass = "Select t_classid,ClassName,ClassType,Depth,NextID from t_area where ChannelID=" & iChannelID & " order by RootID,OrderID"
  266. Set rsClass = Conn.Execute(sqlClass)
  267. If rsClass.BOF And rsClass.EOF Then
  268. strTemp = "<option value=''>请先添加区域</option>"
  269. Else
  270. strTemp = ""
  271. Do While Not rsClass.EOF
  272. tmpDepth = rsClass(3)
  273. If rsClass(4) > 0 Then
  274. arrShowLine(tmpDepth) = True
  275. Else
  276. arrShowLine(tmpDepth) = False
  277. End If
  278. strTemp = strTemp & "<option value='" & rsClass(0) & "'"
  279. If CurrentID > 0 And rsClass(0) = CurrentID Then
  280. strTemp = strTemp & " selected"
  281. End If
  282. strTemp = strTemp & ">"
  283. If tmpDepth > 0 Then
  284. For i = 1 To tmpDepth
  285. strTemp = strTemp & "&nbsp;&nbsp;"
  286. If i = tmpDepth Then
  287. If rsClass(4) > 0 Then
  288. strTemp = strTemp & "├&nbsp;"
  289. Else
  290. strTemp = strTemp & "└&nbsp;"
  291. End If
  292. Else
  293. If arrShowLine(i) = True Then
  294. strTemp = strTemp & "│"
  295. Else
  296. strTemp = strTemp & "&nbsp;"
  297. End If
  298. End If
  299. Next
  300. End If
  301. strTemp = strTemp & rsClass(1)
  302. If rsClass(2) = 2 Then
  303. strTemp = strTemp & "(外)"
  304. End If
  305. strTemp = strTemp & "</option>"
  306. rsClass.MoveNext
  307. Loop
  308. End If
  309. rsClass.Close
  310. Set rsClass = Nothing
  311. GetClass_Option = strTemp
  312. End Function
  313. Function GetPath(ParentID, ParentPath)
  314. on error resume next
  315. Dim strPath, i
  316. If ParentID <= 0 Then
  317. GetPath = "无(所属区域已被删除)"
  318. Exit Function
  319. End If
  320. ParentPath = ParentPath & "," & ParentID
  321. Dim rsParent, sqlParent
  322. sqlParent = "Select * from t_area where t_classid in (" & ParentPath & ") order by Depth"
  323. Set rsParent = Conn.Execute(sqlParent)
  324. Do While Not rsParent.EOF
  325. For i = 1 To rsParent("Depth")
  326. strPath = strPath & "&nbsp;&nbsp;&nbsp;"
  327. Next
  328. If rsParent("Depth") > 0 Then
  329. strPath = strPath & "└&nbsp;"
  330. End If
  331. strPath = strPath & rsParent("ClassName") & "<br>"
  332. rsParent.MoveNext
  333. Loop
  334. rsParent.Close
  335. Set rsParent = Nothing
  336. GetPath = strPath
  337. End Function
  338. Call CloseConn
  339. %>