package zpxx;
import java.sql.*;
import java.util.ArrayList;
public class pageCount {
//出来输出的html代码
public String StrDispPageTable="";
//脚本文件名
public String PageScriptName="";
//待显示页码
int IntOffset = 1;
//下一页
int IntNext = 0;
//上一页
int IntPrv = 0;
//一页显示的记录数
int intPageSize = 10;
//总页数
public int intPageCount;
//总记录数
private int intRowCount;
public void setpageCount(ResultSet rs) throws SQLException
{
if(rs != null ) {
rs.last();
intRowCount = rs.getRow();
intPageCount = (intRowCount + intPageSize - 1) / intPageSize;
}
}
public void setpageCountList( int arrayRs)
{
if(arrayRs > 0 ) {
intRowCount = arrayRs;
intPageCount = (intRowCount + intPageSize - 1) / intPageSize;
}
}
public void setScriptName(String Strvalue){
PageScriptName = Strvalue;
}
public void setPageSize(int value){
intPageSize = value;
intPageCount = (intRowCount + intPageSize - 1) / intPageSize;
}
public void setCurrentPage(int value){
IntOffset = value;
IntNext = IntOffset + 1;
IntPrv = IntOffset - 1;
}
private int getTotalPages(){
return intPageCount;
}
private int getPageNext(){
return IntNext;
}
private int getPagePrv(){
return IntPrv;
}
private int getPageSize(){
return intPageSize;
}
private int getCurrentPage() {
return IntOffset;
}
public String getHtmlPageCount() {
int Ipagenext = getPageNext();
int Ipageprv = getPagePrv();
int Ipages = getTotalPages();
int IPS = getPageSize();
int Icurpagenum = getCurrentPage();
StrDispPageTable += "<table width=/"68%/" border=/"0/" cellspacing=/"0/" cellpadding=/"0/">";
StrDispPageTable += "<tr align=/"center/">";
if(IntOffset > 1) {
StrDispPageTable += "<td width=/"5%/"><font face=/"Webdings/"><a href=/"" + PageScriptName +"?IRP=" + IPS +"&offset=1/">9</a></font></td>";}
else {
StrDispPageTable += "<td width=/"5%/"><font face=/"Webdings/">9</font></td>";
}
if(IntOffset > 1) {
StrDispPageTable += "<td width=/"5%/"><font face=/"Webdings/"><a href=/""+ PageScriptName +"?IRP="+ IPS +"&offset="+ Ipageprv +"/">7</a></font></td>";}
else {
StrDispPageTable += "<td width=/"5%/"><font face=/"Webdings/">7</font></td>";
}
StrDispPageTable += "<td width=/"10%/">[<font color=/"#FF0000/">"+ Icurpagenum +"</font>]</td>";
if(IntOffset < intPageCount) {
StrDispPageTable += "<td width=/"5%/"><font face=/"Webdings/"><a href=/""+ PageScriptName +"?IRP="+ IPS +"&offset="+ Ipagenext +"/">8</a></font></td>";}
else {
StrDispPageTable += "<td width=/"5%/"><font face=/"Webdings/">8</font></td>";
}
if(IntOffset < intPageCount) {
StrDispPageTable += "<td width=/"5%/"><font face=/"Webdings/"><a href=/""+ PageScriptName +"?IRP="+ IPS +"&offset="+ intPageCount +"/">:</a></font></td>";}
else {
StrDispPageTable += "<td width=/"5%/"><font face=/"Webdings/">:</font></td>";
}
StrDispPageTable += "<td> 跳转到";
StrDispPageTable += "<select name=/"menu1/" onChange=/"MM_jumpMenu('self',this,0)/">";
StrDispPageTable += "<option value=/""+ PageScriptName +"/">..</option>";
for(int i=1;i<=Ipages;i++) {
StrDispPageTable += "<option value=/""+ PageScriptName +"?IRP="+ IPS +"&offset=" + i +"/">"+ i +"</option>";
}
StrDispPageTable += "</select> 页 </td>";
StrDispPageTable += "<td>共"+ Ipages +"页/每页显示";
StrDispPageTable += "<select name=/"menu2/" size=/"1/" onChange=/"MM_jumpMenu('self',this,0)/">";
if(intPageSize == 10)
StrDispPageTable += "<option value=/""+ PageScriptName +"?IRP=10/" selected>10</option>";
else {
StrDispPageTable += "<option value=/""+ PageScriptName +"?IRP=10/">10</option>";}
if(intPageSize == 20)
StrDispPageTable += "<option value=/""+ PageScriptName +"?IRP=20/" selected>20</option>";
else
StrDispPageTable += "<option value=/""+ PageScriptName +"?IRP=20/">20</option>";
if(intPageSize == 30)
StrDispPageTable += "<option value=/""+ PageScriptName +"?IRP=30/" selected>30</option>";
else
StrDispPageTable += "<option value=/""+ PageScriptName +"?IRP=30/">30</option>";
if(intPageSize == 40)
StrDispPageTable += "<option value=/""+ PageScriptName +"?IRP=40/" selected>40</option>";
else
StrDispPageTable += "<option value=/""+ PageScriptName +"?IRP=40/">40</option>";
if(intPageSize == 50)
StrDispPageTable += "<option value=/""+ PageScriptName +"?IRP=50/" selected>50</option>";
else
StrDispPageTable += "<option value=/""+ PageScriptName +"?IRP=50/">50</option>";
if(intPageSize == 100)
StrDispPageTable += "<option value=/""+ PageScriptName +"?IRP=100/" selected>100</option>";
else
StrDispPageTable += "<option value=/""+ PageScriptName +"?IRP=100/">100</option>";
StrDispPageTable += "</select>条记录</td>";
StrDispPageTable += "</tr></table>";
return StrDispPageTable;
}
}