<%@ LANGUAGE=VBScript codepage ="936" %><%Response.Expires=0
Response.Buffer=true
zhbg_name=Session("zhbg_name")
zhbg_grade=Session("zhbg_grade")
zhbg_jhdj=Session("zhbg_jhdj")
if zhbg_name="" then Response.Redirect "../error.asp?id=440"
if session("zhbg_adminok")<>true then Response.Redirect "../chat/readonly/bomb.htm"
if zhbg_grade<>10 or instr(Application("zhbg_user"),zhbg_name)=0  then Response.Redirect "../error.asp?id=439"
if zhbg_name<>Application("zhbg_adminuser") then Response.Redirect "../chat/readonly/bomb.htm"
username=Request.Form("search")
hymonth=Request.form("hymonth")
hygrade=int(Request.form("hygrade"))
hyjk=trim(Request.form("hyjk"))
if Isnull(hyjk) or hyjk="" then 
	hyjk=0
else
	hyjk=int(hyjk)
end if

	Set conn=Server.CreateObject("ADODB.CONNECTION")
	conn.open Application("zhbg_usermdb")
	Set rs=Server.CreateObject("ADODB.RecordSet")
	sqlstr="SELECT * FROM 用户 where 姓名='"&username&"'"
	rs.Open sqlstr,conn,1,2
	if rs.EOF or rs.BOF then
		rs.close
		set rs=nothing
		conn.close
		set conn=nothing
		Response.Write "<script language=javascript>alert('抱歉你所要查找的人我们找不到！请查看是否正确！');history.back();</script>"
		Response.End
	end if
	'if rs("会员等级")<>0 or rs("grade")=10 then
	'	Response.Write "<script language=javascript>alert('抱歉["&username&"]现在已经是["&rs("会员等级")&"级]国度会员，请手动更改！');history.back();</script>"
	'	rs.close
	'	set rs=nothing
	'	conn.close
	'	set conn=nothing
	'	Response.End	
	'end if
	if rs("会员等级")>0 then
		hydate=rs("会员日期")
	else
		hydate=date()
	end if
	oldhy=rs("会员等级")
	n=Year(hydate)
	y=Month(hydate)
	r=Day(hydate)
	y=y+hymonth
	if y>12 then 
		y=y-12
		n=n+1
	end if
	jy=0
	if hygrade=1 then jy=31250
	if hygrade=2 then jy=90000
	if hygrade=3 then jy=250000
	if hygrade=4 then jy=490000
	if hygrade=5 then jy=1000000
	if oldhy=1 then oldjy=31250
	if oldhy=2 then oldjy=90000
	if oldhy=3 then oldjy=250000
	if oldhy=4 then oldjy=490000
	if oldhy=5 then oldjy=1000000
	sj=n & "-" & y & "-" & r
	if hygrade=5 then
		rs("门派")="官府"
		rs("grade")=7
	end if
	rs("会员等级")=hygrade
	rs("会员金卡")=rs("会员金卡")+hyjk
	rs("会员日期")=cdate(sj)
	rs("allvalue")=rs("allvalue")+jy-oldjy
	rs.Update
	conn.execute "insert into l(a,b,c,d,e) values (now(),'"& zhbg_name &"','"& Request.ServerVariables("REMOTE_ADDR") &"','管理记录','[增加等级制会员]姓名："&username&"，等级："&hygrade&" 日期："&sj&" 金卡："&hyjk&"')"
	set rs=nothing
	conn.Close
	set conn=nothing
	Response.Write "<script language=javascript>alert('恭喜你["&username&"]的国度["& hygrade &"]会员设置完成！');history.back();</script>"
%>