<!--#include file="../conn/conn.asp" -->
<!--#include file="../inc/sub.asp"-->
<!--#include file="../inc/safe.asp"-->
<!--#include file="checkcmember.asp" -->
<%
  
  if not Chkrequest(request("usertype")) then
   Response.Write ("<script language=JavaScript>{alert('请选择升级类型。');location.href = 'javascript:history.go(-1)';}</script>")
   Response.End
  else
   usertype=cint(request("usertype"))
  end if
  
  sql="select * from JOB_C_cmembertype where type_id="&usertype
  set rs=server.CreateObject("adodb.recordset")
  rs.open sql,conn,1,1
  money=clng(rs("money"))
  moneyadd=clng(rs("moneyadd"))
  days=rs("days")
  if days&""="" Then
    days=0
  else
  	days=cint(days)
  end if
  rs.close 
  money=clng(money-moneyadd)
  
  sql="select * from JOB_C_cmember where cmember_login='"&session("user_name")&"'"
  rs.open sql,conn,1,3
  if clng(rs("cmember_consumenums"))-money<0 then
     rs.close
     set rs=nothing
     Response.Write ("<script language=JavaScript>{alert('账户余额不够。');javascript:history.go(-1);}</script>")
     Response.End
  end if
     lastconsumenums=rs("cmember_consumenums")-money
     rs("cmember_consumenums")=lastconsumenums
	 rs("cmember_type")=usertype
	 rs("cmember_startdate")=date()
	 rs("cmember_enddate")=cdate(date()+days)
     rs.update
	 rs.close
	 set rs=nothing 
    session("user_type")=usertype
	select case usertype
	case 1
	usertype="包月"
	case 2
	usertype="包季"
	case 3
	usertype="半年"
	case 4
	usertype="全年"
    end select
   Response.Write ("<script language=JavaScript>alert('您现在的会员类型:"&usertype&"VIP\n VIP帐户有效期是:"&cdate(date())&"--"&cdate(cdate(date())+cint(days))&"\n 会员升级成功,您的帐户还有"&lastconsumenums&"点');location.href='company_onlinepay.asp';</script>")
   Response.End
  
%>

