<!--#include file="../Conn.asp"-->
<!--#include file="../inc/User_AHHFCH.asp"-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>用户管理中心</title>
<link href="Images/css/css.css" rel="stylesheet" type="text/css">
</head>
<body>
<%
Dim  UserHS,ID,SqlStr,Rs,totalPut,MaxPerPage,CurrentPage
 Set UserHS = New User_AHHFCH
		MaxPerPage=20
		IF Cbool(UserHS.UserLoginChecked)=false then
		  Response.Write "<script>top.location.href ='login.asp' ;</script>"
		  Response.end
		End If
		%>
		  <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
              <td valign="top">
				<%
			   		       If S("page") <> "" Then
						          CurrentPage = CInt(S("page"))
							Else
								  CurrentPage = 1
							End If
								   %>
								     <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table">
                                        <tr>
                                          <td width=167 height=20 class="bg_tr"><B><span style="FONT-SIZE: 10.5pt">查询我的资金明细</span></B></td>
                                          <td width=806 height=20 align=right class="bg_tr"> <a href='?'><font color=red>·所有记录</font></a> ·<a href='?IncomeFlag=1'>收入记录[<%=conn.execute("select count(id) from Money_Log_ACT where IncomeFlag=1 and username='" & UserHS.UserName & "'")(0)%>]</a> ·<a href='?IncomeFlag=2'>支出记录[<%=conn.execute("select count(id) from Money_Log_ACT where IncomeFlag=2 and username='" & UserHS.UserName & "'")(0)%>]</a></td>
                                        </tr>
                </table>
				<table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
					<tr class=title align=middle>
					  <td width=150 height="25" class="bg_tr">交易时间</td>
					  <td width=80 height="25" class="bg_tr">用户名</td>
					  <td width=80 height="25" class="bg_tr">客户姓名</td>
					  <td width=60 height="25" class="bg_tr">交易方式</td>
					  <td width=50 height="25" class="bg_tr">币种</td>
					  <td width=70 height="25" class="bg_tr">收入金额</td>
					  <td width=70 height="25" class="bg_tr">支出金额</td>
					  <td width=40 height="25" class="bg_tr">摘要</td>
					  <td height="25" class="bg_tr">备注/说明</td>
					</tr>
					<%  If ChkNumeric(S("IncomeFlag"))=1 Or ChkNumeric(S("IncomeFlag"))=2 Then
						  SqlStr="Select * From Money_Log_ACT Where IncomeFlag=" & ChkNumeric(S("IncomeFlag")) & " And  UserName='" & UserHS.UserName &"' order by id desc"
 					    Else
						  SqlStr="Select * From Money_Log_ACT Where UserName='" & UserHS.UserName &"' order by id desc"
						End if
						 Set RS=Server.createobject("adodb.recordset")
						 RS.open SqlStr,conn,1,1

						 If RS.EOF And RS.BOF Then
								  Response.Write "<tr class='tdbg'><td align=center height=25 colspan=9 valign=top>找不到您要的记录!</td></tr>"
								 Else
									totalPut = RS.RecordCount
						
											If CurrentPage < 1 Then
												CurrentPage = 1
											End If
			
								If (CurrentPage - 1) * MaxPerPage > totalPut Then
									If (totalPut Mod MaxPerPage) = 0 Then
										CurrentPage = totalPut \ MaxPerPage
									Else
										CurrentPage = totalPut \ MaxPerPage + 1
									End If
								End If
			
								If CurrentPage = 1 Then
									Call ShowContent
								Else
									If (CurrentPage - 1) * MaxPerPage < totalPut Then
										RS.Move (CurrentPage - 1) * MaxPerPage
										Call ShowContent
									Else
										CurrentPage = 1
										Call ShowContent
									End If
								End If
				End If

						
						 %>
					
          </table>
		  </td>
		  </tr>
</table>
		  </TD>
		 </TR>
	</TABLE> 
		  <div align=right style='margin:6px'>
		    <div align="center">
		      <%
		 Call  ShowPagePara(totalPut, MaxPerPage, "", True, "条记录", CurrentPage, "IncomeFlag=" &  ChkNumeric(S("IncomeFlag")))
          %>
	          </div>
		  </div>

		  <%
  Sub ShowContent()
     Dim I,intotalmoney,outtotalmoney
     Do While Not rs.eof 
	%>
    <tr onMouseOver=overColor(this) onMouseOut=outColor(this)>
      <td align=middle  class="td_bg" ><%=rs("LogTime")%></td>
      <td align=middle width=80  class="td_bg" ><%=rs("username")%></td>
	  <td align=middle width=80  class="td_bg" ><%=rs("clientname")%></td>
      <td align=middle width=60  class="td_bg" >
	  <% Select Case rs("MoneyType")
	      Case 1:Response.WRite "现金"
		  Case 2:Response.Write "银行汇款"
		  Case 3:Response.Write "在线支付"
		  Case 4:Response.Write "资金余额"
		 End Select
	 %>
	  </td>
      <td align=middle width=50  class="td_bg" >人民币</td>
      <td width=80 align=right  class="td_bg" > 
	  <%If rs("IncomeFlag")=1 Then
	     Response.Write formatnumber(rs("money"),2)
		 intotalmoney=intotalmoney+rs("money")
	    End If
		%></td>
      <td align=right width=80  class="td_bg" >
	  <%If rs("IncomeFlag")=2 Then
	     Response.Write formatnumber(rs("money"),2)
		 outtotalmoney=outtotalmoney+rs("money")
	    End If
		%></td>
      <td align=center width=40  class="td_bg" >
	  <% If rs("IncomeFlag")=1 Then
	      Response.Write "<font color=red>收入</font>"
		 Else
		  Response.Write "<font color=green>支出</font>"
		 End If
		 %></td>
      <td align=middle  class="td_bg" ><%=rs("Remark")%></td>
    </tr>
	<%
	            
				I = I + 1
				RS.MoveNext
				If I >= MaxPerPage Then Exit Do

	 loop
	%>
    <tr >
      <td align=right colSpan=5  class="td_bg" >本页合计：</td>
      <td align=right class="td_bg" ><%=formatnumber(intotalmoney,2)%></td>
      <td align=right class="td_bg" ><%=formatnumber(outtotalmoney,2)%></td>
      <td colSpan=3 class="td_bg" >&nbsp;</td>
    </tr>
    <tr>
      <td align=right colSpan=5 class="td_bg" >总计金额：</td>
	  	  <%intotalmoney=Conn.execute("Select Sum(Money) From Money_Log_ACT Where UserName='" & UserHS.UserName & "' And IncomeFlag=1")(0)
	    outtotalmoney=Conn.execute("Select Sum(Money) From Money_Log_ACT Where UserName='" & UserHS.UserName & "' And IncomeFlag=2")(0)
	    if not isnumeric(intotalmoney) then intotalmoney=0
		if not isnumeric(outtotalmoney) then outtotalmoney=0
	  %>
      <td align=right class="td_bg" ><%=formatnumber(intotalmoney,2)%></td>
      <td align=right class="td_bg" ><%=formatnumber(outtotalmoney,2)%></td>
      <td align=middle colSpan=3 class="td_bg" >资金余额：<%=formatnumber(intotalmoney-outtotalmoney,2)%></td>

    </tr>
  </table>
		<%
		End Sub


	Public Function ShowPagePara(totalnumber, MaxPerPage, FileName, ShowAllPages, strUnit, CurrentPage, ParamterStr)
		  Dim N, I, PageStr
				Const Btn_First = "第一页"'样式定义
				Const Btn_Prev = "上一页" 
				Const Btn_Next = "下一页" 
				Const Btn_Last = "最后一页" 
				  PageStr = ""
					If totalnumber Mod MaxPerPage = 0 Then
						N = totalnumber \ MaxPerPage
					Else
						N = totalnumber \ MaxPerPage + 1
					End If
				If N > 1 Then
					PageStr = PageStr & ("页次：<font color=red>" & CurrentPage & "</font>/" & N & "页 共有:" & totalnumber & strUnit & " 每页:" & MaxPerPage & strUnit & " ")
					If CurrentPage < 2 Then
						PageStr = PageStr & Btn_First & " " & Btn_Prev & " "
					Else
						PageStr = PageStr & ("<a href=" & FileName & "?page=1" & "&" & ParamterStr & ">" & Btn_First & "</a> <a href=" & FileName & "?page=" & CurrentPage - 1 & "&" & ParamterStr & ">" & Btn_Prev & "</a> ")
					End If
					
					If N - CurrentPage < 1 Then
						PageStr = PageStr & " " & Btn_Next & " " & Btn_Last & " "
					Else
						PageStr = PageStr & (" <a href=" & FileName & "?page=" & (CurrentPage + 1) & "&" & ParamterStr & ">" & Btn_Next & "</a> <a href=" & FileName & "?page=" & N & "&" & ParamterStr & ">" & Btn_Last & "</a> ")
					End If
					If ShowAllPages = True Then
						PageStr = PageStr & ("GO:<select  onChange='location.href=this.value;' style='width:55;' name='select'>")
				   For I = 1 To N
					 If Cint(CurrentPage) = I Then
						PageStr = PageStr & ("<option value=" & FileName & "?page=" & I & "&" & ParamterStr & " selected>NO." & I & "</option>")
					 Else
						 PageStr = PageStr & ("<option value=" & FileName & "?page=" & I & "&" & ParamterStr & ">NO." & I & "</option>")
					 End If
				   Next
				  PageStr = PageStr & "</select>"
				  End If
			 End If
			 ShowPagePara = PageStr
			 response.write ShowPagePara
	End Function

%> 
<script language="javascript">

//CSS背景控制
function overColor(Obj)
{
	var elements=Obj.childNodes;
	for(var i=0;i<elements.length;i++)
	{
		elements[i].className="tdbg1"
		Obj.bgColor="";
	}
	
}
function outColor(Obj)
{
	var elements=Obj.childNodes;
	for(var i=0;i<elements.length;i++)
	{
		elements[i].className="tdbg";
		Obj.bgColor="";
	}
}
</script>