分页帮助类

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Ajax.CRUD.Utility
{
    public static class PagerHelper
    {
        #region 数字分页类
        public static string strPage(int intCounts, int intPageSizes, int intPageCounts, int intThisPages, string strUrl)
        {
            int intCount = Convert.ToInt32(intCounts); //总记录数
            int intPageCount = Convert.ToInt32(intPageCounts); //总共页数
            int intPageSize = Convert.ToInt32(intPageSizes); //每页显示
            int intPage = 7;  //数字显示
            int intThisPage = Convert.ToInt32(intThisPages); //当前页数
            int intBeginPage = 0; //开始页数
            int intCrossPage = 0; //变换页数
            int intEndPage = 0; //结束页数
            string strPage = null; //返回值

            intCrossPage = intPage / 2;
                strPage = "共 <font color=\"#FF0000\">" + intCount.ToString() + "</font> 条记录 第 <font color=\"#FF0000\">" + intThisPage.ToString() + "/" + intPageCount.ToString() + "</font> 页 每页 <font color=\"#FF0000\">" + intPageSize.ToString() + "</font> 条 &nbsp;&nbsp;&nbsp;&nbsp;";
                if (intThisPage > 1)
                {
                    strPage = strPage + "<a href=\"" + strUrl + "1\">首页</a> ";
                    strPage = strPage + "<a href=\"" + strUrl + Convert.ToString(intThisPage - 1) + "\">上一页</a> ";
                }
                if (intPageCount > intPage)
                {
                    if (intThisPage > intPageCount - intCrossPage)
                    {
                        intBeginPage = intPageCount - intPage + 1;
                        intEndPage = intPageCount;
                    }
                else
                {
                    if (intThisPage <= intPage - intCrossPage)
                    {
                        intBeginPage = 1;
                        intEndPage = intPage;
                    }
                    else
                    {
                        intBeginPage = intThisPage - intCrossPage;
                        intEndPage = intThisPage + intCrossPage;
                    }
                }
            }
            else
            {
                intBeginPage = 1;
                intEndPage = intPageCount;
            }
            if (intCount > 0)
            {

                for (int i = intBeginPage; i <= intEndPage; i++)
                {
                    if (i == intThisPage)
                    {
                        strPage = strPage + " <font color=\"#FF0000\">" + i.ToString() + "</font> ";
                    }
                    else
                    {
                        strPage = strPage + " <a href=\"" + strUrl + i.ToString() + "\" title=\"第" + i.ToString() + "页\">" + i.ToString() + "</a> ";
                    }
                }
            }
            if (intThisPage < intPageCount)
            {
                strPage = strPage + "<a href=\"" + strUrl + Convert.ToString(intThisPage + 1) + "\">下一页</a> ";
                strPage = strPage + "<a href=\"" + strUrl + intPageCount.ToString() + "\">尾页</a> ";
            }
            return strPage;
        }
        #endregion
    }
}
时间: 2024-08-05 11:09:10

分页帮助类的相关文章

分页工具类及其使用

Pager.java 1 package pers.kangxu.datautils.common; 2 3 import java.io.Serializable; 4 import java.util.List; 5 6 /** 7 * 8 * <b> 分页通用类 </b> 9 * 10 * @author kangxu 11 * @param <T> 12 * 13 */ 14 public class Pager<T> implements Seri

标记页数、页码的实体类(分页实体类)

/** * 标记页数.页码的实体类(分页实体类) */public class PaginationData{ private int recordCount;             // 数据条数总数    private int pageCount;                 // 页面总数    private int index = 1;                 // 当前页    private int pageSize = 10;             // 每页显

c#分页工具类,完美实现List分页

using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace ProjectProgress.BLL { /// <summary> /// 分页工具类 /// </summary> /// <typeparam name="T"></typeparam> public class PagingUtil<T

Java Web的分页工具类

最近写一个java web项目,以前分页的工具类,都是基础架构的人写好了的.也没有去细看,现在遇到这个状况. 就整理一下思路,自己写了一个分页的工具类.写的不好之处,还望斧正. 下面是我的代码: PageUtil.java 1 package util; 2 3 import java.util.Map; 4 5 /** 6 * 分页工具类 7 * @author lyh 8 * 9 */ 10 public class PageUtil { 11 private int total; //总数

php 之 封装分页查询类及其使用方法

分页查询的使用: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="

简单分页计算类

/// <summary> /// 简单分页列表类 /// </summary> public class SimplePagedList { /// <summary> /// 每页页面大小 /// </summary> public int PageSize { get; set; } /// <summary> /// 页面总数 /// </summary> public int TotalCount { get; set; }

分页 工具类 前后台代码 Java JavaScript (ajax) 实现 讲解

[博客园cnblogs笔者m-yb原创, 转载请加本文博客链接,笔者github: https://github.com/mayangbo666,公众号aandb7,QQ群927113708]https://www.cnblogs.com/m-yb/p/9986309.html分页功能的实现可以使用各种插件, 笔者今日闲来无事, 写了 分页工具类 前后台代码 Java JavaScript 的 实现及思路梳理.供大家参考.分页功能的需求一般有: 当前页/每页条数/总页数/总记录数/起始记录数/数

个人常用工具类:分页工具类

import java.io.Serializable; import java.util.List; // 分页工具类 public class PageBean implements Serializable { private static final long serialVersionUID = -8741766802354222579L; private int pageSize = 5; // 每页显示多少条记录 private int currentPage = 1; //当前第

分页工具类 BaseAction

package com.xxxxxxx.bos.web.action.common; import java.io.IOException; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.struts2.Servlet