<!--#include file="../conn.asp"-->
<!--#include file="admin_check.asp"-->
<!--#include file="../inc/Function.asp"-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>管理页面</title>
<link id="maincss" rel="stylesheet" href="images/css/admin_style_<%= AdminSkin %>.css" type="text/css" media="all" /></head>
<body leftmargin="0" bottommargin="0" rightmargin="0" topmargin="5" marginheight="0" marginwidth="0" bgcolor="#DDEEFF">
<%
Call chkFlag(15)
Dim act
act=Trim(Request.QueryString("act"))
opendb
Select Case act
	Case "del"
	  Call del()
	Case else
	   Call Main()
End Select
closedb

Sub Del()
   IF DataType=0 Then
      Conn.execute("Delete from "&predb&"Details where DateDiff("&Sday&",AddTime,now())>Day(now())")
   Else
      Conn.execute("Delete from "&predb&"Details where DateDiff("&Sday&",AddTime,Getdate())>Day(Getdate())")
   End IF
   
   Call SendMsg("清除积分明细成功！")
   Response.Write("<script>setTimeout(""window.parent.leftFrame.location.reload();location.href='?'"",2000)</script>")
End Sub

Sub Main()
dim rs,i,rs1,sql,c
Dim idcount,maxperpage,n,page,minid
maxperpage=25
page=clng(Request.QueryString("page"))
        set rs=conn.execute("select count(id) from "&predb&"Details")
		idcount=rs(0) 
		set rs=nothing
		
		If idcount Mod maxperpage = 0 Then
			n = idcount \ maxperpage
		else
			n = idcount \ maxperpage + 1
		end If
		
IF page>n then page=n
IF page<1 then page=1

		if page=1 then
           set rs=conn.execute("select top "&maxperpage&" * from "&predb&"Details order by id desc")
		else
			set rs1=conn.execute("select min(id) from (select top "&(page-1)*maxperpage&" id from "&predb&"Details order by id desc) d")
			    minid=rs1(0)
			set rs1=nothing
			set rs=conn.execute("select top "&maxperpage&" * from "&predb&"Details where id<"&minid&" order by id desc")
		end if
%>
<table class="tableBorder" cellspacing="1" cellpadding="2" width="96%" align="center" border="0">
  <tr>
	<th height="25" colspan="5" align="left">积分明细管理</th>
  </tr>
  <tr>
    <td width="10%" align="center" class="TableRow1"><strong>排列</strong></td>
    <td align="center" class="TableRow1"><strong>积分项目说明</strong></td>
    <td width="11%" align="center" class="TableRow1"><strong>分值</strong></td>
    <td width="17%" align="center" class="TableRow1"><strong>获分者</strong></td>
    <td width="18%" align="center" class="TableRow1"><strong>积分时间</strong></td>
  </tr>
  <%
  do while not rs.eof
i=i+1
if i mod 2=0 then
  c=1
else
  c=2
end if
  %>
  <tr>
    <td align="center" class="TableRow<%= c %>"><b><%= i %></b></td>
    <td class="TableRow<%= c %>"><%= rs("mTitle") %></td>
    <td align="center" class="TableRow<%= c %>"><%= rs("FenZ") %></td>
    <td class="TableRow<%= c %>">
    <%
	set rs1=conn.execute("select userid from "&predb&"user where id="&rs("uid"))
	    Response.Write(rs1("userid"))
	set rs1=nothing
	%>
    </td>
    <td align="center" class="TableRow<%= c %>"><%= rs("addtime") %></td>
  </tr>
  <% 
  rs.movenext
  loop
  %>
  <tr>
    <td colspan="7" align="center" class="TableRow1">共<b><%= idcount %></b>则 <font color="#FF0000"><%= page %></font>/<%= n %>页&nbsp;&nbsp; <a href="?page=1">首页</a>&nbsp;&nbsp; <a href="?page=<%= page-1 %>">上一页</a>&nbsp;&nbsp; <a href="?page=<%= page+1 %>">下一页</a>&nbsp;&nbsp; <a href="?page=<%= n %>">尾页</a></td>
  </tr>
  <tr>
    <td colspan="5" class="TableRow1">
      <input type="button" name="button" id="button" value="清理积分记录" onClick="location.href='?act=del'">
    </td>
  </tr>
</table>
<%
set rs=nothing
End Sub
%>
<br>
</body>
</html>
