<!--#include file="Inc.asp"-->
<%
Dim Coin,Interest
If Not BBS94KK.Founduser Then BBS94KK.GoToErr(10)
Coin=BBS94KK.Fun.GetStr("Coin")
If Coin<>"" Then If Not BBS94KK.Fun.isInteger(Coin) then BBS94KK.Alert"请输入正确的金额！","?"
Select Case Request.querystring("Action")
Case "Save"
	Save
Case "Draw"
	Draw
Case "Virement"
	Virement
Case"Convert"
	Convert
Case Else
	Main
End Select
BBS94KK.Footer()
Set BBS94KK=Nothing

Sub GetInterest()
	Dim Rs,Temp
		Set Rs=BBS94KK.Execute("select Coin,BankSave,Banktime from [KK_user] where ID="&BBS94KK.MyID&"")
		If Rs.Eof Then
			BBS94KK.SetMemorEmpty()
			BBS94KK.GoToErr(4)
		End If
		Temp=ccur(ccur(rs(1))*ccur(Datediff("d",cdate(rs("banktime")),cdate(BBS94KK.NowBbsTime)))*BBS94KK.Info(119))
		Session(CacheName & "Bank")=Datediff("d",cdate(rs(2)),cdate(BBS94KK.NowBbsTime))&"|"&Temp
		BBS94KK.Execute("Update [KK_user] Set BankSave=BankSave+"&Temp&",BankTime='"&BBS94KK.NowBbsTime&"' where Name='"&BBS94KK.MyName&"' ")
		Session(CacheName & "MyInfo") = Empty
		'更新缓存
		BBS94KK.UserLoginTrue()
		Rs.Close
		Set Rs=Nothing
End Sub


Sub Main
	BBS94KK.Head"大埔银行"
	Dim Content
	If Session(CacheName & "Bank")="" Then GetInterest
	Interest=Split(Session(CacheName & "Bank"),"|")
	Content="<table border=0 cellpadding=4 cellspacing=0 style='border-collapse: collapse' width='100%'><tr><td width='46%' align='center'><img src=images/bank.gif width=249 height=107></td><td>"&_
	"<table align='center' width='97%' border='0' cellpadding='0' cellspacing='5' bgcolor='#FFFFFF' style='border-right: #BCBCBC 2px solid; border-bottom: #BCBCBC 2px solid;border-top: #e8e8e8 1px solid; border-left: #e8e8e8 1px solid;'>"&_
	"<tr><th height='25' bgcolor='#E8E8E8' colspan=2>财务状况&nbsp;[存款利率:<font color=red>"&BBS94KK.Info(119)*1000&"</font>‰]</th></tr>"&_
	"<tr><td width='15%'>&nbsp;银行户主：</td><td width='39%'><b>"&BBS94KK.MyName&"</b></td></tr>"&_
	"<tr><td>&nbsp;存款(含利息)：</td><td><b><font color='red'>"&SESSION(CacheName & "MyInfo")(26)&"</font></b> 元</td></tr>"&_
	"<tr><td>&nbsp;今日结算利息：</td><td><b><font color='red'>"&Interest(1)&"</font></b> 元("&Interest(0)&"天)</td></tr>"&_
	"<tr><td>&nbsp;持有现金：</td><td><b><font color='Red'>"&SESSION(CacheName & "MyInfo")(7)&"</font></b> 元</td></tr>"&_
	"<tr><td>&nbsp;个人资金总共：</td><td><b><font color='red'>"&Ccur(SESSION(CacheName & "MyInfo")(26))+Ccur(SESSION(CacheName & "MyInfo")(7))&"</font></b> 元</td></tr>"&_
	"</table></td></tr></table>"&_
	"<table width='100%' border='0' cellPadding='0' cellSpacing='0'><tr><td>"&_
	"<form action='?Action=Save' method='post'><table align='center' width='97%' border='0' cellpadding='0' cellspacing='5' bgcolor='#FFFFFF' style='border-right: #BCBCBC 2px solid; border-bottom: #BCBCBC 2px solid;border-top: #e8e8e8 1px solid; border-left: #e8e8e8 1px solid;'>"&_
	"<tr><th height='25' bgcolor='#E8E8E8'>存款柜台</th></tr>"&_
	"<tr><td>&nbsp;现金：<b><font color=red>"&SESSION(CacheName & "MyInfo")(7)&"</font></b> 元</td></tr>"&_
	"<tr><td align='center'>存储：<input size='10' value='1000' name='Coin'>元&nbsp;&nbsp;<input type='submit'  value=' 存钱 '></td></tr></table></form>"&_
	"</td><td>"&_
	"<form action='?Action=Draw' method='post'><table align='center' width='97%' border='0' cellpadding='0' cellspacing='5' bgcolor='#FFFFFF' style='border-right: #BCBCBC 2px solid; border-bottom: #BCBCBC 2px solid;border-top: #e8e8e8 1px solid; border-left: #e8e8e8 1px solid;'>"&_
	"<tr><th height='25' bgcolor='#E8E8E8'>支取柜台</th></tr>"&_
	"<tr><td>&nbsp;存款：<b><font color=Red>"&SESSION(CacheName & "MyInfo")(26)&"</font></b> 元</td></tr>"&_
	"<tr><td align='center'>支取 <input size='10' value='1000' name='Coin'> 元&nbsp;&nbsp;<input type='submit'  value=' 支取 '></td></tr></table></form>"&_
	"</td><td>"&_
	"<form action='?Action=Virement' method='post'><table align='center' width='97%' border='0' cellpadding='0' cellspacing='5' bgcolor='#FFFFFF' style='border-right: #BCBCBC 2px solid; border-bottom: #BCBCBC 2px solid;border-top: #e8e8e8 1px solid; border-left: #e8e8e8 1px solid;'>"&_
	"<tr><th height='25' bgcolor='#E8E8E8'>转帐柜台</th></tr>"&_
	"<tr><td>&nbsp;把存款转帐给好友</td></tr>"&_
	"<tr><td align='center'><input size='5' value='1000' name='Coin'>元&nbsp;给<input size='5' name='ToUserName'>&nbsp<input type='submit' value=' 转帐 '></td></tr></table></form>"&_
	"</td></tr></table>"
	Call BBS94KK.ShowTable("论坛银行",Content)
End Sub

Sub Save
	If Coin="" Then BBS94KK.Alert"失败！您还没有填写要存款的金额！","?"
	If Int(Coin) > Int(SESSION(CacheName & "MyInfo")(7)) Then BBS94KK.Alert "失败！拜托你先看看你口袋里有多少钱行不行？别老把一毛钱当一百！","?"
	BBS94KK.Execute("update [KK_user] Set BankSave=BankSave+"&Coin&",Coin=Coin-"&Coin&" where Name='"&BBS94KK.MyName&"'")
	Session(CacheName & "MyInfo") = Empty
	BBS94KK.Alert"恭喜！大埔银行存款成功","?"
End sub

Sub Draw
	If Coin="" Then Call Alert("失败！您还没有填写要取款的金额！")
	If int(Coin) > Int(SESSION(CacheName & "MyInfo")(26)) Then BBS94KK.Alert "耶！这位漂亮的先生或英俊的小姐，您真是英勇无比，请问银行很好抢吗？小心飞毛腿呀你！（请注意你的存款还有多少）","?"
	BBS94KK.Execute("update [KK_user] Set BankSave=BankSave-"&Coin&",Coin=Coin+"&Coin&" where Name='"&BBS94KK.MyName&"'")
	Session(CacheName & "MyInfo") = Empty
	BBS94KK.Alert"恭喜！大埔银行取款成功！","?"
End Sub

Sub Virement
	Dim ToUserName,Sms,TmpUbbString
	ToUserName=BBS94KK.Fun.GetStr("ToUserName")
	IF Not BBS94KK.Fun.CheckIn(ToUserName) Or ToUserName="" Then BBS94KK.Alert"失败！查无此人,如果您实在想送出钱来的话,送给站长就好了！","?"
	If Int(Coin) > Int(SESSION(CacheName& "MyInfo")(26)) then BBS94KK.Alert "失败！你是不是好心过头啦？还是人家催债催得太紧，让你自己还有多少钱都不知道？！","?"
	If LCase(ToUserName)=LCase(BBS94KK.MyName) Then BBS94KK.Alert "失败！给自己转帐很好玩吗？","?"
	IF BBS94KK.Execute("Select Name From[KK_user] where Name='"&ToUserName&"'").Eof Then
 	  BBS94KK.Alert"失败！查无此人,如果您实在想送出钱来的话,送给站长就好了！","?"
	End if
	BBS94KK.Execute("Update [KK_user] Set BankSave=BankSave-"&Coin&" where Name='"&BBS94KK.MyName&"'")
	Sms="天下掉下大馅饼啦,"&BBS94KK.MyName&"通过友情转帐赠送您"&Coin&"元现金！您可以到大埔银行柜台查收！"&vbcrlf&"<div align='right' style='color:#F00'>「社区银行」自动送信系统</div>"
	BBS94KK.Execute("Update [KK_user] Set BankSave=BankSave+"&Coin&",NewSmsNum=NewSmsNum+1,SmsSize=SmsSize+1 where Name='"&ToUserName&"'")
	BBS94KK.execute("insert Into [KK_Sms](Name,Content,MyName,MyFlag)VALUES('自动送信系统','"&Replace(Sms,"'","''")&"','"&ToUserName&"',1)")
	BBS94KK.UpdageOnline ToUserName,1
	Session(CacheName & "MyInfo") = Empty
	BBS94KK.Alert"恭喜！转帐成功,系统已自动发信通知了您的朋友！","?"
End sub

%>