<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<%If session("admau")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。"
elseIf session("cancheckmoney")="" Then
	ef=True
	ec="您没有此操作的权限。"
end if
if not ef then
Set conn=Server.CreateObject("ADODB.Connection")
	conn.Open Application("FreeHostDBlink")
	Set dsmoney = Server.CreateObject("ADODB.Recordset")	
Sql="Select username,usermoney=sum(usermoney) from FreeHost.FreeHost_moneylog WHERE isnew='y' and isdel is null and attime > '"&formatdatetime(dateadd("d",Request.QueryString ("d"),now),2)&"' and attime < '"&formatdatetime(dateadd("d",Request.QueryString ("dend"),now),2)&"' group by [username] ORDER BY usermoney desc"

if Request.QueryString ("type") ="add" then Sql="Select username,usermoney=sum(usermoney) from FreeHost.FreeHost_moneylog WHERE id in (select id from FreeHost.FreeHost_moneylog where isnew='y' and isdel is null and isadd='y' and attime > '"&formatdatetime(dateadd("d",Request.QueryString ("d"),now),2)&"' and attime < '"&formatdatetime(dateadd("d",Request.QueryString ("dend"),now),2)&"') group by [username] ORDER BY usermoney desc"

if Request.QueryString ("type") ="dec" then Sql="Select username,usermoney=sum(usermoney) from FreeHost.FreeHost_moneylog WHERE id in (select id from FreeHost.FreeHost_moneylog where isnew='y' and isdel is null and isadd='n' and attime > '"&formatdatetime(dateadd("d",Request.QueryString ("d"),now),2)&"' and attime < '"&formatdatetime(dateadd("d",Request.QueryString ("dend"),now),2)&"' ) group by [username] ORDER BY usermoney desc"

	dsmoney.PageSize = 25
	if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
	dsmoney.Open Sql,conn,1,1
%>
<!--#include virtual="/inc-freehost-function/htmlwrite.asp"--><%=htmlwrite("html8")%>
　财务统计
<%=htmlwrite("html9")%>
<%
if dsmoney.Eof then
%>
<br>数据库中不存在款项操作记录。
<%
else
if Request.ServerVariables("QUERY_STRING")<>"" then
ask=Split(Request.ServerVariables("QUERY_STRING"), chr(38)&"pn")
else
ask=Split("freehost=1", "")
ask(0)="freehost=lsoft"
end if
	pn=1
if Request.QueryString ("pn")<>"" then pn=Request.QueryString ("pn")
If dsmoney.RecordCount <> 0 Then dsmoney.AbsolutePage = CLng(pn)  
    if clng(pn)<=10 then
    begini=1
      if dsmoney.PageCount<=10 then
       endini=dsmoney.PageCount 
       else
       endini=10
      end if
    end if
%>
<%if clng(pn)<=10 then%>最新 <%for i=begini to endini
    if clng(pn)=i then%><font color=red>[<%=i%>]</font><%else%><a href="?<%=ask(0)%>&pn=<%=i%>"><font color="#000000">[<%=i%>]</font></a><%end if%>　<%next%> 
        <%else%>　<a href="?<%=ask(0)%>&pn=1"><font color="#000000">最新[1]--[10]</font></a>　　现在是第<font color=red>[<%=pn%>]</font>页 
        　共<%=dsmoney.PageCount%>页　<%end if%><%If Clng(pn)>1 Then%><a href="?<%=ask(0)%>&pn=<%=pn-1%>"><font color="#000000">上一页</font></a>
        <%End If%>|<%If Clng(pn)<dsmoney.PageCount Then%><a href="?<%=ask(0)%>&pn=<%=pn+1%>"><font color="#000000">下一页</font></a>
        <%End If%>
<table width="100%"  border="0" cellspacing="1" bgcolor="#000000">
  <tr bgcolor="#CCCCCC">
    <td width="6%" align="center">编号</td>    
    <td width="11%" align="center">用户名</td>
	<td align="center">金额变化</td>
  </tr>
<%
For N=1 To dsmoney.PageSize 
					If dsmoney.RecordCount=0 Then Exit For
%>
  <tr>
    <td width="6%" align="center" bgcolor="#FFCC66"><%=N%></td>
    <td width="11%" align="center" bgcolor="#FFCC66"><a href="searchuser.asp?username=<%=dsmoney("username")%>" target="_blank"><font color="black"><%=dsmoney("username")%></font></a></td>
	<td width="10%" align="center" bgcolor="#FFCC66"><%=dsmoney("usermoney")%> 元</td>
  </tr>
<%
If clng(pn)=dsmoney.PageCount Then
I = dsmoney.RecordCount - (dsmoney.PageCount-1) * dsmoney.PageSize
If N=I Then Exit For
End If
dsmoney.movenext
Next
%>
</table>
<%
end if
dsmoney.close
set dsmoney=nothing%><br>
<br>

<%=htmlwrite("html10")%>
<%end if
if ef then
Response.Redirect "e.asp?e="&ec
end if%>
