**后台:** http://www.823315.com/wlms/admin/
**账号:** admin
**密码:** 123456<br>
**参数模拟提交:** http://www.823315.com/wlms/admin/debug.asp
<br><br>
## 一、添加账户主要代码。位于源代码文件:AccountAdd.asp

```
if request("tijiao")="1" then
'//手机到的表单信息
a_user = request("a_user")
a_pass = request("a_pass")
a_role_rid = request("a_role_rid")
a_creator_aid = request("a_creator_aid")
a_memo = request("a_memo")
'//判断只能管理员才能创建用户
if session("role")="管理员" then
'//将表单内容插入数据库,创建一个用户
strSql="INSERT INTO Account(a_user, a_pass, a_role_rid, a_create_datetime, a_creator_aid, a_memo) VALUES ('" & a_user & "', '" & a_pass & "', " & a_role_rid & ", '" & Now() & "', " & a_creator_aid & ", '" & a_memo & "')"
else
response.write "其他身份角色(" & session("role") & ")不可以操作新建[账号]记录!"
response.end
end if
response.write strSQL
conn.execute(checkSql(strSql))
CloseConn conn
'//创建成功后跳转回用户管理列表
response.redirect "AccountManage.asp"
end if
```

<br><br>
## 二、实时监控主要代码。位于源代码文件:WaterLevelRecordManage_time.asp
```
<meta http-equiv="refresh" content="2">
```
以上代码是每2秒刷新一次以便获得最新结果。<br><br>
```
strSql="SELECT top 1 * FROM WaterLevelRecord ORDER BY id DESC"
set rs=server.createobject("adodb.recordset")
rs.Open (strSql),conn,1,3
```
以上代码是获取水位记录表中的最新的一条,然后显示出来。

<br><br>
## 三、记录管理主要代码。位于源代码文件:WaterLevelRecordManage.asp
```
<%
dim strNoAll
dim strSql
keyword=request("keyword")
session("keyword")=keyword
if keyword<>"" then
strSqlMatchPart=strSqlMatchPart & "(w_a4 LIKE '%" & keyword & "%' OR w_a3 LIKE '%" & keyword & "%' OR w_a2 LIKE '%" & keyword & "%' OR w_a1 LIKE '%" & keyword & "%' OR w_result LIKE '%" & keyword & "%') "
UrlPara=UrlPara & "&keyword=" & keyword
strInfo="关键字为“" & keyword & "”的记录"
end if
'最后只用,只执行一次
UrlParaWithoutPage=UrlPara'不含page,因为页面中不需要page参数
if request("page")<>"" then UrlPara=UrlPara & "&page=" & request("page")
if strSqlMatchPart<>"" then
strSql="SELECT * FROM WaterLevelRecord WHERE " & strSqlMatchPart & " ORDER BY id DESC"
else
strSql="SELECT * FROM WaterLevelRecord ORDER BY id DESC"
end if
if strInfo<>"" then strInfo="(" & strInfo & ")"
set rs=server.createobject("adodb.recordset")
rs.Open checkSql(strSql),conn,1,3
%>
<div style="text-align:center;clear: both; margin:20px auto;"><h1>水位记录一览表<%=strInfo%></h1></div>
<TABLE class="mytable" width="95%" border=0 align="center" cellSpacing=0>
<TR bgcolor="EEF9FF">
<th nowrap><div align="center">序号</div></th>
<th nowrap><div align="center">开关A4状态 开/关</div></th>
<th nowrap><div align="center">开关A3状态 开/关</div></th>
<th nowrap><div align="center">开关A2状态 开/关</div></th>
<th nowrap><div align="center">开关A1状态 开/关</div></th>
<th nowrap><div align="center">判断结果</div></th>
<th nowrap><div align="center">添加者ID</div></th>
<th nowrap><div align="center">创建时间</div></th>
<th nowrap><div align="center">修改时间</div></th>
<th nowrap><div align="center">操作</div></th>
</TR>
<%
if rs.eof then
response.write "<div align='center'><font style='color: #CC0000;font-weight: bold;font-size:18;'>没有数据!</font></div>"
else
rs.pagesize = 20
if request("page")="" or isempty(request("page")) then
page = 1
else
page=int(request("page"))
end if
if page>rs.pagecount then
page=rs.pagecount
end if
Rs.Move Rs.PageSize*(page-1)'根据pagesize和参数page设置记录位置
i=1
do while not rs.eof and i<=rs.pagesize'定义输出条件:1.不能到记录尾,否则出错;2.只能输出不超过pagesize定义的值
%>
<TR>
<td><div align="center"><%=rs("id")%></div></TD>
<td><div align="center"><%=rs("w_a4")%></div></TD>
<td><div align="center"><%=rs("w_a3")%></div></TD>
<td><div align="center"><%=rs("w_a2")%></div></TD>
<td><div align="center"><%=rs("w_a1")%></div></TD>
<td><div align="center"><%="<div style='font-weight:bold; color:" & split(rs("w_result")," ")(1) & "'>" & split(rs("w_result")," ")(0) & "</div>" %></div></TD>
<td><div align="center"><%=rs("w_creator_aid")%></div></TD>
<td><div align="center"><%=rs("w_create_datetime")%></div></TD>
<td><div align="center"><%=rs("w_modify_datetime")%></div></TD>
<TD nowrap><div align="center"><a href="WaterLevelRecordModify.asp?id=<%=rs("id") & UrlPara%>"><i class="dzwfont dzw-xiugai-copy"></i>编辑</a> <a onclick="if(!(confirm('删除该记录“<%=rs("id")%>”将不可恢复,是否确定继续操作?点取消返回'))){return false;}" href="WaterLevelRecordDelete.asp?id=<%=rs("id") & UrlPara%>"><i class="dzwfont dzw-shanchu1"></i>删除</a></div></TD>
</TR>
<%
i=i+1
rs.MoveNext
loop
%>
<TR align="center">
<TD height="26" colspan="10" align=right>
<div align="center">
<%
if rs.recordcount<>0 then
if (page-1) mod 10=0 then
p=(page-1) \ 10
else
p=(page-1) \ 10
end if
response.write "页次:" & page & "/" & rs.pagecount & "页 每页" & rs.pagesize & " 共" & rs.recordcount & "条记录" & " 分页:"
if p*10>0 then
response.write "<a href='?page=" & p*10 & UrlParaWithoutPage & "' title=上十页>[<<]</a>"
end if
uming_i=1
for ii=p*10+1 to P*10+10
if ii=page then
response.write "<font color=#ff0000>["+Cstr(ii)+"]</font> "
else
response.write "<a href='?page="& ii & UrlParaWithoutPage & "'>["+Cstr(ii)+"]</a> "
end if
if ii=rs.pagecount then exit for
uming_i=uming_i+1
next
if ii<=rs.pagecount and uming_i=11 then
response.write "<a href='?page=" & ii & UrlParaWithoutPage & "' title='下十页'>[>>]</a> "
end if
response.write "跳页:<input type=text name=page size='2' maxlength='4' class=wenbenkuang onkeypress='if(event.keyCode==13){document.all.tiaoye.click();}'> <input type=button id='tiaoye' value=Go class=go-wenbenkuang onclick=""javascript:" & "window.open('?page=' + document.all.page.value + '" & UrlParaWithoutPage & "', '_self');"" > "
end if
%>
</div></TD>
</TR>
<%
end if
CloseRs rs
CloseConn conn
%>
```
以上代码是显示所有水位数据记录,每条记录后面有操作项,可以编辑或者删除。

<br><br>
## 四、逻辑判断管理主要代码。位于源代码文件:JudgeManage.asp、JudgeAdd.asp

```
if request("tijiao")="1" then
j_a4 = request("j_a4")
j_a3 = request("j_a3")
j_a2 = request("j_a2")
j_a1 = request("j_a1")
j_result = request("j_result")
j_color = request("j_color")
j_creator_aid = request("j_creator_aid")
if session("role")="管理员" then
strSql="INSERT INTO Judge(j_a4, j_a3, j_a2, j_a1, j_result, j_color, j_creator_aid, j_create_datetime) VALUES ('" & j_a4 & "', '" & j_a3 & "', '" & j_a2 & "', '" & j_a1 & "', '" & j_result & "', '" & j_color & "', " & j_creator_aid & ", '" & Now() & "')"
else
response.write "其他身份角色(" & session("role") & ")不可以操作新建[逻辑判断]记录!"
response.end
end if
response.write strSQL
conn.execute(checkSql(strSql))
CloseConn conn
response.redirect "JudgeManage.asp"
end if
```
以上代码为将表单数据提交到逻辑判断表中,便于后面实时数据传递过来比较来判定结果。

上图只设置了正常情况,这几种情况之外的都会被判定为“ **浮球故障**”
<br><br>
## 五、逻辑判断管理。是用桌面程序嵌入的网页提交数据的。主要代码位于debug.asp

