<!--#include file="../Include/Const.asp" -->
<!--#include file="../Include/ConnSiteData.asp" -->
<!--#include file="CheckAdmin.asp"-->
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="Images/Admin.css">
<script language="javascript" src="../Scripts/Admin.js"></script>
<%
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,mHomepage,mWorking,mIntegral,mMoneys
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="MemEdit.asp?Action=SaveEdit&Result=<%=Result%>&ID=<%=ID%>">
    <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"><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">性别：</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">地址：</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">电子信箱：</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="Integral" type="text" id="Integral" style="width: 280" value="<%=mIntegral%>" maxlength="50"></td>
    </tr>
	<tr>
      <td align="right" class="forumRow">会员金额：</td>
      <td class="forumRowHighlight"><input name="Moneys" type="text" id="Moneys" style="width: 280" value="<%=mMoneys%>" maxlength="50"></td>
    </tr>
	<tr>
      <td align="right" class="forumRow">生效：</td>
      <td class="forumRowHighlight"><input name="Working" type="checkbox"  value="1" <%if mWorking 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>
<%
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 liangjing_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 liangjing_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
	  If IsNumeric(trim(Request.Form("Integral")))=False Then 
        response.write "<script language='javascript'>alert('积分必须为数字?');history.back(-1);</script>"
        response.end
	  End If 
	  If trim(Request.Form("Moneys"))="" 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("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")=trim(Request.Form("Email"))
	  rs("Integral")=trim(Request.Form("Integral"))
	  rs("Moneys")=trim(Request.Form("Moneys"))
	  rs("HomePage")=StrReplace(trim(Request.Form("HomePage")))
	  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 liangjing_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("HomePage")=StrReplace(trim(Request.Form("HomePage")))
	  rs("Integral")=trim(Request.Form("Integral"))
	  rs("Moneys")=trim(Request.Form("Moneys"))
	  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 liangjing_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")
	  mHomepage=rs("Homepage")
	  mWorking=rs("Working")
	  mIntegral= rs("Integral")
	  mMoneys= rs("Moneys")
	  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,GroupName from liangjing_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("GroupName")&"'")
    if mGroupID=rs("GroupID") then response.write ("selected")
    response.write(">"&rs("GroupName")&"</option>")
    rs.movenext
  wend
  rs.close
  set rs=nothing
end sub
%>