<!-- #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: bank_ClientEvents.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
'=========================================================
dim Pcount
dim page
dim total,bankuser
BankUser = trim(request("bankuser"))
if not isnumeric(request("page")) or request("page")="" then
    page=1
else
    page=cint(request("page"))
end if

if session("joekoe_online_admin")<>"joekoe_admin" then
    if not FoundBankUserID and not FoundBankUser then
        founderr=true
        Errmsg=Errmsg+"<br>"+"<li>你还没有在该银行开户，若想单查该银行的用户，请到该银行开户，若想查某用户在哪些银行开户，请选所有银行，然后输入用户名。</li>"
    end if
end if
if session("joekoe_online_admin")<>"joekoe_admin" then
   if  BankID=0 and BankUser="" then
      founderr=true
      Errmsg=Errmsg+"<br>"+"<li>不允许查询所有银行，请键入具体要查询的名字。</li>"
   end if
end if
if request("action")="events" and not OpenEventsLog then
    if not IsBankMaster and session("joekoe_online_admin")<>"joekoe_admin" then
            founderr=true
        Errmsg=Errmsg+"<br>"+"<li>该银行没有开放事件记录。</li>"
    end if
end if
if FoundErr then
    tit_fir="<a href='z_bank_index.asp'>社区银行</a>"
    tit="银行错误信息"
    call web_head(1,0,2,0,0)
        call bank_error()
        call web_end(0)
else
    if request("action")="delEvents" then
        tit_fir="<a href='z_bank_index.asp'>社区银行</a>"
        tit="删除事件记录"
        call web_head(1,0,2,0,0)
        call delEvents()
    elseif request("action")="freezeuser" then
        tit_fir="<a href='z_bank_index.asp'>社区银行</a>"
        tit="冻结用户"
        call web_head(1,0,2,0,0)
        call FreezeUser()
    elseif request("action")="events" then
        tit_fir="<a href='z_bank_index.asp'>社区银行</a>"
        tit="客户事件"
        call web_head(1,0,2,0,0)
        call BankEvents()
    else
        tit_fir="<a href='z_bank_index.asp'>社区银行</a>"
        tit="用户查询"
        call web_head(1,0,2,0,0)
        call search()
    end if
    if FoundErr then
        call bank_error()
    end if
    call web_end(0)
end if

sub BankEvents()
  if format_power(login_mode,0)="admin" then
      csql="select * from bankevent order by eventid desc"
  elseif IsBankMaster then
      csql="select * from bankevent where bankid="&BankID&" order by eventid desc"
  else
      csql="select * from bankevent where bankid="&BankID&" and name1='"&login_username&"' order by eventid desc"
  end if
  set crs=server.CreateObject("adodb.recordset")
  crs.Open csql,cjconn,1,1
  if crs.BOF and crs.EOF then
      founderr=true
      Errmsg=Errmsg+"<br>"+"<li>没有找到您要查询的内容。"
  else
%>
<div align="center">
  <center>
<table cellpadding=0 border=1 width="98%" bordercolor=<%response.write web_var(web_color,3)%> height="27"><tr>
  <td class=bg_3 height="23">
  <p align="center">以下是您所查询到的记录。<%if format_power(login_mode,0)="admin" and BankID=0 then Response.Write "如果想知道事件属哪个银行，把址栏上的bankid=?改为该银行的ＩＤ，也可先进入所想查的银行，再点事件记录。"%></td></tr></table>
  </center>
</div>
<form action=z_bank_ClientEvents.asp?bankid=<%=BankID%>&action=delEvents method=post>
<div align="center">
  <center>
<TABLE cellPadding=3  border="1" bordercolor=<%response.write web_var(web_color,3)%> width="98%" style="border-collapse: collapse" cellspacing="0">
<TR valign=middle>
<Th height=25 width=60>事件ID</Th>
<Th width=120>操作人</Th>
<Th width=120>接受人（银行）</Th>
<Th width=120>事件</Th>
<Th width=120>交易金</Th>
<Th width=*>操作时间</Th>
<%if format_power(login_mode,0)="admin" then Response.Write "<Th width=40>管理</Th>"%>
</TR>
<%
      crs.PageSize = 20
      total = crs.recordcount
      Pcount = crs.pagecount
      if page < 1 then page = 1
      if page > Pcount then page = Pcount
      crs.move (page-1)*crs.pagesize
      ii = 0
      do while not crs.eof and ii < crs.pagesize
%>
  <TR> 
    <TD align=middle class=tablebody2 width=60><%=crs(0)%>　</TD> 
    <TD align=middle class=tablebody1 width=120><%=crs(2)%>　</TD> 
    <TD align=middle class=tablebody2  width=120><%=crs(3)%><%if crs(3)="" then Response.Write bankname%>　</TD> 
    <TD align=middle class=tablebody1 width=120><%=crs(4)%>　</TD>
    <TD align=middle class=tablebody2  width=120><%=crs(5)%>　</TD> 
    <TD align=middle class=tablebody1 width=*><%=crs(6)%>　</TD>
    <%if format_power(login_mode,0)="admin" then Response.Write "<TD align=middle class=tablebody2  width=40><input type=checkbox name=del value="&crs(0)&"></TD>"%>
</TR> 
<%
          ii = ii+1
          crs.movenext
      loop
      Response.Write "</table>"
      call PageFooter
      if format_power(login_mode,0)="admin" then
          Response.Write "<br><table cellpadding=0 cellspacing=0 border=0  align=center><tr><td><input type=submit name=s value=删除 onclick=""return confirm('是否删除所选定的记录？');""> 清空该银行的记录：<input type=checkbox name=delAll value=1>　</td></tr></table>"
      end if
      Response.Write "</form>"
  end if
  crs.Close
  set crs = nothing
end sub

sub search()
  dim Bank
  if format_power(login_mode,0)="admin" and bankid=0 and BankUser="" then
      Bank=""
  elseif bankID > 0 and BankUser<>"" then
      Bank=" where u.bankid="&BankID&" and u.name='"&BankUser&"' "
  elseif bankID=0 and BankUser<>"" then
      Bank=" where u.name='"&BankUser&"' "
  else
      Bank=" where u.bankid="&BankID&" "
  end if
  if format_power(login_mode,0)="admin"  and request("vt")="DelUser" then
      csql="select b.bankname,u.bankuserid,u.name,u.CurrDeposit,u.TimeDeposit,u.PaymentForGoods,u.freeze from bankuser u inner join bank b on b.bankid=u.bankid and b.bankmaster<>u.name "&Bank&" order by u.bankuserid desc"
  else
      csql="select b.bankname,u.bankuserid,u.name,u.CurrDeposit,u.TimeDeposit,u.PaymentForGoods,u.freeze from bankuser u inner join bank b on b.bankid=u.bankid "&Bank&" order by u.bankuserid desc"
  end if
  set crs=server.CreateObject("adodb.recordset")
  crs.Open csql,cjconn,1,1
  if crs.BOF and crs.EOF then
      founderr=true
      Errmsg=Errmsg+"<br>"+"<li>没有找到您要查询的内容。"
  else
%>
  </center>
</div>
<div align="center">
  <center>
<table cellpadding=0 border=2 width="98%" bordercolor=<%response.write web_var(web_color,3)%> height="30"><tr>
  <td height="26" class=bg_3>
  <p align="center">以下是您所查询到的记录</td></tr></table>
  </center>
</div>
<form action=z_bank_ClientEvents.asp?bankid=<%=Bankid%>&action=freezeuser&vt=<%=request("vt")%> method=post>
<div align="center">
  <center>
<TABLE cellPadding=3 class=bg_3 width="98%" border="2" bordercolor=<%response.write web_var(web_color,3)%> style="border-collapse: collapse" cellspacing="0">
<TR valign=middle>
<Th height=25 width=120>所在银行</Th>
<Th width=120>用户名称</Th>
<Th width=120>活期存款</Th>
<Th width=*>定期存款</Th>
<Th width=120>贷款</Th>
<Th width=100>是否被冻结</Th>
<%if format_power(login_mode,0)="admin" or IsBankMaster then Response.Write "<Th width=40>管理</Th>"%>
</TR>
<%
      crs.PageSize = 20
      total = crs.recordcount
      Pcount = crs.pagecount
      if page < 1 then page = 1
      if page > Pcount then page = Pcount
      crs.move (page-1)*crs.pagesize
      ii = 0
      do while not crs.eof and ii < crs.pagesize
%>
  <TR> 
    <TD align=middle class=tablebody2 width=120><%=crs(0)%>　</TD> 
    <TD align=middle class=tablebody1 width=120><%=crs(2)%>　</TD> 
    <TD align=middle class=tablebody2  width=120><%=crs(3)%>　</TD> 
    <TD align=middle class=tablebody1 width=*><%=crs(4)%>　</TD>
    <TD align=middle class=tablebody2  width=120><%=crs(5)%>　</TD> 
    <TD align=middle class=tablebody1 width=100><%=crs(6)%>　</TD>
    <%if format_power(login_mode,0)="admin"  or IsBankMaster then Response.Write "<TD align=middle class=tablebody2  width=40><input type=checkbox name=Bfreeze value="&crs(1)&"></TD>"%>
</TR> 
  </center>
</div>
<%
          ii = ii+1
          crs.movenext
      loop
      Response.Write "</table>"
      call PageFooter
      if format_power(login_mode,0)="admin" then
          if request("vt")="unfreeze" then
              Response.Write "<table border=1 cellpadding=0 cellspacing=1 width=98% align=center bordercolor='"&web_var(web_color,3)&"'><tr><td><input type=submit name=s value=解冻 onclick=""return confirm('是否解冻所选定的用户？');"">　<input type=button name=t value=切换到冻结用户界面 onclick=""javascript:location.href='z_bank_ClientEvents.asp?bankid="&BankID&"';"">　<input type=button name=t value=切换到删除用户界面 onclick=""javascript:location.href='z_bank_ClientEvents.asp?bankid="&BankID&"&vt=DelUser';""> 本操作为解冰结所选中的用户</td></tr></table>"
          elseif request("vt")="DelUser" then
              Response.Write "<table border=1 cellpadding=0 cellspacing=1 width=98% align=center bordercolor='"&web_var(web_color,3)&"'><tr><td><input type=submit name=s value=删除 onclick=""return confirm('是否删除所选定的用户？');"">　<input type=button name=t value=切换到解冻用户界面 onclick=""javascript:location.href='z_bank_ClientEvents.asp?bankid="&BankID&"&vt=unfreeze';"">　<input type=button name=t value=切换到冻结用户界面 onclick=""javascript:location.href='z_bank_ClientEvents.asp?bankid="&BankID&"';""> 本操作为删除所选中的用户</td></tr></table>"
          else
              Response.Write "<table border=1 cellpadding=0 cellspacing=1 width=98% align=center bordercolor='"&web_var(web_color,3)&"'><tr><td><input type=submit name=s value=冻结 onclick=""return confirm('是否冻结所选定的用户？');"">　<input type=button name=t value=切换到解冻用户界面 onclick=""javascript:location.href='z_bank_ClientEvents.asp?bankid="&BankID&"&vt=unfreeze';"">　<input type=button name=t value=切换到删除用户界面 onclick=""javascript:location.href='z_bank_ClientEvents.asp?bankid="&BankID&"&vt=DelUser';""> 本操作为冻结所选中的用户（要注意别把自己也冻了）</td></tr></table>"
          end if
      elseif format_power(login_mode,0)="admin" or IsBankMaster then
          if request("vt")="unfreeze" then
              Response.Write "<table border=1 cellpadding=0 cellspacing=1 width=98% align=center bordercolor='"&web_var(web_color,3)&"'><tr><td><input type=submit name=s value=解冻 onclick=""return confirm('是否解冻所选定的用户？');"">　<input type=button name=t value=切换到冻结用户界面 onclick=""javascript:location.href='z_bank_ClientEvents.asp?bankid="&BankID&"';""> 本操作为解冰结所选中的用户</td></tr></table>"
          else
              Response.Write "<table border=1 cellpadding=0 cellspacing=1 width=98% align=center bordercolor='"&web_var(web_color,3)&"'><tr><td><input type=submit name=s value=冻结 onclick=""return confirm('是否冻结所选定的用户？');"">　<input type=button name=t value=切换到解冻用户界面 onclick=""javascript:location.href='z_bank_ClientEvents.asp?bankid="&BankID&"&vt=unfreeze';""> 本操作为冻结所选中的用户（要注意别把自己也冻了）</td></tr></table>"
          end if
      end if
      Response.Write "</form>"
  end if
  crs.Close
  set crs = nothing
  call search1
end sub

sub PageFooter()
  dim BPage
  ii=0
  if request("action")="events" then
      BPage="action=events"
  elseif request("vt")<>"" then
      BPage="vt="&request("vt")&"&bankuser="&BankUser
  else
      BPage="bankuser="&BankUser
  end if
  Response.Write  "<br><table border=1 cellpadding=0 cellspacing=1 width=98% align=center bordercolor='"&web_var(web_color,3)&"'>"&_
                  "<tr><td valign=middle nowrap>"&_
                  "页次：<font color=#ff0000><b>"&page&"</b></font>/<b>"&Pcount&"</b>页"&_
			     " 每页<font color=#ff0000><b>20</b></font>条记录 总共有<font color=#ff0000><b>"&total&"</b></font>条记录</td>"&_
			     "<td valign=middle nowrap><div align=right><p>分页： "
			if page > 4 then
			    Response.Write "<a href=z_bank_ClientEvents.asp?bankid="&bankID&"&"&BPage&"&page=1>[1]</a>..."
			end if
			if Pcount>page+3 then
			    ii=page+3
			else
			    ii=Pcount
			end if
			for i=page-3 to ii
			    if not i < 1 then
			        if i=cint(page) then
			            Response.Write "<font color=#ff000000>["&i&"]</font>"
			        else
			            Response.Write "<a href=z_bank_ClientEvents.asp?bankid="&bankID&"&"&BPage&"&page="&i&">["&i&"]</a>"
			        end if
			    end if
			next
			if page+3 < Pcount then
			    Response.Write "...<a href=z_bank_ClientEvents.asp?bankid="&bankID&"&"&BPage&"&page="&Pcount&">["&Pcount&"]</a>"
			end if
			response.write "</p></div></font></td></tr></table>"
end sub
sub search1()
  Response.Write "<br><table border=0 cellpadding=0 cellspacing=2 width=98% align=center bordercolor='"&web_var(web_color,3)&"'>"&_
                 "<tr><td valign=middle align=center nowrap>"&_
                 "<form action=z_bank_ClientEvents.asp method=get>"&_
                 "选择银行：<select name=bankid><option value=0>所有银行</option>"
                 csql="select bankid,bankname from bank"
                 set crs=cjconn.execute (csql)
                 do while not crs.eof
                     Response.Write "<option value="&crs(0)&" "
                     if Bankid=crs(0) then
                         Response.Write "selected"
                     end if
                     Response.Write ">"&crs(1)&"</option>"
                     crs.movenext
                 loop
                 set crs=nothing
  Response.Write "</select> 填入想找的用户名（选全部银行时必须查询具体的某用户）：<input type=text name=bankuser size=10> <input type=submit name=s value=查询></form></td></tr></table>"
end sub
'删除事件
sub delEvents()
  dim del,DelAll
  del=Request.Form("del")
  DelAll=Request.Form("delAll")
  if format_power(login_mode,0)<>"admin" then
      founderr=true
      Errmsg=Errmsg+"<br>"+"<li>你不是管理员或还没有登录后台，但可以肯定你是非法操作。</li>"
  end if
  if not FoundBankID then
      founderr=true
      Errmsg=Errmsg+"<br>"+"<li>找不到你所操作的银行。</li>"
  end if
  if DelAll<>1 and del="" then
      founderr=true
      Errmsg=Errmsg+"<br>"+"<li>你没有选择任何记录。</li>"
  end if
  if not FoundErr then
      if DelAll=1 then
          cjconn.execute ("delete from bankevent where bankid="&BankID)
      else
          cjconn.execute ("delete from bankevent where eventid in ("&del&") and bankid="&BankID)
      end if
      call yaoyue_banksuc()
  end if
end sub
'用户管理
sub FreezeUser()
  dim Bfreeze,unfreeze
  Bfreeze=Request.Form("Bfreeze")
  if request("vt")="unfreeze" then
      unfreeze=0
  elseif request("vt")="DelUser" then
      unfreeze=2
  else
      unfreeze=1
  end if
  if unfreeze=2 then
      if format_power(login_mode,0)="admin" then
          founderr=true
          Errmsg=Errmsg+"<br>"+"<li>你不是管理员或还没登录后台。</li>"
      end if
  elseif not IsBankMaster and format_power(login_mode,0)="admin" then
      founderr=true
      Errmsg=Errmsg+"<br>"+"<li>你不是该行行长或管理员。</li>"
  end if
  if Bfreeze="" then
      founderr=true
      Errmsg=Errmsg+"<br>"+"<li>你没有选择用户。</li>"
  end if
  if not FoundErr then
      if unfreeze = 2 then
          csql="select bankid,name,CurrDeposit,TimeDeposit,PaymentForGoods,ByDetainCP from bankuser where bankuserid in("&Bfreeze&")"
          set crs=cjconn.execute (csql)
          if crs.bof and crs.eof then
              founderr=true
              Errmsg=Errmsg+"<br>"+"<li>操作后请不要刷新本页。</li>"
              exit sub
          end if
          do while not crs.eof
              cjconn.execute ("update bank set alldeposit=alldeposit-"&(crs(2)+crs(3))&",PaymentForGoods=PaymentForGoods-"&crs(4)&",loveliness=loveliness+"&crs(5)&" where bankid="&crs(0))
              crs.movenext
          loop
          set crs=nothing
          cjconn.execute ("delete from TimeDeposit where bankuserid in ("&Bfreeze&")")
          cjconn.execute ("delete from PaymentForGoods where bankuserid in ("&Bfreeze&")")
          cjconn.execute ("delete from bankuser where bankuserid in ("&Bfreeze&")")
      else
          cjconn.execute ("update bankuser set freeze="&unfreeze&" where bankuserid in ("&Bfreeze&")")
      end if
      call yaoyue_banksuc()
  end if
end sub
%>