⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 depart_manage.asp

📁 OFFICE办公自动化
💻 ASP
字号:
<%
'功能:部门信息
'参数:ID 当前部门ID,ParentID 上级部门ID
'作者:董力勤
'日期: 2003-11-29 15:18
%>
<!--#include file="../inc/Secure.asp"-->
<!--#include file="../inc/conn.asp"-->
<!--#include file="../inc/const.asp"-->
<!--#include file="../inc/md5.asp"-->

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="../css/main.css" type=text/css>
<script src="../js/user_select.js"></script>
<script language="JavaScript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
 function change_role(userid){
	Re_str = showModalDialog("change_role.asp?userid="+userid, "", "dialogWidth:32em; dialogHeight:20em; center: Yes; scroll:No; resizable: No; status: No; help: No;");
	if (Re_str!='') {
		document.form3.Sdep.value=Re_str.split("|")[0];
		document.form3.srole.value=Re_str.split("|")[2];
		document.form3.infoid.value=Re_str.split("|")[1];
		document.form3.addedit_subed3.value='1';
		form3.submit();
	}
}

function role_add_del(form){
 	addlist=form.useraddlist.value;
 	dellist=form.useraddlist.value
 	strusers=users.join(",");
	strtmpusers = showModalDialog("role_selectuser.asp?yxrylb="+strusers, "", "dialogWidth:32em; dialogHeight:18em; center: Yes; scroll:No; resizable: No; status: No; help: No;")
	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 selectmanager(form){
	userid=SelectUser()
	if (userid) {
		form.Manager_Add.value=userid.split("_")[0]
		form.Manager.value=userid.split("_")[1]
	}
}
//-->
</script>
</head>

<body bgcolor="#FFFFFF" text="#000000">
<%
	dim sql,rs,ParentID,Pmod
	dim ID,Name
	ID=request("id")
	if ID<>"" and isnumeric(ID) then

	'''''''''''''修改部门
	 	if request.form("Name")<>"" then
			sql="update tbioaDepartment set Name='"&crequest("Name")&"'"
			if request.form("ParentID")<>"" then sql=sql & ",ParentID=" & request.form("ParentID")
			if request.form("Pmod")<>"" then sql=sql & ",Pmod=" & request.form("Pmod")
			sql=sql & " where ID=" & ID
			oConn.execute sql
			response.write"<script>parent.frames.Left.location.reload();</script>"
			response.write"<script>location='?id="&ID&"';</script>"
		end if
	''''''''''''''增加部门
	 	if request.form("Name_ADD")<>"" then
			sql="insert tbioaDepartment (Name,ParentID) values('"&crequest("Name_ADD")&"'," & request.form("ID") & ")"
			oConn.execute sql
			response.write"<script>parent.frames.Left.location.reload();</script>"
			response.write"<script>location='?id="&ID&"';</script>"
		end if
	''''''''''''''删除部门
	 	if request.querystring("Action")="Delete" then
	 		set rs_d=Server.CreateObject("ADODB.RECORDSET")
			rs_d.Open "SELECT COUNT(*) AS id FROM tbioaDepartment where ParentID=" & ID,oConn
			set rs_m=Server.CreateObject("ADODB.RECORDSET")
			rs_m.Open "SELECT COUNT(*) AS id FROM tbioaUser where Department=" & ID,oConn
			set rs_z=Server.CreateObject("ADODB.RECORDSET")
			rs_z.Open "SELECT COUNT(*) AS id FROM tbioaRole where Department=" & ID,oConn
			del_mod=rs_m(0)+rs_d(0)+rs_z(0)
			rs_d.close
			rs_m.close
			rs_z.close

			if del_mod=0 then
				sql="delete tbioaDepartment where ID=" & ID
				on error resume next
				oConn.execute sql
				response.write "部门删除成功!"
				response.write"<script>parent.frames.Left.location.reload();</script>"
				response.end
			else
				response.write "<script>alert('部门删除失败!\n\n请检查该部门下面是否还存在子部门、员工或职位信息。')</script>"
				response.write"<script>location='?id="&ID&"';</script>"
			end if
		end if
	''''''''''''''修改部门主管
	 	if request.form("Manager_ADD")<>"" then
			sql="Update tbioaDepartment set ManagerID="&crequest("Manager_ADD")&" where ID=" & ID
			oConn.execute sql
			response.write"<script>location='?id="&ID&"';</script>"
		end if
	''''''''''''''修改员工部门职务
		if request.form("addedit_subed3")="1" then
			department=request.form("Sdep")
			role=trim(request.form("srole"))
			if len(role)>1 then
				role=left(role,len(role)-1)
			else
				role=""
			end if
			infoid=request.form("infoid")
			sqlstr="update tbioauser set department="&department&",roleid='"&role&"' where id="&infoid
			oConn.Execute sqlstr
			response.write"<script>location='?id="&ID&"';</script>"
		end if
	''''''''''''''恢复员工口令
		if request("repass")="1" then
			UserID=trim(request("UserID"))
			sqlstr="update tbioauser set Pwd='"&md5("123")&"' where id="&UserID
			oConn.Execute sqlstr
		end if
%>
<%
	sql="select * from tbioaDepartment where id=" & id
	set rs=server.createobject("adodb.recordset")
	rs.open sql,oConn,1,1
	if rs.eof then
		response.write "点击部门名称修改部门资料。"
	else
		ParentID=cint(rs("ParentID"))
		Name=rs("Name")
		ManagerID=rs("ManagerID")
		Pmod=rs("Pmod")
%>
<table width="100%" border="0" cellspacing="3" cellpadding="0">
  <tr>
    <td width="49%" valign="top">
      <form name="form0" method="post" action="">
        <table width="300" border="0" cellpadding="3" cellspacing="1" class="tab">
          <tr>
            <td width="80" class="td2">部门名称:</td>
            <td width="219" class="td1"> <input type=text name="Name" value="<%=Name%>" class=input>
            </td>
          </tr>
          <%if ParentID>0 then%>
          <tr>
            <td width="80" class="td2">上级部门:</td>
            <td width="219" class="td1"> <select name="ParentID">
                <%
	  	rs.close
		sql="select * from tbioaDepartment where ParentID<>" & ID & " and ID<>" & ID & " Order by ParentID"
		rs.open sql,oConn,1,1
		while not rs.eof
	  	%>
                <option value=<%=rs("ID")%> <%if rs("ID")=ParentID then response.write " selected"%>><%=rs("Name")%></option>
                <%
	  	rs.movenext
		wend
		rs.close
		set rs=nothing
	  	%>
              </select> </td>
          </tr>
          <tr>
            <td width="80" class="td2">看全部信息:</td>
            <td width="219" class="td1">
            	<input type="radio" name="Pmod" value="0" checked>否
            	<input type="radio" name="Pmod" value="1" <%if Pmod then response.write "checked"%>>是
            </td>
          </tr>
          <%end if%>
          <tr align="center">
            <td colspan="2" class="tdBottom"> <input TYPE="submit" class="button0" value="修改" name="submit2" onmouseout=className="button0" onmouseover=className="button1">
              <input type="button" name="Submit" value="删除" class="button0" onmouseout=className="button0" onmouseover=className="button1" onClick='if (window.confirm("真的要删除吗?\n该操作不可逆。")) document.location="<%=request.servervariables("SCRIPT_NAME")%>?ID=<%=ID%>&Action=Delete";'>
              <input type=hidden name=ID2 value=<%=ID%>> </td>
          </tr>
        </table>
      </form>
      <form name="form1" method="post" action="">
        <table width="300" border="0" cellpadding="3" cellspacing="1" class="tab">
          <tr>
            <td width="75" class="td2">部门主管:</td>
            <td class="td1">
              <input type=hidden name="Manager_Add" value="<%=ManagerID%>">
              <input type=text name="Manager" value="<%=GetUsername(ManagerID)%>" class=input disabled>
              <input TYPE="button" class="button0" value="选择" name="select" onclick="selectmanager(form1)" onmouseout=className="button0" onmouseover=className="button1">
            </td>
          </tr>
          <tr align="center">
            <td colspan="2" class="tdBottom"> <input type=hidden name=ID value=<%=ID%>>
              <input TYPE="submit" class="button0" value="提交" name="submit" onmouseout=className="button0" onmouseover=className="button1">
              <INPUT TYPE="reset" class="Button0" value="重置" name="reset" onmouseout=className="button0" onmouseover=className="button1">
            </td>
          </tr>
        </table>
        <hr align="left" width="300" size="1" height=1>
      </form>
      <form name="form2" method="post" action="">
        <table width="300" border="0" cellpadding="3" cellspacing="1" class="tab">
          <tr align="center">
            <td colspan="2" class="td2">在 <b><%=Name%></b> 下增加子部门</td>
          </tr>
          <tr>
            <td width="80" class="td2">部门名称:</td>
            <td width="221" class="td1"> <input type=text name="Name_ADD" class=input>
            </td>
          </tr>
          <tr align="center">
            <td colspan="2" class="tdBottom"> <input type=hidden name=ID value=<%=ID%>>
              <input TYPE="submit" class="button0" value="提交" name="submit" onmouseout=className="button0" onmouseover=className="button1">
              <INPUT TYPE="reset" class="Button0" value="重置" name="reset" onmouseout=className="button0" onmouseover=className="button1">
            </td>
          </tr>
        </table>
        <hr align="left" width="300" size="1" height=1>
      </form>
    </td>
    <td width="51%" valign="top">
      <table width="100%" border="0" cellspacing="1" cellpadding="2" class="tab">
        <tr>
          <td width="250" class="tdTop2" nowrap><img src="../images/icon_title.gif" align="left"> 本部门员工</td>
          <td width="50" class="tdTop2" nowrap>
           <img src="../images/icon_close.gif" width="16" height="16" border="0" align="absmiddle">
           <a href="#" class="LinkTop" onClick="MM_openBrWindow('main.asp?Department=<%=id%>','','scrollbars=yes,width=600,height=600,left=150,top=95')">增加 </a>
          </td>
        </tr>
        <tr>
          <td colspan="2" valign="top" class="td1">
            <table width="100%" border="0" cellspacing="1" cellpadding="2">
              <%sqlstr="select * from tbioauser where department="&cint(id)
		 set rsA=Server.CreateObject("ADODB.RECORDSET")
		 rsA.open sqlstr,oconn,1,1
		 do while not rsA.eof
		 %>
              <tr class="td2">
                <td nowrap><a href="userdetail.asp?strid=<%=rsA("id")%>"><%=rsA("loginName")%></a></td>
                <td nowrap><%=rsA("name")%></td>
                <td width="20" nowrap>
                  <%if rsA("pwd")<>md5("123") then%>
                  <a href="?repass=1&id=<%=id%>&UserID=<%=rsA("id")%>" onClick='return window.confirm("你确定要恢复该人员口令为默认口令吗?")'>
                  <img src="../images/resetpwd.gif" alt="恢复口令为默认口令" width="16" height="16" border="0" align="absmiddle"></a>
                  <%else%>
                  <img src="../images/resetpwd.gif" alt="已为默认口令" width="16" height="16" border="0" align="absmiddle" style="filter:xray">
                  <%end if%>
                </td>
                <td width="20" nowrap>
                  <a href="#" onClick="MM_openBrWindow('MAIN.ASP?SelectID=<%=rsA("id")%>&Department=<%=id%>','','scrollbars=yes,width=600,height=600,left=150,top=95')">
                  <img src="../images/icon_edit.gif" alt="修改员工信息" width="16" height="16" border="0" align="absmiddle"></a>
                </td>
                <td width="20" nowrap>
                  <a href="#" onClick='if (window.confirm("真的要删除吗?\n该操作不可逆。")) document.location="deluser.asp?strID=<%=rsA("id")%>&strDepID=<%=id%>";'>
		  <img src="../images/icon_dele1.gif" alt="删除员工" width="16" height="16" border="0" align="absmiddle"></a>
		</td>
		<td width="20" nowrap><a href="javascript:change_role(<%=rsA("id")%>)"><img src="../images/rs_move.gif" alt="人事调动" width="16" height="16" border="0" align="absmiddle"></a>
		</td>
              </tr>
              <%rsA.movenext
		loop
		rsA.close%>
            </table>
          </td>
        </tr>
        <tr>
          <td class="tdTop2" nowrap><img src="../images/icon_title.gif" align="left"> 本部门职位</td>
          <td width="50" class="tdTop2" nowrap><img src="../images/icon_close.gif" width="16" height="16" border="0" align="absmiddle">
            <a href="#" class="LinkTop" onClick="MM_openBrWindow('../role/role_add.asp?dep_id=<%=id%>','','scrollbars=yes,width=600,height=600,left=150,top=95')">增加</a>
          </td>
        </tr>
        <tr>
          <td height="24" colspan="2" valign="top" class="td1">
            <table width="100%" border="0" cellspacing="1" cellpadding="2">
              <%sqlstr="select * from tbioaRole where department="&cint(id)
		 set rsA=Server.CreateObject("ADODB.RECORDSET")
		 rsA.open sqlstr,oconn,1,1
		 do while not rsA.eof
		 %>
              <tr class="td2">
                <td nowrap><%=rsA("RoleName")%></td>
                <td width="20" nowrap>
                  <a href="#" onClick="MM_openBrWindow('../role/role_edit.ASP?ID=<%=rsA("id")%>','','scrollbars=yes,width=650,height=600,left=150,top=95')">
                    <img src="../images/icon_edit.gif" alt="修改职务" width="16" height="16" border="0" align="absmiddle">
                  </a></td>
                <td width="20" nowrap>
                  <a href="../role/role_dele.asp?ID=<%=rsA("id")%>&Dep_ID=<%=id%>" onClick='return window.confirm("真的要删除吗?\n该操作不可逆。")'>
                    <img src="../images/icon_dele1.gif" alt="删除职务" width="16" height="16" border="0" align="absmiddle">
                  </a></td>
              </tr>
		<%rsA.movenext
		loop
		rsA.close%>
            </table>
          </td>
        </tr>
      </table>
      <form name="form3" method="post" action="">
        <input name="Sdep" type="hidden" id="Sdep" value="">
        <input name="srole" type="hidden" id="srole" value="">
		<input type=hidden name="addedit_subed3" value="0">
        <input name="infoid" type=hidden id="infoid" value="">
      </form></td>
  </tr>
</table>
<p>
<%
		end if
	else
		response.write "<script>location='W_user.asp'</script>"
	end if
%>
<!--#include file="../inc/conn_close.asp"-->
</body>
</html>
 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -