<!--#include file="Conn.asp"-->
<!--#include file ="Check_Manager.asp"-->
<!--#include file="MD5.asp"-->
<script language="JavaScript">
<!--
function chk(theForm){
        if (theForm.UserName.value == ""){
                alert("名字不能为空!");
                theForm.UserName.focus();
                return (false);
        } 
         for (var i=0; i < theForm.UserName.value.length; i++)
{ var pp=theForm.UserName.value.substring(i,i+1)
      if (pp == '"' || pp == "'" || pp == "<" || pp == ">"|| pp == ";"|| pp == "("|| pp == ")"|| pp == "$"|| pp == ";"|| pp == "*")
	  { alert("姓名中有非法字符，请重新输入！");
	    theForm.UserName.focus();
	    return (false); }  }
		
        if (theForm.Question.value == ""){
                alert("问题不能为空!");
                theForm.Question.focus();
                return (false);
        }
        
        if (theForm.Answer.value == ""){
                alert("问题答案不能为空!");
                theForm.Answer.focus();
                return (false);
        } 

        if (theForm.email.value == ""){
                alert("E-mail不能为空!");
                theForm.email.focus();
                return (false);
        } 
         if (theForm.home.value == ""){
                alert("请输入公司地址!");
                theForm.home.focus();
                return (false);
        } 
          if (theForm.Comane.value == ""){
                alert("请输入公司名称!");
                theForm.Comane.focus();
                return (false);
        } 
         if (theForm.Fox.value == ""){
                alert("请输入公司传真!");
                theForm.Fox.focus();
                return (false);
        } 
        if (theForm.Zip.value == ""){
                alert("邮政编码不能为空!");
                theForm.Zip.focus();
                return (false);
        } 
        var checkOK = "0123456789";
        var checkStr = theForm.Zip.value;
        var allValidp = true;
        for (i = 0;i < checkStr.length;i++){
                ch = checkStr.charAt(i);
                for (j = 0;j < checkOK.length;j++)
                if (ch == checkOK.charAt(j))
                        break;
                if (j == checkOK.length){
                        allValidp = false;
                        break;
                }
        }
        if (!allValidp){
                alert("邮政编码只能是数字!");
                theForm.Zip.focus();
                return (false);
        }

      if (theForm.Phone.value == ""){
                alert("联系电话不能为空!");
                theForm.Phone.focus();
                return (false);
        } 
        var checkOK = "0123456789";
        var checkStr = theForm.Phone.value;
        var allValidp = true;
        for (i = 0;i < checkStr.length;i++){
                ch = checkStr.charAt(i);
                for (j = 0;j < checkOK.length;j++)
                if (ch == checkOK.charAt(j))
                        break;
                if (j == checkOK.length){
                        allValidp = false;
                        break;
                }
        }
        if (!allValidp){
                alert("联系电话只能是数字!");
                theForm.Phone.focus();
                return (false);
        }

        var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_@.";
        var checkStr = theForm.email.value;
        var allValid = true;
        for (i = 0;i < checkStr.length;i++){
                ch = checkStr.charAt(i);
                for (j = 0;j < checkOK.length;j++)
                if (ch == checkOK.charAt(j))
                        break;
                if (j == checkOK.length){
                        allValid = false;
                        break;
                }
        }
        if (theForm.email.value.length < 8){
                allValid = false;
        }
        if (!allValid){
                alert("您输入的电子邮件地址无效!");
                theForm.email.focus();
                return (false);
        }
        address=theForm.email.value;
        if(address.length>0){
                i=address.indexOf("@");
                if(i==-1){
                        window.alert("对不起！您输入的电子邮件地址是错误的！")
                        theForm.email.focus();
                        return (false);
                }
                 ii=address.indexOf(".")
                if(ii==-1){
                        window.alert("对不起！您输入的电子邮件地址是错误的！")
                        theForm.email.focus();
                        return (false);
                }

 if (checktext(theForm.email.value)){
                alert("请您输入有效的email");
                theForm.email.select();
                theForm.email.focus();
                return (false);
        }   
}
}
//-->
</script>
<%If Request.QueryString("action")="del" Then
Set du=Conn.Execute("Delete * From [User] Where ID="&Cint(Request("id")))
JaSys("管理员" & session("ManagerUser") & "<font color=red>删除用户"&Request("id")&"</font>成功")
Response.Redirect "User_Manage.asp"
End if

If Request.QueryString("action")="update" Then
If Request.Form("up")=" 修 改 " Then
UserName = Trim(Request.Form("UserName"))
Password = Trim(Request.Form("Password"))
Question = Trim(Request.Form("Question"))
Answer = Trim(Request.Form("Answer"))
sex = Trim(Request.Form("sex"))
email = Trim(Request.Form("email"))
home = Trim(Request.Form("home"))
Comane = Trim(Request.Form("Comane"))
Zip = Trim(Request.Form("Zip"))
Phone = Trim(Request.Form("Phone"))
Fox = Trim(Request.Form("Fox"))

  If Password<>"" Then
     If Len(Password)<6 Then
     Response.Write("<script language=""JavaScript"">alert(""密码至少6位!"");history.go(-1);</script>")
     End if
  End if

Password = MD5(Password)
Sql = "Update [User] Set "
If Trim(Request.Form("Password"))<>"" Then 
Sql = Sql & " [Password]='"&Password&"'," 
End If
Sql = Sql & " [UserName]='"&UserName&"',[Question]='"&Question&"',[Answer]='"&Answer&"',[Sex]='"&sex&"',"
Sql = Sql & " [Email]='"&email&"',[Home]='"&home&"',[Compname]='"&Comane&"',[Zip]='"&Zip&"',"
Sql = Sql & " [Phone]='"&Phone&"',[Fox]='"&Fox&"' Where ID="&Cint(Request("id"))
Conn.Execute (Sql)
JaSys("管理员" & session("ManagerUser") & "<font color=red>更新用户"&UserName&"</font>成功")
Response.write "<script language='javascript'>" & chr(13)
		Response.write "alert('更新成功!');" & Chr(13)
		Response.write "window.document.location.href='User_Manage.asp';"&Chr(13)
		Response.write "</script>" & Chr(13)
Response.End
Else
Set rs=Server.CreateObject("Adodb.Recordset")
Sql="Select * From [User] Where ID="&Cint(Request("id"))
rs.Open Sql,Conn,1,1
%>
<html>
<head>
<titel></titel>
<LINK href="admin/admin.css" type=text/css rel=stylesheet>
</head>
<body>
<table width="700" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr> 
    <td valign="top" style="BORDER-RIGHT: #d8d8d8 1px solid; BORDER-BOTTOM: #d8d8d8 1px solid"> 
      <p align="center">&nbsp;</p>
      <p align="center"><strong><font color="#000000">用户资料</font></strong></p>
      <TABLE width="90%" border=0 align="center" cellPadding=0 cellSpacing=0>
        <TBODY>
          <TR> 
            <TD 
                  height=1 background=img/naBialym.gif><IMG height=1 src="img/1x1_pix.gif" 
              width=10></TD>
          </TR>
          <TR> 
            <TD 
                  height=1 background=img/naBialym.gif><IMG height=1 src="img/1x1_pix.gif" 
              width=10></TD>
          </TR>
          <TR> 
            <TD> 
              <FORM name='UserReg' action='User_Edit.asp?action=update&id=<%=rs("ID")%>' method='post' onSubmit="return chk(this)">
                <table width=500 border=0 align="center" cellpadding=5 cellspacing=0 bordercolor="#FFFFFF" class=tableBorder>
                  <TR> 
                    <TD width="29%">用户名：</TD>
                    <TD width="71%"> <INPUT name=UserName id="UserName" value="<%=rs("UserName")%>" size=20   maxLength=14> 
                    </TD>
                  </TR>
                  <TR> 
                    <TD width="29%">密码：<BR> </TD>
                    <TD width="71%"><input name="Password" type="Password" id="Password" size="20" maxlength="15"> 
                      <font color="#FF0000">(如果不想修改，请留空)</font> </TD>
                  </TR>
                  <TR> 
                    <TD>密码问题：</TD>
                    <TD width="71%"><input name="Question"   type=text value="<%=rs("Question")%>" size=30 maxlength=50></TD>
                  </TR>
                  <TR> 
                    <TD width="29%">问题答案：<BR> </TD>
                    <TD width="71%"> <INPUT name="Answer"   type=text value="<%=rs("Answer")%>" size=30 maxLength=20> 
                    </TD>
                  </TR>
                  <TR> 
                    <TD width="29%">性别：<BR> </TD>
                    <TD width="71%"> 
					<INPUT type=radio <%If rs("Sex")=1 Then Response.Write "CHECKED"%> value="1" name=sex>
                      男 &nbsp;&nbsp; <INPUT type=radio value="0" name="sex" <%If rs("Sex")=0 Then Response.Write "CHECKED"%>>
                      女</TD>
                  </TR>
                  <TR> 
                    <TD width="29%">Email地址：<BR> </TD>
                    <TD width="71%"> <INPUT name="email" value="<%=rs("Email")%>" size=30 maxLength=50> 
                    </TD>
                  </TR>
                  <TR> 
                    <TD>公司名称：</TD>
                    <TD width="71%"><INPUT name=Comane id="Comane"  value="<%=rs("Compname")%>" size=30   maxLength=50></TD>
                  </TR>
                  <TR> 
                    <TD width="29%">公司网址：<BR> </TD>
                    <TD width="71%"> <INPUT name=home id="home" value="<%=rs("Home")%>" size=30 maxLength=100></TD>
                  </TR>
                  <TR> 
                    <TD>邮政编码：</TD>
                    <TD width="71%"><input name=Zip id="Zip" value="<%=rs("Zip")%>" size=30 maxlength=20> 
                    </TD>
                  </TR>
                  <TR> 
                    <TD>联系电话：</TD>
                    <TD width="71%"><input name=Phone id="Phone" value="<%=rs("Phone")%>" size=30 maxlength=20> 
                    </TD>
                  </TR>
                  <TR> 
                    <TD width="29%">传 真：</TD>
                    <TD width="71%"> <INPUT name=Fox id="Fox" value="<%=rs("Fox")%>" size=30 maxLength=50></TD>
                  </TR>
                  <TR> 
                    <TD colspan="2"><div align="center"> 
                        <input name="up" type=submit id="up" value=" 修 改 ">
                        &nbsp; 
                        <input name="Reset" type="reset" id="Reset" value=" 复 位 ">
                      </div></TD>
                  </TR>
                </TABLE>
                <div align="center"> </div>
              </form></TD>
          </TR>
          <TR> 
            <TD 
                  height=1 background=img/naBialym.gif><IMG height=1 src="img/1x1_pix.gif" 
              width=10></TD>
          </TR>
          <TR> 
            <TD><IMG height=1 src="img/1x1_pix.gif" 
              width=10> </TD>
          </TR>
        </TBODY>
      </TABLE>
      
    </td>
  </tr>
</table>
<%rs.Close
Conn.Close
call CloseConn()%>
</body>
</html>
<%End if
End if%>