<!--#include file=conn.asp-->
<!-- #include file="inc/const.asp" -->
<!--#include file=bank_data.asp-->
<!-- #include file="bank/bank_const.asp" -->
<%
'=========================================================
' file: bank_ebank.asp
' Forum_Version:2.1 for Dvbbs7.0
' date: 2004-1-7
' script modified by winriver from yaoyue Version
'=========================================================
' copyright (c) 2004 黄河论坛 all rights reserved.
' web: http://www.paperbridge.net http://www.winriver.org
' email: huanghetv@163.com winriver2002@yahoo.com
'=========================================================
Dvbbs.LoadTemplates("")
If Not IsObject(Conn) Then ConnectionDatabase
dim sql,rs,founderr,i,errmsg
founderr=false

if not Dvbbs.FoundUser then
    founderr=true
    errmsg=errmsg+errmsg6+"您还没有登录或注册，请先<a href=login.asp>登录</a>或<a href=reg.asp>注册</a>。"
    Dvbbs.Stats="钱庄错误信息"
    call Dvbbs.Nav()
	call new_head()
    Response.redirect "showerr.asp?ErrCodes="&errmsg&"&action=OtherErr"
	call Dvbbs.ActiveOnline()
	call Dvbbs.Footer()
	response.end
end if
if Dvbbs.ChkPost=false then
    founderr=true
    errmsg=errmsg+errmsg6+"呵呵，亲爱的<font color=#ff0000><b>"&bankname&"</b></font>顾客您好，本行是网上服务且已自制好互交页，您不必这么辛苦自己再做提交页面。"
    Dvbbs.Stats="钱庄错误信息"
    call Dvbbs.Nav()
	call new_head()
    Response.redirect "showerr.asp?ErrCodes="&errmsg&"&action=OtherErr"
end if
if request("action")<>"open" and not foundbankuserid then
    founderr=true
    errmsg=errmsg+errmsg6+"您还没有在钱庄开户。"
    Dvbbs.Stats="钱庄错误信息"
    call Dvbbs.Nav()
	call new_head()
    Response.redirect "showerr.asp?ErrCodes="&errmsg&"&action=OtherErr"
end if
if userfreeze then
    founderr=true
    errmsg=errmsg+errmsg6+"您的账号已经被冻结，请联系该钱庄掌柜。"
    Dvbbs.Stats="钱庄错误信息"
    call Dvbbs.Nav()
	call new_head()
    Response.redirect "showerr.asp?ErrCodes="&errmsg&"&action=OtherErr"
end if
if not foundbankid and request("action")<>"open" then
    founderr=true
    errmsg=errmsg+errmsg6+"没有找到该钱庄。或者该钱庄还没有开放。"
    Dvbbs.Stats="钱庄错误信息"
    call Dvbbs.Nav()
	call new_head()
    Response.redirect "showerr.asp?ErrCodes="&errmsg&"&action=OtherErr"
end if
if request("action")="" then
    founderr=true
    errmsg=errmsg+errmsg6+"非法操作。"
    Dvbbs.Stats="钱庄错误信息"
    call Dvbbs.Nav()
	call new_head()
    Response.redirect "showerr.asp?ErrCodes="&errmsg&"&action=OtherErr"
end if

Dvbbs.Stats="钱庄信息"
call Dvbbs.Nav()
	call new_head()
select case request("action")
    case "open"
      call bankreg()
    case "off"
      call off()
    case "c_d_1"
      call c_d_1()
    case "c_d_2"
      call c_d_2()
    case "t_d_1"
      call t_d_1()
    case "t_d_2"
      call t_d_2()
    case "b_loveliness"
      call b_loveliness()
    case "p_loveliness"
      call p_loveliness()
    case "p_f_1"
      call p_f_1()
    case "p_f_2"
      call p_f_2()
    case "vir"
      call vir()
    case "r_e_m"
      call r_e_m()
    case else
      founderr=true
      errmsg=errmsg+errmsg6+"非法操作。"
	Response.redirect "showerr.asp?ErrCodes="&errmsg&"&action=OtherErr"
end select
call Dvbbs.ActiveOnline()

if founderr then
Dvbbs.Stats="钱庄错误信息"
Response.redirect "showerr.asp?ErrCodes="&errmsg&"&action=OtherErr"
end if

call Dvbbs.Footer()



'开户
sub bankreg()
  if foundbankuserid then
      founderr=true
      errmsg=errmsg+errmsg6+"你已经在该钱庄注册过了。"
      exit sub
  end if
  if U_ep < integral then
      founderr=true
      errmsg=errmsg+errmsg6+"你的积分不足以在该钱庄开户。"
      exit sub
  end if
  if U_wealth < l_trade then
      founderr=true
      errmsg=errmsg+errmsg6+"你的现金不够开户。"
      exit sub
  end if
  if not founderr then
      csql="insert into bankuser(bankid,name,currdeposit,events) values ("&cint(request("bankid"))&",'"&Dvbbs.MemberName&"',"&l_trade&",'"&l_trade&"|钱庄开户|"&now()&"')"
      cjconn.execute (csql)
      cjconn.execute ("update bank set alldeposit=alldeposit+"&l_trade&",stockpile=stockpile+"&l_trade&",clientcount=clientcount+1 where bankid="&bankid)
      if openeventslog=-1 then
          cjconn.execute ("insert into bankevent (bankid,name1,name2,events,trade) values ("&cint(request("bankid"))&",'"&Dvbbs.MemberName&"','','开户',"&l_trade&")")
      end if
      conn.execute ("update [dv_user] set userwealth=userwealth-"&l_trade&" where username='"&Dvbbs.MemberName&"'")
      '那一刀加
      call  HyhSaveCookie(-l_trade,0,0,0,0,0)
      call yaoyue_banksuc()
  end if
end sub
'销户
sub off()
  if not foundbankuserid then
      founderr=true
      errmsg=errmsg+errmsg6+"您还没有在该钱庄开户。"
      exit sub
  end if
  if timedeposit>0 then
      founderr=true
      errmsg=errmsg+errmsg6+"你还有定期存耶……不想要了？如果想要就等它到期再来咯。"
      exit sub
  end if
  if paymentforgoods>0 then
      founderr=true
      errmsg=errmsg+errmsg6+"你想的倒是很美哦，你还欠钱庄的钱耶，就想逃？"
      exit sub
  end if
  if isbankmaster then
      founderr=true
      errmsg=errmsg+errmsg6+"有没有搞错啊，你是本钱庄的掌柜耶！"
      exit sub
  end if
  if stockpile < currdeposit + c_accrual then
      founderr=true
      errmsg=errmsg+errmsg6+"销户吗？可怜的你，该钱庄已经人财两空，还不起你所存的款项与应得的利息了。给您一个良好的提示，如果想扁人出气的话，找掌柜吧，所有人都跑得了，就掌柜不行。"
      exit sub
  end if
  if not founderr then
      cjconn.execute ("delete from bankuser where bankuserid="&bankuserid)
      cjconn.execute ("update bank set alldeposit=alldeposit-"&(currdeposit+c_accrual)&",stockpile=stockpile+"&log_on&"-"&(currdeposit+c_accrual)&",clientcount=clientcount-1 where bankid="&bankid)
      if openeventslog then
          cjconn.execute ("insert into bankevent (bankid,name1,name2,events,trade) values ("&bankid&",'"&Dvbbs.MemberName&"','','销户',"&log_on&")")
      end if
      conn.execute ("update [dv_user] set userwealth=userwealth-"&log_on&"+"&(currdeposit+c_accrual)&" where username='"&Dvbbs.MemberName&"'")
      '那一刀加
      call  HyhSaveCookie(-log_on+(currdeposit+c_accrual),0,0,0,0,0)
      call yaoyue_banksuc()
  end if
end sub

'活期存款
sub c_d_1()
  dim c_d_1_1
  if not isnumeric(request.form("c_d_1_1")) or isnumeric(request.form("c_d_1_1"))="" then
      founderr=true
      errmsg=errmsg+errmsg6+"请输入数字"
      exit sub
  else
      c_d_1_1=int(abs(request.form("c_d_1_1")))
      if c_d_1_1<l_trade and c_d_1_1<>0 then
          founderr=true
          errmsg=errmsg+errmsg6+"就那么点钱，您还是存在钱包里吧。（最低单笔交易为 <font color=red><b>"&l_trade&curr&"</b></font> 以上）"
	      exit sub
      end if
      if c_d_1_1 > U_wealth then
          founderr=true
          errmsg=errmsg+errmsg6+"拜托你先看看你口袋里有多少钱行不行？别老把一毛钱当一百！"
	      exit sub
      end if
      if c_d_1_1 > h_trade then
          founderr = true
          errmsg=errmsg+errmsg6+"哇噻，你的钱真多，不过每次最多只能存<b>"&h_trade&curr&"</b>咯。"
	      exit sub
      end if
  end if
  if not founderr then
      cjconn.execute ("update bankuser set currdeposit=currdeposit+"&(c_d_1_1+c_accrual)&",c_accrual=0,events='"&c_d_1_1&"|活期存款|"&now()&"',dateandtime='"&now()&"' where bankuserid="&bankuserid)
      cjconn.execute ("update bank set alldeposit=alldeposit+"&(c_d_1_1-c_accrual)&",stockpile=stockpile+"&(c_d_1_1-c_accrual)&" where bankid="&bankid)
      if openeventslog then
          cjconn.execute ("insert into bankevent (bankid,name1,name2,events,trade) values ("&bankid&",'"&Dvbbs.MemberName&"','','活期存款',"&c_d_1_1&")")
      end if
      conn.execute ("update [dv_user] set userwealth=userwealth-"&c_d_1_1&" where username='"&Dvbbs.MemberName&"'")
      '后句那一刀加
      call HyhSaveCookie(-c_d_1_1,0,0,0,0,0)
      call yaoyue_banksuc()
  end if
end sub

'活存取款
sub c_d_2()
  dim c_d_2_1,stockpilelack,acc,acc1
  stockpilelack=false
  if not isnumeric(request.form("c_d_2_1")) then
      founderr=true
      errmsg=errmsg+errmsg6+"请输入数字"
      Response.redirect "showerr.asp?ErrCodes="&errmsg&"&action=OtherErr"
  else
      c_d_2_1=int(abs(request.form("c_d_2_1")))
      acc = - c_d_2_1
      acc1 = c_d_2_1 + c_accrual
      if c_d_2_1 < l_trade and c_d_2_1 <> 0 then
          founderr=true
          errmsg=errmsg+errmsg6+"只见出纳小姐娇声娇气地说，别那么小气嘛，就取那么点钱，最低单笔交易得 <font color=red><b>"&l_trade&curr&" </b></font>以上呢！"
	      exit sub
      end if
      if c_d_2_1 > currdeposit then
          founderr=true
          errmsg=errmsg+errmsg6+"耶！这位帅哥／美女，您真是英勇无比，请问钱庄很好抢吗？小心飞毛腿呀你！（请注意您存了多少钱？）"
	      exit sub
      end if
      if c_d_2_1 > h_trade then
          founderr = true
          errmsg=errmsg+errmsg6+"一下子提那么多钱不怕被抢？不过就算你不怕也没用，每次最多只能提 <font color=red><b>"&h_trade&curr&"</b></font> 咯。"
	      exit sub
      end if
      if stockpile=0 then
          founderr = true
          errmsg=errmsg+errmsg6+"该钱庄的库存为0，你说还有人在那里等你扁人出气吗？"
	      exit sub
      end if
      if not founderr and stockpile < c_d_2_1 + c_accrual then
          founderr=true
          stockpilelack=true
          acc = c_accrual - stockpile
          acc1 = stockpile
          errmsg=errmsg+errmsg6+"由于该钱庄库存不足，出纳小姐只好尴尬的说：“对不起，本钱庄这时的库存只有<font color=red><b>"&stockpile&"</b></font>"&curr&"了。”（注意：你只取到<font color=red><b>"&stockpile&"</b></font>"&curr&"，不足的请联系该钱庄掌柜。）"
	      exit sub
      end if
  end if
  if not founderr or stockpilelack then
      cjconn.execute ("update bankuser set currdeposit=currdeposit+"&acc&",c_accrual=0,events='"&acc1&"|取款（活）|"&now()&"',dateandtime='"&now()&"' where bankuserid="&bankuserid)
      cjconn.execute ("update bank set alldeposit=alldeposit+"&acc&",stockpile=stockpile-"&acc1&" where bankid="&bankid)
      if openeventslog then
          cjconn.execute ("insert into bankevent (bankid,name1,name2,events,trade) values ("&bankid&",'"&Dvbbs.MemberName&"','','活存取款',"&acc1&")")
      end if
      conn.execute ("update [dv_user] set userwealth=userwealth+"&acc1&" where username='"&Dvbbs.MemberName&"'")
      '后句那一刀加
      call HyhSaveCookie(acc1,0,0,0,0,0)
      if not stockpilelack then
          call yaoyue_banksuc()
      end if
  end if
end sub

'定期存款
sub t_d_1()
  dim t_d_1_1,timelong
  if not isnumeric(request.form("t_d_1_1")) then
      founderr=true
      errmsg=errmsg+errmsg6+"请输入数字"
      exit sub
  else
      t_d_1_1 = int(abs(request.form("t_d_1_1")))
      timelong = cint(request.form("timelong"))
      if t_d_1_1 > U_wealth then
          founderr=true
          errmsg=errmsg+errmsg6+"啊！啊！这位帅哥／美女，不知您戴几度的眼镜？如果还看得清楚的话请返回上一页，稍微往左看看你的<b>现金总数</b>还有多少。"
	      exit sub
      end if
      if t_d_1_1 < l_timedeposit then
          founderr=true
          errmsg=errmsg+errmsg6+"哇哦！！！只见钱庄的出纳ｍｍ拿了大把大把的钞镖数了大半天差点气喘发作，却非常迷惘：怎么超过"&l_timedeposit&"张的纸钞会少于"&l_timedeposit&"元？只好无奈的对您说，对不起，本行的定期存款最少为<font color=#ff0000><b>"&l_timedeposit&"</b></font>"&curr&"。"
	      exit sub
      end if
      if t_d_1_1 > h_timedeposit then
          founderr=true
          errmsg=errmsg+errmsg6+"啊！！！出纳ｍｍ看到那么一大把的镖镖，顿时眼泛桃花，连存款人是男是女都还没看清楚，就急着说：“钱哥，今晚约我吗？”但她还是很无奈的请你分期存你的巨款，因为钱庄定期存款一次最多只能存<font color=#ff0000><b>"&h_timedeposit&"</b></font>"&curr&"。"
	      exit sub
      end if
  end if
  if not founderr then
      cjconn.execute ("insert into timedeposit (bankid,bankuserid,timedeposit,t_accrual,datecount) values ("&bankid&","&bankuserid&","&t_d_1_1&","&int(t_dateprofit/100*timelong*t_d_1_1)&","&timelong&")")
      cjconn.execute ("update bankuser set timedeposit=timedeposit+"&t_d_1_1&",t_accrual=t_accrual+"&int(t_dateprofit/100*timelong*t_d_1_1)&",events='"&t_d_1_1&"|定期存款|"&now()&"' where bankuserid="&bankuserid)
      cjconn.execute ("update bank set alldeposit=alldeposit+"&t_d_1_1&",stockpile=stockpile+"&t_d_1_1&" where bankid="&bankid)
      if openeventslog then
          cjconn.execute ("insert into bankevent (bankid,name1,name2,events,trade) values ("&bankid&",'"&Dvbbs.MemberName&"','','定期存款',"&t_d_1_1&")")
      end if
      conn.execute ("update [dv_user] set userwealth=userwealth-"&t_d_1_1&" where username='"&Dvbbs.MemberName&"'")
      '后句那一刀加
      call HyhSaveCookie(-t_d_1_1,0,0,0,0,0)
      call yaoyue_banksuc()
  end if
end sub

'定存取款及其相关操作
sub t_d_2()
  dim tid,t_d_2_1,t_d_2_2,t_ac,oldtimelong,newtimelong,t_datetime,selects,stockpilelack,acc,acc1
  if not isnumeric(request.form("t_d_2_1")) then
      founderr=true
      errmsg=errmsg+errmsg6+"请输入数字"
      exit sub
  else
      stockpilelack=false
      tid=cint(request.form("tid"))
      t_d_2_1=int(abs(request.form("t_d_2_1")))
      oldtimelong=cint(request.form("timelong"))
      selects=trim(request.form("selects"))
      csql="select timedeposit,t_accrual,datecount,dateandtime from timedeposit where tid="&tid
      set crs=cjconn.execute (csql)
      if crs.bof and crs.eof then
          errmsg=errmsg+errmsg6+"有吗？有吗？糟了，我怎么也找不到你这个存款号耶！嗯！！哇！救命啊，原来是抢钱庄的！"
	      Response.redirect "showerr.asp?ErrCodes="&errmsg&"&action=OtherErr"
          exit sub
      else
          t_d_2_2=crs(0)
          t_ac=crs(1)
          newtimelong=crs(2)
          t_datetime=crs(3)
      end if
      set crs=nothing
      if datediff("d",datediff("d",t_datetime,now()),newtimelong)>0 then
          founderr=true
          errmsg=errmsg+errmsg6+"你刷，我给你刷，我刷爆你的头，再刷你的钱就有危险了！"
	      exit sub
      end if
      select case selects
          case 1
            acc=0
            acc1=t_d_2_2 + t_ac
            if t_d_2_1 <> t_d_2_2 then
                founderr=true
                errmsg=errmsg+errmsg6+"您存了多少就必须取出多少，不能多也不能少。"
	      exit sub
            end if
            if stockpile=0 then
                founderr = true
                errmsg=errmsg+errmsg6+"该钱庄的库存为0，你说还有人在那里等你扁人出气吗？"
	      exit sub
            end if
            if not founderr and stockpile < t_d_2_2 + t_ac then
                founderr=true
                stockpilelack=true
                acc = t_d_2_2 + t_ac - stockpile
                acc1 = stockpile
                errmsg=errmsg+errmsg6+"由于该钱庄库存不足，出纳小姐只好尴尬的说：“对不起，本钱庄这时的库存只有<font color=#ff0000><b>"&stockpile&"</b></font>"&curr&"了。”（注意：你只取到<font color=#ff0000><b>"&stockpile&"</b></font>"&curr&"，不足的已转为活期存款，有问题请找该钱庄掌柜。）"
	      exit sub
            end if
            if not founderr or stockpilelack then
                cjconn.execute ("delete from timedeposit where tid="&tid)
                cjconn.execute ("update bankuser set currdeposit=currdeposit+"&acc&",timedeposit=timedeposit-"&t_d_2_2&",t_accrual=t_accrual-"&t_ac&",events='"&t_d_2_2&"|取款（定）|"&now()&"' where bankuserid="&bankuserid)
                cjconn.execute ("update bank set alldeposit=alldeposit+"&acc&"-"&t_d_2_2&",stockpile=stockpile-"&acc1&" where bankid="&bankid)
                if openeventslog then
                    cjconn.execute ("insert into bankevent (bankid,name1,name2,events,trade) values ("&bankid&",'"&Dvbbs.MemberName&"','','取款（定）',"&t_d_2_2&")")
                end if
                conn.execute ("update [dv_user] set userwealth=userwealth+"&acc1&" where username='"&Dvbbs.MemberName&"'")
                '后句那一刀加
                call HyhSaveCookie(acc1,0,0,0,0,0)
                if not stockpilelack then
                    call yaoyue_banksuc()
                end if
            end if
          case 2
            if t_d_2_1 < t_d_2_2 then
                founderr = true
                errmsg=errmsg+errmsg6+"转为活存，只能不要修改或填比原款项更大的数据，超出的部分会自动从你现金中扣除。"
	      exit sub
            end if
            if t_d_2_1 - t_d_2_2 > U_wealth then
                fuunderr=true
                errmsg=errmsg+errmsg6+"根据本钱庄第698574587条规定的第78546247点，增出的部分超过你现在的现金数，本行可以无偿的扣去你身上的所有现金。"
	      exit sub
            end if
            if t_d_2_1 + t_ac > h_timedeposit then
                founderr=true
                errmsg=errmsg+errmsg6+"啊！！！出纳ｍｍ看到那么一大把的镖镖，顿时眼泛桃花，连存款人是男是女都还没看清楚，就急着说：“钱哥，今晚约我吗？”但她还是得无奈的请你分期存你的巨款，钱庄定期存款一次最多只能存<font color=#ff0000><b>"&h_timedeposit&"</b></font>"&curr&"。"
	      exit sub
            end if
            cjconn.execute ("delete from timedeposit where tid="&tid)
            cjconn.execute ("update bankuser set currdeposit=currdeposit+"&t_d_2_1+t_ac&",timedeposit=timedeposit-"&t_d_2_2&",t_accrual=t_accrual-"&t_ac&",events='"&t_d_2_1+t_ac&"|活期存款|"&now()&"' where bankuserid="&bankuserid)
            cjconn.execute ("update bank set alldeposit=alldeposit+"&t_ac + t_d_2_1 - t_d_2_2&",stockpile=stockpile+"&t_d_2_1 - t_d_2_2&" where bankid="&bankid)
            if openeventslog then
                cjconn.execute ("insert into bankevent (bankid,name1,name2,events,trade) values ("&bankid&",'"&Dvbbs.MemberName&"','','活期存款',"&t_d_2_1 + t_ac&")")
            end if
            conn.execute ("update [dv_user] set userwealth=userwealth-"&(t_d_2_1 - t_d_2_2)&" where username='"&Dvbbs.MemberName&"'")
            '后句那一刀加
            call HyhSaveCookie(-(t_d_2_1 - t_d_2_2),0,0,0,0,0)
            call yaoyue_banksuc()
          case 3
            acc=0
            acc1=t_ac
            if t_d_2_1 - t_d_2_2 > U_wealth then
                founderr=true
                errmsg=errmsg+errmsg6+"喂，你想混水摸鱼啊？先查查自己的现金吧。"
	      exit sub
            end if
            if t_d_2_1 < l_timedeposit then
                founderr=true
                errmsg=errmsg+errmsg6+"最少也得"&l_timedeposit&curr&"吧，不然怎么延期啊？"
	      exit sub
            end if
            if t_d_2_1 > h_timedeposit then
                founderr=true
                errmsg=errmsg+errmsg6+"啊！！！出纳ｍｍ看到那么一大把的镖镖，顿时眼泛桃花，连存款人是男是女都还没看清楚，就急着说：“钱哥，今晚约我吗？”但她还是得无奈的请你分期存你的巨款，钱庄定期存款一次最多只能存<font color=#ff0000><b>"&h_timedeposit&"</b></font>"&curr&"。"
	      exit sub
            end if
            if stockpile=0 then
                founderr = true
                errmsg=errmsg+errmsg6+"该钱庄的库存为0，你说还有人在那里等你扁人出气吗？"
	      exit sub
            end if
            if not founderr and stockpile < t_ac then
                founderr = true
                stockpilelack = true
                acc = t_ac - stockpile
                acc1 = stockpile
                errmsg=errmsg+errmsg6+"由于该钱庄库存不足，出纳小姐只好尴尬的说：“对不起，本钱庄这时的库存只有<font color=#ff0000><b>"&stockpile&"</b></font>"&curr&"了。”（注意：你的利息只取到<font color=#ff0000><b>"&stockpile&"</b></font>"&curr&"，不足的已转为活期存款，存期照你输入的数字延长，如果正在因为没看清该钱庄的库存还有多少而气得跳脚，那我只有说你活该了。有问题请找该钱庄掌柜。）"
	      exit sub
            end if
            if not founderr or stockpilelack then
                cjconn.execute ("update timedeposit set timedeposit="&t_d_2_1&",t_accrual="&int(t_dateprofit/100*oldtimelong*t_d_2_1)&",datecount="&oldtimelong&",dateandtime='"&now()&"' where tid="&tid)
                cjconn.execute ("update bankuser set currdeposit=currdeposit+"&acc&",events='"&t_d_2_1&"|定存延期|"&now()&"' where bankuserid="&bankuserid)
                cjconn.execute ("update bank set alldeposit=alldeposit+"&acc&"+"&(t_d_2_1 - t_d_2_2)&",stockpile=stockpile-"&acc1&" where bankid="&bankid)
                if openeventslog then
                    cjconn.execute ("insert into bankevent (bankid,name1,name2,events,trade) values ("&bankid&",'"&Dvbbs.MemberName&"','','定存延期',"&t_d_2_1&")")
                end if
                conn.execute ("update [dv_user] set userwealth=userwealth+"&acc1&" where username='"&Dvbbs.MemberName&"'")
                '后句那一刀加
                call HyhSaveCookie(acc1,0,0,0,0,0)
                call yaoyue_banksuc()
            end if
      end select
  end if
end sub

'买魅力
sub b_loveliness()
  dim b_ls
  if not isnumeric(request.form("b_ls")) then
      founderr=true
      errmsg=errmsg+errmsg6+"请输入数字"
      exit sub
  else
      b_ls=int(abs(request.form("b_ls")))
      if b_ls > loveliness then
          founderr=true
          errmsg=errmsg+errmsg6+"呃，本钱庄魅力存货没这么多，如果需要请您下次早点来！"
	      exit sub
      end if
      if b_ls*zhml*4 < l_trade then
          founderr=true
          errmsg=errmsg+errmsg6+"买那么少有什么用啊，最少也得买"&l_trade\(zhml*4)&"点吧？"
	      exit sub
      end if
      if b_ls*zhml*4 > U_wealth then
          founderr=true
          errmsg=errmsg+errmsg6+"钱呢钱呢？你有那么多钱吗？有吗？有吗？（注意：你的现金不足"&b_ls*zhml*4&curr&"）"
	      exit sub
      end if
      if b_ls*zhml*4 > h_trade then
          founderr=true
          errmsg=errmsg+errmsg6+"阁下硬是要得，钱多得让人发疯！但交易额超过了"&h_trade&curr&"，只好请你分批买了咯！"
	      exit sub
      end if
  end if
  if not founderr then
      cjconn.execute ("update bankuser set events='"&b_ls*zhml*4&"|买魅力值|"&now()&"' where bankuserid="&bankuserid)
      cjconn.execute ("update bank set loveliness=loveliness-"&b_ls&",stockpile=stockpile+"&b_ls*zhml*4&" where bankid="&bankid)
      if openeventslog then
          cjconn.execute ("insert into bankevent (bankid,name1,name2,events,trade) values ("&bankid&",'"&Dvbbs.MemberName&"','','买魅力值',"&b_ls*zhml*4&")")
      end if
      conn.execute ("update [dv_user] set userwealth=userwealth-"&b_ls*zhml*4&",usercp=usercp+"&b_ls&" where username='"&Dvbbs.MemberName&"'")
      '后句那一刀加
      call HyhSaveCookie(-b_ls*zhml*4,b_ls,0,0,0,0)
      call yaoyue_banksuc()
  end if
end sub
'卖魅力
sub p_loveliness()
  dim p_ls
  if not isnumeric(request.form("p_ls")) then
      founderr=true
      errmsg=errmsg+errmsg6+"请输入数字"
      exit sub
  else
      p_ls=int(abs(request.form("p_ls")))
      if p_ls > U_cp then
          founderr=true
          errmsg=errmsg+errmsg6+"看到你开出的这个数字，柜台小姐不得不对你仔细的研究了一下，然后无奈的说：“你以为你是万人迷啊？有那么大的魅力！”"
	      exit sub
      end if
      if p_ls*zhml*2 < l_trade then
          founderr=true
          errmsg=errmsg+errmsg6+"卖血也不能那么少吧？总共"&l_trade&curr&"都不到，不收。"
	      exit sub
      end if
      if p_ls*zhml*2 > stockpile - 10000 then
          founderr=true
          errmsg=errmsg+errmsg6+"阁下硬是要得，魅力高得让ｍｍ们为之发疯！但也别卖得太猛，本钱庄还得留点老本啊！"
      end if
      if p_ls*zhml*2 > h_trade then
          founderr=true
          errmsg=errmsg+errmsg6+"阁下硬是要得，魅力高得让ｍｍ们为之发疯！但交易额超过了"&h_trade&curr&"，只好请你分批卖了咯！"
	      exit sub
      end if
  end if
  if not founderr then
      cjconn.execute ("update bankuser set events='"&p_ls*zhml*2&"|卖魅力值|"&now()&"' where bankuserid="&bankuserid)
      cjconn.execute ("update bank set loveliness=loveliness+"&p_ls&",stockpile=stockpile-"&p_ls*zhml*2&" where bankid="&bankid)
      if openeventslog then
          cjconn.execute ("insert into bankevent (bankid,name1,name2,events,trade) values ("&bankid&",'"&Dvbbs.MemberName&"','','卖魅力值',"&p_ls*zhml*2&")")
      end if
      conn.execute ("update [dv_user] set userwealth=userwealth+"&p_ls*zhml*2&",usercp=usercp-"&p_ls&" where username='"&Dvbbs.MemberName&"'")
      '后句那一刀加
      call HyhSaveCookie(p_ls*zhml*2,-p_ls,0,0,0,0)
      call yaoyue_banksuc()
  end if
end sub

'贷款
sub p_f_1()
  dim pfg
  if not isnumeric(request.form("pfg")) then
      founderr=true
      errmsg=errmsg+errmsg6+"请输入数字"
      exit sub
  else
      pfg=int(abs(request.form("pfg")))
      csql="select count(bankuserid) from paymentforgoods where bankuserid="&bankuserid
      set crs=cjconn.execute (csql)
      ii=crs(0)
      set crs=nothing
      if pfg > U_cp then
          founderr=true
          errmsg=errmsg+errmsg6+"喂，你没有搞错啊，你还真以为你是万人迷，有那么大魅力啊？"
	      exit sub
      end if
      if ii >= pfgtimes then
          founderr=true
          errmsg=errmsg+errmsg6+"唉，就算你的魅力再大，但……你已经贷了"&ii&"次款了，你只有还一次款后才能再贷了。"
	      exit sub
      end if
      if pfg*zhml < l_trade then
          founderr=true
          errmsg=errmsg+errmsg6+"你这叫贷款？就贷那么点我还不如不要。"
	      exit sub
      end if
      if pfg*zhml > stockpile - 10000 then
          founderr=true
          errmsg=errmsg+errmsg6+"唉，虽然很想贷给你，但钱庄还得留点底，不然到时要给人拆了。（注意：每次贷款，不能使钱庄的库金少于一万，你可以偿试贷少一点）"
	      exit sub
      end if
      if pfg*zhml > h_trade then
          founderr=true
          errmsg=errmsg+errmsg6+"哇！！您真是超级万人迷，但请不要那么猛啊！（注意：你要贷的款项超过"&h_trade&curr&"，钱庄的最大单笔交易为"&h_trade&curr&"。"
	      exit sub
      end if
  end if
  if not founderr then
      cjconn.execute ("insert into paymentforgoods (bankid,bankuserid,paymentforgoods,p_accrual,bydetaincp,lasttime) values ("&bankid&","&bankuserid&","&pfg*zhml&","&int(p_dateprofit/100*pfg*zhml*p_datecount)&","&pfg&",'"&dateadd("d",p_datecount,now())&"')")
      cjconn.execute ("update bankuser set paymentforgoods=paymentforgoods+"&pfg*zhml&",p_accrual=p_accrual+"&int(p_dateprofit/100*pfg*zhml*p_datecount)&",bydetaincp=bydetaincp+"&pfg&",events='"&pfg*zhml&"|贷款|"&now()&"' where bankuserid="&bankuserid)
      cjconn.execute ("update bank set stockpile=stockpile-"&pfg*zhml&",paymentforgoods=paymentforgoods+"&pfg*zhml&" where bankid="&bankid)
      if openeventslog then
          cjconn.execute ("insert into bankevent (bankid,name1,name2,events,trade) values ("&bankid&",'"&Dvbbs.MemberName&"','','贷款',"&pfg*zhml&")")
      end if
      conn.execute ("update [dv_user] set userwealth=userwealth+"&pfg*zhml&",usercp=usercp-"&pfg&" where username='"&Dvbbs.MemberName&"'")
      '后句那一刀加
      call HyhSaveCookie(pfg*zhml,-pfg,0,0,0,0)
      call yaoyue_banksuc()
  end if
end sub

'还款
sub p_f_2()
  dim pid,pf2_1,pf2_2,p_ac,p_cp,centtb
  if not isnumeric(request.form("pf2")) then
      founderr=true
      errmsg=errmsg+errmsg6+"请输入数字"
      exit sub
  else
      pid=cint(request.form("pid"))
      pf2_1=int(abs(request.form("pf2")))
      centtb=false
      csql="select paymentforgoods,p_accrual,bydetaincp from paymentforgoods where pid="&pid
      set crs=cjconn.execute (csql)
      if crs.bof and crs.eof then
          errmsg=errmsg+errmsg6+"你有毛病还是发财了嫌钱多，这也刷？"
          founderr=true
          exit sub
      else
          pf2_2=crs(0)
          p_ac=crs(1)
          p_cp=crs(2)
      end if
      set crs=nothing
      if pf2_1 > pf2_2 then
          founderr=true
          errmsg=errmsg+errmsg6+"只见钱庄的柜台小姐双颊泛红，眼带桃花，直瞪着你：你还真凯，你本笔贷款并没有这么多钱。"
	      exit sub
      end if
      if pf2_1 + p_ac > U_wealth then
          founderr=true
          errmsg=errmsg+errmsg6+"sorry，我们不收假钞，真的你又没那么多，记住，要加上利息一并还的哦。"
	      exit sub
      end if
      if pf2_1 < pf2_2 then
          if pf2_1*zhml < l_trade then
              founderr=true
              errmsg=errmsg+errmsg6+"分期还款每次最少得还" & l_trade&curr & "。"
		      exit sub
          elseif  pf2_1 mod zhml > 0 then
              founderr=true
              errmsg=errmsg+errmsg6+"分期还清贷款，还款的数目必须是"&zhml&"的倍数，也就是每"&zhml&curr&"换回1点魅力。"
		      exit sub
          elseif p_cp-pf2_1\zhml < 10 then
              founderr=true
              errmsg=errmsg+errmsg6+"本期最后剩下所押的魅力已经不足10，请一次还清。"
		      exit sub
          elseif not founderr then
              centtb=true
          end if
      end if
  end if
  if not founderr then
      if not centtb then
          cjconn.execute ("delete from paymentforgoods where pid="&pid)
      else
          cjconn.execute ("update paymentforgoods set paymentforgoods=paymentforgoods-"&pf2_1&",p_accrual=0,bydetaincp=bydetaincp-"&pf2_1\zhml&" where pid="&pid)
      end if
      cjconn.execute ("update bankuser set paymentforgoods=paymentforgoods-"&pf2_1&",p_accrual=p_accrual-"&p_ac&",bydetaincp=bydetaincp-"&pf2_1\zhml&",events='"&pf2_1&"|还贷款|"&now()&"' where bankuserid="&bankuserid)
      cjconn.execute ("update bank set stockpile=stockpile+"&pf2_1+p_ac&",paymentforgoods=paymentforgoods-"&pf2_1&" where bankid="&bankid)
      if openeventslog then
          cjconn.execute ("insert into bankevent (bankid,name1,name2,events,trade) values ("&bankid&",'"&Dvbbs.MemberName&"','','贷款',"&pf2_1*zhml&")")
      end if
      conn.execute ("update [dv_user] set userwealth=userwealth-"&pf2_1+p_ac&",usercp=usercp+"&pf2_1 \ zhml&" where username='"&Dvbbs.MemberName&"'")
      '后句那一刀加
      call HyhSaveCookie(-pf2_1+p_ac,pf2_1\zhml,0,0,0,0)
      call yaoyue_banksuc()
  end if
end sub

'转帐
sub vir()
  dim bvir,bankuser,takeoveruser,bfreeze
  if not isnumeric(request.form("bvir")) then
      founderr=true
      errmsg=errmsg+errmsg6+"请输入数字"
      exit sub
  else
      bvir=int(abs(request.form("bvir")))
      bankuser=Dvbbs.HTMLEncode(Dvbbs.CheckStr(request.form("bankuser")))
      bfreeze=false
      csql="select bankuserid,freeze from bankuser where bankid="&bankid&" and name='"&bankuser&"'"
      set crs=cjconn.execute (csql)
      if crs.bof and crs.eof then
          errmsg=errmsg+errmsg6+"本钱庄没有该用户，请确定输入的用户名正确。"
          founderr=true
          exit sub
      else
          takeoveruser=crs(0)
          if crs(1)=-1 then
              bfreeze=true
          end if
      end if
      set crs=nothing
      if bfreeze then
          founderr=true
          errmsg=errmsg+errmsg6+"你所要转帐的用户已经被冻结。"
	      exit sub
      end if
      if int(bvir+bvir*virement/100) > U_wealth then
          founderr=true
          errmsg=errmsg+errmsg6+"你是不是好心过头啦？还是人家催债催得太紧，让你自己还有多少钱都不知道？（注意：所转的帐及转帐所需的手继费都从你现金中扣除，本笔转加手继费一共需"&int(bvir+bvir*virement/100)&curr&"，而你的现金只有"&U_wealth&curr&"。）"
      end if
      if bankuser = Dvbbs.MemberName then
          founderr=true
          errmsg=errmsg+errmsg6+"给自己转帐很好玩吗？"
	      exit sub
      end if
      if bvir < l_trade then
          founderr=true
          errmsg=errmsg+errmsg6+"hi！亲爱的客户，您转的钱也未免太……少了点吧？"
	      exit sub
      end if
      if bvir > h_trade then
          founderr=true
          errmsg=errmsg+errmsg6+"晕，你的钱太多太重了，请分次，ｏｋ？"
	      exit sub
      end if
  end if
  if not founderr then
      '转方更新信息
      cjconn.execute ("update bankuser set events='"&bvir&"|转帐|"&now()&"' where bankuserid="&bankuserid)
      cjconn.execute ("update bank set alldeposit=alldeposit+"&bvir&",stockpile=stockpile+"&int(bvir+bvir*virement/100)&" where bankid="&bankid)
      if openeventslog then
          cjconn.execute ("insert into bankevent (bankid,name1,name2,events,trade) values ("&bankid&",'"&Dvbbs.MemberName&"','"&bankuser&"','转帐',"&bvir&")")
      end if
      conn.execute ("update [dv_user] set userwealth=userwealth-"&int(bvir+bvir*virement/100)&" where username='"&Dvbbs.MemberName&"'")
      '后句那一刀加
      call HyhSaveCookie(-int(bvir+bvir*virement/100),0,0,0,0,0)
      '收方更新信息
      cjconn.execute ("update bankuser set currdeposit=currdeposit+"&bvir&" where bankuserid="&takeoveruser)
      dim title,body
	  title="天上掉下个林姐姐啦……"
	  body=Dvbbs.MemberName&"从"&bankname&"转"&bvir&curr&"给你，已经存入你在"&bankname&"的账户中。"
	  sql="insert into dv_message(incept,sender,title,content,sendtime,flag,issend) values('"&bankuser&"','"&Dvbbs.MemberName&"','"&title&"','"&body&"',now(),0,1)"
	  conn.execute(sql)
	  call update_user_msg(BankUser)
	  call yaoyue_banksuc
  end if
end sub

'汇款
sub r_e_m()
  dim bremit,takebank,bankuser,takeoveruser,takeoverbank,bfreeze
  if not isnumeric(request.form("bremit")) then
      founderr=true
      errmsg=errmsg+errmsg6+"金额请输入数字。"
      exit sub
  else
      bremit=int(abs(request.form("bremit")))
      takebank=Dvbbs.HTMLEncode(Dvbbs.CheckStr(request.form("takbank_ebank")))
      bankuser=Dvbbs.HTMLEncode(Dvbbs.CheckStr(request.form("bankuser")))
      csql="select bankid from bank where bankname='"&takebank&"'"
      bfreeze=false
      set crs=cjconn.execute (csql)
      if crs.bof and crs.eof then
          errmsg=errmsg+errmsg6+"找不到你所要汇到的钱庄，请确定该钱庄存在。"
          founderr=true
          exit sub
      else
          takeoverbank=crs(0)
      end if
      csql="select bankuserid,freeze from bankuser where bankid="&takeoverbank&" and name='"&bankuser&"'"
      set crs=cjconn.execute (csql)
      if crs.bof and crs.eof then
          errmsg=errmsg+errmsg6+"在所汇到的钱庄中找不到所指定的用户，请确认该用户存在。"
          founderr=true
          exit sub
      else
          takeoveruser=crs(0)
          if crs(1)=-1 then
              bfreeze=true
          end if
      end if
      set crs=nothing
      if bfreeze then
          founderr=true
          errmsg=errmsg+errmsg6+"你所要转帐的用户已经被冻结。"
	      exit sub
      end if
      if takebank=bankname then
          founderr=true
          errmsg=errmsg+errmsg6+"相同钱庄，只要用转帐就行吧？"
	      exit sub
      end if
      if int(bremit+bremit*remit/100) > U_wealth then
          founderr=true
          errmsg=errmsg+errmsg6+"你是不是好心过头啦？还是人家催债催得太紧，让你自己还有多少钱都不知道？（注意：所转的帐及转帐所需的手继费都从你现金中扣除，本笔转加手继费一共需"&int(bremit+bremit*remit/100)&curr&"，而你的现金只有"&U_wealth&curr&"。）"
	      exit sub
      end if
      if bankuser = Dvbbs.MemberName then
          founderr=true
          errmsg=errmsg+errmsg6+"给自己汇款很好玩吗？"
	      exit sub
      end if
      if bremit < l_trade then
          founderr=true
          errmsg=errmsg+errmsg6+"hi！亲爱的客户，您转的钱也未免太……少了点吧？"
	      exit sub
      end if
      if bremit > h_trade then
          founderr=true
          errmsg=errmsg+errmsg6+"晕，你的钱太多太重了，请分批来，ｏｋ？"
	      exit sub
      end if
  end if
  if not founderr then
      '汇方更新信息
      cjconn.execute ("update bankuser set events='"&bremit&"|转帐|"&now()&"' where bankuserid="&bankuserid)
      cjconn.execute ("update bank set stockpile=stockpile+"&int(bremit*remit/100)&" where bankid="&bankid)
      if openeventslog then
          cjconn.execute ("insert into bankevent (bankid,name1,name2,events,trade) values ("&bankid&",'"&Dvbbs.MemberName&"','"&bankuser&"','汇款',"&bremit&")")
      end if
      conn.execute ("update [dv_user] set userwealth=userwealth-"&int(bremit+bremit*remit/100)&" where username='"&Dvbbs.MemberName&"'")
      '后句那一刀加
      call HyhSaveCookie(-int(bremit+bremit*remit/100),0,0,0,0,0)
      '收方更新信息
      cjconn.execute ("update bankuser set currdeposit=currdeposit+"&bremit&" where bankuserid="&takeoveruser)
      cjconn.execute ("update bank set alldeposit=alldeposit+"&bremit&",stockpile=stockpile+"&bremit&" where bankid="&takeoverbank)
      dim title,body
	  title="天上掉下个林姐姐啦……"
	  body=Dvbbs.MemberName&"从"&bankname&"汇"&bremit&curr&"到"&takebank&"给你，已经存入你在"&takebank&"的账户中。"
	  sql="insert into dv_message(incept,sender,title,content,sendtime,flag,issend) values('"&bankuser&"','"&Dvbbs.MemberName&"','"&title&"','"&body&"',now(),0,1)"
	  conn.execute(sql)
	  call update_user_msg(BankUser)
	  call yaoyue_banksuc
  end if
end sub

'更新用户短信通知信息（新短信条数||新短讯ID||发信人名）
Sub UPDATE_User_Msg(username)
	Dim msginfo,i,UP_UserInfo,newmsg
	newmsg=newincept(username)
	If newmsg>0 Then
		msginfo=newincept(username) & "||" & inceptid(1,username) & "||" & inceptid(2,username)
	Else
		msginfo="0||0||null"
	End If
	Dvbbs.execute("UPDATE [Dv_User] Set UserMsg='"&Dvbbs.CheckStr(msginfo)&"' WHERE username='"&Dvbbs.CheckStr(username)&"'")
  If username=Dvbbs.MemberName Then
		DVBBS.UserSession.documentElement.selectSingleNode("userinfo/@usermsg").text=msginfo
	Else
		Call Dvbbs.NeedUpdateList(username,1)
	End If
End Sub

'统计留言
Function newincept(iusername)
Dim Rss
Rss=Dvbbs.execute("SELECT Count(id) FROM Dv_Message WHERE flag=0 And issend=1 And DelR=0 And incept='"& iusername &"'")
    newincept=Rss(0)
	Set Rss=nothing
	If isnull(newincept) Then newincept=0
End Function

Function inceptid(stype,iusername)
	dim Rss
	Set Rss=Dvbbs.execute("SELECT top 1 id,sender FROM Dv_Message WHERE flag=0 And issend=1 And DelR=0 And incept='"& iusername &"'")
	If not Rss.eof Then
		If stype=1 Then
			inceptid=Rss(0)
		Else
			inceptid=Rss(1)
		End If
	Else
		If stype=1 Then
			inceptid=0
		Else
			inceptid="null"
		End If
	End If
	Set Rss=nothing
End Function
%>

<%
sub HyhSaveCookie(UserWealth,UserCP,UserEP,UserPower,UserMoney,Usertopic)
	DVBBS.UserSession.documentElement.selectSingleNode("userinfo/@activetime").text = Now()
	DVBBS.UserSession.documentElement.selectSingleNode("userinfo/@usermoney").text=DVBBS.UserSession.documentElement.selectSingleNode("userinfo/@usermoney").text+cCur(UserMoney)
	DVBBS.UserSession.documentElement.selectSingleNode("userinfo/@userpost").text=DVBBS.UserSession.documentElement.selectSingleNode("userinfo/@userpost").text+Clng(Usertopic)
	DVBBS.UserSession.documentElement.selectSingleNode("userinfo/@userwealth").text=DVBBS.UserSession.documentElement.selectSingleNode("userinfo/@userwealth").text+cCur(UserWealth)
	DVBBS.UserSession.documentElement.selectSingleNode("userinfo/@userep").text=DVBBS.UserSession.documentElement.selectSingleNode("userinfo/@userep").text+Clng(UserEP)
	DVBBS.UserSession.documentElement.selectSingleNode("userinfo/@usercp").text=DVBBS.UserSession.documentElement.selectSingleNode("userinfo/@usercp").text+Clng(UserCP)
	DVBBS.UserSession.documentElement.selectSingleNode("userinfo/@userpower").text=DVBBS.UserSession.documentElement.selectSingleNode("userinfo/@userpower").text+Clng(UserPower)
end sub

%>

<%
'黄河7.0插件自助升级器2004-1-7 17:41:30自动添加
sub new_head()
Dvbbs.Head_var 3,0,"钱庄","bank_index.asp"
end sub
%>