Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

79 rindas
1.3KB

  1. using System;
  2. namespace HealthMonitor.Util.QueryObjects
  3. {
  4. public class Paging
  5. {
  6. private int _curPage = 1;
  7. /// <summary>
  8. /// 当前页
  9. /// </summary>
  10. public int CurPage
  11. {
  12. get
  13. {
  14. return Math.Min(Math.Max(1, this._curPage), this.PageCount);
  15. }
  16. set
  17. {
  18. this._curPage = value;
  19. }
  20. }
  21. private int _pageSize = 10;
  22. /// <summary>
  23. /// 每页记录数
  24. /// </summary>
  25. public int PageSize
  26. {
  27. get
  28. {
  29. return Math.Max(1, this._pageSize);
  30. }
  31. set
  32. {
  33. this._pageSize = value;
  34. }
  35. }
  36. private int _totalCount = 0;
  37. /// <summary>
  38. /// 总记录数
  39. /// </summary>
  40. public int TotalCount
  41. {
  42. get { return this._totalCount; }
  43. set { this._totalCount = value; }
  44. }
  45. /// <summary>
  46. /// 总页数
  47. /// </summary>
  48. public int PageCount
  49. {
  50. get
  51. {
  52. int cnt = (int)Math.Ceiling((double)_totalCount / _pageSize);
  53. return Math.Max(1, cnt);
  54. }
  55. }
  56. ///// <summary>
  57. ///// 计算排号
  58. ///// </summary>
  59. ///// <param name="idx">索引,以0开始计算</param>
  60. ///// <returns></returns>
  61. //public int CalcSerialNum(int idx)
  62. //{
  63. // if (IsAscendSort)
  64. // {
  65. // return (CurPage - 1) * PageSize + idx + 1;
  66. // }
  67. // else
  68. // {
  69. // return TotalCount - (CurPage - 1) * PageSize - idx;
  70. // }
  71. //}
  72. }
  73. }