📄 emachinery.inc
字号:
<%
''*******************************************************************************
' 服务器端代码
''*******************************************************************************
' 建立数据库连接
dim conn : Set conn = DBConnection
dim gEid : gEid = GetParam("eid")
dim gAid : gAid= GetParam("aid")
'-------------------------------------------------------------------------------------------------------------------------------
' 分页相关的变量定义
'-------------------------------------------------------------------------------------------------------------------------------
Dim sSQL, sWhere, sOrderby :
Dim sFileName : sFileName = "emachinery.asp"
Dim iTotalRecords : iTotalRecords = 0 ' 分页
Dim iRecordsPerPage : iRecordsPerPage = 5
Dim iTotalPages : iTotalPages = 0
Dim iCols : iCols = 5
Dim iCurrentPage : iCurrentPage = GetParam("Page")
Dim sSorting : sSorting = GetParam("Sorting")
Dim sSorted : sSorted = GetParam("Sorted")
Dim sSortParams : sSortParams = ""
Dim sFormParams : sFormParams = "eid="& gEid & "&"
Dim sDirection : sDirection = ""
''*******************************************************************************
'' 构造分页的SQL语句
''*******************************************************************************
sSQL = "select * from t_machinery where equi_id=" & gEid
'sOrderby = " order by name asc"
'sWhere =
''*******************************************************************************
'' 构造Where子句
'-------------------------------------------------------------------------------------------------------------------------------
' 定义全局变量 ---- 查询参数
'response.write sSQL & sWhere & sOrderby & "<br>"
'response.end
''*******************************************************************************
' 分页SQL语句构造完毕,调用PrepareListData进行分页前的准备
'-------------------------------------------------------------------------------------------------------------------------------
dim nf : nf = Array("名称","产地","启用时间","数量","保养商")
dim arrayFields : arrayFields = Array("name","origin","starttime","quantity","maintainer")
dim sDelimiter : sDelimiter = "*"
dim lb : lb = LBound(nf)
dim ub : ub = UBound(nf)
call PrepareListData(conn, sSQL, Join(arrayFields, sDelimiter), sDelimiter)
''*******************************************************************************
Dim sFormAction
if UCase(Request.ServerVariables("REQUEST_METHOD") = "POST") then
sFormAction = GetParam("FormAction")
select case sFormAction
case "insert":
call AddEq()
case "insertchild":
call AddChildEq()
case "update":
call UpdateEq()
case "delete":
call DeleteEq()
end select
end if
Function ListTableHeader()
dim s
dim s1
dim i
s = _
"<table cellspacing=1 cellpadding=3 width=""100%"" border=0 align=center bgcolor=silver style=""table-layout:fixed"">" & vbLF & _
"<tr style=""display:none"">" & vbLF & _
" <td width=160>这一行仅用于控制表格宽度</td>" & vbLF & _
" <td width=160></td>" & vbLF & _
" <td width=120></td>" & vbLF & _
" <td width=65></td>" & vbLF & _
" <td width='*'></td>" & vbLF & _
"<tr><td colspan=" & iCols & " bgcolor=""#0040a0"" align=center style=""color:white;font-weight:600"" height=20 >设 备 电 机 列 表</td></tr>" & vbLF & _
"<tr bgcolor=""#eeeeee"">" & vbLF
s1 = " <td class=tdHead > <img src=""../images/bg/ar-y.gif"" width=8 height=8> " & _
TableHeaderField(sFileName, arrayFields(0), nf(0), sFormParams, sSorting, sSorted) & "</td>" & vbLF
for i = lb+1 to ub
s1 = s1 & " <td class=tdHead align=center>" & _
TableHeaderField(sFileName, arrayFields(i), nf(i), sFormParams, sSorting, sSorted) & "</td>" & vbLF
next
' s1 = wdas("删除|更新"," class=tdHead ")
s= s & s1 & "</tr>" & vbLF
ListTableHeader = s
End Function
Function ListTableTailer()
ListTableTailer = "</table>" & vbLF
End Function
Function ListTableRecords(sSQL, iCols, iRecordsPerPage, iTotalRecords, iCurrentPage, iTotalPages, sFileName, sFormParams, sSortParams)
dim sTemp : sTemp = "" ' 临时字符串变量
dim j,i ' 临时循环变量
dim ne : ne = nf
dim s1,s2
'------------------------------------
' 分页所需的变量定义
'------------------------------------
Dim iCounter : iCounter = 1
Dim iPrevPage, iNextPage
'------------------------------------
' 获取数据库连接
'------------------------------------
' response.write sSQL
' response.end
dim rs : set rs = Openrs(conn,sSQL)
dim iEquiId, iSysId, iParentEquiId, sName, sNumber, sModel, sTypeDesc, sRoomno
dim sty : sty = ""
dim a,t
' 如果未到记录尾,将记录定位到你翻到的页面的第一个记录,否则显示空行
if Not rs.EOF then
rs.Move (iCurrentPage - 1) * iRecordsPerPage
end if
while not rs.EOF and iCounter <= iRecordsPerPage
for i = lb to ub
ne(i) = GetValue(rs, arrayFields(i))
Next
'baoyangshang
if cint(ne(4)) = 0 Then
ne(4)="未知"
Else
ne(4) = DLookup(conn,"select name from t_firm where id=" & ne(4))
End IF
a = GetValue(rs,"id")
If cint(a) = cint(gAid) Then
sty = "color:red"
'' t = ModifyTable
Else
sty= "color:blue"
' t=""
End If
s1 = "<tr bgcolor=white style = "& sty &">" & vbLF
s1 = s1 & " <td title=""" & ne(0) & """ style=""cursor:hand"" onclick=""javascript:location.href='emachinery.asp?eid="&gEid & "&aid="&a&"';""> <img src=""../images/bg/ar-g.gif"" width=8 height=8> " & Bref(ne(0),16) & " </td>" & vbLF
for i = lb+1 to ub
s1 = s1 & " <td align=center>" & ne(i) & "</td>" & vbLF
next
sTemp = sTemp & s1 & "</tr>" & vbLF
iCounter = iCounter + 1
rs.movenext
wend
' 填补空白行
sTemp = sTemp & WhiteRows(iCols, iCounter, iRecordsPerPage)
' 首页、前页、后页、尾页等分页信息
sTemp = sTemp & "<tr bgcolor=white><td colspan=" & iCols & " align=right>" & vbLF & _
Paginate(sFileName, sFormParams, sSortParams, iCurrentPage, iTotalPages) & vbLF & _
" </td></tr>" & vbLF
ListTableRecords = sTemp
End Function
Function FormHead()
dim s : s=""
s = s & "<form method=post name=frmMgr action=""emachinery.asp"">" & vbLF
s = s & "<input type=""hidden"" name=""FormAction"">" & vbLF
s = s & "<input type=""hidden"" name=""aid"" value=""" & gAid & """>" & vbLF
s = s & "<input type=""hidden"" name=""eid"" value=""" & gEid & """>" & vbLF
' s = s & "<input type=""hidden"" name=""pid"" value=""" & gPid & """>" & vbLF
FormHead = s
End Function
Function ToolTable()
dim sActionLinks
if IsEmpty(gAid) then
sActionLinks = _
"<tr bgcolor=white height=30>" & vbLF & _
" <td colspan=8 align=center>" & vbLF & _
" <img border=0 src=""../images/button/add.gif"" onclick=""btnAdd_OnClick()"" style=""cursor:hand"">" & vbLF & _
" " & vbLF & _
" <img border=0 src=""../images/button/clear.gif"" onclick=""btnClear_OnClick()"" style=""cursor:hand"">" & vbLF & _
" " & vbLF & _
" <img border=0 src=""../images/button/print.gif"" onclick=""javascript:window.open('emprint.asp?eid="& gEid & "','','width=800,height=600,top=20,left=20');"" style=""cursor:hand"" target=_blank>" & vbLF & _
" </td>" & vbLF & _
"</tr>" & vbLF
else
sActionLinks = _
"<tr bgcolor=white height=30>" & vbLF & _
" <td colspan=8 align=center>" & vbLF & _
" <img border=0 src=""../images/button/update.gif"" onclick=""btnUpdate_OnClick()"" style=""cursor:hand"">" & vbLF & _
" " & vbLF & _
" <img border=0 src=""../images/button/delete.gif"" onclick=""btnDelete_OnClick()"" style=""cursor:hand"">" & vbLF & _
" " & vbLF & _
" <img border=0 src=""../images/button/cancel.gif"" onclick=""btnCancel_OnClick()"" style=""cursor:hand"">" & vbLF & _
" " & vbLF & _
" <img border=0 src=""../images/button/print.gif"" onclick=""javascript:window.open('emprint.asp?eid="& gEid & "','','width=800,height=600,top=20,left=20');"" style=""cursor:hand"" target=_blank>" & vbLF & _
" </td>" & vbLF & _
"</tr>" & vbLF
end if
If Hasright(ID_EQUIPMENT) < RIGHT_WRITE Then
sActionLinks = ""
End If
ToolTable = wtba(sActionLinks)
End Function
Function InsertTable()
dim s : s = ""
dim s1 : s1= ""
dim i
dim n1 : n1 = Array("名 称","产 地","数 量","额定电压","额定电流","功 率","启用时间","频 率","转 速","保养商","控制柜编号","备 件")
dim a1 : a1 = Array("name","origin","quantity","rating_voltage","rating_current","power","starttime","frequency","speed","maintainer","controller","spareparts")
dim sDelimiter : sDelimiter = "*"
dim l : l = LBound(n1)
dim u : u = UBound(a1)
dim ee : ee = a1
dim el : el = Array(0,1,2,3)
for i = l to u
ee(i) = "<input type=text maxlength=20 size=20 name="&ee(i)&">"
next
'starttime
ee(6) = DrawCal("", Date, a1(6), "img6")
'maintainer
ee(9) = "<select name=" & a1(9) & "><option value=0>未知</option>"& SelectOptions(conn, "select * from t_firm", "id", "name", "")&"</select>"
s1 = "<tr style=""display:none"">" & vbLF & _
" <td width=60>这一行仅用于控制表格宽度</td>" & vbLF & _
" <td width=140></td>" & vbLF & _
" <td width=70></td>" & vbLF & _
" <td width=140></td>" & vbLF & _
" <td width=40></td>" & vbLF & _
" <td width=*></td>" & vbLF
for i = l to u
ee(i) = wda(n1(i)) & wdas(ee(i), " ")
Next
for i = 0 to 3
i = cint(i)
el(i) = wra(ee(i*3) & ee(i*3+1) & ee(i*3+2))
Next
s = s & "<table cellspacing=0 cellpadding=2 width=""100%"" border=0 align=center style=""table-layout:fixed"">" & vbLF
s = s & s1 & JOin(el," ")
s = s & wtbe
InsertTable = "<center>" & FormHead & s & ToolTable
End Function
Function ModifyTable()
dim s : s = ""
dim i
dim n1 : n1 = Array("名 称","产 地","数 量","额定电压","额定电流","功 率","启用时间","频 率","转 速","保养商","控制柜编号","备 件")
dim a1 : a1 = Array("name","origin","quantity","rating_voltage","rating_current","power","starttime","frequency","speed","maintainer","controller","spareparts")
dim sDelimiter : sDelimiter = "*"
dim l : l = LBound(n1)
dim u : u = UBound(a1)
dim s1 : s1= ""
dim sql
dim ee : ee = a1
dim el : el = Array(0,1,2,3)
sql = "select * from t_machinery where id = " & ToSQL(gAid, "Number")
' ww(sql)
dim rs : set rs = openrs(conn,sql)
If not rs.eof then
for i = l to u
ee(i) = getvalue(rs,a1(i))
Next
Else
werr("无该电机!")
End If
closers(rs)
for i = l to u
If i = 6 or i = 9 Then
Else
ee(i) = "<input type=text maxlength=20 size=20 name="&a1(i)&" value="& ee(i)&">"
End If
next
'starttime
ee(6) = DrawCal("", ee(6), a1(6), "img6")
'maintainer
ee(9) = "<SELECT NAME="& a1(9) &"><option value=0>未知</option>" & SelectOptions(conn, "select * from t_firm", "id", "name", ee(9))&"</SELECT>"
s1 = "<tr style=""display:none"">" & vbLF & _
" <td width=60>这一行仅用于控制表格宽度</td>" & vbLF & _
" <td width=140></td>" & vbLF & _
" <td width=70></td>" & vbLF & _
" <td width=140></td>" & vbLF & _
" <td width=40></td>" & vbLF & _
" <td width=*></td>" & vbLF
for i = l to u
ee(i) = wda(n1(i)) & wdas(ee(i), " ")
Next
for i = 0 to 3
i = cint(i)
el(i) = wra(ee(i*3) & ee(i*3+1) & ee(i*3+2))
Next
s = s & "<table cellspacing=0 cellpadding=2 width=""100%"" border=0 align=center style=""table-layout:fixed"">" & vbLF
s = s & s1 & JOin(el," ")
s = s & wtbe
ModifyTable = "<center>" & FormHead & s & ToolTable
End Function
Function FormTable()
If IsEmpty(gAid) Then
FormTable = InsertTable
Else
FormTable = ModifyTable
End If
End Function
Sub AddEq()
dim i,j
dim sql
dim mev
dim n1 : n1 = Array("名 称","产 地","数 量","额定电压","额定电流","功 率","启用时间","频 率","转 速","保养商","控制柜编号","备 件")
dim a1 : a1 = Array("name","origin","quantity","rating_voltage","rating_current","power","starttime","frequency","speed","maintainer","controller","spareparts")
dim sDelimiter : sDelimiter = "*"
dim l : l = LBound(n1)
dim u : u = UBound(a1)
dim ev2 : ev2 = a1
for i = l to u
If cint(i) = 9 Then
Else
ev2(i) = ToSQL(GetParam(a1(i)),"Text")
End If
Next
ev2(9) = ToSQL(GetParam(a1(9)),"Number")
sql= "insert into t_machinery (equi_id," & Join(a1,",") & ")" & _
"values ("&gEid & "," & JOin(ev2,",") & ")"
' response.write sql
conn.Execute(sql)
End Sub
Sub DeleteEq()
' LookUp sub equipment
dim sSQL, iRows
sSQL = "delete from t_machinery where id=" & gAid
' ww(sSQL)
conn.Execute(sSQL)
gAid = empty
End Sub
Sub UpdateEq()
dim i,j
dim sql
dim mev
dim n1 : n1 = Array("名 称","产 地","数 量","额定电压","额定电流","功 率","启用时间","频 率","转 速","保养商","控制柜编号","备 件")
dim a1 : a1 = Array("name","origin","quantity","rating_voltage","rating_current","power","starttime","frequency","speed","maintainer","controller","spareparts")
dim sDelimiter : sDelimiter = "*"
dim l : l = LBound(n1)
dim u : u = UBound(a1)
dim ev3 : ev3 = a1
for i = l to u
If cint(i) = 9 Then
Else
ev3(i) = ev3(i) & "=" & ToSQL(GetParam(a1(i)),"Text")
End If
Next
ev3(9) = ev3(9) & "=" & ToSQL(GetParam(ev3(9)),"Number")
sql= "update t_machinery set " & Join(ev3,",") & " where id=" & gAid
' ww sql
conn.Execute(sql)
End Sub
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -