<%@ LANGUAGE = VBScript.Encode %>
<HTML xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312" />
<TITLE>会员信息编辑</TITLE>
<link rel="stylesheet" href="Images/Admin.css">
<script language="javascript" src="../Script/Admin.js"></script>
</HEAD>
<!--#include file="../Include/conn.asp" -->
<!--#include file="../Include/ConnDatabase.asp" -->
<!--#include file="CheckAdmin.asp"-->
<%
'=====================================
'天天企业网站管理系统  TianTianCMS
'天天网络科技工作室版权所有
'官方客服中心 http://www.ip126.com
'微信公众号 ip126com
'QQ:530051328 mail:bbfhq@163.com
'=====================================
%>
<BODY>

<%
if Instr(session("AdminPurview"),"|31,")=0 then
  response.write ("<br><br><div align=""center""><font style=""color:red; font-size:9pt; "")>您没有管理该模块的权限！</font></div>")
  response.end
end if
dim Result
Result=request.QueryString("Result")
dim ID,mMemName,mRealName,mPassword,vPassword,mSex,mGroupID,mGroupName,mGroupIdName
dim mCompany,mAddress,mZipCode,mTelephone,mFax,mMobile,mEmail,muserqq,mHomepage,mWorking,mmaillist
ID=request.QueryString("ID")
call MemEdit()
%>
<br>
<table class="tableborder" width="95%" border="0" align="center" cellpadding="3" cellspacing="1">
  <form name="editForm" method="post" action="MemEdit.asp?Action=SaveEdit&Result=<%=Result%>&ID=<%=ID%>">
    <tr>
      <th height="22" colspan="2">【<%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"><input name="MemName" type="text" id="MemName" style="width: 120" value="<%=mMemName%>" maxlength="16" <%if Result="Modify" then response.write ("readonly")%>> <font color="red">*</font>3-16个字符</td>
    </tr>
    <tr>
      <td align="right" class="forumRow">真实姓名：</td>
      <td class="forumRowHighlight"><input name="RealName" type="text" id="RealName" style="width: 120" value="<%=mRealName%>" maxlength="16"></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">性&nbsp;&nbsp;&nbsp;&nbsp;别：</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>
      <td align="right" class="forumRow">会员组别：</td>
      <td class="forumRowHighlight"><select name="GroupID"><% call SelectGroup() %></select></td>
    </tr>
	<tr>
      <td align="right" class="forumRow">公司名称：</td>
      <td class="forumRowHighlight"><input name="Company" type="text" id="Company" style="width: 280" value="<%=mCompany%>" maxlength="100"></td>
    </tr>
	<tr>
      <td align="right" class="forumRow">地&nbsp;&nbsp;&nbsp;&nbsp;址：</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="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">联络QQ号：</td>
      <td class="forumRowHighlight"><input name="userqq" type="text" id="userqq" style="width: 280" value="<%=muserqq%>" maxlength="50"></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">网&nbsp;&nbsp;&nbsp;&nbsp;址：</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="maillist" type="checkbox"  value="1" <%if mmaillist=1 then response.write ("checked")%>></td>
    </tr>
	<tr>
      <td align="right" class="forumRow">活动会员：</td>
      <td class="forumRowHighlight"><input name="Working" type="checkbox"  value="1" <%if mWorking=True then response.write ("checked")%>></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>
</BODY>
</HTML>
<%
sub MemEdit()
  dim Action,rs,sql
  Action=request.QueryString("Action")
  if Action="SaveEdit" then
    set rs = server.createobject("adodb.recordset")
    if Result="Add" then
      if not conn.execute("select MemName from TianTianCMS_Members where MemName='" & trim(Request.Form("MemName")) & "'").eof then
        response.write "<script language='javascript'>alert('" & trim(Request.Form("MemName")) & "会员名已经存在！');history.back(-1);</script>"
        response.end
      end if
	  sql="select * from TianTianCMS_Members"
      rs.open sql,conn,1,3
      rs.addnew
      rs("MemName")=trim(Request.Form("MemName"))
      rs("RealName")=StrReplace(trim(Request.Form("RealName")))
      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"))
	  rs("Sex")=Request.Form("Sex")
      mGroupIdName=split(Request.Form("GroupID"),"┎╂┚")
	  rs("GroupID")=mGroupIdName(0)
	  rs("GroupNameCH")=mGroupIdName(1)
	  rs("Company")=StrReplace(trim(Request.Form("Company")))
	  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")=trim(Request.Form("Email"))
	  rs("userqq")=StrReplace(trim(Request.Form("userqq")))
	  rs("HomePage")=StrReplace(trim(Request.Form("HomePage")))
	  rs("maillist")=Request.Form("aillist")
	  if Request.Form("Working")=1 then
        rs("Working")=Request.Form("Working")
	  else
        rs("Working")=0
	  end if
	  rs("AddTime")=now()
	end if
	if Result="Modify" then
      sql="select * from TianTianCMS_Members where ID="&ID
      rs.open sql,conn,1,3
      rs("MemName")=trim(Request.Form("MemName"))
      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")
      mGroupIdName=split(Request.Form("GroupID"),"┎╂┚")
	  rs("GroupID")=mGroupIdName(0)
	  rs("GroupName")=mGroupIdName(1)
	  rs("Company")=StrReplace(trim(Request.Form("Company")))
	  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("userqq")=StrReplace(trim(Request.Form("userqq")))
	  rs("HomePage")=StrReplace(trim(Request.Form("HomePage")))
	  rs("maillist")=Request.Form("maillist")
	  if Request.Form("Working")=1 then
        rs("Working")=Request.Form("Working")
	  else
        rs("Working")=0
	  end if
	end if
	rs.update
	rs.close
    set rs=nothing
    response.write "<script language='javascript'>alert('设置成功！');location.replace('MemList.asp');</script>"
  else
	if Result="Modify" then
      set rs = server.createobject("adodb.recordset")
      sql="select * from TianTianCMS_Members where ID="& ID
      rs.open sql,conn,1,1
	  mMemName=rs("MemName")
	  mRealName=rs("RealName")
	  mSex=rs("Sex")
	  mGroupID=rs("GroupID")
	  mGroupName=rs("GroupName")
	  mCompany=rs("Company")
	  mAddress=rs("Address")
	  mZipCode=rs("ZipCode")
	  mTelephone=rs("Telephone")
	  mFax=rs("Fax")
	  mMobile=rs("Mobile")
	  mEmail=rs("Email")
	  muserqq=rs("userqq")
	  mHomepage=rs("Homepage")
	  mWorking=rs("Working")
	  mmaillist=rs("maillist")
	  rs.close
      set rs=nothing
	end if
  end if
end sub

sub SelectGroup()
  dim rs,sql
  set rs = server.createobject("adodb.recordset")
  sql="select GroupID,GroupNameCH from TianTianCMS_MemGroup"
  rs.open sql,conn,1,1
  if rs.bof and rs.eof then
    response.write("未设组别")
  end if
  while not rs.eof
    response.write("<option value='"&rs("GroupID")&"┎╂┚"&rs("GroupNameCH")&"'")
    if mGroupID=rs("GroupID") then response.write ("selected")
    response.write(">"&rs("GroupNameCH")&"</option>")
    rs.movenext
  wend
  rs.close
  set rs=nothing
end sub
%>