Browse Source

数据展示BUG修改

章政 7 years ago
parent
commit
8d4fb9a85e

+ 1 - 0
UAS_DeviceMonitor/CustomerControl/PagingControl/PageControl.Designer.cs

@@ -145,6 +145,7 @@
             "50"});
             this.PageSize.Size = new System.Drawing.Size(59, 28);
             this.PageSize.TabIndex = 9;
+            this.PageSize.SelectedIndexChanged += new System.EventHandler(this.PageSize_SelectedIndexChanged);
             // 
             // PageCount_label
             // 

+ 7 - 0
UAS_DeviceMonitor/CustomerControl/PagingControl/PageControl.cs

@@ -3,6 +3,7 @@ using System.Windows.Forms;
 using DevExpress.XtraEditors;
 using UAS_DeviceMonitor.DataOperate;
 using UAS_DeviceMonitor.Entity;
+using System.Data;
 
 namespace UAS_DeviceMonitor.CustomerControl.PagingControl
 {
@@ -82,5 +83,11 @@ namespace UAS_DeviceMonitor.CustomerControl.PagingControl
             }
             gridcontrol.DataSource = dh.ExecuteSql("select * from (select RowNum RN, A.* from(" + SQL + ")A) where RN<=" + pagesize * currentpage + "and RN >" + pagesize * (currentpage - 1), "select");
         }
+
+        private void PageSize_SelectedIndexChanged(object sender, EventArgs e)
+        {
+            DataTable dt = (DataTable)dh.ExecuteSql(gridcontrol.GetDataSQL,"select");
+            PageCount.Text = (dt.Rows.Count / int.Parse(PageSize.Text)).ToString();
+        }
     }
 }

+ 13 - 11
UAS_DeviceMonitor/Main.Designer.cs

@@ -133,11 +133,11 @@ namespace UAS_DeviceMonitor
             this.pl_dccode = new DevExpress.XtraGrid.Columns.GridColumn();
             this.pl_remark = new DevExpress.XtraGrid.Columns.GridColumn();
             this.PageDeviceStatus = new DevExpress.XtraTab.XtraTabPage();
+            this.PanelDeviceStatus = new DevExpress.XtraEditors.XtraScrollableControl();
             this.PageWorkCenterStatus = new DevExpress.XtraTab.XtraTabPage();
             this.GridWorkCenterStatus = new UAS_DeviceMonitor.CustomerControl.AutoDataGridControl.AutoDataGridControl();
             this.GridViewWorkCenterStatus = new UAS_DeviceMonitor.CustomerControl.GridViewWithSerialNum.GridViewWithSerialNum();
             this.TimerDeviceStatus = new System.Windows.Forms.Timer(this.components);
-            this.PanelDeviceStatus = new DevExpress.XtraEditors.XtraScrollableControl();
             ((System.ComponentModel.ISupportInitialize)(this.RibbonNav)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.MainTabControl)).BeginInit();
             this.MainTabControl.SuspendLayout();
@@ -329,8 +329,10 @@ namespace UAS_DeviceMonitor
             // 
             // GridDeviceList
             // 
+            this.GridDeviceList.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
+            | System.Windows.Forms.AnchorStyles.Left) 
+            | System.Windows.Forms.AnchorStyles.Right)));
             this.GridDeviceList.Condition = null;
-            this.GridDeviceList.Dock = System.Windows.Forms.DockStyle.Fill;
             this.GridDeviceList.GetDataSQL = null;
             this.GridDeviceList.ID = null;
             this.GridDeviceList.InsertSQL = null;
@@ -339,7 +341,7 @@ namespace UAS_DeviceMonitor
             this.GridDeviceList.MenuManager = this.RibbonNav;
             this.GridDeviceList.Name = "GridDeviceList";
             this.GridDeviceList.RowCount = 0;
-            this.GridDeviceList.Size = new System.Drawing.Size(1027, 577);
+            this.GridDeviceList.Size = new System.Drawing.Size(1027, 545);
             this.GridDeviceList.TabIndex = 0;
             this.GridDeviceList.TableName = null;
             this.GridDeviceList.ViewCollection.AddRange(new DevExpress.XtraGrid.Views.Base.BaseView[] {
@@ -1194,6 +1196,14 @@ namespace UAS_DeviceMonitor
             this.PageDeviceStatus.Text = "xtraTabPage1";
             this.PageDeviceStatus.VisibleChanged += new System.EventHandler(this.PageDeviceStatus_VisibleChanged);
             // 
+            // PanelDeviceStatus
+            // 
+            this.PanelDeviceStatus.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.PanelDeviceStatus.Location = new System.Drawing.Point(0, 0);
+            this.PanelDeviceStatus.Name = "PanelDeviceStatus";
+            this.PanelDeviceStatus.Size = new System.Drawing.Size(1027, 577);
+            this.PanelDeviceStatus.TabIndex = 0;
+            // 
             // PageWorkCenterStatus
             // 
             this.PageWorkCenterStatus.Controls.Add(this.GridWorkCenterStatus);
@@ -1234,14 +1244,6 @@ namespace UAS_DeviceMonitor
             this.TimerDeviceStatus.Interval = 10000;
             this.TimerDeviceStatus.Tick += new System.EventHandler(this.TimerDeviceStatus_Tick);
             // 
-            // PanelDeviceStatus
-            // 
-            this.PanelDeviceStatus.Dock = System.Windows.Forms.DockStyle.Fill;
-            this.PanelDeviceStatus.Location = new System.Drawing.Point(0, 0);
-            this.PanelDeviceStatus.Name = "PanelDeviceStatus";
-            this.PanelDeviceStatus.Size = new System.Drawing.Size(1027, 577);
-            this.PanelDeviceStatus.TabIndex = 0;
-            // 
             // Main
             // 
             this.AllowFormGlass = DevExpress.Utils.DefaultBoolean.False;

+ 14 - 5
UAS_DeviceMonitor/Main.cs

@@ -401,18 +401,24 @@ namespace UAS_DeviceMonitor
             int Count = dt.Rows.Count;
             int RowCount = Count % CountPerRow == 0 ? Count / CountPerRow : Count / CountPerRow + 1;
             PanelDeviceStatus.Controls.Clear();
-            for (int i = 0; i < (CountPerRow < dt.Rows.Count ? CountPerRow : dt.Rows.Count); i++)
+            int LastRowCount = 0;
+            for (int j = 0; j < RowCount; j++)
             {
-                for (int j = 0; j < RowCount; j++)
+                //如果是最后一行则循环尾数
+                if (j == RowCount - 1)
+                {
+                    LastRowCount = Count % CountPerRow;
+                }
+                for (int i = 0; i < (j == RowCount - 1 ? LastRowCount : CountPerRow); i++)
                 {
                     PictureEditWithText pic = new PictureEditWithText();
                     pic.Anchor = AnchorStyles.Left;
                     pic.Anchor = AnchorStyles.Top;
-                    if (dt.Rows[i * CountPerRow + j]["dpc_status"].ToString() != "Running")
+                    if (dt.Rows[j * CountPerRow + i]["dpc_status"].ToString() != "Running")
                         pic.Picedit.Image = Properties.Resources.close_24px_1069872_easyicon_net;
                     else
                         pic.Picedit.Image = Properties.Resources.devicecontrol;
-                    pic.Text = dt.Rows[i * CountPerRow + j]["de_code"].ToString();
+                    pic.Text = dt.Rows[j * CountPerRow + i]["de_code"].ToString();
                     pic.Picedit.BorderStyle = BorderStyles.HotFlat;
                     pic.Location = new Point((10 + RightPadding) / 2 + 110 * i, 10 + j * 130);
                     PanelDeviceStatus.Controls.Add(pic);
@@ -423,7 +429,10 @@ namespace UAS_DeviceMonitor
         //刷新界面
         private void TimerDeviceStatus_Tick(object sender, EventArgs e)
         {
-            ShowDeviceStatus();
+            if (PageDeviceStatus.PageVisible)
+            {
+                ShowDeviceStatus();
+            }
         }
 
         private void PanelDeviceStatus_SizeChanged(object sender, EventArgs e)