<!--#include file="conn.asp"-->
<%
if session("admin")="" then
conn.close
set conn = nothing
response.Write "<script language='javascript'>alert('请先登录！');history.go(-1);</script>"
response.End
else
if request.cookies("timesshop")("admin")="" then
conn.close
set conn = nothing
response.Write "<script language='javascript'>alert('请先登录！');history.go(-1);</script>"
response.End
end if
end if

dim action,grpid
grpid=SafeRequest("id",1)
action=FormatSQL(SafeRequest("action",0))
select case action

case "add" 
if session("rank")>1 then
conn.close
set conn = nothing
response.Write "<script language='javascript'>alert('你无权添加会员等级！');history.go(-1);</script>"
response.End
end if
if Not isNumeric(request.form("minipost")) then
response.Write "<script language=javascript>alert('等级积分必须是数字！');history.go(-1);</script>"
response.End
end if
if request.form("GRPName") ="" then
response.Write "<script language=javascript>alert('请填写等级名称！');history.go(-1);</script>"
response.End
end if
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from TimesGRP",conn,1,3
rs.AddNew
rs("GRPName")=trim(request.form("GRPName"))
rs("startgrp")=int(request.form("startgrp"))
rs("minipost")=int(request.form("minipost"))
rs("stars")=request.form("stars")
rs.Update
rs.Close
set rs=nothing
conn.close
set conn = nothing
response.Redirect "addgrp.asp"

case "edit"
if session("rank")>1 then
conn.close
set conn = nothing
response.Write "<script language='javascript'>alert('你无权编辑会员等级！');history.go(-1);</script>"
response.End
end if
if Not isNumeric(request.form("minipost")) then
response.Write "<script language=javascript>alert('等级积分必须是数字！');history.go(-1);</script>"
response.End
end if
if request.form("GRPName") ="" then
response.Write "<script language=javascript>alert('请填写等级名称！');history.go(-1);</script>"
response.End
end if
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from TimesGRP where grpid="&grpid,conn,1,3
rs("GRPName")=trim(request.form("GRPName"))
rs("startgrp")=int(request.form("startgrp"))
rs("minipost")=int(request.form("minipost"))
rs("stars")=request.form("stars")
rs.Update
rs.Close
set rs=nothing
conn.close
set conn = nothing
response.Redirect "addgrp.asp"

end select
%>
<title>管理会员等级</title>
<script language = "JavaScript">
<!--
function CheckAdd()
{
    if(checkspace(document.AddForm.GrpNmae.value)) {
	document.AddForm.GrpNmae.focus();
    alert("请输入会员等级名称！");
	return false;
  }

     if(checkspace(document.AddForm.MiniPost.value)) {
	document.AddForm.MiniPost.focus();
    alert("请输入等级积分！");
	return false;
  }
     
}
function checkspace(checkstr) {
  var str = '';
  for(i = 0; i < checkstr.length; i++) {
    str = str + ' ';
  }
  return (str == checkstr);
}
	function regInput(obj, reg, inputStr)
	{
		var docSel	= document.selection.createRange()
		if (docSel.parentElement().tagName != "INPUT")	return false
		oSel = docSel.duplicate()
		oSel.text = ""
		var srcRange	= obj.createTextRange()
		oSel.setEndPoint("StartToStart", srcRange)
		var str = oSel.text + inputStr + srcRange.text.substr(oSel.text.length)
		return reg.test(str)
	}
//-->
</script>
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#6699cc">
  <tr> 
    <td height="20" bgcolor="#6699cc" align="center"><font color="#FFFFFF">会员等级管理</font></td>
  </tr>
  <tr> 
    <td bgcolor="#FFFFFF">
	<table width="80%" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#CCCCCC">
        <tr align="center" bgcolor="#FFFFFF" height="25"> 
          <td width="28%">等级名称</td>
          <td width="18%">所需积分</td>
          <td width="18%">操作</td>
        </tr>
        <%set rs=server.CreateObject("adodb.recordset")
		  rs.Open "select * from TimesGRP order by startgrp",conn,1,1
		  if rs.EOF and rs.BOF then
		  response.Write "<div align=center><font color=red>还没有等级</font></center>"
		  else
		  do while not rs.EOF
		  %>
        <form name="form1" method="post" action="addgrp.asp?action=edit&id=<%=int(rs("grpid"))%>">
          <tr bgcolor="#FFFFFF" align="center">
		  <td><input name="GRPName" type="text" id="category" size="20" value="<%=trim(rs("GRPName"))%>"></td>
            <td><input name=minipost type="text" value="<% = rs("minipost") %>" size="10"></td>
            <td><input type="submit" name="Submit" value="修 改" onClick="return CheckAdd();"></td>
          </tr>
        </form>
        <%rs.MoveNext
          loop
          end if%>
      </table><br></td>
  </tr>
</table>
<br>
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#6699cc">
  <tr> 
    <td bgcolor="#6699cc" height="20" align="center"><font color="#FFFFFF">操作注意事项及说明</font></td>
  </tr>
  <tr> 
    <td bgcolor="#FFFFFF"> 
	<table width="92%" border="0" align="center" cellpadding="5" cellspacing="0">
        <tr> 
          <td height="20"><font color="#FF6600">会员等级对应于添加商品的商品价格。<br>
            ·新会员注册时默认的等级为普通会员。<br>
            ·当会员达到等级所需的积分时，可以在前台的用户中心选择升级，但这不是必须的，程序没有设定成达到积分自动升级。</font></td>
        </tr>
      </table></td>
  </tr>
</table>
<!--#include file="footer.asp"-->