<!--#INCLUDE FILE="HXINCLUDE/HXINCLUDETOP.ASP"-->
<%if REGISTER=False then HX_GoBack "",""
action=request("action"):ColumnName="":Tablename="HX_CompanyUser"
if action="saveinfo" then  Orderby=" where WS_Username='"&WS_s.HX_Replace(request.form("WS_Username"))&"'" else  Orderby=" ORDER BY WS_Uid DESC"
set rs=WS_S.HX_SetRSD(ColumnName,Tablename,Orderby)
if action="saveinfo" then
 if rs.recordcount<=0 then   
  rs.addnew:rs("WS_Code")=WS_s.HX_Replace(request.form("WS_Code")):rs("WS_username")=WS_s.HX_Replace(request.form("WS_username")):rs("WS_password")=MD5(WS_s.HX_Replace(request.form("WS_password")))
  rs("WS_name")=WS_s.HX_Replace(request.form("WS_name")):rs("WS_Appointment")=WS_s.HX_Replace(request.form("WS_Appointment"))  :  rs("WS_sex")=WS_s.HX_Replace(request.form("WS_sex"))
  rs("WS_phone")=WS_s.HX_Replace(request.form("WS_phone")):rs("WS_email")=WS_s.HX_Replace(request.form("WS_email")):rs("WS_department")=WS_s.HX_Replace(request.form("WS_department")):rs("WS_title")=WS_s.HX_Replace(request.form("WS_title"))
  if RegFlag=True then rs("WS_leave")=True:msg="注册成功：\n请等待审核！" else  msg="注册成功！"  end if
  rs.update
  response.write "<script>alert('"&msg&"');window.close();</script>"
 else
  HX_Goback "对不起,此用户名已存在,不允许注册!",""
 end if
end if
If rs.recordcount>0 then  WS_Code="HX"&(replace(rs("WS_Code"),"HX","")+1) else  WS_Code="HX1000"
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>员工自行注册</title>
<link rel=stylesheet type=text/css href="HXinclude/HX_Style.css">
</head>
<body topmargin="10" leftmargin="0" bottommargin="0">
<%
set aprs=WS_S.HX_SetRSD("WS_Aid,WS_AppointmentName,WS_Did","HX_Appointment"," order by WS_OrderBy asc")
if aprs.recordcount>0 then		    %>
<script language = "JavaScript">
var onecount;
onecount=0;
subcat = new Array();
<%
   count = 0
   do while not aprs.eof 
%>
subcat[<%=count%>] = new Array("<%= trim(aprs("WS_AppointmentName"))%>","<%= aprs("WS_Did")%>","<%= aprs("WS_Aid")%>");
<%
        count = count + 1
        aprs.movenext
        loop
		end if
call WS_S.HX_RSClose(aprs)        
%>
		
onecount=<%=count%>;

function changelocation(locationid)
    {
    document.form1.WS_Appointment.length = 0; 

    var locationid=locationid;
    var i;
    for (i=0;i < onecount; i++)
        {
            if (subcat[i][1] == locationid)
            { 
             document.form1.WS_Appointment.options[document.form1.WS_Appointment.length] = new Option(subcat[i][0], subcat[i][2]);
            }        
        }
        
    }    
</script>
<script language="JavaScript">
function amsub(form)
{
if (form.WS_UserName.value=="")
{ alert("请输入用户名!");
  form.WS_UserName.focus();
  return false
}
if ((form.WS_password.value=="")||(form.WS_password.value!=form.repassword.value))
{ alert("密码不能为空或二次密码不一致!");
  form.repassword.focus();
  return false
}
if (form.WS_name.value=="")
{ alert("请输入姓名!");
  form.WS_name.focus();
  return false
}
if (form.WS_Appointment.value=="")
{ alert("请输入职务!");
  form.WS_Appointment.focus();
  return false
}
return true
}
</script>
<table width="400"  border="0" cellspacing="1" cellpadding="0" align=center bgcolor="#613c25">
  <tr>
    <td width="400" 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="" onSubmit="return amsub(this);">
    <tr bgcolor="#FFFBE8">
      <td align="right">员工编号：</td>
      <td><input type="text" name="WS_Code" maxlength="8" size="8" value="<%=WS_Code%>" readonly></td>
    </tr>
    <tr bgcolor="#FFFBE8">
    <td width="27%" align="right">用 户 名：</td>
    <td width="73%"><input type="text" name="WS_UserName"></td>
  </tr>
  <tr bgcolor="#FFFBE8">
    <td align="right">密　　码：</td>
    <td><input type="password" name="WS_password" size=21></td>
  </tr>
  <tr bgcolor="#FFFBE8">
    <td align="right">确认密码：</td>
    <td><input type="password" name="repassword" size=21></td>
  </tr>
  <tr bgcolor="#FFFBE8">
    <td align="right">姓　　名：</td>
    <td><input type="text" name="WS_name"></td>
  </tr>
  <tr bgcolor="#FFFBE8">
    <td align="right">性　　别：</td>
    <td><select name="WS_sex">
                                <option>男</option>
                                <option>女</option>
                           </select>  </td>
  </tr>
  <tr bgcolor="#FFFBE8">
    <td align="right">&nbsp;联系电话：</td>
     <td><input type="text" name="WS_phone" maxlength="50"></td>
  </tr>
  <tr bgcolor="#FFFBE8">
    <td align="right">电子信箱：</td>
    <td><input type="text" name="WS_email" maxlength="50"></td>
  </tr>
  <tr bgcolor="#FFFBE8">
    <td align="right">所属部门：</td>
    <td>
	  <select name="WS_department" onChange="changelocation(document.form1.WS_department.options[document.form1.WS_department.selectedIndex].value)">
							  <%set ders=WS_S.HX_SetRSD("WS_DepartmentName,WS_Did","HX_Department"," order by WS_OrderBy asc")
							    if ders.recordcount>0 then
								sele=ders(1)
								do until ders.eof
								%>
                                <option value="<%=ders(1)%>"><%=ders(0)%></option>
                                <%
								ders.movenext
								loop
								end if
								call WS_S.HX_RSClose(ders)
								%>
                              </select></label></td>
  </tr>
  <tr bgcolor="#FFFBE8">
    <td align="right">职　　务：</td>
    <td><select name="WS_Appointment">
                              <%
							    set aprs=WS_S.HX_SetRSD("WS_Aid,WS_AppointmentName","HX_Appointment"," where WS_Did="&sele&" order by WS_OrderBy asc")
							    if aprs.recordcount>0 then								
								do until aprs.eof
							  %>
                              <option value="<%=aprs(0)%>"><%=aprs(1)%></option>
                              <%
								aprs.movenext
								loop
								end if
							   call WS_S.HX_RSClose(aprs)
								%>
                            </select></label></td>
  </tr>
  <tr bgcolor="#FFFBE8">
    <td align="right" valign=top>备　　注：</td>
    <td><textarea rows="5" name="WS_title" cols="30"  class="input4"></textarea></td>
  </tr>
  <tr bgcolor="#FFFBE8">
    <td align="right">&nbsp;</td>
    <td><input type="submit" name="Submit" value=" 确定注册 ">
      <input type="reset" name="Submit2" value=" 重 置 ">
	  <input type="hidden" name="action" value="saveinfo">
	  </td>
  </tr></form>
</table></td>
  </tr>
</table>

