<!--#include file=conn.asp-->
<!-- #include file="inc/const.asp" -->
<!--#include file=bank_data.asp-->
<!-- #include file="bank/bank_const.asp" -->
<%
'=========================================================
' file: bank_reg.asp
' 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

dim admin_flag
	admin_flag=",15,"
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.master or instr(","&session("flag")&",",admin_flag)>0 then
    select case request("action")
        case "reg"
          Dvbbs.Stats="发送钱庄注册信息"
          call Dvbbs.Nav()
	call new_head()
          call reg()
        case else
          Dvbbs.Stats="申请开设钱庄"
          call Dvbbs.Nav()
	call new_head()
          call main()
    end select
else
    if U_wealth<regbank then
        founderr=true
        errmsg=errmsg+errmsg6+"你还没有<font color=#ff0000>"&regbank&"</font>元呐，就想开钱庄？再加油吧。"
	    Dvbbs.Stats="钱庄错误信息"
	    call Dvbbs.Nav()
	call new_head()
	    Response.redirect "showerr.asp?ErrCodes="&errmsg&"&action=OtherErr"
    end if
    csql="select bankid from bank where bankmaster='"&Dvbbs.MemberName&"'"
    set crs=cjconn.execute (csql)
    if crs.bof and crs.eof then
        isbankmaster=false
    else
        isbankmaster=true
    end if
    set crs=nothing
    if isbankmaster then
        founderr=true
        Dvbbs.Stats="钱庄错误信息"
        errmsg=errmsg+errmsg6+"你已是钱庄掌柜了，还想再要，不会吧？"
	    call Dvbbs.Nav()
	call new_head()
	    Response.redirect "showerr.asp?ErrCodes="&errmsg&"&action=OtherErr"
    end if
    select case request("action")
        case "reg"
          Dvbbs.Stats="发送钱庄注册信息"
          call Dvbbs.Nav()
	call new_head()
          call reg()
        case else
          Dvbbs.Stats="申请开设钱庄"
          call Dvbbs.Nav()
	call new_head()
          call main()
    end select
end if
call Dvbbs.ActiveOnline()
if founderr then
Response.redirect "showerr.asp?ErrCodes="&errmsg&"&action=OtherErr"
end if
call Dvbbs.Footer()


sub main()
%>
<form action=bank_reg.asp?action=reg method=post>
<table cellpadding=3 cellspacing=1 align=center class=tableborder1>
<tr align=middle> 
<th colspan=2 height=24>注册新钱庄，请仔细填下列表格</td>
</tr>
<tr> 
<td width=56% class=tablebody1><b>钱庄名称</b>：<br>注册钱庄名称长度限制为<font color=red><b>6</b></font>个字</td>
<td width=44%  class=tablebody1> 
<input maxlength="6" size=30 name=bankname></td>
</tr>
<tr> 
<td width=56%  class=tablebody1><b>钱庄掌柜名称</b>：<br>请填写正确，否则后果自负</font></td>
<td width=44%  class=tablebody1><input size=30 name=bankmaster value=<%=Dvbbs.MemberName%>></td>
</tr>
<tr> 
<td width=56% class=tablebody1><b>钱庄说明</b>：<br>
可以是用来吸引客户的语言，最多<font color=red><b>30</b></font>个字<br>
</td>
<td width=44% class=tablebody1>
<input maxlength=30 size=30 name=msg>
</td>
</tr>
<tr> 
<td width=56% class=tablebody1><b>货款率</b>：<br>当客户用魅力来抵押贷款时的比数，请填<font color=red><b>1</b></font>－<font color=red><b>10000</b></font>的数字</td>
<td class=tablebody1> 
<input size=30 name=zhml value=5>
</td>
</tr>
<tr> 
<td width=56%  class=tablebody1><b>开户最低积分(经验值)</b>：<br>设定客户要在该钱庄开户所需要的积分，最低可以为<font color=red><b>0</b></font>，最大不得超过<font color=red><b>10000</b></font>。</td>
<td class=tablebody1> 
<input type=text size=30 name=integral value=0>
</td>
</tr>
<tr> 
<td width=56%  class=tablebody1><b>汇款转账所需的积分(经验值)</b>：<br>设定汇款转账时所需要的积分，最低可以为<font color=red><b>0</b></font>，最高<font color=red><b>10000</b></font>。</td>
<td class=tablebody1> 
<input type=text size=30 name=ep value=200>
</td>
</tr>
<%if Dvbbs.master then%>
<tr> 
<td width=56%  class=tablebody1><b>库金</b>：<br>管理员可以指定该钱庄的初始库存金额，最低<font color=red><b>100000</b></font>，最高<font color=red><b>10000000</b></font>。</font></td>
<td width=44%  class=tablebody1> 
<input maxlength=50 size=30 name=stockpile value=100000></td>
</tr>
<tr> 
<td width=56%  class=tablebody1><b>是否官方钱庄</b>：<br>管理员可以指定该钱庄是否官方钱庄。</font></td>
<td width=44%  class=tablebody1> 
<input type=checkbox name=everybody value=1></td>
</tr>
<tr> 
<td width=56%  class=tablebody1><b>是否天启事件记录</b>：<br>管理员可以指定该钱庄是否开启客户每次操作的事件记录。</font></td>
<td width=44%  class=tablebody1> 
<input type=checkbox name=eventslog value=1></td>
</tr>
<tr> 
<td width=56%  class=tablebody1><b>该钱庄是否开放</b>：<br>指定该钱庄是否直接开放。</font></td>
<td width=44%  class=tablebody1> 
<input type=checkbox name=opened value=1 checked></td>
</tr>
<%end if%>
<tr> 
<td width=44%  class=tablebody1 colspan=2 align=center> 
　　<input type=submit name=s value=提交></td>
</tr>
</table>
</form>
<%
end sub

sub reg()
  dim bankname,bankmaster,msg,zhml,ep,integral,stockpile,everybody,eventslog,opened,foundbankname
  foundbankname=false
  bankname=trim(request.form("bankname"))
  bankmaster=trim(request.form("bankmaster"))
  msg=trim(request.form("msg"))
  zhml=request.form("zhml")
  ep=request.form("ep")
  integral=request.form("integral")
  csql="select bankid from bank where bankname='"&bankname&"'"
  set crs=cjconn.execute (csql)
  if crs.bof and crs.eof then
      foundbankname=false
  else
      foundbankname=true
  end if
  set crs=nothing
  if foundbankname then
      founderr=true
      errmsg=errmsg+errmsg6+"该钱庄名称已经存在，请返回重新填写。"
  end if
  if bankname="" then
      founderr=true
      errmsg=errmsg+errmsg6+"请填写钱庄名称。"
  end if
  if bankmaster="" then
      founderr=true
      errmsg=errmsg+errmsg6+"请填写钱庄掌柜名称。"
  end if
  if not Dvbbs.master then
      if bankmaster<>Dvbbs.MemberName then
          founderr=true
          errmsg=errmsg+errmsg6+"你只能为你自己申请钱庄，请不要填别人的名字。"
      end if
  end if
  if msg="" then
      founderr=true
      errmsg=errmsg+errmsg6+"请填写钱庄说明。"
  end if
  if not isnumeric(zhml) or zhml="" or clng(zhml)<1 or clng(zhml)>10000 then
      founderr=true
      errmsg=errmsg+errmsg6+"货款率：请填1至10000之间的数字。"
  end if
  if not isnumeric(ep) or ep="" or clng(ep)<0 or clng(ep)>10000 then
      founderr=true
      errmsg=errmsg+errmsg6+"开户最低积分：请填0至10000之间的数字。"
  end if
  if not isnumeric(integral) or integral="" or clng(integral)<0 or clng(integral)>10000 then
      founderr=true
      errmsg=errmsg+errmsg6+"汇款转账所需的积分：请填0至10000之间的数字。"
  end if
  if Dvbbs.master then
      stockpile=request.form("stockpile")
      if request.form("everybody")=1 then
          everybody=1
      else
          everybody=0
      end if
      if request.form("eventslog")=1 then
          eventslog=1
      else
          eventslog=0
      end if
      if request.form("opened")=1 then
          opened=1
      else
          opened=0
      end if
      sql="select username from [dv_user] where username='"&bankmaster&"'"
      set rs=conn.execute (sql)
      if rs.bof and rs.eof then
          foundbankuserid=false
      else
          foundbankuserid=true
      end if
      if not foundbankuserid then
          founderr=true
          errmsg=errmsg+errmsg6+"找不到所填的钱庄掌柜的用户名，请确认该用户名正确。"
      end if
      if not isnumeric(stockpile) or stockpile="" or clng(stockpile)<100000 or clng(stockpile)>10000000 then
          founderr=true
          errmsg=errmsg+errmsg6+"库金：请填100,000至10,000,000之间的数字。"
      end if
  end if
  if founderr then
      Response.redirect "showerr.asp?ErrCodes="&errmsg&"&action=OtherErr"
      exit sub
  else
      if Dvbbs.master then
          set crs=server.createobject("adodb.recordset")
          csql="select bankid,bankname,bankmaster,msg,zhml,ep,integral,stockpile,log_on,everybody,eventslog,opened,opentime from bank"
          crs.open csql,cjconn,1,3
          crs.addnew
          crs("bankname")=bankname
          crs("bankmaster")=bankmaster
          crs("msg")=msg
          crs("zhml")=clng(zhml)
          crs("ep")=clng(ep)
          crs("integral")=clng(integral)
          crs("stockpile")=clng(stockpile)
          crs("log_on")=100
          crs("everybody")=everybody
          crs("eventslog")=eventslog
          crs("opened")=opened
          crs("opentime")="0|24||0|24||0|24||0|24||0|24"
          crs.update
          session("bankid")=crs("bankid")
          crs.close
          set crs=nothing
          csql="insert into bankuser (bankid,name,currdeposit,events) values ("&session("bankid")&",'"&bankmaster&"',"&l_trade&",'"&l_trade&"|注册新钱庄|"&now()&"')"
          cjconn.execute (csql)
          if everybody=1 then
              cjconn.execute ("insert into evbankmasterlog (bankid,mastername) values ("&session("bankid")&",'"&bankmaster&"')")
          end if
          conn.execute ("update [dv_user] set userwealth=userwealth-"&l_trade&" where username='"&bankmaster&"'")
          '后两句那一刀加
            Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userwealth").text=Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userwealth").text-ccur(l_trade)
          session("bankid")=""
          response.write "<table width='95%' border='0' cellspacing='1' cellpadding='3'  align=center><tr><td height='23' colspan='2' ><font color=#ff0000>新钱庄添加完成，请在左边列表选择别的操作！</td></tr></table>"
      else
          set crs=server.createobject("adodb.recordset")
          csql="select bankid,bankname,bankmaster,msg,zhml,ep,integral,stockpile,log_on,opentime from bank"
          crs.open csql,cjconn,1,3
          crs.addnew
          crs("bankname")=bankname
          crs("bankmaster")=bankmaster
          crs("msg")=msg
          crs("zhml")=clng(zhml)
          crs("ep")=clng(ep)
          crs("integral")=clng(integral)
          crs("stockpile")=regbank
          crs("log_on")=100
          crs("opentime")="0|24||0|24||0|24||0|24||0|24"
          crs.update
          session("bankid")=crs("bankid")
          crs.close
          set crs=nothing
          csql="insert into bankuser (bankid,name,currdeposit,events) values ("&session("bankid")&",'"&bankmaster&"',"&l_trade&",'"&l_trade&"|注册新钱庄|"&now()&"')"
          cjconn.execute (csql)
          conn.execute ("update [dv_user] set userwealth=userwealth-"&(l_trade+regbank)&" where username='"&Dvbbs.MemberName&"'")
          '后两句那一刀加
               Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userwealth").text=Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userwealth").text-ccur(l_trade+regbank)
          session("bankid")=""
          response.write "你的钱庄申请信息已经提交并从你的现金中扣除了"&regbank&curr&"，请向管理员发短信通知他们尽快审核，<a href=bank_index.asp>返回</a>钱庄列表。"
      end if
  end if
end sub

%>

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