<%
if request.cookies("buyok")("admin")="" then response.write "<meta http-equiv='refresh' content='0;URL=../admin.asp'>"
%>
<!--#include file="../include/config.asp"-->
<!--#include file="../md5.asp"-->

<script language=javascript src=../include/mouse.js></script>
    <%
sub checkmanage(str)
Set mrs = conn.Execute("select * from manage where username='"&request.cookies("buyok")("admin")&"'")
if not (mrs.bof and mrs.eof) then
manage=mrs("manage")
if instr(manage,str)<=0 then
response.write "<script language='javascript'>"
response.write "alert('警告：您没有此项操作的权限！');"
response.write "location.href='quit.asp';"
response.write "</script>"
response.end
else
session("buyok_admin_login")=0
end if
else 
response.write "<script language='javascript'>"
response.write "alert('没有登陆，不能执行此操作！');"
response.write "location.href='quit.asp';"
response.write "</script>"
response.end
end if
set mrs=nothing
end sub
%>
<%call checkmanage("05")%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<LINK href="../images/css.css" type=text/css rel=stylesheet>
<LINK href="../list/newhead.css" type=text/css rel=stylesheet>
<script language=javascript>
<!--
function CheckAll(form){
for (var i=0;i<form.elements.length;i++){
var e = form.elements[i];
if (e.name != 'chkall') e.checked = form.chkall.checked; 
}
}
-->
</script>
</head>
<BODY bgcolor="#D9EAFC">
<%
action=request("action")
if action="" then call user()
if action="useredit" then
if request("edit")="ok" then
call save()
else
call edit()
end if
end if
if action="del" then call userdel()

sub user()
'会员首页
%>
<table height="5"><tr><td></td></tr></table>
<TABLE cellSpacing=0 cellPadding=0 width=95% border=0 style="BORDER-RIGHT: #b1bfee 1px solid; BORDER-TOP: #b1bfee 1px solid; BORDER-LEFT: #b1bfee 1px solid; BORDER-BOTTOM: #b1bfee 1px solid" 
>
  <TBODY>
    <TR>
      <TD width="90%" bgColor=#f4f5fd><font color="#000000">　<B><font color="#FF0000">&nbsp;注册会员管理 
        </font></B></font></TD>
      <TD bgColor=#f4f5fd height=30></TD>
    </TR>
  </TBODY>
</TABLE>
		  <table height="5"><tr><td></td></tr></table>

<table width="95%"  border="0" cellpadding="0" cellspacing="1" bgcolor="#b1bfee">
<form action=user1.asp method=post name=user>
<%
usersql=request.cookies("buyok")("usersql")
if request("show")="yes" then
  response.cookies("buyok")("usersql")=""
end if

pages = 20
set rs=server.createobject("adodb.recordset")
sql="select * from buser where UserNum is not null "
if request("show")<>"yes" then sql=sql+usersql 
sql=sql+" order by SignDate desc"
rs.open sql,conn,1,3
if rs.eof and rs.bof then
response.write "<tr bgcolor=#FFFFFF><td colspan=7 align=center height=50>暂时没有会员</td></tr>"
response.end 
else
totalrs=rs.RecordCount
rs.pageSize = pages
allPages = rs.pageCount
page = Request("page")
If not isNumeric(page) then page=1
if isEmpty(page) or int(page) <=1 then
page = 1
elseif int(page) > allPages then
page = allPages 
end if
rs.AbsolutePage = page
%>
<tr bgcolor="#f4f5fd">
<td width=5% align=center>选</td>
<td width='18%' align=center>会员ID</td>
<td width='18%' align=center>会员姓名</td>
<td width='15%' align=center>会员级别</td>
<td width='16%' align=center>注册日期</td>
<td width='16%' align=center>上次登陆</td>
<td width='12%' align=center>登陆次数</td>
</tr>
<% Do While Not rs.eof and pages>0 
usertype=rs("usertype")
if usertype="2" then
usertype=type2
elseif usertype="3" then
usertype=type3
elseif usertype="4" then
usertype=type4
elseif usertype="5" then
usertype=type5
elseif usertype="6" then
usertype=type6
else
usertype=type1
end if
%>
<tr bgcolor="#FFFFFF"><td><input type='checkbox' value='<%=rs("UserNum")%>' name=num></td>
<td><a href='user1.asp?action=useredit&id=<%=rs("UserId")%>'><%=rs("UserId")%></a></td>
<td><%=rs("UserName")%></td><td><%=usertype%></td>
<td><span alt="<%=rs("SignDate")%>"><%=split(rs("SignDate")," ")(0)%></span></td>
<td><span alt="<%=rs("lastlogin")%>"><%=split(rs("lastlogin")," ")(0)%></span></td>
<td align=center><%=rs("totallogin")%></td></tr>

<%
pages = pages - 1
rs.movenext
if rs.eof then exit do
loop
end if
%>
<tr bgcolor="#FFFFFF"><td colspan=7>
<input type='checkbox' name=chkall onclick='CheckAll(this.form)'>全选 
<input type=hidden name=action value="del">
<input type=submit value="删除" onClick="{if(confirm('确认要删除选定的会员吗？')){this.document.user.submit();return true;}return false;}">
</td></tr>
</form>
</table>
		  <table height="5"><tr><td></td></tr></table>

<%

'if allpages<=1 then exit sub
response.write "<br>总会员数<font color=red>"&totalrs&"</font> &nbsp; 每页<font color=red>20</font>&nbsp; "
if page <= 1 then
response.write "<font color=darkgray>首页 前页</font>"
else
response.write "<a href=user1.asp?keywords="&keywords&"&page=1>首页</a> <a href=user1.asp?keywords="&keywords&"&page="&page-1&">前页</a>"
end if
if page = allpages then
response.write "<font color=darkgray> 下页 末页</font>"
else
response.write " <a href=user1.asp?keywords="&keywords&"&page="&page+1&">下页</a> <a href=user1.asp?keywords="&keywords&"&page="&allpages&">末页</a>"
end if
response.write " &nbsp;&nbsp;&nbsp;第"&page&"页 共"&allpages&"页"
end sub


sub edit()
'修改会员资料
name=request("id")
set rs=conn.execute("select * from buser where UserId='"&name&"'")
if rs.eof and rs.bof then
response.write "<script language='javascript'>"
response.write "alert('出错了，没有此用户。');"
response.write "location.href='javascript:history.go(-1)';"
response.write "</script>"
response.end
end if
usertype=rs("usertype")
if usertype="2" then
usertype=type2
userkou=kou2
elseif usertype="3" then
usertype=type3
userkou=kou3
elseif usertype="4" then
usertype=type4
userkou=kou4
elseif usertype="5" then
usertype=type5
userkou=kou5
elseif usertype="6" then
usertype=type6
userkou=kou6
else
usertype=type1
userkou=kou1
end if
%>
<table height="5"><tr><td></td></tr></table>
<TABLE cellSpacing=0 cellPadding=0 width=95% border=0 style="BORDER-RIGHT: #b1bfee 1px solid; BORDER-TOP: #b1bfee 1px solid; BORDER-LEFT: #b1bfee 1px solid; BORDER-BOTTOM: #b1bfee 1px solid" 
>
  <TBODY>
    <TR>
      <TD width="90%" bgColor=#f4f5fd><font color="#000000">　<B><font color="#FF0000">&nbsp;查看/编辑会员资料</font></B></font></TD>
      <TD bgColor=#f4f5fd height=30></TD>
    </TR>
  </TBODY>
</TABLE>
		  <table height="5"><tr><td></td></tr></table>

<table width="95%"  border="0" cellpadding="0" cellspacing="1" bgcolor="#b1bfee">
  <form name="myinfo" action="user1.asp?action=useredit" method="post">
    <tr bgcolor="#FFFFFF"> 
      <td width='20%' height=25 align=right>会员ID &nbsp; </td>
      <td><%=Name%></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td width='20%' height=25 align=right>推荐人 &nbsp; </td>
      <td><%=rs("tjr")%></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height=25 align=right>推荐的会员 &nbsp;</td>
      <td> 
        <%
set rstjr=conn.execute("select * from buser where tjr='"&name&"'")
Do While Not rstjr.eof
tjrname=rstjr("UserId")
response.write "<font color=#000000>"&tjrname&"</font>&nbsp;&nbsp;&nbsp;&nbsp;"
if rstjr.eof then exit do
rstjr.movenext
loop
set rstjr=nothing
%>
      </td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td width='20%' height=25 align=right>注册时间 &nbsp; </td>
      <td><%=rs("SignDate")%></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td width='20%' height=25 align=right>上次登陆时间 &nbsp; </td>
      <td><%=rs("lastlogin")%></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td width='20%' height=25 align=right>上次登陆IP &nbsp; </td>
      <td><%=rs("IP")%></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td width='20%' height=25 align=right>登陆次数 &nbsp; </td>
      <td><%=rs("totallogin")%> 次</td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height=25 align=right>消费总金额 &nbsp; </td>
      <td><input type="text" name="totalsum" value="<%if rs("totalsum")<>"" then response.write formatnum(rs("totalsum"),2)%>" maxlength=8> 
        &nbsp;&nbsp; <img src=../images/admin/memo.gif alt="订单完成后，会自动追加金额<br>管理员亦可手工修改此处金额"> 
      </td>
    </tr>
    <tr bgcolor="#FFFFFF">
      <td height=25 align=right>积分 &nbsp; </td>
      <td><input name="jifensum" type="text" id="jifensum" value="<%=rs("jifensum")%>" maxlength=8>
        &nbsp;&nbsp; <img src=../images/admin/memo.gif alt="订单完成后，会自动为推荐人追加<br>管理员亦可手工修改此处金额"> 
      </td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height=25 align=right>佣金提成 &nbsp; </td>
      <%
	  set rstc=conn.execute("select * from bconfig1")
       %>
      <td><input type="text" name="jifen" value="<%if rs("jifen")<>"" then response.write formatnum(rs("jifen")*rstc("usertype1")*0.01,2)%>" maxlength=8> 
        &nbsp;&nbsp; <img src=../images/admin/memo.gif alt="订单完成后，会自动为推荐人追加<br>管理员亦可手工修改此处金额"> 
      </td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td width='20%' height=25 align=right>会员等级 &nbsp; </td>
      <td><select size="1" name="usertype">
          <option value="1" <%if usertype=type1 then%>selected<%end if%>><%=type1%></option>
          <%if type2<>"" then%>
          <option value="2" <%if usertype=type2 then%>selected<%end if%>><%=type2%></option>
          <%if type3<>"" then%>
          <option value="3" <%if usertype=type3 then%>selected<%end if%>><%=type3%></option>
          <%if type4<>"" then%>
          <option value="4" <%if usertype=type4 then%>selected<%end if%>><%=type4%></option>
          <%if type5<>"" then%>
          <option value="5" <%if usertype=type5 then%>selected<%end if%>><%=type5%></option>
          <%if type6<>"" then%>
          <option value="6" <%if usertype=type6 then%>selected<%end if%>><%=type6%></option>
          <%
end if
end if
end if
end if
end if%>
        </select> </td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td width='20%' height=25 align=right>购物折扣 &nbsp; </td>
      <td><input type="text" name="userkou"value="<%=FormatNumber(userkou,2)%>" disabled></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height=25 align=right>会员密码 &nbsp; </td>
      <td><input type="text" name="Userpassword" value="" maxlength="16"> &nbsp;&nbsp; 
        <img src=../images/admin/memo.gif alt="若不修改密码，请空出"> </td>
    </TR>
    <tr bgcolor="#FFFFFF"> 
      <td width='20%' height=25 align=right>真实姓名 &nbsp; </td>
      <td><input type="text" name="Username" value="<%=rs("UserName")%>" maxlength="16"></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height=25 align=right>电子邮箱 &nbsp; </td>
      <td><input type="text" name="UserMail" value="<%=rs("UserMail")%>" maxlength="100"> 
        &nbsp; &nbsp; <a href='sendmail.asp?<%=rs("UserMail")%>'><img alt='发邮件' border=0 src='../images/small/e-mail.gif'></a> 
      </td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height=25 align=right>联系地址 &nbsp; </td>
      <td><input type="text" name="Address" value="<%=rs("Address")%>" maxlength="100"></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height=25 align=right>邮政编码 &nbsp; </td>
      <td><input type="text" name="ZipCode" value="<%=rs("ZipCode")%>" maxlength="8"></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height=25 align=right>联系电话 &nbsp; </td>
      <td><input type="text" name="HomePhone" value="<%=rs("HomePhone")%>" maxlength="20"></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height=25 align=right>移动电话 &nbsp; </td>
      <td><input type="text" name="CompPhone" value="<%=rs("CompPhone")%>" maxlength="20"></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height=25 align=right>腾讯ＱＱ &nbsp; </td>
      <td><input type="text" name="UserQQ" value="<%=rs("UserQQ")%>" maxlength="11"> 
        &nbsp; &nbsp; 
        <%if rs("UserQQ")<>"" then%>
        <a target=blank href=http://wpa.qq.com/msgrd?V=1&Uin=<%=rs("UserQQ")%>&Site=<%=sitename%>&Menu=yes><img border="0" SRC=http://wpa.qq.com/pa?p=1:<%=rs("UserQQ")%>:6 alt="与该会员交谈或留言"></a> 
        <%end if%>
      </td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height=25 align=right>ICQ号 &nbsp; </td>
      <td><input type="text" name="UserICQ" value="<%=rs("UserICQ")%>" maxlength="15"></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height=25 align=right>MSN号 &nbsp; </td>
      <td><input type="text" name="UserMSN" value="<%=rs("UserMSN")%>" maxlength="100"></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height=25 align=right>国家 &nbsp; </td>
      <td><input type="text" name="Country" value="<%=rs("Country")%>"></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height=25 align=right>省份 &nbsp; </td>
      <td><input type="text" name="Province" value="<%=rs("Province")%>"></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height=25 align=right>城市 &nbsp; </td>
      <td><input type="text" name="City" value="<%=rs("City")%>"></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height=25 align=right>性别 &nbsp; </td>
      <td><input name="Sex" type="radio" value="1" <%if rs("Sex")="1" then response.write "checked"%>>
        帅哥 
        <input type="radio" name="Sex" value="0" <%if rs("Sex")="0" then response.write "checked"%>>
        靓妹 </td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height=25 align=right>生日 &nbsp; </td>
      <td><input type="text" name="Birthday" value="<%=rs("Birthday")%>"></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height=25 align=right>个人说明 &nbsp; </td>
      <td><TEXTAREA style="overflow:auto;" type="text" name="Memo" ROWS="3" COLS="40"><%=rs("Memo")%></TEXTAREA></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height=25 align=right>管理附言 &nbsp; </td>
      <td><TEXTAREA style="overflow:auto;background-color: #FFFFCC;" type="text" name="Memo2" ROWS="3" COLS="40"><%=rs("Memo2")%></TEXTAREA> 
        &nbsp;&nbsp; <img src=../images/admin/memo.gif alt="管理员此处添加的信息<br>会员只能查看不能修改<br>此信息在会员的个人资料页中滚动提示"> 
      </td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height=25 align=right>会员状态 &nbsp; </td>
      <td> <input name="Status" type="radio" value="1" <%if rs("Status")<>"0" then%>checked<%end if%>>
        正常/通过审核 
        <input name="Status" type="radio" value="0" <%if rs("Status")="0" then%>checked<%end if%>>
        锁定/未审核 </tr>
    <tr bgcolor="#FFFFFF"> 
      <td colspan=2> <input name="id" type="hidden" value="<%=rs("UserId")%>"> 
        <input name="edit" type="hidden" value="ok"> <input type="submit" name="Submit" value="确认修改"> 
        &nbsp;&nbsp; <input alt='给此会员发送站内消息' type="button" value="发送站内消息" onClick="javascript:location.href='hand2.asp?back=user&name=<%=rs("UserId")%>';" > 
      </td>
    </tr>
  </form>
</table>
		  <table height="5"><tr><td></td></tr></table>

<%
set rs=nothing 
end sub


sub save()
'保存会员资料
name=request("id")
sql = "select * from buser where UserId='"&name&"'"
set rs=Server.Createobject("ADODB.RecordSet")
rs.Open sql,conn,1,3
if rs.eof and rs.bof then
response.write "<script language='javascript'>"
response.write "alert('出错了，没有此会员。');"
response.write "location.href='user1.asp';"
response.write "</script>"
response.end
rs.close
set rs=nothing
end if
rs("Usertype") = request("usertype")
rs("userkou") = request("usertype")
rs("Username") = trim(request("Username"))
rs("Sex") = request("Sex")
if trim(request("totalsum"))<>"" then rs("totalsum")= trim(request("totalsum"))
if trim(request("jifen"))<>"" then rs("jifen")= trim(request("jifen"))
rs("jifensum") = trim(request("jifensum"))

rs("UserQQ") = trim(request("UserQQ"))
rs("UserICQ") = trim(request("UserICQ"))
rs("UserMSN") = trim(request("UserMSN"))
rs("Birthday") = trim(request("Birthday"))
rs("HomePhone")= trim(request("HomePhone"))
rs("CompPhone") = trim(request("CompPhone"))
rs("UserMail") = trim(request("UserMail"))
rs("Country") = trim(request("Country")) 
rs("Province") = trim(request("Province"))
rs("City") = trim(request("City"))
rs("Address") = trim(request("Address"))
rs("ZipCode") = trim(request("ZipCode"))
rs("Memo") = request("Memo")
rs("Memo2") = request("Memo2")
rs("Status") = request("Status")
if trim(request("Userpassword"))<>"" then rs("Userpassword")=md5(trim(request("Userpassword")))
rs.update
rs.close
set rs = nothing
response.write "<script language='javascript'>"
response.write "alert('操作成功，会员资料已保存！');"
response.write "location.href='user1.asp?action=useredit&id="&name&"';"
response.write "</script>"
response.end
end sub


sub userdel()
delnum=request("num")
if delnum="" or isnull(delnum) then
response.write "<script language='javascript'>"
response.write "alert('出错了，您什么也没有选择！');"
response.write "location.href='user1.asp';"
response.write "</script>"
response.end
end if
conn.execute("delete from buser where UserNum in ("&delnum&")")
response.write "<script language='javascript'>"
response.write "alert('操作成功，选定的会员已被删除！');"
response.write "location.href='user1.asp';"
response.write "</script>"
response.end
conn.close
set conn=nothing
end sub
%>
