posts - 495,  comments - 11,  trackbacks - 0

          package com.zh.util;

          import com.zh.conpool.Condata;
          import java.sql.ResultSet;
          import java.sql.SQLException;

          public class page
          {

          ???? ResultSet rs;
          ???? ResultSet rst;
          ???? private int intCountTopic;
          ???? public int intPageSize;
          ???? public int intPageCount;
          ???? public int intPage;
          ???? private String Countsql;
          ???? private String Pagisql;
          ???? private String str;
          ???? private String str_where;
          ???? private String str_parameter;
          ???? private String nowPage;
          ???? private String HttpFile;
          ???? Condata db;

          ???? public page()
          ???? {
          ???????? rs = null;
          ???????? rst = null;
          ???????? intCountTopic = 0;
          ???????? intPage = 0;
          ???????? Countsql = null;
          ???????? Pagisql = null;
          ???????? str = null;
          ???????? str_where = null;
          ???????? str_parameter = "";
          ???????? db = new Condata();
          ???? }

          ???? public static void main(String args[])
          ???? {
          ?????
          ???? }

          ???? public void setPages(int i)
          ???? {
          ???????? intPageSize = i;
          ???? }

          ???? public String getPagisql()
          ???? {
          ???????? return Pagisql;
          ???? }

          ???? public ResultSet setQuerysql(String s, String s1, String s2, String s3)
          ???????? throws SQLException
          ???? {
          ???????? ResultSet resultset = null;
          ???????? nowPage = s3;
          ???????? HttpFile = s2;
          ???????? Countsql = "select count(*) from " + s + " " + s1;
          ???????? Pagisql = "select * from " + s + " " + s1 + " order by id desc";
          ???????? try
          ???????? {
          ???????????? Condata _tmp = db;
          ???????????? Condata.getConnection();
          ???????? }
          ???????? catch(Exception exception)
          ???????? {
          ???????????? exception.getMessage();
          ???????? }
          ???????? try
          ???????? {
          ???????????? resultset = querySql(Countsql, Pagisql);
          ???????? }
          ???????? catch(SQLException sqlexception)
          ???????? {
          ???????????? sqlexception.getMessage();
          ???????? }
          ???????? return resultset;
          ???? }

          ???? public ResultSet querySql(String s, String s1)
          ???????? throws SQLException
          ???? {
          ???????? try
          ???????? {
          ???????????? Condata condata = db;
          ???????????? Condata.getConnection();
          ???????? }
          ???????? catch(Exception exception) { }
          ???????? if(nowPage == null)
          ???????? {
          ???????????? intPage = 1;
          ???????? } else
          ???????? {
          ???????????? intPage = Integer.parseInt(nowPage);
          ???????????? if(intPage < 1)
          ???????????????? intPage = 1;
          ???????? }
          ???????? rs = db.executeQuery(s);
          ???????? if(rs.next())
          ???????????? intCountTopic = rs.getInt(1);
          ???????? intPageCount = intCountTopic % intPageSize == 0 ? intCountTopic / intPageSize : intCountTopic / intPageSize + 1;
          ???????? if(intPage > intPageCount)
          ???????????? intPage = intPageCount;
          ???????? rs.close();
          ???????? rst = db.executeQuery(s1);
          ???????? return rst;
          ???? }

          ???? public int getCountTopic()
          ???? {
          ???????? return intCountTopic;
          ???? }

          ???? public int getPageCount()
          ???? {
          ???????? return intPageCount;
          ???? }

          ???? public int getIntPage()
          ???? {
          ???????? return intPage;
          ???? }

          ???? public String PageFooter()
          ???? {
          ???????? String s = "<form action=" + HttpFile + " name=form1 methord=post>";
          ???????? int i = intPage - 1;
          ???????? int j = intPage + 1;
          ???????? int k = (intPageSize * getIntPage() + 1) - intPageSize;
          ???????? if(k < 0)
          ???????????? k = 0;
          ???????? s = s + "<font style='font-size: 9pt'>\u603B\u8BA1<font color='red'>" + getCountTopic() + "</font>\u6761\u8BB0\u5F55," + "\u3010\u5171<font?? color='red'>" + getPageCount() + "</font>\u9875\u3011";
          ???????? s = s + "\u3010" + intPageSize + "\u6761/\u9875\u3011 \u5F53\u524D\u7B2C<font color='red'>" + getIntPage() + "</font>\u9875(\u5217\u51FA\u7B2C" + k + "\u5230\u7B2C" + getIntPage() * intPageSize + "\u6761) &nbsp; &nbsp; ";
          ???????? if(intPage > 1)
          ???????????? s = s + " <A href=" + HttpFile + "?pages=1" + str_parameter + ">\u9996\u9875</A> ";
          ???????? else
          ???????????? s = s + " \u9996\u9875 ";
          ???????? if(intPage > 1)
          ???????????? s = s + " <A href=" + HttpFile + "?pages=" + i + str_parameter + ">\u4E0A\u4E00\u9875</A> ";
          ???????? else
          ???????????? s = s + " \u4E0A\u4E00\u9875 ";
          ???????? if(intPage < intPageCount)
          ???????????? s = s + " <A href=" + HttpFile + "?pages=" + j + str_parameter + ">\u4E0B\u4E00\u9875</A> ";
          ???????? else
          ???????????? s = s + " \u4E0B\u4E00\u9875 ";
          ???????? if(intPageCount > 1 && intPage != intPageCount)
          ???????????? s = s + " <A href=" + HttpFile + "?pages=" + intPageCount + str_parameter + ">\u5C3E\u9875</A>";
          ???????? else
          ???????????? s = s + " \u5C3E\u9875</font>";
          ???????? s = s + "</form>";
          ???????? return s;
          ???? }

          ???? public void closeConn()
          ???? {
          ???????? db.close();
          ???? }
          }

          posted on 2007-10-02 21:32 jadmin 閱讀(62) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 麻栗坡县| 井陉县| 商丘市| 临夏市| 潼南县| 榆树市| 株洲市| 勐海县| 桓仁| 彭水| 定州市| 雷州市| 保山市| 通海县| 苍南县| 舟山市| 治县。| 滨海县| 清河县| 平利县| 陆川县| 东山县| 新晃| 肥东县| 河北省| 南华县| 黄浦区| 天等县| 临安市| 邵阳市| 潼关县| 巩义市| 宣威市| 阿合奇县| 邵东县| 富顺县| 秀山| 台北市| 九台市| 宁化县| 宝应县|