using System;
using ;
using ;
using ;
using ;
using ;
using ;
using ;
using ;
using ;
namespace Common
{
public partial class WinFormPager : UserControl
{
public event EventHandler PageChanged; //Event: The current page number of the control has changed.
private int pageSize;
private int curPage;
private int pageCount;
public WinFormPager()
{
InitializeComponent();
}
private void WinFormPager_Load(object sender, EventArgs e)
{
}
/// <summary>
/// [Properties] The number of records displayed per page.
/// </summary>
public int PageSize
{
get
{
if (pageSize <= 0)
{
pageSize = 10;
}
return pageSize;
}
set
{
pageSize = value;
}
}
/// <summary>
/// Current page count
/// </summary>
public int CurPage
{
get
{
if (curPage <= 0)
{
curPage = 1;
}
return curPage;
}
set
{
curPage = value;
if (PageChanged != null)
{
(PageChanged,null);//Trigger the page number change event of the same piece.
}
}
}
/// <summary>
/// [Properties] Total number of pages.
/// </summary>
public int PageCount
{
get
{
if (RecordCount > 0)
{
int pageCount = RecordCount / PageSize;
if (RecordCount % PageSize == 0)
{
pageCount = RecordCount / PageSize;
}
else
{
pageCount = RecordCount / PageSize + 1;
}
return pageCount;
}
else
{
return 0;
}
}
set
{
pageCount = value;
}
}
/// <summary>
/// [Attribute] Total number of records.
/// </summary>
public int RecordCount
{
get;
set;
}
/// <summary>
/// [Properties] Relative to the previous page of the current page
/// </summary>
public int PrevPage
{
get
{
if (CurPage > 1)
{
return CurPage - 1;
}
return 1;
}
}
/// <summary>
/// [Properties] Relative to the next page of the current page
/// </summary>
public int NextPage
{
get
{
if (CurPage < PageCount)
{
return CurPage + 1;
}
return PageCount;
}
}
private void btnFirstPage_Click(object sender, EventArgs e)
{
= 1;
}
private void btnLastPage_Click(object sender, EventArgs e)
{
= ;
}
private void btnNextPage_Click(object sender, EventArgs e)
{
= ;
}
private void btnEndPage_Click(object sender, EventArgs e)
{
= ;
}
private void txtPageNumber_TextChanged(object sender, EventArgs e)
{
if (!(()))
{
("Please enter numbers!");
}
}
private void btnJump_Click(object sender, EventArgs e)
{
if (!(()))//Verify whether the input is a number
{
("Please enter numbers!");
}
else
{
if ((()) > 0)
{
if ((()) < )
{
= (());
}
else
{
= ;
}
}
else
{
= 1;
}
}
}
}
}