<!--#INCLUDE FILE="../HXINCLUDE/HXINCLUDEHEAD.ASP"-->
<%if WS_S.MemberPriv("WS_SystemSetDepartment")<>1 then HX_GoBack "对不起,您的权限不够!",""
columnName="":Tablename="HX_Department":action=request("action"):WS_Did=request("WS_Did")
if WS_Did<>"" and isnumeric(WS_Did) then Orderby=" where WS_Did="&WS_Did else Orderby=" ORDER BY WS_OrderBy ASC"
set rs=WS_S.HX_SetRSD(ColumnName,Tablename,Orderby)
WS_DepartmentName=WS_S.HX_Replace(request.form("WS_DepartmentName")):WS_DepartmentTel=WS_S.HX_Replace(request.form("WS_DepartmentTel")):WS_DepartmentFax=WS_S.HX_Replace(request.form("WS_DepartmentFax")):WS_OrderBy=WS_S.HX_Replace(request.form("WS_OrderBy"))
if WS_OrderBy="" then WS_OrderBy=1
select case action
case "addsaveinfo"
  WS_S.HX_Isnull "部门名称不能为空",WS_DepartmentName
  set SERS=WS_S.HX_SetRSD(ColumnName,Tablename," where WS_DepartmentName='"&WS_DepartmentName&"'")	 
  If SERS.recordcount>0 then  HX_GoBack "添加失败:\n此部门已存在!",""
  Call WS_S.HX_RSClose(SERS)  
  msg="“"&WS_DepartmentName&"”部门添加成功!"
  rs.addnew :rs("WS_DepartmentName")=WS_DepartmentName: rs("WS_DepartmentTel")=WS_DepartmentTel:rs("WS_DepartmentFax")=WS_DepartmentFax:rs("WS_OrderBy")=WS_OrderBy:rs.update
  Call WS_S.SaveAdminLog(LOGINUSERNAME,LogAppointment,msg)
  HX_GoBack msg,"Department.asp"
case "editsaveinfo"
  WS_S.HX_Isnull "部门名称不能为空",WS_DepartmentName
  set SERS=WS_S.HX_SetRSD(ColumnName,Tablename," where WS_DepartmentName='"&WS_DepartmentName&"' and WS_Did<>"&WS_Did)	 
  If SERS.recordcount>0 then HX_GoBack "修改失败:\n此部门已存在!",""
  msg="“"&rs("WS_DepartmentName")&"”部门修改成功!"
  rs("WS_DepartmentName")=WS_DepartmentName:rs("WS_DepartmentTel")=WS_DepartmentTel: rs("WS_DepartmentFax")=WS_DepartmentFax:rs("WS_OrderBy")=WS_OrderBy:rs.update
  call WS_S.SaveAdminLog(LOGINUSERNAME,LogAppointment,msg)
  HX_GoBack msg,"Department.asp"
case "del"
msg="“"&rs("WS_DepartmentName")&"”部门删除成功"
conn.execute("delete from HX_Department where WS_Did="&WS_Did)	
	 conn.execute("delete from HX_Appointment where WS_Did="&WS_Did)
	 conn.execute("delete from HX_CompanyUser where WS_department="&WS_Did)
	 call WS_S.SaveAdminLog(LOGINUSERNAME,LogAppointment,msg) 
	 HX_GoBack msg,"Department.asp"  
end select
response.write "<head><meta http-equiv='Content-Type' content='text/html; charset=gb2312'><title>单位管理</title><link rel=stylesheet type=text/css href='../HXinclude/HX_Style.css'><script src='../HXinclude/HX_Function.js'></script></head><body topmargin='20' leftmargin='0' bottommargin='0'><table width='596'  border='0' cellspacing='1' cellpadding='0' align=center bgcolor='#613c25'><tr><td colspan='2' bgcolor=FFFBE8><table width='100%'  border='0' cellspacing='0' cellpadding='0'><tr><td height='25' background='../hximages/titleline.gif'><font class='fontmenu'>部门管理</font></td></tr></table><table width='100%'  border='0' cellspacing='1' cellpadding='3' bgcolor='#FFFBE8'><form name='form1' method='post' action='?action=addsaveinfo'><tr bgcolor='#BF9B73' class='td4'><td width='25%'><div align='center'>部门名称</div></td><td width='21%'><div align='center'>电 话</div></td><td width='20%'><div align='center'>传 真</div></td><td width='21%'><div align='center'>排 序</div></td><td><div align='center'>操 作</div></td></tr><tr bgcolor='#FFFBE8' onmouseover=javascript:this.bgColor='#F9F8F2' onmouseout=javascript:this.bgColor='#FFFBE8'><td align='center'><input type='text' name='WS_DepartmentName' size='18' value=''></td><td align='center'><div align='center'><input type='text' name='WS_DepartmentTel' size='15' value=''></div></td><td align='center'><div align='center'><input type='text' name='WS_DepartmentFax' size='15' value=''><strong></strong></div></td><td width='20%' align='center'><input type='text' name='WS_OrderBy' size='10' value='"&rs.recordcount+1&"' onKeyPress='event.returnValue=IsDigit();' style='ime-mode:disabled'></td><td width='13%' align='center'><input type='submit' name='Submit' value=' 添 加 '></td></tr></form></table><br><table width='100%'  border='0' cellspacing='1' cellpadding='3' bgcolor='#FFFBE8'><tr bgcolor='#BF9B73' class='td4'><td width='9%'><div align='center'>序　号</div></td><td width='22%'><div align='center'>部门名称</div></td><td width='19%'><div align='center'>电 话</div></td><td width='21%'><div align='center'>传 真</div></td><td><div align='center'>排 序</div></td><td><div align='center'>操 作</div></td></tr>"
if rs.recordcount<=0 then
response.write "<tr><td height=30 align=center colspan=4 bgcolor=FFFBE8>暂 无 数 据</td></tr>"
else
do while not rs.EOF
response.write "<form name='form1' method='post' action='?action=editsaveinfo&WS_Did="&rs("WS_Did")&"'><tr bgcolor='#FFFBE8' onmouseover=javascript:this.bgColor='#F9F8F2' onmouseout=javascript:this.bgColor='#FFFBE8'><td align='center'>"&rs("WS_Did")&"</td><td align='center'><input type='text' name='WS_DepartmentName' size='18' value='"&rs("WS_DepartmentName")&"'></td><td align='center'><div align='center'><input type='text' name='WS_DepartmentTel' size='15' value='"&rs("WS_DepartmentTel")&"'></div></td><td align='center'><div align='center'><input type='text' name='WS_DepartmentFax' size='15' value='"&rs("WS_DepartmentFax")&"'><strong></strong></div></td><td width='8%' align='center'><input type='text' name='WS_OrderBy' size='4' value='"&rs("WS_OrderBy")&"' onKeyPress='event.returnValue=IsDigit();' style='ime-mode:disabled'></td><td width='21%' align='center'><input type='submit' name='Submit' value=' 修改 '>&nbsp;<input type='button' name='Submit' value=' 删除 ' onclick=""javascript:if(!confirm('是否要删除此部门及其下面的职位和员工！')) return false;else location.href='department.asp?action=del&WS_Did="&rs("WS_Did")&"';""></td></tr></form>"
rs.movenext
loop
end if
call WS_S.HX_RSClose(RS) 
response.write "</table></td></tr></table>"%>