<!--#include file="User_Const.asp"-->
<%
Const MaxPerPage=20
dim Action
CurrentPage	= Cl.ChkClng(request("page"))
Action=Trim(request("Action"))
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
<link rel="stylesheet" type="text/css" href="../Skins/User_Style.Css">
<script language = "JavaScript" src="../Inc/Js/Admin.js"></script>
</head>
<body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0">
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" Class="border">  
	<tr class="title"><td height="22" align=center><b>充 值 卡 管 理 中 心</b></td></tr>
	<tr class="tdbg" onMouseOut="this.className='tdbg'" onMouseOver="this.className='tdbg2'">
	<td height="22" align=left>
		&nbsp;&nbsp;&nbsp;&nbsp;<a href="User_UserCz.Asp?Action=CzMain">充值卡充值</a>&nbsp;|&nbsp;<a href="User_UserCz.Asp">我的充值记录</a><%if SysTemVersion > 1 then%>&nbsp;|&nbsp;<a href="User_UserCz.Asp?Action=BuyCard">购买充值卡</a>&nbsp;|&nbsp;<a href="User_UserCz.Asp?Action=MyBuyLog">我的购买记录</a>&nbsp;|&nbsp;<a href="User_UserCz.Asp?Action=Transfer">对外转帐</a>&nbsp;|&nbsp;<a href="User_UserCz.Asp?Action=TransferLog">我的转帐记录</a><%end if%>
		</td>
	</tr>
</table>
<br>
<table border="0" align="center" cellpadding="0" cellspacing="1" class="border">
    <tr>
      <td align="center" colspan="4" class="title"><strong>我 的 账 户</strong></td>
    </tr>
    <tr class="tdbg" onMouseOut="this.className='tdbg'" onMouseOver="this.className='tdbg2'">
      <td width="120" align="right"><b>我的ＩＤ：</b></td>
      <td><font color="#FF0033"><b><%=Cl.User_Info(4)%></b></font></td>
      <td width="120" align="right"></td>
      <td></td>
    </tr>
    <tr class="tdbg" onMouseOut="this.className='tdbg'" onMouseOver="this.className='tdbg2'">
      <td width="120" align="right"><b>用 户 名：</b></td>
      <td><b><%=Cl.User_Info(5)%></b></td>
      <td width="120" align="right"><b>真实姓名：</b></td>
      <td><b><%=Cl.User_Info(7)%></b></td>
    </tr>
    <tr class="tdbg" onMouseOut="this.className='tdbg'" onMouseOver="this.className='tdbg2'">
      <td width="120" align="right"><b>剩余<%=Cl.Web_Setting(26)%>：</b></td>
      <td><font color="#FF0033"><b><%=Cl.User_Info(23)%></b></font>&nbsp<%=Cl.Web_Setting(27)%></td>
	  <%if Cint(CL.User_Info(24))=1 then%>
      <td width="120" align="right"><b>剩余<%=Cl.Web_Setting(28)%>：</b></td>
      <td><font color="#FF0033"><b><%=Cl.User_Info(22)%></b></font>&nbsp<%=Cl.Web_Setting(29)%></td>
	  <%else%>
      <td width="120" align="right"><b>剩余天数：</b></td>
      <td><font color="#FF0033"><b><%=Cl.User_Info(40)%></b></font>&nbsp天</td>
	  <%end if%>
    </tr>
   </table>
   <br>
<%

Select Case Action
Case "chkCzNum"
	call chkCzNum()
Case "CzMain"
	Call CzMain()
Case "BuyCard"
	call BuyCard()
Case "DoBuyCard"
	call DoBuyCard()
Case "MyBuyLog"
	Call MyBuyLog()
Case "Transfer"
	Call Transfer()
Case "DoTransfer"
	Call DoTransfer()
Case "TransferLog"
	Call TransferLog()
Case "CheckUser"
	Call CheckUser()
Case else
	call Listmain()
end Select

Footer

Sub ListMain()
%>
<table border="0" align="center" cellpadding="0" cellspacing="1" class="border">
    <tr class="title">
      <td align="center" Colspan=6><strong>我 的 充 值 记 录</strong></td>
    </tr>
    <tr class="tdbg" onMouseOut="this.className='tdbg'" onMouseOver="this.className='tdbg2'">
      <td align="center" width=40><strong>编号</strong></td>
      <td align="center"><strong>充值卡号码</strong></td>
      <td align="center" width=60><strong>充值<%=Cl.Web_Setting(28)%></strong></td>
      <td align="center" width=60><strong>充值天数</strong></td>
      <td align="center" width=100><strong>充值用户</strong></td>
      <td align="center" width=120><strong>充值时间</strong></td>
    </tr>

<%
Set Rs=Server.CreateObject("adodb.recordset")
SQL="Select ID,CzNum,Pass,Point,DayNum,IsUser,UserID,UserName,UserDate,CzUserName From Cl_UserCz Where IsUser=1 and UserID="&Cl.UserID&""
OpenConn : Rs.Open SQL,Conn,1,1
if Rs.Bof and Rs.Eof then
%>
    <tr>
      <td align="center" Colspan=6 class=tdbg>暂无任何充值记录！</td>
    </tr>
<%
	Rs.Close : Set Rs=Nothing
else
	TotalPut=rs.recordcount
	if (TotalPut mod MaxPerPage)=0 then
		TotalPages = TotalPut \ MaxPerPage
	else
		TotalPages = TotalPut \ MaxPerPage + 1
	end if
	if CurrentPage > TotalPages then CurrentPage=TotalPages
	if CurrentPage < 1 then CurrentPage=1
	rs.move (CurrentPage-1)*MaxPerPage
	SQL		= rs.GetRows(MaxPerPage)
	rs.close : set rs=Nothing
	For i=0 To Ubound(SQL,2)
%>
    <tr class="tdbg" onMouseOut="this.className='tdbg'" onMouseOver="this.className='tdbg2'">
      <td align="center" width=40><%=SQL(0,i)%></td>
      <td align="center"><%=SQL(1,i)%></td>
      <td align="center" width=60><font color=#0000ff><b><%=SQL(3,i)%></b></font></td>
      <td align="center" width=60><font color=#0000ff><b><%=SQL(4,i)%></b></font></td>
      <td align="center" width=100><%=SQL(9,i)%></td>
      <td align="center" width=120><%=SQL(8,i)%></td>
    </tr>
<%
	Next
	SQL=Empty
End if
%>
</table>
<%
Response.write Cl.ShowPage("?Action="&Action,TotalPut,MaxPerPage,"条","记录")
End Sub

Sub CzMain() %>
<script language=javascript>
function CheckForm1()
{
	if(document.myform.CzNum.value=="")
	{
		alert("请输入充值卡号码！");
		document.myform.CzNum.focus();
		return false;
	}
	if(document.myform.Pass.value=="")
	{
		alert("请输入充值卡密码！");
		document.myform.Pass.focus();
		return false;
	}
	if(document.myform.ChkPlusCz.value=="")
	{
		alert("请输入验证码！");
		document.myform.ChkPlusCz.focus();
		return false;
	}
}
</script>
<table border="0" align="center" cellpadding="0" cellspacing="1" class="border">
<form name="myform" action="User_UserCz.asp?Action=chkCzNum" method="post" onSubmit="return CheckForm1();">
    <tr>
      <td align="center" colspan="2" class="title"><strong>充 值 卡 充 值</strong></td>
    </tr>
    <tr class="tdbg" onMouseOut="this.className='tdbg'" onMouseOver="this.className='tdbg2'">
      <td width="200" align="right"><b>充值用户：</b></td>
      <td><input type="text" name="CzUser" size="20" value="<%=Cl.User_Info(5)%>" disabled>&nbsp<input type="checkbox" name="Self" value="yes" checked onclick="document.myform.CzUser.disabled=this.checked">自己&nbsp;<font color="#FF0033">*</font>&nbsp<font color="#888888">如果为他人充值，请去掉前面的钩，然后输入他人用户名</font></td>
    </tr>
    <tr class="tdbg" onMouseOut="this.className='tdbg'" onMouseOver="this.className='tdbg2'">
      <td width="200" align="right"><b>充值卡号：</b></td>
      <td><input type="text" name="CzNum" size="35">&nbsp<font color="#FF0033">*</font>&nbsp<font color="#888888">请输入充值卡号码，区分大小写</font></td>
    </tr>
    <tr class="tdbg" onMouseOut="this.className='tdbg'" onMouseOver="this.className='tdbg2'">
      <td width="200" align="right"><b>充值密码：</b></td>
      <td><input type="text" name="Pass" size="35">&nbsp<font color="#FF0033">*</font>&nbsp<font color="#888888">请输入充值卡密码，区分大小写</font></td>
    </tr>
    <tr class="tdbg" onMouseOut="this.className='tdbg'" onMouseOver="this.className='tdbg2'">
      <td width="200" align="right"><b>验 证 码：</b></td>
      <td><input name="ChkPlusCz" size="6" maxlength="4">&nbsp<%=Cl.GetCode("ChkPlusCz")%>&nbsp<font color="#FF0033">*</font>&nbsp<font color="#888888">请输入左边的验证码</font></td>
    </tr>
    <tr class="tdbg" onMouseOut="this.className='tdbg'" onMouseOver="this.className='tdbg2'">
      <td colspan=2 align="center">
         <input type="submit" name="Submit" value=" 充&nbsp;&nbsp;值 ">&nbsp;&nbsp&nbsp
         <input type=reset name="reset" value=" 重&nbsp;&nbsp;填 "></td>
    </tr>
	</form>
   </table>
<%
End Sub

Sub chkCzNum()
	Dim CzUser,Self,CzNum,Pass
	Dim sPoint,sPointAll,sDayNum,sDayNumAll
	Dim rsUser,ChargeType
	CzUser	= Trim(request("CzUser"))
	Self	= Trim(request("Self"))
	CzNum	= Trim(request("CzNum"))
	Pass	= Trim(request("Pass"))
	if CzNum="" or Pass="" then
		Call Cl.OutMsg("充值卡号或充值密码不能为空！","User_UserCz.asp")
	end if
	if Not Cl.CodeIsTrue(Trim(request("ChkPlusCz")),"ChkPlusCz") then
		Call Cl.OutMsg("验证码不正确","User_UserCz.asp")
	end if
	dim rsCz
	set rsCz=Server.CreateObject("Adodb.RecordSet")
	OpenConn : rsCz.open "Select * from Cl_UserCz where CzNum='"&CzNum&"' and Pass='"&Pass&"'",Conn,1,3
	if rsCz.bof and rsCz.eof then
		rsCz.close:set rsCz=Nothing
		Call Cl.OutMsg("不存在此充值卡或密码错误，请重新输入！","User_UserCz.asp")
	End if
	sPoint	=rsCz("Point")
	sDayNum	=rsCz("DayNum")
	if rsCz("IsUser")<>0 then
		rsCz.close:set rsCz=Nothing
		Call Cl.OutMsg("该充值卡已被使用！","User_UserCz.asp")
	end if
	if Lcase(Self)="yes" or CzUser="" then
		sql="select "&Db.UserID&","&Db.UserName&","&Db.ChargeType&","&Db.UserPoint&","&Db.ValidNum&" from "&Db.UserTable&" where "&Db.UserID&"="&Cl.UserID&""
		CzUser = Cl.User_Info(5)
	else
		sql="select "&Db.UserID&","&Db.UserName&","&Db.ChargeType&","&Db.UserPoint&","&Db.ValidNum&" from "&Db.UserTable&" where "&Db.UserName&"='"&CzUser&"'"
	end if
	set rsUser=server.createobject("adodb.recordset")
	OpenConn_U : rsUser.open sql,Conn_U,1,3
	if rsUser.bof and rsUser.eof then
		rsCz.close:set rsCz=Nothing
		rsUser.close:set rsUser=Nothing
		Call Cl.OutMsg("数据库中没有找到相对应该的用户数据！","User_UserCz.asp")
	else
		ChargeType=rsUser(Db.ChargeType)
		if ChargeType=1 then
			rsCz("DayNum")	= 0
			sPointAll=rsUser(Db.UserPoint)+sPoint
			rsUser(Db.UserPoint)=sPointAll
		else
			rsCz("Point")	= 0
			sDayNumAll=rsUser(Db.ValidNum)+sDayNum
			rsUser(Db.ValidNum)=sDayNumAll
		end if
		rsUser.update
		rsUser.close:set rsUser=Nothing
	end if
	rsCz("IsUser")	= 1
	rsCz("UserID")	= Cl.UserID
	rsCz("UserName")= Cl.User_Info(5)
	rsCz("UserDate")= Now()
	rsCz("CzUserName")= CzUser
	rsCz.update
	rsCz.close:set rsCz=Nothing
	if Lcase(Self)="yes" or CzUser="" then
		Cl.GetCacheUserInfo
		if ChargeType=1 then
		Call Cl.OutMsg("恭喜您，充值成功！您的账户上成功增加"&Cl.Web_Setting(28)&" "&sPoint&" "&Cl.Web_Setting(29)&",目前共有"&Cl.Web_Setting(28)&" "&sPointAll&" "&Cl.Web_Setting(28)&"！","User_UserCz.asp")
		else
		Call Cl.OutMsg("恭喜您，充值成功！您的账户成功延长 "&sDayNum&" 天！","User_UserCz.asp")
		end if
	else
		if CzUser = Cl.User_Info(5) then
			Cl.GetCacheUserInfo
		end if
		if ChargeType=1 then
		Call Cl.OutMsg("恭喜您，充值成功！用户 "&CzUser&" 的账户上成功增加"&Cl.Web_Setting(28)&" "&sPoint&" "&Cl.Web_Setting(29)&"！","User_UserCz.asp")
		else
		Call Cl.OutMsg("恭喜您，充值成功！用户 "&CzUser&" 的账户成功延长 "&sDayNum&" 天！","User_UserCz.asp")
		end if
	end if
end Sub

Function NewCzNum(sL)
	Dim Ran,i
	NewCzNum=""
	For i=1 To (sL-9)
		Randomize
		Ran = CInt(Rnd * 9)
		NewCzNum = NewCzNum & Ran
	Next
	Randomize
	Ran = Int(90000*rnd)+10000
	NewCzNum = Year(Now()) & NewCzNum & Ran
End Function
'===================================================
' CreateLive CMS Version 3.1
'							Powered by Aspoo.CoM
'===================================================
' Mail: aspoo@126.com, Info@aspoo.cn
' Q  Q: 3315263, 596197794
' Msn : aspoo@126.com, Clw866@hotmail.com
' Web : http://www.aspoo.com, http://www.aspoo.net
' Bbs : http://bbs.aspoo.com, http://bbs.aspoo.net
' Copyright (C) 2005 Aspoo.CoM All Rights Reserved.
'===================================================
%>