<%@ 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"/>
<%!
	ResultSet rs = null;
	ResultSet rsTmp = null;
	String m_type = "";
	String sql = "";
	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"%>
<%
m_type = request.getParameter("m_type");
if(m_type==null || m_type.equals("")) {
	m_type = "hits";
}
sql = "Select * From download Order By " + m_type + " DESC";
rs = conn.executeQuery( sql );
%>
<h2>我的软件仓库-分类显示</h2>
<form action="disp.jsp" method="get">
	请选择类别：
	<Select name="m_type">
		<option value="filename">文件名</option>
		<option value="dateandtime">入库时间</option>
		<option value="hits">下载数量</option>
	</Select>
	<Input type="Submit" Value="查看">
</form>
</Center>
<%
rsTmp = conn.executeQuery("select count(id) as countid from download");
rsTmp.next();
totalPage = (int) Math.floor( rsTmp.getInt("countid") / 10 ) + 1;
if(totalPage == 0) totalPage = 1;
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中的ShowOnePage方法
// ShowOnePage( ResultSet, 页数, 每页记录数)
out.println( rstogbk.ShowOnePage(rs, Page, PageSize) );
%>
<form Action="disp.jsp" Method="GET" name=form1>
<Center>
<% 
   if(Page != 1) {
      out.println("<A HREF=disp.jsp?Page=1>第一页</A>");
      out.println("<A HREF=disp.jsp?Page=" + (Page-1) + ">上一页</A>");
   }
   if(Page != totalPage) {
      out.println("<A HREF=disp.jsp?Page=" + (Page+1) + ">下一页</A>");
      out.println("<A HREF=disp.jsp?Page=" + totalPage + ">最后一页</A>");
   }
%>
  <p>输入页数：<input TYPE="TEXT" Name="Page" SIZE="3"> 页数:<font COLOR="Red"><%=Page%>/<%=totalPage%></font> 
  </p>
</form>
</Center>
</div>
</body>
</html>
