<!-- #include file="../conn.asp" -->
<!-- #include file="../const.asp" -->
<%call chksunzom()
if instr(quanxs,"x6t")<=0 then call sunzomqx()
if instr(quanxs,"zxtj")<=0 then call sunzomqx()

chk=requestA("chk")
bid=chk0(requestA("zuid"))
nowzwname=requestA("zwname")
memo=requestA("memo")
zuid=replace(requestA("zuid")," ","")
zwqx=replace(requestA("zwqx")," ","")
id=chk0(requestA("id"))
zwpx=chk0(requestA("zwpx"))
zwzt=chk0(requestA("zwzt"))

if chk="add" then
sql="select * from sz_zw where zwname='"&nowzwname&"'"
set rs=conn.execute(sql)
if rs.eof=false then
Response.Write "<script language='javascript'>alert('输入的职位已经存在！');history.back();</script>":Response.end
end if
sql="insert into sz_zw(zwname,zuid,zwqx,memo,zwzt,zwpx) values('"&nowzwname&"','"&zuid&"','"&zwqx&"','"&memo&"',"&zwzt&","&zwpx&")"
conn.execute(sql)
conn.execute("insert into rizi(username,class,address,rznr) values('"&nowuser&"|"&nowuserhao&"','职位增加','"&userip&"','"&nowzwname&"')")
Response.Write ("<Script> if (confirm('增加成功,继续添加吗?')) { location.href='zw_add.asp?zuid="&bid&"';} else{location.href='zw.asp';}</script>")
end if

if chk="editok" then
sql="update sz_zw set zwname='"&nowzwname&"',zuid='"&zuid&"',zwqx='"&zwqx&"',memo='"&memo&"',zwzt="&zwzt&",zwpx="&zwpx&" where id="&id&""
conn.execute(sql)
conn.execute("insert into rizi(username,class,address,rznr) values('"&nowuser&"|"&nowuserhao&"','职位修改','"&userip&"','"&zwqx&"')")
Response.Write ("<Script> if (confirm('修改成功,继续修改吗?')) { location.href='zw_add.asp?chk=edit&id="&id&"';} else{location.href='zw.asp';}</script>")
end if


if chk<>"edit" then chk="add"
%>
<html>
<head>
<title><%=dianming%> - 部门添加</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="../images/sunzom.css" rel="stylesheet" type="text/css">

</HEAD>
<BODY>
<script language="javascript">
function check()
{
if (document.form1.zwname.value=="")
{
alert("有*号的必须填写！");
return false;
}
}
</script>
<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#C4D8ED">
<tr>
<td><img src="../images/r_1.gif" alt="" /></td>
<td width="100%" background="../images/r_0.gif">
  <table cellpadding="0" cellspacing="0" width="100%">
    <tr>
      <td>&nbsp;职位管理(带*号的为必填项)</td>
	  <td align="right">　</td>
    </tr>
  </table>
</td>
<td><img src="../images/r_2.gif" alt="" /></td>
</tr>
<tr>
<td></td>
<td>
<%
if chk="edit" then
sql="select * from sz_zw where id="&id&""  
set rs1 =server.createobject("ADODB.RecordSet")	
rs1.open sql,conn,1,3
if not rs1.eof then
zwname=rs1("zwname"):zuid=rs1("zuid"):zwqx=rs1("zwqx"):memo=rs1("memo"):id=rs1("id"):zwzt=rs1("zwzt"):zwpx=rs1("zwpx")
end if
rs1.close:set rs1=nothing
chk="editok"
else
zwzt=1
end if

%>
<table align="center" cellpadding="4" cellspacing="1" class="toptable grid" border="1">
  <form name="form1"  method="POST" action="?chk=<%=chk%>">
  <tr>
    <td width="25%" height="30" align="right">职位名称：</td>
    <td width="75%" class="category">
        <input type="text" name="zwname" style="width:150px" value="<%=zwname%>" size="11">
        &nbsp;<font color="#ff0000">*</font>  <input type="checkbox" name="zwzt" value="1" <%if zwzt=1 then%>checked<%end if%>>开启</td>
  </tr>
  <tr>
    <td width="25%" height="30" align="right">适用部门：</td>
    <td width="75%" class="category"><%=zuxuan1(zuid,zux1)%></td>
  </tr>
  <tr>
    <td width="25%" height="30" align="right">权限属性：</td>
    <td width="75%" class="category">
        <input type="checkbox" name="zwqx" value="查看" <%if instr(zwqx,"查看")>0 then%>checked<%end if%>>查看 
        <input type="checkbox" name="zwqx" value="增加" <%if instr(zwqx,"增加")>0 then%>checked<%end if%>>增加(录入) 
		<input type="checkbox" name="zwqx" value="删除" <%if instr(zwqx,"删除")>0 then%>checked<%end if%>>删除 
		<input type="checkbox" name="zwqx" value="修改" <%if instr(zwqx,"修改")>0 then%>checked<%end if%>>修改(编辑)
		<input type="checkbox" name="zwqx" value="审核" <%if instr(zwqx,"审核")>0 then%>checked<%end if%>>审核</td>
  </tr>
  <tr>
    <td width="25%" height="30" align="right">职责与分工：</td>
    <td width="75%" class="category">
        <textarea rows="3" name="memo" cols="44"><%=memo%></textarea></td>
  </tr>
  <tr>
    <td height="30" align="right">排序：</td>
    <td class="category">
        <input type="text" name="zwpx" value="<%=zwpx%>" size="6"> 数字越大越靠前</td>
  </tr>
  <tr>
    <td height="30">　</td>
    <td class="category">
        <input name="submit" type="submit" onClick="return check()" value=" 确 认 " class="button">
      &nbsp;&nbsp;&nbsp;&nbsp;
        <input type="hidden" name="id" value="<%=id%>">
        <input name="reset" type="reset" value=" 重新填写 " class="button">
    </td>
  </tr>
</table>
</td>
<td></td>
</tr>
<tr>
<td><img src="../images/r_4.gif" alt="" /></td>
<td></td>
<td><img src="../images/r_3.gif" alt="" /></td>
</tr>
</table>
</form>
</body>
</html>