📄 typemgr.inc
字号:
<%
Function ListTableHeader()
ListTableHeader = _
"<table cellspacing=1 cellpadding=3 width=300 border=0 align=center bgcolor=silver>" & vbLF & _
"<tr><td colspan=" & iCols & " bgcolor=""#0040a0"" align=center style=""color:white;font-weight:600"" height=20 >设备类型列表</td></tr>" & vbLF & _
"<tr bgcolor=""#eeeeee""><td class=tdHead width=300> <img src=""../images/bg/ar-y.gif"" width=8 height=8> " & TableHeaderField(sFileName, "description", "设备类型名称", sFormParams, sSorting, sSorted) & "</td>" & vbLF & _
"</tr>" & vbLF
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 ' 临时循环变量
'------------------------------------
' 分页所需的变量定义
'------------------------------------
Dim iCounter : iCounter = 1
Dim iPrevPage, iNextPage
'------------------------------------
' 获取数据库连接
'------------------------------------
' response.write sSQL
' response.end
dim rs : set rs = Openrs(conn,sSQL)
dim iTypeId, sTypeDescription
dim sColor
' 如果未到记录尾,将记录定位到你翻到的页面的第一个记录,否则显示空行
if Not rs.EOF then
rs.Move (iCurrentPage - 1) * iRecordsPerPage
end if
while not rs.EOF and iCounter <= iRecordsPerPage
iTypeId = rs("id")
sTypeDescription = rs("description")
if CStr(iTypeId) = CStr(pTypeId) then '' 如果是选中的纪录,显示不同的颜色,这里指定红色
sColor = "red"
else
sColor = "black"
end if
sTemp = sTemp & "<tr bgcolor=white>" & vbLF & _
"<td title=""" & sTypeDescription & """ style=""cursor:hand;color:" & sColor & """ onclick=""javascript:location.href='typemgr.asp?id=" & iTypeId & "&Page="&iCurrentPage&"';""> <img src=""../images/bg/ar-g.gif"" width=8 height=8> " & Bref(sTypeDescription,20) & " </td>" & vbLF & _
"</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 FormTable()
dim sTitle, sActionLinks
if IsEmpty(pTypeId) then
sTitle = "新增类型" '' 显示新增、取消的链接
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 & _
" </td>" & vbLF & _
"</tr>" & vbLF
else
sTitle = "重命名类型名称" '' 显示修改、删除、取消的链接
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 & _
" </td>" & vbLF & _
"</tr>" & vbLF
end if
if hasright(ID_EQUIPMENT) < RIGHT_WRITE then
' Response.Write _
' "<script language=""javascript"">" & vbLF & _
' " alert(""对不起,您没有更新系统结构的权限(您的角色没有设备更新的权限)!"");" & vbLF & _
' "</script>" & vbLF
FormTable = _
"<table cellspacing=1 cellpadding=0 bgcolor=white border=0 width=300 height=""100%"">" & vbLF & _
"<tr height=40><td><center></center></td></tr>" & vbLF & _
"<tr height=20><td><center>此处是新增和更新设备类型的页面。</center></td></tr>" & vbLF & _
"<tr height=20><td><center></center></td></tr>" & vbLF & _
"<tr height=20>" & vbLF & _
" <td><center>目前您没有权限修改设备类型!</center></td></tr>" & vbLF & _
"<tr height=210><td></td></tr>" & vbLF & _
"</table>" & vbLF & _
""
exit function
end if
FormTable = _
"<table cellspacing=1 cellpadding=0 bgcolor=white border=0 width=300 height=""100%"">" & vbLF & _
"<form method=post name=frmMgr action=""typemgr.asp"">" & vbLF & _
"<input type=""hidden"" name=""FormAction"">" & vbLF & _
"<input type=""hidden"" name=""Page"" value=""" & iCurrentPage & """>" & vbLF & _
"<input type=""hidden"" name=""id"" value=""" & pTypeId & """>" & vbLF & _
"<tr height=20>" & vbLF & _
" <td colspan=2 background=""../images/bg/bnbg.gif"" style=""color:white;font-weight:600"" align=center>" & sTitle & "</td></tr>" & vbLF & _
"<tr height=20><td></td></tr>" & vbLF & _
"<tr bgcolor=""#FFFFFF"" height=60>" & vbLF & _
" <td width=80 align=right>类型名称:</td>" & _
" <td><input type=""text"" name=""description"" value=""" & sTypeDesc & """ size=31 maxlength=10></td></tr>" & vbLF & _
sActionLinks & vbLF & _
"<tr height=180><td></td></tr>" & vbLF & _
"</form>" & _
"</table>" & vbLF & _
""
End Function
Function TableLink()
TableLink = _
"<table width=600 cellspacing=0 cellpadding=0 border=2 align=center>" & _
"<tr height=10>" & _
" <td width=600><img src=""../images/bg/line.gif"" width=600 height=3></td>" & _
"</tr>" & _
"<tr height=20>" & _
" <td width=600> " & _
" <img src=""../images/goto.gif""> <a href=""position.asp"">职务管理</a>" & _
" " & _
" <img src=""../images/goto.gif""> <a href=""emp_ol.asp"">员工信息查询</a></td>" & _
"</tr>" & _
"</table>"
End Function
sub AddType()
if hasright(ID_EQUIPMENT) < RIGHT_WRITE then
Response.Write _
"<script language=""javascript"">" & vbLF & _
" alert(""对不起,您没有添加设备类型的权限(您的角色没有设备更新的权限)!"");" & vbLF & _
"</script>" & vbLF
exit sub
end if
dim sSQL, iRows
sTypeDesc = Trim(GetParam("description"))
'' 类别名称不能为空
if sTypeDesc = "" then
Response.Write _
"<script language=""javascript"">" & vbLF & _
" alert(""对不起,请输入类型名称"");" & vbLF & _
"</script>" & vbLF
exit sub
end if
'' 检查是否存在重复的类别名称
iRows = DLookUp(conn, "select count(*) from t_equipment_type where type_desc =" & ToSQL(sTypeDesc, "Text"))
if iRows > 0 then
Response.Write _
"<script language=""javascript"">" & vbLF & _
" alert(""对不起,已经存在名称为“" & sTypeDesc & "”的类型,类型名称不能重复!"");" & vbLF & _
"</script>" & vbLF
exit sub
end if
sSQL = "insert into t_equipment_type(type_desc) values(" & ToSQL(sTypeDesc, "Text") & ")"
conn.Execute(sSQL)
pTypeId = empty '' 重新置成新增状态
sTypeDesc = ""
end sub
sub UpdateType()
if hasright(ID_EQUIPMENT) < RIGHT_WRITE then
Response.Write _
"<script language=""javascript"">" & vbLF & _
" alert(""对不起,您没有更新设备类型的权限(您的角色没有设备更新的权限)!"");" & vbLF & _
"</script>" & vbLF
exit sub
end if
dim sSQL, iRows
sTypeDesc = Trim(GetParam("description"))
'' 类别名称不能为空
if sTypeDesc = "" then
Response.Write _
"<script language=""javascript"">" & vbLF & _
" alert(""对不起,请输入类型名称"");" & vbLF & _
"</script>" & vbLF
exit sub
end if
'' 检查是否存在重复的类别名称
iRows = DLookUp(conn, "select count(*) from t_equipment_type where type_desc=" & ToSQL(sTypeDesc, "Text") & " and type_id<>" & ToSQL(pTypeId,"Number"))
if iRows > 0 then
Response.Write _
"<script language=""javascript"">" & vbLF & _
" alert(""对不起,类型名称不能重复!"");" & vbLF & _
"</script>" & vbLF
exit sub
end if
sSQL = "update t_equipment_type set type_desc = " & ToSQL(sTypeDesc, "Text") & " where type_id = " & ToSQL(pTypeId, "Number")
' response.write sSQL
' response.end
conn.Execute(sSQL)
pTypeId = empty
sTypeDesc = ""
end sub
sub DeleteType()
if hasright(ID_EQUIPMENT) < RIGHT_WRITE then
Response.Write _
"<script language=""javascript"">" & vbLF & _
" alert(""对不起,您没有删除设备类型的权限(您的角色没有设备更新的权限)!"");" & vbLF & _
"</script>" & vbLF
exit sub
end if
sTypeDesc = Trim(GetParam("description"))
dim sSQL, iRows
'' 检查是否存在使用中的类别名称
iRows = DLookUp(conn, "select count(*) from t_equipment where type =" & ToSQL(pTypeId, "Number"))
if iRows > 0 then
Response.Write _
"<script language=""javascript"">" & vbLF & _
" alert(""对不起,系统中有" & iRows & "个类型为“" & sTypeDesc & "”的设备,该类型名称不能删除!"");" & vbLF & _
"</script>" & vbLF
exit sub
end if
sSQL = "delete from t_equipment_type where type_id = " & ToSQL(pTypeId, "Number")
conn.Execute(sSQL)
pTypeId = empty '' 重新置成新增状态
sTypeDesc = ""
end sub
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -