role_edit.asp
来自「OFFICE办公自动化」· ASP 代码 · 共 330 行
ASP
330 行
<%
'功能:编辑职位
'作者:展亮
'日期:2003-12-2 12:00
'参数: request.form("addedit_subed")="true"#表单提交; request("id")#要编辑记录的ID;
' request("page")=int #当前页码; request.form("Search")=chr #上次查询条件
%>
<!--#include file="../inc/Secure.asp"-->
<!--#include file="../inc/conn.asp"-->
<!--#include file="../inc/Const.asp"-->
<%
'response.buffer=false
'------------------------------------------------设置参数
LoginID=trim(session("LoginID")) : if LoginID="" then LoginID=0 '当前用户ID
currentpage=request("page") : if currentpage="" then currentpage=1 '当前页码
Search=request("Search") '上次查询条件
pid=request("id") '记录ID
'------------------------------------------------
'------------------------------------------------修改记录
table="tbioaRole" '表名
if request.form("addedit_subed")="true" then
'表单提交后
'接受录入参数
input_rolename=Request.Form("input_rolename")'职位名
input_rights=Request.Form("input_rights")'职位权限
'添加时使用的字段
field1=array("rolename","rights","sdate")
value1=array(input_rolename,input_rights,date())
sql="UPDATE " & table & " SET "
for i=0 to ubound(field1)
sql = sql & field1(i) & "='" & replace(value1(i),"'","''") & "'"
if i <> ubound(field1) then sql=sql & "," else sql=sql & " where id=" & pid
next
oConn.Execute sql
word="<p>职位修改成功!</p><p><img border=0 src=../images/icon_show.gif align=left width=16 height=16><a href='#' onclick='javascript:history.back();'>[返回]</a>"
else
'------------------------------------------------修改用户职位
if request.form("edit_subed")="role_add_del" then
'增加用户职位
userlist=Request.Form("useraddlist")'用户列表
if userlist<>"" then
sql="UPDATE tbioaUser SET RoleID=RoleID+',"&pid&"' where id in ("&userlist&") and RoleID<>''"
oConn.Execute sql
sql="UPDATE tbioaUser SET RoleID='"&pid&"' where id in ("&userlist&") and (RoleID='' or RoleID is null)"
oConn.Execute sql
end if
'删除用户职位
userlist=Request.Form("userdellist")'用户列表
if userlist<>"" then
sql = "update tbioaUser set RoleID=" & "replace(replace(replace(replace(replace('@' + RoleID +'@','@" & pid & ",',''),'," & pid & ",',','),'," & pid & "@',''),'@" & pid & "@',''),'@','') where id in(" & userlist & ")"
oConn.Execute sql
end if
end if
'--------------------------------------------取记录
set rs=Server.CreateObject("ADODB.RecordSet")
sql="select * from " & table & " where ID="&pid
rs.open sql,oConn,1,1
'显示字段变量
if (isnull(rs("id"))) then show_id="" else show_id=Server.HTMLEncode(rs("id"))
if (isnull(rs("sdate"))) then show_sdate="" else show_sdate=Server.HTMLEncode(rs("sdate"))
if (isnull(rs("rolename"))) then show_rolename="" else show_rolename=Server.HTMLEncode(rs("rolename"))
if (isnull(rs("rights"))) then show_rights="" else show_rights=Server.HTMLEncode(rs("rights"))
end if
'------------------------------------------------
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="../css/main.css" type=text/css>
<title>编辑部门职位</title>
<script src="../js/Popup.js"></script>
<script src="../js/front_chec.js"></script>
<script src="../js/user_select.js"></script>
<script language="JavaScript">
<!--
function require(form){
return checnull(form.input_rolename,"请填写职位名!")&&
1==1;
}
function role_add_del(form){
addlist=form.useraddlist.value;
dellist=form.useraddlist.value
strusers=users.join(",");
var s,n;
strtmpusers = SelectUsers(strusers);
if (strtmpusers!=""){
strtmpusers=strtmpusers.split("_")[0]
tmpusers=strtmpusers.split(",");
if (strtmpusers != ""){
str=","+strusers+","
for(i=0;i<tmpusers.length;i++) {//判断新增加的成员
k=str.indexOf(","+tmpusers[i]+",");
if (k==-1){
if (addlist=="") addlist = tmpusers[i];
else addlist += ","+tmpusers[i];
}
}
form.useraddlist.value=addlist;
}
if (strusers != ""){
str=","+strtmpusers+","
for(i=0;i<users.length;i++) {//判断被删除的成员
k=str.indexOf(","+users[i]+",");
if (k==-1){
if (dellist=="") dellist = users[i];
else dellist += ","+users[i];
}
}
form.userdellist.value=dellist;
}
form.submit();
}
}
function check_input_rights(per,star,end){
for(i=star;i<=end;i++){
if (per.checked) eventfrm.input_rights[i].checked=true
else eventfrm.input_rights[i].checked=false
}
}
-->
</script>
</head>
<body topmargin="10" leftmargin="10">
<br>
<%=SearchScrip(Search)%>
<div align="center">
<table width="600" cellspacing="1" cellpadding="4" class="tab">
<tr>
<td width="100%" class="tdBottom" valign="top">
<table width="100%" cellspacing="1" cellpadding="2" class="tab">
<tr>
<td width="100%" class="tdTop">
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td class="tdTop2">
<img border="0" src="../images/icon_title.gif" align="left">编辑职位
</td>
<td width="60" class="tdTop2">
<img border="0" src="../images/icon_return.gif" align="left">
<a href="javascript:window.close()" class="linkTop">关闭</a>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="td1">
<% if request.form("addedit_subed")="true" then %>
<script>opener.location.reload();</script>
<table border="0" width="100%" cellspacing="10" cellpadding="0">
<tr>
<td width="36%"> <p align="right"><img border="0" src="../images/edit.gif" width="32" height="32">
</td>
<td width="64%"><p> </p>
<%=word%> </td>
</tr>
<tr>
<td width="100%" colspan="2"> </td>
</tr>
</table>
<% else %>
<form name="eventfrm" method="POST" action="?id=<%=pid%>&page=<%=currentpage%>" onSubmit="return require(this)">
<input type=hidden name="addedit_subed" value="true">
<table border="0" width="100%" cellspacing="1" cellpadding="2" class="tab">
<tr class="td1">
<td nowrap>职位名:
<input type="text" name="input_rolename" value="<%=show_rolename%>" size="40" maxlength="250" class="input">
<font COLOR="RED">*</font> </td>
</tr>
<tr>
<td class="tdtop">职位权限</td>
</tr>
<%set oRsRightType=server.createobject("ADODB.RecordSet")
sql="select Title,Number,Mod from tbioaRoleRightsType"
oRsRightType.open sql,oConn,1,1
dim s,e: s=0: e=0
while not oRsRightType.eof
if oRsRightType("Mod")<>"X" then
set oRsRight=server.createobject("ADODB.RecordSet")
sql="select Title,Number,Mod from tbioaRoleRights where TypeNumber="&oRsRightType("number")
oRsRight.open sql,oConn,1,1
e=s+oRsRight.RecordCount-1
set oRsTypeRight=server.createobject("ADODB.RecordSet")
sql="SELECT COUNT(*) FROM tbioaRoleRights,tbioaRole WHERE CHARINDEX(tbioaRoleRights.Number, tbioaRole.rights)>0 AND tbioaRoleRights.TypeNumber="&oRsRightType("number")&" AND tbioaRole.id="&pid
oRsTypeRight.open sql,oConn,1,1
%>
<tr>
<td width="100%" nowrap class="td2">
<table border="0" cellspacing="0" cellpadding="0"><tr>
<td><INPUT TYPE="checkbox" NAME="all_rights" hidefocus=true onclick="check_input_rights(this,<%=s%>,<%=e%>)" <%if oRsTypeRight(0) then response.write "checked"%>></td>
<td>
<span style="cursor:hand" onClick="if (list_<%=oRsRightType("Number")%>.style.display=='none'){list_<%=oRsRightType("Number")%>.style.display='';p_<%=oRsRightType("Number")%>.src='../images/menu_open.gif';} else {list_<%=oRsRightType("Number")%>.style.display='none';p_<%=oRsRightType("Number")%>.src='../images/menu_close.gif';} ">
<img src="../images/menu_close.gif" border="0" id="p_<%=oRsRightType("Number")%>" align="left">
<%=trim(oRsRightType("Title"))%>
</span>
</td>
</tr></table>
</td>
</tr>
<%s=s+oRsRight.RecordCount%>
<tr id="list_<%=oRsRightType("Number")%>" style="display=none">
<td width="100%" nowrap class="td1">
<table width="100%">
<%while not oRsRight.eof%>
<tr>
<td width="10" nowrap></td>
<td width="50%" nowrap>
<%if not oRsRight.eof then%>
<INPUT TYPE="checkbox" NAME="input_rights" hidefocus=true value="<%=trim(oRsRight("Number"))%>" <%if instr(show_rights,trim(oRsRight("Number")))>0 then response.write " checked"%> <%if oRsRight("Mod")="X" then response.write " disabled"%>>
<font color="#000080"> <%=trim(oRsRight("Title"))%></font>
<%oRsRight.movenext
end if%>
</td>
<td width="50%" nowrap>
<%if not oRsRight.eof then%>
<INPUT TYPE="checkbox" NAME="input_rights" hidefocus=true value="<%=trim(oRsRight("Number"))%>" <%if instr(show_rights,trim(oRsRight("Number")))>0 then response.write " checked"%> <%if oRsRight("Mod")="X" then response.write " disabled"%>>
<font color="#000080"> <%=trim(oRsRight("Title"))%></font>
<%oRsRight.movenext
end if%>
</td>
</tr>
<%wend
oRsRight.close
set oRsRight = nothing%>
</table>
</td>
</tr>
<%end if
oRsRightType.movenext
wend
oRsRightType.close
set oRsRightType = nothing%>
<tr>
<td width="100%" class="tdBottom" align="center"><input type="submit" value=" 确 定 " name="B1" class="button0" onmouseout=className="button0" onmouseover=className="button1">
<input type="reset" value="全部重写" name="B2" class="button0" onmouseout=className="button0" onmouseover=className="button1">
</td>
</tr>
</table>
</form>
<%
rs.close
end if
%>
</td>
</tr>
<tr>
<td width="25%" class="tdBottom"> </td>
</tr>
</table>
</td>
<td valign="top" class="tdBottom" height="100%">
<table width="100%" cellspacing="1" cellpadding="2" class="tab" height="100%">
<tr>
<td class="tdTop" nowrap>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td class="tdTop2">
<img border="0" src="../images/icon_title.gif" align="left">用户列表
</td>
<td width="60" class="tdTop2">
<img border="0" src="../images/icon_add_del.gif" align="left">
<a href="javascript: role_add_del(frmrole)" class="linkTop">编辑</a>
</td>
</tr>
</table>
</td>
</tr>
<form name="frmrole" method="POST" action="?id=<%=pid%>&page=<%=currentpage%>">
<input type=hidden name="edit_subed" value="role_add_del">
<input type=hidden name="useraddlist" value="">
<input type=hidden name="userdellist" value="">
</form>
<tr>
<td valign="top" class="td1" height="100%">
<table width="200" border="0" cellspacing="1" cellpadding="2" class="tab">
<%sqlstr="select * from vioauser where ','+RoleID+',' like '%,"&pid&",%' order by ParentID,department"
set rsA=Server.CreateObject("ADODB.RECORDSET")
rsA.open sqlstr,oconn,1,1%>
<%if not rsA.eof then%>
<tr>
<td class="td2" nowrap>姓名</td>
<td class="td2" nowrap>所在部门</td>
</tr>
<%end if%>
<script>users = new Array()//当前用户</script>
<%i=0: do while not rsA.eof%>
<tr>
<td class="td1" nowrap><a href="../hrm/userdetail.asp?strid=<%=rsA("id")%>"><%=rsA("name")%></a></td>
<td class="td1" nowrap><%=rsA("departmentname")%></td>
</tr>
<script>users[<%=i%>]="<%=rsA("id")%>"</script>
<%rsA.movenext
i=i+1
loop
rsA.close%>
</table>
</td>
</tr>
<tr>
<td width="100%" class="tdBottom"></td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</body>
</html>
<%'释放对象变量
oConn.close
%>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?