| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- 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)
- {
- if (gridcontrol != null)
- 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");
- }
- }
- }
|