Browse Source

添加自动带出设备编号和名称

章政 7 years ago
parent
commit
2c7469e515
2 changed files with 59 additions and 11 deletions
  1. 38 11
      PLCDataReader/Main.Designer.cs
  2. 21 0
      PLCDataReader/Main.cs

+ 38 - 11
PLCDataReader/Main.Designer.cs

@@ -136,6 +136,8 @@ namespace UAS_PLCDataReader
             this.PollSettingCheckedColumn = new DevExpress.XtraGrid.Columns.GridColumn();
             this.dpc_id = new DevExpress.XtraGrid.Columns.GridColumn();
             this.dpc_decode = new DevExpress.XtraGrid.Columns.GridColumn();
+            this.PollSettingDeviceSearchLookUpEdit = new DevExpress.XtraEditors.Repository.RepositoryItemSearchLookUpEdit();
+            this.repositoryItemSearchLookUpEdit1View = new DevExpress.XtraGrid.Views.Grid.GridView();
             this.dpc_dename = new DevExpress.XtraGrid.Columns.GridColumn();
             this.dpc_interval = new DevExpress.XtraGrid.Columns.GridColumn();
             this.dpc_dccode = new DevExpress.XtraGrid.Columns.GridColumn();
@@ -190,12 +192,12 @@ namespace UAS_PLCDataReader
             this.drr_doman = new DevExpress.XtraGrid.Columns.GridColumn();
             this.drr_remark = new DevExpress.XtraGrid.Columns.GridColumn();
             this.PageClientParam = new DevExpress.XtraTab.XtraTabPage();
+            this.ButtonSaveClientParam = new DevExpress.XtraEditors.SimpleButton();
             this.UpdateTimeSpan = new System.Windows.Forms.NumericUpDown();
             this.label1 = new System.Windows.Forms.Label();
             this.TimerDeviceStatus = new System.Windows.Forms.Timer(this.components);
             this.CommonTipController = new DevExpress.Utils.ToolTipController(this.components);
             this.TimerUpdateDevice = new System.Windows.Forms.Timer(this.components);
-            this.ButtonSaveClientParam = new DevExpress.XtraEditors.SimpleButton();
             ((System.ComponentModel.ISupportInitialize)(this.RibbonNav)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.MainTabControl)).BeginInit();
             this.MainTabControl.SuspendLayout();
@@ -222,6 +224,8 @@ namespace UAS_PLCDataReader
             this.PagePollingSetting.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.GridPollingSetting)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.GridViewPollSetting)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.PollSettingDeviceSearchLookUpEdit)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.repositoryItemSearchLookUpEdit1View)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.PollSettingItemSearchLookUpEdit)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.PollSettingItemSearchLookUpEditView)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.PollingSetItemLookUpEdit)).BeginInit();
@@ -1257,7 +1261,8 @@ namespace UAS_PLCDataReader
             this.GridPollingSetting.RepositoryItems.AddRange(new DevExpress.XtraEditors.Repository.RepositoryItem[] {
             this.dpc_enableCheckEdit,
             this.PollingSetItemLookUpEdit,
-            this.PollSettingItemSearchLookUpEdit});
+            this.PollSettingItemSearchLookUpEdit,
+            this.PollSettingDeviceSearchLookUpEdit});
             this.GridPollingSetting.RowCount = 0;
             this.GridPollingSetting.Size = new System.Drawing.Size(1027, 543);
             this.GridPollingSetting.TabIndex = 0;
@@ -1286,6 +1291,7 @@ namespace UAS_PLCDataReader
             this.GridViewPollSetting.Name = "GridViewPollSetting";
             this.GridViewPollSetting.OptionsSelection.MultiSelectMode = DevExpress.XtraGrid.Views.Grid.GridMultiSelectMode.CheckBoxRowSelect;
             this.GridViewPollSetting.OptionsView.ShowGroupPanel = false;
+            this.GridViewPollSetting.CellValueChanged += new DevExpress.XtraGrid.Views.Base.CellValueChangedEventHandler(this.GridViewPollSetting_CellValueChanged);
             // 
             // PollSettingCheckedColumn
             // 
@@ -1308,12 +1314,29 @@ namespace UAS_PLCDataReader
             // dpc_decode
             // 
             this.dpc_decode.Caption = "设备编号";
+            this.dpc_decode.ColumnEdit = this.PollSettingDeviceSearchLookUpEdit;
             this.dpc_decode.FieldName = "DPC_DECODE";
             this.dpc_decode.Name = "dpc_decode";
             this.dpc_decode.Visible = true;
             this.dpc_decode.VisibleIndex = 1;
             this.dpc_decode.Width = 90;
             // 
+            // PollingSettingDeviceSearchLookUpEdit1
+            // 
+            this.PollSettingDeviceSearchLookUpEdit.AutoHeight = false;
+            this.PollSettingDeviceSearchLookUpEdit.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
+            new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
+            this.PollSettingDeviceSearchLookUpEdit.Name = "PollSettingDeviceSearchLookUpEdit";
+            this.PollSettingDeviceSearchLookUpEdit.NullText = "";
+            this.PollSettingDeviceSearchLookUpEdit.View = this.repositoryItemSearchLookUpEdit1View;
+            // 
+            // repositoryItemSearchLookUpEdit1View
+            // 
+            this.repositoryItemSearchLookUpEdit1View.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.RowFocus;
+            this.repositoryItemSearchLookUpEdit1View.Name = "repositoryItemSearchLookUpEdit1View";
+            this.repositoryItemSearchLookUpEdit1View.OptionsSelection.EnableAppearanceFocusedCell = false;
+            this.repositoryItemSearchLookUpEdit1View.OptionsView.ShowGroupPanel = false;
+            // 
             // dpc_dename
             // 
             this.dpc_dename.Caption = "设备名称";
@@ -1869,6 +1892,15 @@ namespace UAS_PLCDataReader
             this.PageClientParam.Size = new System.Drawing.Size(1027, 577);
             this.PageClientParam.VisibleChanged += new System.EventHandler(this.PageClientParam_VisibleChanged);
             // 
+            // ButtonSaveClientParam
+            // 
+            this.ButtonSaveClientParam.Location = new System.Drawing.Point(140, 122);
+            this.ButtonSaveClientParam.Name = "ButtonSaveClientParam";
+            this.ButtonSaveClientParam.Size = new System.Drawing.Size(64, 23);
+            this.ButtonSaveClientParam.TabIndex = 2;
+            this.ButtonSaveClientParam.Text = "保存";
+            this.ButtonSaveClientParam.Click += new System.EventHandler(this.ButtonSaveClientParam_Click);
+            // 
             // UpdateTimeSpan
             // 
             this.UpdateTimeSpan.Location = new System.Drawing.Point(140, 30);
@@ -1900,15 +1932,6 @@ namespace UAS_PLCDataReader
             this.TimerUpdateDevice.Interval = 20000;
             this.TimerUpdateDevice.Tick += new System.EventHandler(this.TimerUpdateDevice_Tick);
             // 
-            // ButtonSaveClientParam
-            // 
-            this.ButtonSaveClientParam.Location = new System.Drawing.Point(140, 122);
-            this.ButtonSaveClientParam.Name = "ButtonSaveClientParam";
-            this.ButtonSaveClientParam.Size = new System.Drawing.Size(64, 23);
-            this.ButtonSaveClientParam.TabIndex = 2;
-            this.ButtonSaveClientParam.Text = "保存";
-            this.ButtonSaveClientParam.Click += new System.EventHandler(this.ButtonSaveClientParam_Click);
-            // 
             // Main
             // 
             this.AllowFormGlass = DevExpress.Utils.DefaultBoolean.False;
@@ -1953,6 +1976,8 @@ namespace UAS_PLCDataReader
             this.PagePollingSetting.ResumeLayout(false);
             ((System.ComponentModel.ISupportInitialize)(this.GridPollingSetting)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.GridViewPollSetting)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.PollSettingDeviceSearchLookUpEdit)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.repositoryItemSearchLookUpEdit1View)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.PollSettingItemSearchLookUpEdit)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.PollSettingItemSearchLookUpEditView)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.PollingSetItemLookUpEdit)).EndInit();
@@ -2143,5 +2168,7 @@ namespace UAS_PLCDataReader
         private System.Windows.Forms.NumericUpDown UpdateTimeSpan;
         private System.Windows.Forms.Label label1;
         private SimpleButton ButtonSaveClientParam;
+        private DevExpress.XtraGrid.Views.Grid.GridView repositoryItemSearchLookUpEdit1View;
+        private DevExpress.XtraEditors.Repository.RepositoryItemSearchLookUpEdit PollSettingDeviceSearchLookUpEdit;
     }
 }

+ 21 - 0
PLCDataReader/Main.cs

@@ -51,6 +51,7 @@ namespace UAS_PLCDataReader
             DataItemRepositoryItemComboBox1.SelectedValueChanged += DataItemRepositoryItemComboBox1_SelectedValueChanged;
             CheckEditCommandSet.QueryCheckStateByValue += CheckedEdit_QueryCheckStateByValue;
             PollSettingItemSearchLookUpEdit.ParseEditValue += PollSettingItemSearchLookUpEdit_ParseEditValue;
+            PollSettingDeviceSearchLookUpEdit.ParseEditValue += PollSettingItemSearchLookUpEdit_ParseEditValue;
             GridViewPollSetting.RowCellStyle += GridViewPollSetting_RowCellStyle;
             #region 添加发送接收编码规则的静态值
             ComboBoxData cbd = new ComboBoxData();
@@ -355,6 +356,8 @@ namespace UAS_PLCDataReader
             //    LogicHandler.DoDevicePollingLog(item.Decode, item.SendDataSize.ToString(), item.ReceiveDataSize.ToString());
             //}
         }
+
+
         #endregion
 
         #region PageCommandSet业务代码(指令设置)
@@ -646,6 +649,24 @@ namespace UAS_PLCDataReader
                 PollSettingItemSearchLookUpEdit.DataSource = dt;
                 PollSettingItemSearchLookUpEdit.DisplayMember = "DC_CODE";
                 PollSettingItemSearchLookUpEdit.ValueMember = "DC_CODE";
+
+                DataTable dt1 = (DataTable)SystemInf.dh.ExecuteSql("SELECT DE_CODE,DE_NAME FROM device", "select");
+                PollSettingDeviceSearchLookUpEdit.DataSource = dt1;
+                PollSettingDeviceSearchLookUpEdit.DisplayMember = "DE_CODE";
+                PollSettingDeviceSearchLookUpEdit.ValueMember = "DE_CODE";
+            }
+        }
+
+        private void GridViewPollSetting_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
+        {
+            if (e.Column.FieldName == "DPC_DECODE")
+            {
+                DataTable dt = (DataTable)PollSettingDeviceSearchLookUpEdit.DataSource;
+                DataRow[] dr = dt.Select("de_code='" + e.Value + "'");
+                if (dr.Length > 0)
+                {
+                    GridViewPollSetting.SetRowCellValue(e.RowHandle, "DPC_DENAME", dr[0]["de_name"]);
+                }
             }
         }
         #endregion