| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- using System;
- using System.Windows.Forms;
- using DevExpress.XtraEditors;
- using UAS_DeviceMonitor.DataOperate;
- using UAS_DeviceMonitor.Entity;
- namespace UAS_DeviceMonitor.CustomerControl.PagingControl
- {
- public partial class PageControl : UserControl
- {
- DataHelper dh = SystemInf.dh;
- private AutoDataGridControl.AutoDataGridControl gridcontrol;
- public AutoDataGridControl.AutoDataGridControl Gridcontrol
- {
- get
- {
- return gridcontrol;
- }
- set
- {
- gridcontrol = value;
- }
- }
- public PageControl()
- {
- InitializeComponent();
- }
- private void PageControl_Load(object sender, EventArgs e)
- {
- gridcontrol.VisibleChanged += Gridcontrol_VisibleChanged;
- }
- private void Gridcontrol_VisibleChanged(object sender, EventArgs e)
- {
- PageCount.Text = (gridcontrol.RowCount / int.Parse(PageSize.Text) + 1).ToString();
- }
- private void GoPage_Click(object sender, EventArgs e)
- {
- SimpleButton button = sender as SimpleButton;
- string SQL = gridcontrol.GetDataSQL;
- int pagesize = int.Parse(PageSize.Text);
- int currentpage = int.Parse(CurrentPage.Text);
- int rowcount = gridcontrol.RowCount;
- switch (button.Name)
- {
- case "GoFirstPage":
- CurrentPage.Text = "1";
- currentpage = 1;
- break;
- case "GoFormerPage":
- if (currentpage == 1)
- {
- MessageBox.Show("当前已经是第一页");
- return;
- }
- CurrentPage.Text = (currentpage - 1).ToString();
- currentpage = currentpage - 1;
- break;
- case "GoNextPage":
- if (currentpage.ToString() == PageCount.Text)
- {
- MessageBox.Show("当前已经是最后一页");
- return;
- }
- CurrentPage.Text = (currentpage + 1).ToString();
- currentpage = currentpage + 1;
- break;
- case "GoLastPage":
- CurrentPage.Text = ((rowcount / pagesize) + 1).ToString();
- currentpage = int.Parse(PageCount.Text);
- break;
- default:
- break;
- }
- gridcontrol.DataSource = dh.ExecuteSql("select * from (select RowNum RN, A.* from(" + SQL + ")A) where RN<=" + pagesize * currentpage + "and RN >" + pagesize * (currentpage - 1), "select");
- }
- }
- }
|