Explorar el Código

Merge branch 'master' of ssh://10.10.100.21/source/mes-client

Hcsy hace 6 años
padre
commit
dad6fc6847

+ 7 - 11
UAS_DeviceMonitor/CustomerControl/Button/ButtonDeleteRow.cs

@@ -1,14 +1,9 @@
 using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Drawing;
-using System.Data;
-using System.Linq;
-using System.Text;
 using System.Windows.Forms;
 using DevExpress.XtraEditors;
 using DevExpress.XtraGrid.Views.Grid;
 using UAS_DeviceMonitor.Entity;
+using System.Collections.Generic;
 
 namespace UAS_DeviceMonitor.CustomerControl.Button
 {
@@ -40,17 +35,18 @@ namespace UAS_DeviceMonitor.CustomerControl.Button
             if (grid != null)
             {
                 GridView view = grid.MainView as GridView;
-                int[] DeleteID = view.GetSelectedRows();
-                for (int i = 0; i < DeleteID.Length; i++)
+                List<int> DeleteID = new List<int>();
+                for (int i = 0; i < view.RowCount; i++)
                 {
-                    DeleteID[i] = int.Parse(view.GetRowCellValue(i, grid.ID.ToUpper()).ToString());
+                    if (view.GetRowCellValue(i, SystemInf.CheckedColumnName).ToString() != "0")
+                        DeleteID.Add(int.Parse(view.GetRowCellValue(i, grid.ID.ToUpper()).ToString()));
                 }
-                if (DeleteID.Length > 0)
+                if (DeleteID.Count > 0)
                 {
                     DialogResult result = XtraMessageBox.Show("确认删除", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                     if (result.ToString() == "Yes")
                     {
-                        SystemInf.dh.DeleteDataByID(grid.TableName, grid.ID, DeleteID);
+                        SystemInf.dh.DeleteDataByID(grid.TableName, grid.ID, DeleteID.ToArray());
                         grid.RefreshData();
                     }
                 }

+ 3 - 0
UAS_DeviceMonitor/CustomerControl/GridViewWithSerialNum/GridViewWithSerialNum.Designer.cs

@@ -32,7 +32,10 @@
             // 
             // GridViewWithSerialNum
             // 
+            this.CustomDrawColumnHeader += new DevExpress.XtraGrid.Views.Grid.ColumnHeaderCustomDrawEventHandler(this.GridViewWithSerialNum_CustomDrawColumnHeader);
             this.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler(this.GridViewWithSerialNum_CustomDrawRowIndicator);
+            this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.GridViewWithSerialNum_MouseDown);
+            this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.GridViewWithSerialNum_MouseUp);
             ((System.ComponentModel.ISupportInitialize)(this)).EndInit();
 
         }

+ 152 - 2
UAS_DeviceMonitor/CustomerControl/GridViewWithSerialNum/GridViewWithSerialNum.cs

@@ -1,15 +1,32 @@
-using DevExpress.XtraGrid.Views.Grid;
+using DevExpress.XtraEditors;
+using DevExpress.XtraGrid.Columns;
+using DevExpress.XtraGrid.Views.Grid;
+using DevExpress.XtraGrid.Views.Grid.ViewInfo;
+using System.Drawing;
+using System.Windows.Forms;
+using System.Windows.Forms.VisualStyles;
+using UAS_DeviceMonitor.Entity;
 
 namespace UAS_DeviceMonitor.CustomerControl.GridViewWithSerialNum
 {
     public partial class GridViewWithSerialNum : GridView
     {
+
+        private Rectangle checkBoxColumnHeaderRect = Rectangle.Empty;
+
+        private GridColumn checkBoxColumn = null;
+
         public GridViewWithSerialNum()
         {
             InitializeComponent();
             IndicatorWidth = 30;
         }
 
+        /// <summary>
+        /// 绘制行号
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
         private void GridViewWithSerialNum_CustomDrawRowIndicator(object sender, RowIndicatorCustomDrawEventArgs e)
         {
             if (e.Info.IsRowIndicator && e.RowHandle >= 0)
@@ -17,5 +34,138 @@ namespace UAS_DeviceMonitor.CustomerControl.GridViewWithSerialNum
                 e.Info.DisplayText = (e.RowHandle + 1).ToString();
             }
         }
+
+        /// <summary>
+        /// 绘制指定的列头的CheckBox
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void GridViewWithSerialNum_CustomDrawColumnHeader(object sender, ColumnHeaderCustomDrawEventArgs e)
+        {
+            if (e.Column != null && e.Column.FieldName == SystemInf.CheckedColumnName)
+            {
+                checkBoxColumnHeaderRect = e.Bounds;
+                checkBoxColumn = e.Column;
+                e.Column.Caption = " ";
+                //须把列头标题设置为空
+                e.Painter.DrawObject(e.Info);
+                //在列头中心显示复选框
+                int x = e.Bounds.X + (int)((e.Bounds.Width - CheckBoxRenderer.GetGlyphSize(e.Graphics, CheckBoxState.UncheckedNormal).Width) * 0.5);
+                int y = e.Bounds.Y + (int)((e.Bounds.Height - CheckBoxRenderer.GetGlyphSize(e.Graphics, CheckBoxState.UncheckedNormal).Height) * 0.5);
+                Point location = new Point(x, y);
+                CheckBoxState checkBoxState;
+                if (e.Column.Tag != null && e.Column.Tag.ToString() == "1")
+                    checkBoxState = CheckBoxState.CheckedPressed;
+                else
+                    checkBoxState = CheckBoxState.UncheckedNormal;
+                CheckBoxRenderer.DrawCheckBox(e.Graphics, location, checkBoxState);
+                e.Handled = true;
+            }
+        }
+
+        /// <summary>
+        /// 执行全部勾选或者全部不勾选
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void GridViewWithSerialNum_MouseDown(object sender, MouseEventArgs e)
+        {
+            SyncCheckStatus(this, SystemInf.CheckedColumnName, e);
+        }
+
+        /// <summary>
+        /// 绘制列头的CheckBox
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void GridViewWithSerialNum_MouseUp(object sender, MouseEventArgs e)
+        {
+            if (checkBoxColumnHeaderRect != Rectangle.Empty)
+            {
+                if (e.X > checkBoxColumnHeaderRect.X && e.X < (checkBoxColumnHeaderRect.X + checkBoxColumnHeaderRect.Width) && e.Y > checkBoxColumnHeaderRect.Y && e.Y < (checkBoxColumnHeaderRect.Y + checkBoxColumnHeaderRect.Height))
+                {
+                    if (checkBoxColumn.Tag != null && checkBoxColumn.Tag.ToString() == "1" && CheckRowCount == RowCount)
+                        checkBoxColumn.Tag = "0";
+                    //在这写未全选逻辑
+                    else
+                        checkBoxColumn.Tag = "1";
+                    //在这写全选逻辑
+                    //InvalidateColumnHeader(checkBoxColumn);
+                }
+            }
+        }
+        /// <summary>
+        /// GridViewWithSerialNum_MouseUp事件最后执行,提前记录勾选的行号,防止后面统计错误
+        /// </summary>
+        static int CheckRowCount;
+        public static void SyncCheckStatus(GridView view, string fieldeName, MouseEventArgs e)
+        {
+            if (e.Button == MouseButtons.Left)
+            {
+                view.ClearSorting();
+                view.PostEditor();
+                GridHitInfo _info;
+                Point _pt = view.GridControl.PointToClient(Control.MousePosition);
+                _info = view.CalcHitInfo(_pt);
+                if (_info.InColumn && _info.Column.FieldName.Equals(fieldeName))
+                {
+                    CheckRowCount = getCheckedCount(view, fieldeName);
+                    if (CheckRowCount == view.DataRowCount)
+                        UnChekAll(view, fieldeName);
+                    else
+                        CheckAll(view, fieldeName);
+                }
+            }
+        }
+
+        /// <summary>
+        /// 通过勾选的行数和总行数来判断下一次点击是否全部勾选
+        /// </summary>
+        /// <param name="view"></param>
+        /// <param name="filedName"></param>
+        /// <returns></returns>
+        private static int getCheckedCount(GridView view, string filedName)
+        {
+            int count = 0;
+            for (int i = 0; i < view.DataRowCount; i++)
+            {
+                object _cellValue = view.GetRowCellValue(i, view.Columns[filedName]);
+                if (_cellValue == null) continue;
+                if (string.IsNullOrEmpty(_cellValue.ToString().Trim())) continue;
+                bool _checkStatus = false;
+                if (bool.TryParse(_cellValue.ToString() == "0" ? "false" : "true", out _checkStatus))
+                {
+                    if (_checkStatus)
+                        count++;
+                }
+            }
+            return count;
+        }
+
+        /// <summary>
+        /// 设置全选
+        /// </summary>
+        /// <param name="view"></param>
+        /// <param name="fieldName"></param>
+        private static void CheckAll(GridView view, string fieldName)
+        {
+            for (int i = 0; i < view.DataRowCount; i++)
+            {
+                view.SetRowCellValue(i, fieldName, true);
+            }
+        }
+
+        /// <summary>
+        /// 设置全部不选 
+        /// </summary>
+        /// <param name="view"></param>
+        /// <param name="fieldName"></param>
+        private static void UnChekAll(GridView view, string fieldName)
+        {
+            for (int i = 0; i < view.DataRowCount; i++)
+            {
+                view.SetRowCellValue(i, fieldName, false);
+            }
+        }
     }
-}
+}

+ 2 - 0
UAS_DeviceMonitor/Entity/SystemInf.cs

@@ -41,5 +41,7 @@ namespace UAS_DeviceMonitor.Entity
         public static bool UpperCollection = true;
 
         public static DataOperate.DataHelper dh;
+
+        public static string CheckedColumnName = "CHECKEDCOLUMN";
     }
 }

+ 135 - 10
UAS_DeviceMonitor/Main.Designer.cs

@@ -68,6 +68,7 @@ namespace UAS_DeviceMonitor
             this.ButtonSaveCommand = new UAS_DeviceMonitor.CustomerControl.Button.ButtonSaveGrid();
             this.GridCommandSetting = new UAS_DeviceMonitor.CustomerControl.AutoDataGridControl.AutoDataGridControl();
             this.GridViewCommandSet = new UAS_DeviceMonitor.CustomerControl.GridViewWithSerialNum.GridViewWithSerialNum();
+            this.CommandSetCheckedColumn = new DevExpress.XtraGrid.Columns.GridColumn();
             this.CheckEditCommandSet = new DevExpress.XtraEditors.Repository.RepositoryItemCheckEdit();
             this.dc_id = new DevExpress.XtraGrid.Columns.GridColumn();
             this.dc_code = new DevExpress.XtraGrid.Columns.GridColumn();
@@ -83,10 +84,18 @@ namespace UAS_DeviceMonitor
             this.ButtonStartPolling = new DevExpress.XtraEditors.SimpleButton();
             this.GridPollingSetting = new UAS_DeviceMonitor.CustomerControl.AutoDataGridControl.AutoDataGridControl();
             this.GridViewPollSetting = new UAS_DeviceMonitor.CustomerControl.GridViewWithSerialNum.GridViewWithSerialNum();
+            this.PollSettingCheckedColumn = new DevExpress.XtraGrid.Columns.GridColumn();
             this.dpc_enableCheckEdit = new DevExpress.XtraEditors.Repository.RepositoryItemCheckEdit();
             this.dpc_id = new DevExpress.XtraGrid.Columns.GridColumn();
             this.dpc_decode = new DevExpress.XtraGrid.Columns.GridColumn();
             this.dpc_plcode = new DevExpress.XtraGrid.Columns.GridColumn();
+            this.PollSettingItemSearchLookUpEdit = new DevExpress.XtraEditors.Repository.RepositoryItemSearchLookUpEdit();
+            this.PollSettingItemSearchLookUpEditView = new DevExpress.XtraGrid.Views.Grid.GridView();
+            this.gridColumn1 = new DevExpress.XtraGrid.Columns.GridColumn();
+            this.gridColumn2 = new DevExpress.XtraGrid.Columns.GridColumn();
+            this.gridColumn3 = new DevExpress.XtraGrid.Columns.GridColumn();
+            this.gridColumn4 = new DevExpress.XtraGrid.Columns.GridColumn();
+            this.gridColumn5 = new DevExpress.XtraGrid.Columns.GridColumn();
             this.dpc_plname = new DevExpress.XtraGrid.Columns.GridColumn();
             this.dpc_interval = new DevExpress.XtraGrid.Columns.GridColumn();
             this.dpc_dccode = new DevExpress.XtraGrid.Columns.GridColumn();
@@ -102,6 +111,7 @@ namespace UAS_DeviceMonitor
             this.ButtonSavePolling = new UAS_DeviceMonitor.CustomerControl.Button.ButtonSaveGrid();
             this.GridPolling = new UAS_DeviceMonitor.CustomerControl.AutoDataGridControl.AutoDataGridControl();
             this.GridViewPolling = new UAS_DeviceMonitor.CustomerControl.GridViewWithSerialNum.GridViewWithSerialNum();
+            this.PollingCheckedColumn = new DevExpress.XtraGrid.Columns.GridColumn();
             this.pl_id = new DevExpress.XtraGrid.Columns.GridColumn();
             this.pl_code = new DevExpress.XtraGrid.Columns.GridColumn();
             this.pl_name = new DevExpress.XtraGrid.Columns.GridColumn();
@@ -123,6 +133,8 @@ namespace UAS_DeviceMonitor
             ((System.ComponentModel.ISupportInitialize)(this.GridPollingSetting)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.GridViewPollSetting)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.dpc_enableCheckEdit)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.PollSettingItemSearchLookUpEdit)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.PollSettingItemSearchLookUpEditView)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.PollingSetItemLookUpEdit)).BeginInit();
             this.PagePolling.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.GridPolling)).BeginInit();
@@ -486,6 +498,7 @@ namespace UAS_DeviceMonitor
             // GridViewCommandSet
             // 
             this.GridViewCommandSet.Columns.AddRange(new DevExpress.XtraGrid.Columns.GridColumn[] {
+            this.CommandSetCheckedColumn,
             this.dc_id,
             this.dc_code,
             this.dc_name,
@@ -493,8 +506,17 @@ namespace UAS_DeviceMonitor
             this.GridViewCommandSet.GridControl = this.GridCommandSetting;
             this.GridViewCommandSet.IndicatorWidth = 30;
             this.GridViewCommandSet.Name = "GridViewCommandSet";
-            this.GridViewCommandSet.OptionsSelection.MultiSelect = true;
-            this.GridViewCommandSet.OptionsSelection.MultiSelectMode = DevExpress.XtraGrid.Views.Grid.GridMultiSelectMode.CheckBoxRowSelect;
+            // 
+            // CommandSetCheckedColumn
+            // 
+            this.CommandSetCheckedColumn.Caption = " ";
+            this.CommandSetCheckedColumn.ColumnEdit = this.CheckEditCommandSet;
+            this.CommandSetCheckedColumn.FieldName = "CHECKEDCOLUMN";
+            this.CommandSetCheckedColumn.Name = "CommandSetCheckedColumn";
+            this.CommandSetCheckedColumn.OptionsColumn.AllowSort = DevExpress.Utils.DefaultBoolean.False;
+            this.CommandSetCheckedColumn.Tag = "0";
+            this.CommandSetCheckedColumn.Visible = true;
+            this.CommandSetCheckedColumn.VisibleIndex = 0;
             // 
             // CheckEditCommandSet
             // 
@@ -628,7 +650,8 @@ namespace UAS_DeviceMonitor
             this.GridPollingSetting.Name = "GridPollingSetting";
             this.GridPollingSetting.RepositoryItems.AddRange(new DevExpress.XtraEditors.Repository.RepositoryItem[] {
             this.dpc_enableCheckEdit,
-            this.PollingSetItemLookUpEdit});
+            this.PollingSetItemLookUpEdit,
+            this.PollSettingItemSearchLookUpEdit});
             this.GridPollingSetting.RowCount = 0;
             this.GridPollingSetting.Size = new System.Drawing.Size(1027, 544);
             this.GridPollingSetting.TabIndex = 0;
@@ -639,6 +662,7 @@ namespace UAS_DeviceMonitor
             // GridViewPollSetting
             // 
             this.GridViewPollSetting.Columns.AddRange(new DevExpress.XtraGrid.Columns.GridColumn[] {
+            this.PollSettingCheckedColumn,
             this.dpc_id,
             this.dpc_decode,
             this.dpc_plcode,
@@ -653,10 +677,21 @@ namespace UAS_DeviceMonitor
             this.GridViewPollSetting.GridControl = this.GridPollingSetting;
             this.GridViewPollSetting.IndicatorWidth = 30;
             this.GridViewPollSetting.Name = "GridViewPollSetting";
-            this.GridViewPollSetting.OptionsSelection.MultiSelect = true;
             this.GridViewPollSetting.OptionsSelection.MultiSelectMode = DevExpress.XtraGrid.Views.Grid.GridMultiSelectMode.CheckBoxRowSelect;
             this.GridViewPollSetting.CellValueChanging += new DevExpress.XtraGrid.Views.Base.CellValueChangedEventHandler(this.GridViewPollSetting_CellValueChanging);
             // 
+            // PollSettingCheckedColumn
+            // 
+            this.PollSettingCheckedColumn.Caption = " ";
+            this.PollSettingCheckedColumn.ColumnEdit = this.dpc_enableCheckEdit;
+            this.PollSettingCheckedColumn.FieldName = "CHECKEDCOLUMN";
+            this.PollSettingCheckedColumn.Name = "PollSettingCheckedColumn";
+            this.PollSettingCheckedColumn.OptionsColumn.AllowSort = DevExpress.Utils.DefaultBoolean.False;
+            this.PollSettingCheckedColumn.OptionsFilter.AllowFilter = false;
+            this.PollSettingCheckedColumn.Tag = "0";
+            this.PollSettingCheckedColumn.Visible = true;
+            this.PollSettingCheckedColumn.VisibleIndex = 0;
+            // 
             // dpc_enableCheckEdit
             // 
             this.dpc_enableCheckEdit.AutoHeight = false;
@@ -685,12 +720,75 @@ namespace UAS_DeviceMonitor
             // dpc_plcode
             // 
             this.dpc_plcode.Caption = "业务编号";
+            this.dpc_plcode.ColumnEdit = this.PollSettingItemSearchLookUpEdit;
             this.dpc_plcode.FieldName = "DPC_PLCODE";
             this.dpc_plcode.Name = "dpc_plcode";
             this.dpc_plcode.Visible = true;
             this.dpc_plcode.VisibleIndex = 2;
             this.dpc_plcode.Width = 90;
             // 
+            // PollSettingItemSearchLookUpEdit
+            // 
+            this.PollSettingItemSearchLookUpEdit.AutoHeight = false;
+            this.PollSettingItemSearchLookUpEdit.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
+            new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
+            this.PollSettingItemSearchLookUpEdit.Name = "PollSettingItemSearchLookUpEdit";
+            this.PollSettingItemSearchLookUpEdit.NullText = "";
+            this.PollSettingItemSearchLookUpEdit.View = this.PollSettingItemSearchLookUpEditView;
+            // 
+            // PollSettingItemSearchLookUpEditView
+            // 
+            this.PollSettingItemSearchLookUpEditView.Columns.AddRange(new DevExpress.XtraGrid.Columns.GridColumn[] {
+            this.gridColumn1,
+            this.gridColumn2,
+            this.gridColumn3,
+            this.gridColumn4,
+            this.gridColumn5});
+            this.PollSettingItemSearchLookUpEditView.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.RowFocus;
+            this.PollSettingItemSearchLookUpEditView.Name = "PollSettingItemSearchLookUpEditView";
+            this.PollSettingItemSearchLookUpEditView.OptionsSelection.EnableAppearanceFocusedCell = false;
+            this.PollSettingItemSearchLookUpEditView.OptionsView.ShowGroupPanel = false;
+            // 
+            // gridColumn1
+            // 
+            this.gridColumn1.Caption = "业务编号";
+            this.gridColumn1.FieldName = "PL_CODE";
+            this.gridColumn1.Name = "gridColumn1";
+            this.gridColumn1.Visible = true;
+            this.gridColumn1.VisibleIndex = 0;
+            // 
+            // gridColumn2
+            // 
+            this.gridColumn2.Caption = "业务名称";
+            this.gridColumn2.FieldName = "PL_NAME";
+            this.gridColumn2.Name = "gridColumn2";
+            this.gridColumn2.Visible = true;
+            this.gridColumn2.VisibleIndex = 1;
+            // 
+            // gridColumn3
+            // 
+            this.gridColumn3.Caption = "业务类型";
+            this.gridColumn3.FieldName = "PL_TYPE";
+            this.gridColumn3.Name = "gridColumn3";
+            this.gridColumn3.Visible = true;
+            this.gridColumn3.VisibleIndex = 2;
+            // 
+            // gridColumn4
+            // 
+            this.gridColumn4.Caption = "指令编号";
+            this.gridColumn4.FieldName = "PL_DCCODE";
+            this.gridColumn4.Name = "gridColumn4";
+            this.gridColumn4.Visible = true;
+            this.gridColumn4.VisibleIndex = 3;
+            // 
+            // gridColumn5
+            // 
+            this.gridColumn5.Caption = "备注";
+            this.gridColumn5.FieldName = "PL_REMARK";
+            this.gridColumn5.Name = "gridColumn5";
+            this.gridColumn5.Visible = true;
+            this.gridColumn5.VisibleIndex = 4;
+            // 
             // dpc_plname
             // 
             this.dpc_plname.Caption = "业务名称";
@@ -712,7 +810,6 @@ namespace UAS_DeviceMonitor
             // dpc_dccode
             // 
             this.dpc_dccode.Caption = "指令编号";
-            this.dpc_dccode.ColumnEdit = this.PollingSetItemLookUpEdit;
             this.dpc_dccode.FieldName = "DPC_DCCODE";
             this.dpc_dccode.Name = "dpc_dccode";
             this.dpc_dccode.Visible = true;
@@ -831,16 +928,20 @@ namespace UAS_DeviceMonitor
             this.GridPolling.MainView = this.GridViewPolling;
             this.GridPolling.MenuManager = this.RibbonNav;
             this.GridPolling.Name = "GridPolling";
+            this.GridPolling.RepositoryItems.AddRange(new DevExpress.XtraEditors.Repository.RepositoryItem[] {
+            this.dpc_enableCheckEdit});
             this.GridPolling.RowCount = 0;
             this.GridPolling.Size = new System.Drawing.Size(1027, 549);
             this.GridPolling.TabIndex = 0;
             this.GridPolling.TableName = null;
             this.GridPolling.ViewCollection.AddRange(new DevExpress.XtraGrid.Views.Base.BaseView[] {
             this.GridViewPolling});
+            this.GridPolling.VisibleChanged += new System.EventHandler(this.GridPolling_VisibleChanged);
             // 
             // GridViewPolling
             // 
             this.GridViewPolling.Columns.AddRange(new DevExpress.XtraGrid.Columns.GridColumn[] {
+            this.PollingCheckedColumn,
             this.pl_id,
             this.pl_code,
             this.pl_name,
@@ -851,6 +952,17 @@ namespace UAS_DeviceMonitor
             this.GridViewPolling.IndicatorWidth = 30;
             this.GridViewPolling.Name = "GridViewPolling";
             // 
+            // PollingCheckedColumn
+            // 
+            this.PollingCheckedColumn.Caption = " ";
+            this.PollingCheckedColumn.ColumnEdit = this.dpc_enableCheckEdit;
+            this.PollingCheckedColumn.FieldName = "CHECKEDCOLUMN";
+            this.PollingCheckedColumn.Name = "PollingCheckedColumn";
+            this.PollingCheckedColumn.OptionsColumn.AllowSort = DevExpress.Utils.DefaultBoolean.False;
+            this.PollingCheckedColumn.Tag = "0";
+            this.PollingCheckedColumn.Visible = true;
+            this.PollingCheckedColumn.VisibleIndex = 0;
+            // 
             // pl_id
             // 
             this.pl_id.Caption = "ID";
@@ -863,7 +975,7 @@ namespace UAS_DeviceMonitor
             this.pl_code.FieldName = "PL_CODE";
             this.pl_code.Name = "pl_code";
             this.pl_code.Visible = true;
-            this.pl_code.VisibleIndex = 0;
+            this.pl_code.VisibleIndex = 1;
             // 
             // pl_name
             // 
@@ -871,7 +983,7 @@ namespace UAS_DeviceMonitor
             this.pl_name.FieldName = "PL_NAME";
             this.pl_name.Name = "pl_name";
             this.pl_name.Visible = true;
-            this.pl_name.VisibleIndex = 1;
+            this.pl_name.VisibleIndex = 2;
             // 
             // pl_type
             // 
@@ -879,15 +991,16 @@ namespace UAS_DeviceMonitor
             this.pl_type.FieldName = "PL_TYPE";
             this.pl_type.Name = "pl_type";
             this.pl_type.Visible = true;
-            this.pl_type.VisibleIndex = 2;
+            this.pl_type.VisibleIndex = 3;
             // 
             // pl_dccode
             // 
             this.pl_dccode.Caption = "指令编号";
+            this.pl_dccode.ColumnEdit = this.PollingSetItemLookUpEdit;
             this.pl_dccode.FieldName = "PL_DCCODE";
             this.pl_dccode.Name = "pl_dccode";
             this.pl_dccode.Visible = true;
-            this.pl_dccode.VisibleIndex = 3;
+            this.pl_dccode.VisibleIndex = 4;
             // 
             // pl_remark
             // 
@@ -895,7 +1008,7 @@ namespace UAS_DeviceMonitor
             this.pl_remark.FieldName = "PL_REMARK";
             this.pl_remark.Name = "pl_remark";
             this.pl_remark.Visible = true;
-            this.pl_remark.VisibleIndex = 4;
+            this.pl_remark.VisibleIndex = 5;
             // 
             // Main
             // 
@@ -928,6 +1041,8 @@ namespace UAS_DeviceMonitor
             ((System.ComponentModel.ISupportInitialize)(this.GridPollingSetting)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.GridViewPollSetting)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.dpc_enableCheckEdit)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.PollSettingItemSearchLookUpEdit)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.PollSettingItemSearchLookUpEditView)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.PollingSetItemLookUpEdit)).EndInit();
             this.PagePolling.ResumeLayout(false);
             ((System.ComponentModel.ISupportInitialize)(this.GridPolling)).EndInit();
@@ -1013,5 +1128,15 @@ namespace UAS_DeviceMonitor
         private CustomerControl.Button.ButtonSaveGrid ButtonSaveCommandSet;
         private DevExpress.XtraEditors.Repository.RepositoryItemLookUpEdit PollingSetItemLookUpEdit;
         private DevExpress.XtraGrid.Columns.GridColumn POLLSETTINGSTATUSCOLUMN;
+        private DevExpress.XtraGrid.Columns.GridColumn PollSettingCheckedColumn;
+        private DevExpress.XtraGrid.Columns.GridColumn CommandSetCheckedColumn;
+        private DevExpress.XtraGrid.Columns.GridColumn PollingCheckedColumn;
+        private DevExpress.XtraEditors.Repository.RepositoryItemSearchLookUpEdit PollSettingItemSearchLookUpEdit;
+        private DevExpress.XtraGrid.Views.Grid.GridView PollSettingItemSearchLookUpEditView;
+        private DevExpress.XtraGrid.Columns.GridColumn gridColumn1;
+        private DevExpress.XtraGrid.Columns.GridColumn gridColumn2;
+        private DevExpress.XtraGrid.Columns.GridColumn gridColumn3;
+        private DevExpress.XtraGrid.Columns.GridColumn gridColumn4;
+        private DevExpress.XtraGrid.Columns.GridColumn gridColumn5;
     }
 }

+ 42 - 10
UAS_DeviceMonitor/Main.cs

@@ -24,16 +24,22 @@ namespace UAS_DeviceMonitor
             InitializeComponent();
             dpc_enableCheckEdit.QueryCheckStateByValue += CheckedEdit_QueryCheckStateByValue;
             CheckEditCommandSet.QueryCheckStateByValue += CheckedEdit_QueryCheckStateByValue;
+            PollSettingItemSearchLookUpEdit.ParseEditValue += PollSettingItemSearchLookUpEdit_ParseEditValue;
             GridViewPollSetting.RowCellStyle += GridViewPollSetting_RowCellStyle;
         }
 
+        private void PollSettingItemSearchLookUpEdit_ParseEditValue(object sender, DevExpress.XtraEditors.Controls.ConvertEditValueEventArgs e)
+        {
+            e.Handled = true;
+        }
+
         private void Main_Load(object sender, EventArgs e)
         {
             //设备列表
             GridDeviceList.GetDataSQL = "select de_id,de_code,de_name,de_spec,de_indate,de_runstatus,de_address,de_wccode,de_vendcode,de_vendname from device".ToUpper();
             PageControlDeviceList.Gridcontrol = GridDeviceList;
             //轮询业务
-            GridPolling.GetDataSQL = "select pl_id,pl_code,pl_name,pl_type,pl_dccode,pl_remark from polling".ToUpper();
+            GridPolling.GetDataSQL = "select 0 CHECKEDCOLUMN,pl_id,pl_code,pl_name,pl_type,pl_dccode,pl_remark from polling".ToUpper();
             GridPolling.ID = "pl_id";
             GridPolling.TableName = "polling";
             GridPolling.InsertSQL = "insert into polling(pl_id,pl_code,pl_name,pl_type,pl_dccode,pl_remark) values(polling_seq.nextval,:pl_code,:pl_name,:pl_type,:pl_dccode,:pl_remark)";
@@ -41,17 +47,17 @@ namespace UAS_DeviceMonitor
             ButtonSavePolling.Grid = GridPolling;
             ButtonAddPolling.Grid = GridPolling;
             //轮询配置界面
-            GridPollingSetting.GetDataSQL = "SELECT '' POLLSETTINGSTATUSCOLUMN,DPC_ID,DPC_DECODE ,DPC_PLCODE ,DPC_PLNAME ,DPC_INTERVAL ,DPC_DCCODE ,DPC_FUNCTION , DPC_ENABLE,DPC_STATUS ,DPC_REMARK FROM DEVICEPOLLINGCONFIG";
+            GridPollingSetting.GetDataSQL = "SELECT '' POLLSETTINGSTATUSCOLUMN,0 CHECKEDCOLUMN,DPC_ID,DPC_DECODE ,DPC_PLCODE ,DPC_PLNAME ,DPC_INTERVAL ,DPC_DCCODE ,DPC_FUNCTION , DPC_ENABLE,DPC_STATUS ,DPC_REMARK FROM DEVICEPOLLINGCONFIG";
             GridPollingSetting.ID = "DPC_ID";
             GridPollingSetting.TableName = "DEVICEPOLLINGCONFIG";
             GridPollingSetting.InsertSQL = "insert into DEVICEPOLLINGCONFIG(DPC_ID,DPC_DECODE ,DPC_PLCODE ,DPC_PLNAME ,DPC_INTERVAL ,DPC_DCCODE ,DPC_FUNCTION , DPC_ENABLE,DPC_STATUS ,DPC_REMARK) values(DEVICEPOLLINGCONFIG_seq.nextval,:DPC_DECODE ,:DPC_PLCODE ,:DPC_PLNAME ,:DPC_INTERVAL ,:DPC_DCCODE ,:DPC_FUNCTION , :DPC_ENABLE,:DPC_STATUS ,:DPC_REMARK)";
-        
+
             ButtonSaveCommandSet.Grid = GridPollingSetting;
             ButtonNewCommandSet.Grid = GridPollingSetting;
             ButtonDeleteCommandSet.Grid = GridPollingSetting;
 
             //指令设置界面
-            GridCommandSetting.GetDataSQL = "select 0 GRIDVIEWCOMMANDSETCHOOSE,dc_id,dc_code,dc_name,dc_command from devicecommand".ToUpper();
+            GridCommandSetting.GetDataSQL = "select 0 CHECKEDCOLUMN,dc_id,dc_code,dc_name,dc_command from devicecommand".ToUpper();
             GridCommandSetting.TableName = "devicecommand";
             GridCommandSetting.ID = "dc_id";
             GridCommandSetting.InsertSQL = "insert into devicecommand(dc_id,dc_code,dc_name,dc_command) values(devicecommand_seq.nextval,:dc_code,:dc_name,:dc_command)";
@@ -169,6 +175,19 @@ namespace UAS_DeviceMonitor
 
         #endregion
 
+        #region PagePolling业务代码
+        private void GridPolling_VisibleChanged(object sender, EventArgs e)
+        {
+            if (PagePollingSetting.PageVisible)
+            {
+                DataTable dt = (DataTable)SystemInf.dh.ExecuteSql("select dc_name,dc_code from devicecommand ", "select");
+                PollingSetItemLookUpEdit.DataSource = dt;
+                PollingSetItemLookUpEdit.DisplayMember = "DC_NAME";
+                PollingSetItemLookUpEdit.ValueMember = "DC_CODE";
+            }
+        }
+        #endregion
+
         #region PagePollingSetting业务代码
 
         PollingTask pt = new PollingTask();
@@ -290,21 +309,34 @@ namespace UAS_DeviceMonitor
                     PollSettingPaintRowIndex.Add(e.RowHandle);
                 }
             }
+            //选择业务方案时带出指令编号
+            if (e.Column.FieldName == "DPC_PLCODE")
+            {
+                string pqf01 = e.Value.ToString();
+                DataTable dt = (DataTable)PollSettingItemSearchLookUpEdit.DataSource;
+                DataRow[] rows = dt.Select(string.Format("PL_CODE='{0}'", pqf01));
+                if (rows != null && rows.Length > 0)
+                {
+                    DataRow row = rows[0];
+                    Console.WriteLine(row["PL_DCCODE"].ToString());
+                    GridViewPollSetting.SetRowCellValue(e.RowHandle, "DPC_DCCODE", row["PL_DCCODE"].ToString());
+                }
+            }
         }
 
         /// <summary>
-        /// 设置GridView下拉框的值
+        /// 设置GridView多选放大镜
         /// </summary>
-        /// <param name="sender"></param>
+        /// <param name="sender"></param> 
         /// <param name="e"></param>
         private void PagePollingSetting_VisibleChanged(object sender, EventArgs e)
         {
             if (PagePollingSetting.PageVisible)
             {
-                DataTable dt = (DataTable)SystemInf.dh.ExecuteSql("select dc_name,dc_code from devicecommand ", "select");
-                PollingSetItemLookUpEdit.DataSource = dt;
-                PollingSetItemLookUpEdit.DisplayMember = "DC_NAME";
-                PollingSetItemLookUpEdit.ValueMember = "DC_CODE";
+                DataTable dt = (DataTable)SystemInf.dh.ExecuteSql("SELECT PL_CODE,PL_NAME,PL_TYPE,PL_DCCODE,PL_REMARK FROM POLLING", "select");
+                PollSettingItemSearchLookUpEdit.DataSource = dt;
+                PollSettingItemSearchLookUpEdit.DisplayMember = "PL_CODE";
+                PollSettingItemSearchLookUpEdit.ValueMember = "PL_CODE";
             }
         }
         #endregion