<!-- #include file="include/config.asp" -->
<!-- #include file="INCLUDE/skin.asp" -->
<!--#include file="include/conn.asp"-->
<!--#include file="z_bank_data.asp"-->
<!--#include file="z_bank_const.asp"-->
<%
'=========================================================
' File: z_bank_reg.asp
' Version:1.0
' Date: 2003-7-20
' Script Written by 冰语，倚天电子，http://et8.126.com
'=========================================================
' Copyright (C) 2002,2003 et8.126.Com. All rights reserved.
' Web: ,http://et8.126.com
' Email: lupi@163.net
'=========================================================
    if usermoney<RegBank then
        FoundErr=true
        tit="银行错误信息"
        Errmsg=Errmsg+"<br>"+"<li>你还没有<font color=#ff0000>"&RegBank&"</font>元呐，就想开银行？再加油吧。</li>"
    end if
    csql="select bankid from bank where bankmaster='"&login_username&"'"
    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
        tit="银行错误信息"
        Errmsg=Errmsg+"<br>"+"<li>你已是银行行长了，还想再要，不会吧？</li>"
    end if

    if FoundErr then
        call web_head(1,0,2,0,0)
        call bank_error()
        call web_end(0)  
    else
        select case request("action")
            case "reg"
              tit="发送银行注册信息"
              call web_head(1,0,2,0,0)
              call reg()
              call web_end(0) 
            case else
              tit="申请开设银行"
              call web_head(1,0,2,0,0)
              call main()
              call web_end(0) 
            end select
    end if
sub main()
%>
<form action=z_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=40% class=tablebody1><B>银行名称</B>：<BR>注册银行名称长度限制为6字节</TD>
<TD width=60%  class=tablebody1> 
<INPUT maxLength="6" size=30 name=bankname></TD>
</TR>
<TR> 
<TD width=40%  class=tablebody1><B>银行行长名称</B>：<BR>请填写正确，否则后果自负</font></TD>
<TD width=60%  class=tablebody1><input size=30 name=bankmaster value=<%=login_username%>></TD>
</TR>
<TR> 
<TD width=40% class=tablebody1><B>银行说明</B>：<BR>
用来吸引客户的话，最多三十个字<BR>
</TD>
<TD width=60% class=tablebody1>
<INPUT maxLength=30 size=30 name=MSG>
</TD>
</TR>
<TR> 
<TD width=40% class=tablebody1><B>货款率</B>：<BR>当客户用魅来抵押贷款时的比数，请填5－40的数字</TD>
<TD class=tablebody1> 
<INPUT maxLength=2 size=30 name=ZHML value=5>
</TD>
</TR>
<TR> 
<TD width=40%  class=tablebody1><B>开户最低积分</B>：<BR>设定客户要在该银行开户所需要的积分，可以为0，最大不得超过一千。</TD>
<TD class=tablebody1> 
<INPUT type=text size=30 name=integral value=0>
</TD>
</TR>
<TR> 
<TD width=40%  class=tablebody1><B>汇款转账所需的积分</B>：<BR>设定汇款转账时所需要的积分，最低两百，最高一千。</TD>
<TD class=tablebody1> 
<INPUT type=text size=30 name=EP value=200>
</TD>
</TR>
<% if format_power(login_mode,0)="admin" then%>
<TR> 
<TD width=40%  class=tablebody1><B>库金</B>：<BR>管理员可以指定该银行的初始库存金额，最低十万，最高一千万。</font></TD>
<TD width=60%  class=tablebody1> 
<INPUT maxLength=50 size=30 name=stockpile value=100000></TD>
</TR>
<TR> 
<TD width=40%  class=tablebody1><B>是否公家银行</B>：<BR>管理员可以指定该银行是否公家银行。</font></TD>
<TD width=60%  class=tablebody1> 
<INPUT type=checkbox name=everybody value=1></TD>
</TR>
<TR> 
<TD width=40%  class=tablebody1><B>是否天启事件记录</B>：<BR>管理员可以指定该银行是否开启客户每次操作的事件记录。</font></TD>
<TD width=60%  class=tablebody1> 
<INPUT type=checkbox name=eventslog value=1></TD>
</TR>
<TR> 
<TD width=40%  class=tablebody1><B>该银行是否开放</B>：<BR>指定该银行是否直接开放。</font></TD>
<TD width=60%  class=tablebody1> 
<INPUT type=checkbox name=opened value=1 checked></TD>
</TR>
<%end if%>
<TR> 
<TD width=40%  class=tablebody1></TD>
<TD width=60%  class=tablebody1> 
　　<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+"<br>"+"<li>该银行名称已经存在，请返回重新填写。</li>"
  end if
  if bankname="" then
      FoundErr=true
      Errmsg=Errmsg+"<br>"+"<li>请填写银行名称。</li>"
  end if
  if bankmaster="" then
      FoundErr=true
      Errmsg=Errmsg+"<br>"+"<li>请填写银行行长名称。</li>"
  end if
  if format_power(login_mode,0)<>"admin"  then
      if bankmaster<>login_username then
          FoundErr=true
          Errmsg=Errmsg+"<br>"+"<li>你只能为你自己申请银行，请不要填别人的名字。</li>"
      end if
  end if
  if MSG="" then
      FoundErr=true
      Errmsg=Errmsg+"<br>"+"<li>请填写银行说明。</li>"
  end if
  if not isnumeric(ZHML) or ZHML="" or cint(ZHML)<1 or cint(ZHML)>40 then
      FoundErr=true
      Errmsg=Errmsg+"<br>"+"<li>货款率请填1至40之间的数字。</li>"
  end if
  if not isnumeric(EP) or EP="" or cint(EP)<0 or cint(EP)>1000 then
      FoundErr=true
      Errmsg=Errmsg+"<br>"+"<li>开户最低积分请填0至1000之间的数字。</li>"
  end if
  if not isnumeric(integral) or integral="" or cint(integral)>1000 then
      FoundErr=true
      Errmsg=Errmsg+"<br>"+"<li>转账所需的积分请填0至1000之间的数字。</li>"
  end if
  if format_power(login_mode,0)="admin"  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 user_data 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+"<br>"+"<li>找不到所填的银行行长的用户名，请确认该用户名正确。</li>"
      end if
      if not isnumeric(stockpile) or stockpile="" or clng(stockpile)<100000 or clng(stockpile)>10000000 then
          FoundErr=true
          Errmsg=Errmsg+"<br>"+"<li>库金请填100000至10000000之间的数字。</li>"
      end if
  end if
  if FoundErr then
      call bank_error()
      exit sub
  else
      if format_power(login_mode,0)="admin"  then
          set crs=server.createobject("adodb.recordset")
          csql="select bankid,bankname,bankmaster,msg,zhml,EP,integral,stockpile,log_on,everybody,eventslog,opened from bank"
          crs.open csql,cjconn,1,3
          crs.addnew
          crs("bankname")=bankname
          crs("bankmaster")=bankmaster
          crs("msg")=MSG
          crs("zhml")=cint(ZHML)
          crs("EP")=cint(EP)
          crs("integral")=cint(integral)
          crs("stockpile")=clng(stockpile)
          crs("log_on")=100
          crs("everybody")=everybody
          crs("eventslog")=eventslog
          crs("opened")=opened
          crs.update
          session("bankid")=crs("bankid")
          crs.close
          set crs=nothing
          csql="insert into bankuser (bankid,name,events) values ("&session("bankid")&",'"&bankmaster&"','0|注册新银行|"&now()&"')"
          cjconn.execute (csql)
          if everybody=1 then
              cjconn.execute ("insert into EVBankMasterLog (BankID,MasterName) values ("&session("bankid")&",'"&bankmaster&"')")
          end if
          conn.execute ("update user_data set emoney=emoney-"&L_trade&" where username='"&bankmaster&"'")
          session("bankid")=""
          response.write "<meta http-equiv=refresh content=""3;URL=z_bank_index.asp""><b>新银行添加完成。</b>三秒后将返回银行中心。"
          
      else
          set crs=server.CreateObject("adodb.recordset")
          csql="select bankid,bankname,bankmaster,msg,zhml,EP,integral,stockpile,log_on from bank"
          crs.Open csql,cjconn,1,3
          crs.AddNew
          crs("bankname")=bankname
          crs("bankmaster")=bankmaster
          crs("msg")=MSG
          crs("zhml")=cint(ZHML)
          crs("EP")=cint(EP)
          crs("integral")=cint(integral)
          crs("stockpile")=RegBank
          crs("log_on")=100
          crs.Update
          session("bankid")=crs("bankid")
          crs.Close
          set crs=nothing
          csql="insert into bankuser (bankid,name,events) values ("&session("bankid")&",'"&bankmaster&"','0|注册新银行|"&now()&"')"
          cjconn.execute (csql)
          conn.execute ("update user_data set emoney=emoney-"&(L_trade+RegBank)&" where username='"&login_username&"'")
          session("bankid")=""
          Response.Write "你的银行申请信息已经提交并从你的现金中扣除了"&RegBank&Curr&"，请向管理员发短信通知他们尽快审核，<a href=z_bank_index.asp>返回</a>银行中心。"
      end if
  end if
end sub
%>