<!--#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>1</title>
<link href="Images/css/css.css" rel="stylesheet" type="text/css">
</head>
<body>
<%
Dim  UserHS,ID,SqlStr,Rs,totalPut,MaxPerPage,CurrentPage,TotalPages,SQL
 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%" height=20 border=0 align="center" cellPadding=2 cellSpacing=1 class="table" id=AutoNumber3 style="BORDER-COLLAPSE: collapse">
                                        <tr>
                                          <td height=20 class="bg_tr"><B>&nbsp;<span style="FONT-SIZE: 10.5pt">查询我的有效期明细</span></B></td>
                                          <td width=583 height=20 align=right class="bg_tr"> <a href='?'><font color=red>·所有记录</font></a> ·<a href='?EdaysFlag=1'>收入记录[<%=conn.execute("select count(id) from Edays_ACT where EdaysFlag=1 and username='" & UserHS.UserName & "'")(0)%>]</a> ·<a href='?EdaysFlag=2'>支出记录[<%=conn.execute("select count(id) from Edays_ACT where EdaysFlag=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">
					<td width="80" height="25" align="center" class="bg_tr"><strong> 用户名</strong></td>
					<td width="180" height="25" align="center" class="bg_tr"><strong>消费时间</strong></td>
					<td width="113" align="center" class="bg_tr"><strong>IP地址</strong></td>
					<td width="71" height="25" align="center" class="bg_tr"><strong>收入天数</strong></td>
					<td width="74" align="center" class="bg_tr"><strong>支出天数</strong></td>
					<td width="55" height="25" align="center" class="bg_tr"><strong>摘要</strong></td>
					<td width="75" height="25" align="center" class="bg_tr"><strong> 操作员</strong></td>
					<td width="239" align="center" class="bg_tr"><strong>备注</strong></td>
				  </tr>
					<%  If ChkNumeric(s("EdaysFlag"))=1 Or ChkNumeric(s("EdaysFlag"))=2 Then
						  SqlStr="Select ID,UserName,AddDate,IP,Edays,EdaysFlag,User,Descript From Edays_ACT Where EdaysFlag=" & ChkNumeric(s("EdaysFlag")) & " And  UserName='" & UserHS.UserName &"' order by id desc"
 					    Else
						  SqlStr="Select ID,UserName,AddDate,IP,Edays,EdaysFlag,User,Descript From Edays_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 (TotalPut mod MaxPerPage)=0 then
										TotalPages = TotalPut \ MaxPerPage
									else
										TotalPages = TotalPut \ MaxPerPage + 1
									end if
									if CurrentPage > TotalPages then CurrentPage=TotalPages
									if CurrentPage < 1 then CurrentPage=1
									rs.move (CurrentPage-1)*MaxPerPage
									SQL = rs.GetRows(MaxPerPage)
									rs.Close:set rs=Nothing
									ShowContent
						End If
						 %>
					
          </table>
		  </td>
		  </tr>
</table>
		  </TD>
		 </TR>
	</TABLE> 
		  <div align=right style='margin:6px'>
		    <div align="center">
		      <%Call  ShowPagePara(totalPut, MaxPerPage, "", True, "条记录", CurrentPage, "EdaysFlag=" & ChkNumeric(s("EdaysFlag")))
          %>
	          </div>
		  </div>
		  <%
  Sub ShowContent
 Dim i,InEdays,OutEdays
For i=0 To Ubound(SQL,2)
	%>
  <tr height="25"  onMouseOver=overColor(this) onMouseOut=outColor(this)>
    <td width="80" align="center" class="td_bg" ><%=SQL(1,i)%></td>
    <td align="center" class="td_bg"><%=SQL(2,i)%></td>
    <td align="center" class="td_bg"><%=SQL(3,i)%></td>
    <td align="right" class="td_bg"><%if SQL(5,I)=1 Then Response.Write SQL(4,I):InEdays=InEdays+SQL(4,I) ELSE Response.Write "0"%>天</td>
    <td align="right" class="td_bg"><%if SQL(5,I)=2 Then Response.Write SQL(4,I):OutEdays=OutEdays+SQL(4,I) ELSE Response.Write "0"%>天</td>
    <td align="center" class="td_bg"><%if SQL(5,I)=1 Then Response.Write "<font color=red>收入</font>" Else Response.Write "支出"%></td>
    <td align="center" class="td_bg"><%=SQL(6,i)%></td>
	<td class="td_bg"><%=SQL(7,i)%></td>
  </tr>
  <%Next%>
  <tr class='tdbg' onMouseOver=overColor(this) onMouseOut=outColor(this)>    <td colspan='3' align='right'>本页合计：</td>    <td align='right'><%=InEdays%>天</td>    <td align='right'><%=ChkNumeric(OutEdays)%>天</td>    <td colspan='4'>&nbsp;</td>  </tr> 
  <% Dim totalinEdays:totalinEdays=conn.execute("Select sum(Edays) From Edays_ACT where username='" & UserHS.UserName & "'AND EdaysFlag=1")(0)
     Dim TotalOutEdays:TotalOutEdays=conn.execute("Select sum(Edays) From Edays_ACT where username='" & UserHS.UserName & "'AND  EdaysFlag=2")(0)
	 If ChkNumeric(totalInEdays)=0 Then totalInEdays=0
	 If ChkNumeric(TotalOutEdays)=0 Then TotalOutEdays=0
  %>
    <tr class='tdbg' onMouseOver=overColor(this) onMouseOut=outColor(this)>    <td colspan='3' align='right'>所有合计：</td>    <td align='right'><%=ChkNumeric(totalInEdays)%>天</td>    <td align='right'><%=ChkNumeric(totalOutEdays)%>天</td>    <td colspan='4' align='center'>累计还剩：<%=totalInEdays-totalOutEdays%>天</td>  </tr> 

  <%  

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>