<%@ page contentType="text/html;charset=gbk" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="net.sz600.tool.SzConvert" %>
<%@ page import="net.sz600.system.*" %>
<%@ page import="net.sz600.organize.*" %>
<%@ include file="/sessionInfo.jsp"%>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<link href="<%=strSkin_SESSION%>/css2007.css" rel="stylesheet" type="text/css">
</head>
<%
    //获取提交的参数
    String sPage = SzConvert.toZeroStr(request.getParameter("page"));
    String sSearch = SzConvert.strWriteData(request.getParameter("txtSearch"));
%>
<%
    String sOPERATOR = request.getParameter("OPERATOR");
    String sKEY =  SzConvert.toZeroStr(request.getParameter("KEY"));
    //读取数据
    SzLoginInfo loginInfo = null;
    if (!sKEY.equals("0")) {
        SzLogin login = new SzLogin();
        loginInfo = (SzLoginInfo)login.getInfoByKey(Integer.parseInt(sKEY));
    }
    if (loginInfo == null) {
        loginInfo = new SzLoginInfo();
    }
    //读取数据
    SzUserInfo szUserInfo = null;
    if (!sKEY.equals("0")) {
        SzUser szUser = new SzUser();
        szUserInfo = (SzUserInfo)szUser.getInfoByCond("YGDL=" + sKEY);
    }

    if (szUserInfo == null) {
        szUserInfo = new SzUserInfo();
        szUserInfo.setYGBH(SzKey.getInstance().genNextKey("YG", "YG", 4));
    }

    String sMM = SzConvert.decryptStr(loginInfo.getDLMM());
%>

<!-----上面的工具栏------>
<form name="formUpdate" method="post">
  <%@ include file="/share/title.jsp" %>
  <input type="hidden" name="page" value="<%=sPage%>">
  <input type="hidden" name="txtSearch" value="<%=sSearch%>">
  <input type="hidden" name="OPERATOR" value="<%=sOPERATOR%>">
  <input type="hidden" name="KEY" value="<%=sKEY%>">
  <input type="hidden" name="DLID" value="<%=loginInfo.getDLID()%>">
  <input type="hidden" name="YGID" value="<%=szUserInfo.getYGID()%>">
  <input type="hidden" name="DLMM" value="<%=sMM%>">
<table width="100%">
  <tr>
    <td>
      <input type="button" name="btnSave" class="btnClass" value="保存" OnClick="javascript:FormSave(formUpdate, 'control.jsp');">
      <input type="button" name="btnBack" class="btnClass" value="返回" OnClick="javascript:FormSubmit(formHidden, 'index.jsp');">
    </td>
  </tr>
</table>

<!-----信息维护------>
<table width="600" border="1" bordercolorlight="#C0C0C0" bordercolordark="#FFFFFF" class="tableClass" cellpadding="3" cellspacing="0">
  <tr>
    <td width="100" align="right">登陆帐号</td>
    <td><input type="text" name="DLZH" value="<%=loginInfo.getDLZH()%>">
    <font color="red">*</font>
    </td>

    <td width="100" align="right">用户姓名</td>
    <td><input type="text" name="DLXM" value="<%=loginInfo.getDLXM()%>">
    <font color="red">*</font>
    </td>
  </tr>
  <tr>
    <td width="100" align="right">登陆密码</td>
    <td><input type="password" name="DLMM_INPUT" value=""></td>

    <td width="100" align="right">使用状态</td>
    <td>
      <input type="radio" name="DLBZ" value="0" <% if(loginInfo.getDLBZ() == 0 ) { %> checked <% } %> >可用&nbsp;
      <input type="radio" name="DLBZ" value="1" <% if(loginInfo.getDLBZ() == 1 ) { %> checked <% } %> >禁用&nbsp;
    </td>
  </tr>
  <tr>
    <td width="100" align="right">所属部门</td>
    <td>
      <%=SzPageHelp.idSelectTree2("SZXT_BM","BMID","BMMC","BMBH", "BMGSID=" + szCOMPANY_SESSION, "DLBM",loginInfo.getDLBM(), "txtClass1")%>
    </td>

    <td width="100" align="right">所任职务</td>
    <td>
      <%=SzPageHelp.idSelectTree3("SZXT_ZW","ZWID","ZWMC","ZWDJ", "ZWGSID=" + szCOMPANY_SESSION, "DLZW",loginInfo.getDLZW(), "txtClass1")%>
    </td>
  </tr>
</table>
<br>
<table width="600" border="1" bordercolorlight="#C0C0C0" bordercolordark="#FFFFFF" class="tableClass" cellpadding="3" cellspacing="0">
  <tr>
    <td width="100" align="right">员工编号</td>
    <td><input type="text" name="YGBH" value="<%=szUserInfo.getYGBH()%>" class="txtClass1"></td>

    <td width="100" align="right">性别</td>
    <td>
        <input type="radio" name="YGXB" value="男" <% if(szUserInfo.getYGXB().equals("男") ) { %> checked <% } %> >男&nbsp;
        <input type="radio" name="YGXB" value="女" <% if(szUserInfo.getYGXB().equals("女") ) { %> checked <% } %> >女&nbsp;
        <input type="radio" name="YGXB" value="" <% if(szUserInfo.getYGXB().equals("") ) { %> checked <% } %> >不详&nbsp;
    </td>
  <tr>
    <td width="100" align="right">证件类型</td>
    <td><input type="text" name="YGZJLX" value="<%=szUserInfo.getYGZJLX()%>" class="txtClass1"></td>

    <td width="100" align="right">出生年月</td>
    <td><input type="text" name="YGSR" value="<%=szUserInfo.getYGSR()%>" class="txtClass1"></td>
  </tr>

  <tr>
    <td width="100" align="right">证件号码</td>
    <td colspan="3"><input type="text" name="YGSFZ" value="<%=szUserInfo.getYGSFZ()%>"  class="txtClass2"></td>
  </tr>

  <tr>
    <td width="100" align="right">手机号码</td>
    <td><input type="text" name="YGSJ" value="<%=szUserInfo.getYGSJ()%>" class="txtClass1"></td>

    <td width="100" align="right">联系电话</td>
    <td><input type="text" name="YGDH" value="<%=szUserInfo.getYGDH()%>" class="txtClass1"></td>
  </tr>
  <tr>
    <td width="100" align="right">传真号码</td>
    <td><input type="text" name="YGCZ" value="<%=szUserInfo.getYGCZ()%>" class="txtClass1"></td>

    <td width="100" align="right">电子邮箱</td>
    <td><input type="text" name="YGYX" value="<%=szUserInfo.getYGYX()%>" class="txtClass1"></td>
  </tr>
  <tr>
    <td width="100" align="right">MSN帐号</td>
    <td><input type="text" name="YGMSN" value="<%=szUserInfo.getYGMSN()%>" class="txtClass1"></td>

    <td width="100" align="right">QQ帐号</td>
    <td><input type="text" name="YGQQ" value="<%=szUserInfo.getYGQQ()%>" class="txtClass1"></td>
  </tr>
  <tr>
    <td width="100" align="right">联系地址</td>
    <td colspan="3"><input type="text" name="YGDZ" value="<%=szUserInfo.getYGDZ()%>" class="txtClass2"></td>
  </tr>
  <tr>
    <td width="100" align="right">工作职责</td>
    <td colspan="3"><textarea name="YGZW" rows="5" class="areaClass2"><%=szUserInfo.getYGZW()%></textarea></td>
  </tr>
  <tr>
    <td width="100" align="right">个人简介</td>
    <td colspan="3"><textarea name="YGJJ" rows="5" class="areaClass2"><%=szUserInfo.getYGJJ()%></textarea></td>
  </tr>
</table>
<br>
<%
    //获取本员工的部门任职
    //获取员工，部门，职务的hashMap
    SzDepart szDepart = new SzDepart();
    HashMap mapDepart = szDepart.getMainHashMap("1=1");
    SzPost szPost = new SzPost();
    HashMap mapPost = szPost.getMainHashMap("1=1");

    SzUserPost szUserPost = new SzUserPost();
    SzUserPostInfo szUserPostInfo = null;
    String sCond = "RZDL=" + sKEY;
    Iterator iter = szUserPost.getArrayList(sCond).iterator();
    StringBuffer sb = new StringBuffer("");

    while (iter.hasNext()) {
        szUserPostInfo = (SzUserPostInfo)iter.next();
        sb.append(SzConvert.strReadData((String)mapDepart.get(new Integer(szUserPostInfo.getRZBM()))));
        sb.append("[");
        sb.append(SzConvert.strReadData((String)mapPost.get(new Integer(szUserPostInfo.getRZZW()))));
        sb.append("]  ");
    }
    String sTemp = sb.toString();
    mapDepart = null;
    mapPost = null;
%>
<table  width="600" border="1" bordercolorlight="#C0C0C0" bordercolordark="#FFFFFF" class="tableClass" cellpadding="1" cellspacing="0">
  <tr class="trClassTitle">
    <td width="100" align="right">部门任职</td>
    <td width="10">&nbsp;</td>
    <td><%=sTemp%></td>
  </tr>
</table>
</form>

<!-----这里包含要提交的内容--->
<form name="formHidden" method="post">
  <input type="hidden" name="page" value="<%=sPage%>">
  <input type="hidden" name="txtSearch" value="<%=sSearch%>">
</form>
<script language="javascript">
  //第一个表示对象，form，第二个表示字符串
  function FormSubmit(oFormName, vUrl) {
    oFormName.action = vUrl;
    oFormName.submit();
  }
</script>
<script language="javascript">
  function FormSave(formName, url) {
    //检查是否可以保存
    if (formName.DLZH.value == "") {
      formName.DLZH.focus();
      alert("登陆帐号不能为空");
      return false;
    }
    if (formName.DLXM.value == "") {
      formName.DLXM.focus();
      alert("用户姓名不能为空");
      return false;
    }
    if (formName.YGBH.value == "") {
      formName.YGBH.focus();
      alert("员工编号不能为空");
      return false;
    }

    //密码判断
    if (formName.OPERATOR.value == "update") {
      if (formName.DLMM_INPUT.value != "" && formName.DLMM_INPUT.value != formName.DLMM.value) {
        if (confirm("密码已经改变，是否修改")) {
          formName.DLMM.value = formName.DLMM_INPUT.value;	
        } else {
	  return false;
	}
      }
    } else {
      formName.DLMM.value = formName.DLMM_INPUT.value;	
    }

    //提交
    formName.action = url;
    formName.submit();
  }
</script>