<!--#include file="../Include/Const.Asp" -->
<!--#include file="../Include/ConnSiteData.Asp" -->
<!--#include file="../Include/Md5.Asp" -->
<!--#include file="../CheckAdmin.Asp"-->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="../Images/Admin_style.css">
<script language="javascript" src="../JavaScript/Admin.js"></script>
<script language="javascript" type="text/javascript" src="../My97DatePicker/WdatePicker.js"></script>
<%
Dim Result,MemName
Result = request.QueryString("Result")
Dim ID, memID,mMemName, mRealName, mPassword, vPassword, mSex, mGroupID, mGroupName, mGroupIdName,mAddTime,SortName,SortID,SortPath
Dim mdepartment, mAddress, mZipCode, mTelephone, mFax, mMobile, mEmail, mHomepage, mWorking
ID = request.QueryString("ID")
Call MemEdit()
%>
<br />
<table class="tableBorder" width="95%" border="0" align="center" cellpadding="5" cellspacing="1">
  <form name="editForm" method="post" action="My_MemEdit.Asp?Action=SaveEdit&Result=<%=Result%>" onSubmit="return CheckMemEdit()">
    <tr>
      <th height="22" colspan="2" sytle="line-height:150%">【<%If Result = "Add" then%>添加<%ElseIf Result = "Modify" then%>修改<%End If%>个人信息】</th>
    </tr>
    <tr>
      <td width="20%" align="right" class="forumRow">登录账号：</td>
      <td width="80%" class="forumRowHighlight"> <font color="red"><%=mMemName%></font>
	  
	  </td>
    </tr>
	
    <tr>
      <td align="right" class="forumRow">姓名：</td>
      <td class="forumRowHighlight"><input name="RealName" type="text" id="RealName" style="width: 120;background-color:#EBF2F9" value="<%=mRealName%>" maxlength="16" <%if memID<>1 then response.write ("readonly")%>>
	  &nbsp;&nbsp; 入职时间：<input name="AddTime" class="Wdate" type="text" id="AddTime" style="width: 120;background-color:#EBF2F9" value="<%=mAddTime%>" maxlength="16"<%if memID=1 then response.write (" onFocus=""WdatePicker({skin:'blueFresh'})""")%> readonly>
      
      </td>
    </tr>
    <tr>
      <td align="right" class="forumRow">登录密码：</td>
      <td class="forumRowHighlight"><input name="Password" type="password" id="Password" maxlength="20" style="width: 120"> <font color="red">*</font>6-16个字符，不修改请留空</td>
    </tr>
    <tr>
      <td align="right" class="forumRow">确认密码：</td>
      <td class="forumRowHighlight"><input name="vPassword" type="password" id="vPassword" maxlength="20" style="width: 120"> <font color="red">*</font></td>
    </tr>
    <tr>
      <td align="right" class="forumRow">性别：</td>
      <td class="forumRowHighlight"><input type="radio" name="sex" value="男" <%if mSex="男" then response.write ("checked")%>>男 <input type="radio" name="sex" value="女" <%if mSex="女" then response.write ("checked")%>>女</td>
    </tr>
    <tr style="display:none">
      <td align="right" class="forumRow">身份：</td>
      <td class="forumRowHighlight"> <%=mGroupName%></td>
    </tr>
    <tr>
      <td align="right" class="forumRow">所属部门：</td>
      <td class="forumRowHighlight">
	  <input name="SortID" type="hidden" id="SortID" style="width: 18; background-color:#fffff0" value="<%=SortID%>"> 
	  <input name="SortPath" type="hidden" id="SortPath" style="width: 70; background-color:#fffff0" value="<%=SortPath%>">   <input name="SortName" type="text" id="SortName" value="<%=SortName%>" style="width: 120;background-color:#EBF2F9" readonly>
	  <%if memID=1 then%>
	  <a href="javaScript:OpenScript('../SelectSort.Asp?Result=Department',500,500,'')"><img src="../Images/Select.gif" /></a>
	 <%end if%>
	</td>
    </tr>

    <tr>
      <td align="right" class="forumRow">电话：</td>
      <td class="forumRowHighlight"><input name="Telephone" type="text" id="Telephone" style="width: 120" value="<%=mTelephone%>" maxlength="50"></td>
    </tr>
    <tr>
      <td align="right" class="forumRow">传真号码：</td>
      <td class="forumRowHighlight"><input name="Fax" type="text" id="Fax" style="width: 120" value="<%=mFax%>" maxlength="16"></td>
    </tr>
    <tr>
      <td align="right" class="forumRow">手机号码：</td>
      <td class="forumRowHighlight"><input name="Mobile" type="text" id="Mobile" style="width: 120" value="<%=mMobile%>" maxlength="16"></td>
    </tr>
    <tr>
      <td align="right" class="forumRow">电子信箱：</td>
      <td class="forumRowHighlight"><input name="Email" type="text" id="Email" style="width: 280" value="<%=mEmail%>" maxlength="50"></td>
    </tr>
    <tr>
      <td align="right" class="forumRow">个人主页：</td>
      <td class="forumRowHighlight"><input name="HomePage" type="text" id="HomePage" style="width: 280" value="<%=mHomePage%>" maxlength="50"></td>
    </tr>
    
    <tr>
      <td align="right" class="forumRow">住址：</td>
      <td class="forumRowHighlight"><input name="Address" type="text" id="Address" style="width: 280" value="<%=mAddress%>" maxlength="100"></td>
    </tr>
    <tr>
      <td align="right" class="forumRow">邮政编码：</td>
      <td class="forumRowHighlight"><input name="ZipCode" type="text" id="ZipCode" style="width: 120" value="<%=mZipCode%>" maxlength="16"></td>
    </tr>	
    <tr>
      <td align="right" class="forumRow"></td>
      <td class="forumRowHighlight"><input name="submitSaveEdit" type="submit" id="submitSaveEdit" value="保存"> <input type="button" value="返回上一页" onclick="history.back(-1)"></td>
    </tr>
  </form>
</table>
<%
Sub MemEdit()
    Dim Action, rs, sql
    Action = request.QueryString("Action")
    If Action = "SaveEdit" Then
        Set rs = server.CreateObject("adodb.recordset")
        If Result = "Modify" Then
            sql = "select * from Zqj_Members where MemName='"&session("UserName")&"'"
            rs.Open sql, conn, 1, 3
            rs("RealName") = StrReplace(Trim(Request.Form("RealName")))
            If Trim(Request.Form("Password"))<>"" Then
                If Len(Trim(Request.Form("Password")))<6 Or Len(Trim(Request.Form("Password")))>16 Then
                    response.Write "<script language='javascript'>alert('请填写登录密码(6-16个字符)！');history.back(-1);</script>"
                    response.End
                End If
                If Request.Form("Password")<>Request.Form("vPassword") Then
                    response.Write "<script language='javascript'>alert('两次输入的密码不同！');history.back(-1);</script>"
                    response.End
                End If
                rs("Password") = Md5(Request.Form("Password"))
            End If
            rs("Sex") = Request.Form("Sex")
            rs("Address") = StrReplace(Trim(Request.Form("Address")))
            rs("ZipCode") = StrReplace(Trim(Request.Form("ZipCode")))
            rs("Telephone") = StrReplace(Trim(Request.Form("Telephone")))
            rs("Fax") = StrReplace(Trim(Request.Form("Fax")))
            rs("Mobile") = StrReplace(Trim(Request.Form("Mobile")))
            rs("Email") = StrReplace(Trim(Request.Form("Email")))
            rs("HomePage") = StrReplace(Trim(Request.Form("HomePage")))
			if rs("ID")=1 then
			rs("AddTime")=Trim(Request.Form("AddTime"))
			end if
            If Request.Form("SortID")<>"" And Request.Form("SortPath")<>"" Then
                rs("SortID") = Request.Form("SortID")
                rs("SortPath") = Request.Form("SortPath")
            End If
        End If
        rs.update
        rs.Close
        Set rs = Nothing
        response.Write "<script language='javascript'>alert('更新成功！');location.replace('My_MemEdit.Asp?Result=Modify');</script>"
    Else
        If Result = "Modify" Then
            Set rs = server.CreateObject("adodb.recordset")
            sql = "select * from Zqj_Members where MemName='"&session("UserName")&"'"
            rs.Open sql, conn, 1, 1
			memID=rs("ID")
            mMemName = rs("MemName")
            mRealName = rs("RealName")
            mSex = rs("Sex")
            mGroupID = rs("GroupID")
            mGroupName = rs("GroupName")
            'mdepartment = rs("department")
            mAddress = rs("Address")
            mZipCode = rs("ZipCode")
            mTelephone = rs("Telephone")
            mFax = rs("Fax")
            mMobile = rs("Mobile")
            mEmail = rs("Email")
            mHomepage = rs("Homepage")
			mAddTime=rs("AddTime")
            mWorking = rs("Working")
			SortName = SortText(rs("SortID"))
            SortID = rs("SortID")
            SortPath = rs("SortPath")
            rs.Close
            Set rs = Nothing
        End If
    End If
End Sub

Function SortText(ID)
    Dim rs, sql
    Set rs = server.CreateObject("adodb.recordset")
    sql = "Select * From Zqj_DepartmentSort where ID="& ID
    rs.Open sql, conn, 1, 1
	if rs.bof and rs.eof then
	SortText="未划分部门"
	else
    SortText = rs("SortName")
	end if
    rs.Close
    Set rs = Nothing
End Function
%>