<%@ page contentType="text/html;charset=GBK" %>
<%@ page language="java" import="java.sql.*" %>
<%@ page import="java.lang.Math.*" %>
<jsp:useBean id="conn" scope="page" class="download.conn"/>
<jsp:useBean id="rstogbk" scope="page" class="download.RsToGbk"/>
<%
  if( session.getAttribute("login") == null )  {
%>
      <jsp:forward page="login.jsp"/>
<%
  }
%>     
<%!
	ResultSet rs = null;
	ResultSet rsTmp = null;
	String m_type = "";
	String m_key = "";
	String sql = "";
	String sql1 = "";
	String sqltmp = "";
	int PageSize = 10;
	int Page = 1;
	int totalPage = 1;
%>
<html>
<head>
	<title>软件仓库--系统维护</title>
	<Link rel="stylesheet" type="text/css" href="style.css">
</head>
<body TEXT="#000000" BGCOLOR="#FFFFFF" BACKGROUND="b01.jpg">
<Center>
<%@include file="title.htm"%>
<%
sql = "Select * From download Order By hits DESC";
rs = conn.executeQuery ( sql );
%>
<h2>软件仓库-系统维护</h2>
<%
rsTmp = conn.executeQuery("select count(id) as countid from download");
rsTmp.next();
int totalrecord = rsTmp.getInt("countid");
if(totalrecord % PageSize ==0) totalPage = totalrecord / PageSize;  // 如果是当前页码的整数倍
else  totalPage = (int) Math.floor( totalrecord / PageSize ) + 1;   // 如果最后还空余一页
if(totalPage == 0) totalPage = 1;
rsTmp.close();
PageSize = 10;
if(request.getParameter("Page")==null || request.getParameter("Page").equals(""))
   Page = 1;
else
   Page = Integer.parseInt(request.getParameter("Page"));
if(Page < 1)  Page = 1;
if(Page > totalPage) Page = totalPage;
// 下面调用在RsToGbk中的Xtwh方法
// Xtwh( ResultSet, 页数, 每页记录数)
//out.println( rstogbk.Xt
out.println(rstogbk.Xtwh(rs, Page, PageSize) );
%>
<form Action="xtwh.jsp" Method="GET" name=form1>
<Center>
<% 
   if(Page != 1) {
      out.println("<A HREF=xtwh.jsp?Page=1>第一页</A>");
      out.println("<A HREF=xtwh.jsp?Page=" + (Page-1) + ">上一页</A>");
   }
   if(Page != totalPage) {
      out.println("<A HREF=xtwh.jsp?Page=" + (Page+1) + ">下一页</A>");
      out.println("<A HREF=xtwh.jsp?Page=" + totalPage + ">最后一页</A>");
   }
%>
  <p>输入页数：<input TYPE="TEXT" Name="Page" SIZE="3"> 页数:<font COLOR="Red"><%=Page%>/<%=totalPage%></font> 
  </p>
</form></Center></div></body></html>
