Browse Source

添加维护人员和时间

章政 7 years ago
parent
commit
0a091f8150

+ 2 - 0
UAS_DeviceMonitor/CustomerControl/AutoDataGridControl/AutoDataGridControl.cs

@@ -132,6 +132,8 @@ namespace UAS_DeviceMonitor.CustomerControl.AutoDataGridControl
                 rowCount = dt.Rows.Count;
                 DataSource = dt;
                 getDataSQL = firstsql;
+                //调用列自适应,自动调整最合适列宽
+                (MainView as GridViewWithSerialNum.GridViewWithSerialNum).BestFitColumns();
             }
             DataRefresh?.Invoke(new object(), new EventArgs());
         }

+ 22 - 3
UAS_DeviceMonitor/CustomerControl/Button/ButtonSaveGrid.cs

@@ -40,20 +40,22 @@ namespace UAS_DeviceMonitor.CustomerControl.Button
             }
         }
 
+        public string[] LastSaveID;
+
         public ButtonSaveGrid()
         {
             InitializeComponent();
         }
 
         /// <summary>
-        /// 处理完其他Click事件提供回调函数重新触发保存事件
+        /// 内部调用,重新刷新数据
         /// </summary>
-        public void DoSave()
+        private void DoSave()
         {
             DataTable dt = ((DataTable)grid.DataSource).GetChanges();
             if (dt != null && dt.Rows.Count > 0)
             {
-                SystemInf.dh.SaveDataTable(dt, grid.TableName, grid.ID, grid.InsertSQL);
+                SystemInf.dh.SaveDataTable(dt, grid.TableName, grid.ID, out LastSaveID, grid.InsertSQL);
                 grid.RefreshData();
                 XtraMessageBox.Show("保存成功", "提示");
             }
@@ -63,6 +65,23 @@ namespace UAS_DeviceMonitor.CustomerControl.Button
             }
         }
 
+        /// <summary>
+        /// 外部调用,不重新刷新数据
+        /// </summary>
+        public void DoSaveAfterHandler()
+        {
+            DataTable dt = ((DataTable)grid.DataSource).GetChanges();
+            if (dt != null && dt.Rows.Count > 0)
+            {
+                SystemInf.dh.SaveDataTable(dt, grid.TableName, grid.ID, out LastSaveID, grid.InsertSQL);
+                XtraMessageBox.Show("保存成功", "提示");
+            }
+            else
+            {
+                XtraMessageBox.Show("没有修改过的数据", "提示");
+            }
+        }
+
         private void ButtonSaveGrid_Click(object sender, EventArgs e)
         {
             if (!handlerOtherFirst)

+ 49 - 11
UAS_DeviceMonitor/Main.Designer.cs

@@ -90,6 +90,8 @@ namespace UAS_DeviceMonitor
             this.dc_sendcoding = new DevExpress.XtraGrid.Columns.GridColumn();
             this.CommandSetRepositoryItemComboBox1 = new DevExpress.XtraEditors.Repository.RepositoryItemComboBox();
             this.dc_receivecoding = new DevExpress.XtraGrid.Columns.GridColumn();
+            this.dc_man = new DevExpress.XtraGrid.Columns.GridColumn();
+            this.dc_date = new DevExpress.XtraGrid.Columns.GridColumn();
             this.db_name = new DevExpress.XtraGrid.Columns.GridColumn();
             this.PageDeviceNetSetting = new DevExpress.XtraTab.XtraTabPage();
             this.ButtonDeleteNetConfig = new UAS_DeviceMonitor.CustomerControl.Button.ButtonDeleteRow();
@@ -127,6 +129,7 @@ namespace UAS_DeviceMonitor
             this.gridColumn5 = new DevExpress.XtraGrid.Columns.GridColumn();
             this.dpc_function = new DevExpress.XtraGrid.Columns.GridColumn();
             this.dpc_enable = new DevExpress.XtraGrid.Columns.GridColumn();
+            this.em_name1 = new DevExpress.XtraGrid.Columns.GridColumn();
             this.dpc_status = new DevExpress.XtraGrid.Columns.GridColumn();
             this.dpc_man = new DevExpress.XtraGrid.Columns.GridColumn();
             this.dpc_remark = new DevExpress.XtraGrid.Columns.GridColumn();
@@ -691,6 +694,8 @@ namespace UAS_DeviceMonitor
             this.dc_value,
             this.dc_sendcoding,
             this.dc_receivecoding,
+            this.dc_man,
+            this.dc_date,
             this.db_name});
             this.GridViewCommandSet.GridControl = this.GridCommandSetting;
             this.GridViewCommandSet.IndicatorWidth = 30;
@@ -707,7 +712,7 @@ namespace UAS_DeviceMonitor
             this.CommandSetCheckedColumn.Tag = "0";
             this.CommandSetCheckedColumn.Visible = true;
             this.CommandSetCheckedColumn.VisibleIndex = 0;
-            this.CommandSetCheckedColumn.Width = 60;
+            this.CommandSetCheckedColumn.Width = 46;
             // 
             // CheckEditCommandSet
             // 
@@ -727,7 +732,7 @@ namespace UAS_DeviceMonitor
             this.dc_code.Name = "dc_code";
             this.dc_code.Visible = true;
             this.dc_code.VisibleIndex = 1;
-            this.dc_code.Width = 95;
+            this.dc_code.Width = 64;
             // 
             // dc_name
             // 
@@ -736,7 +741,7 @@ namespace UAS_DeviceMonitor
             this.dc_name.Name = "dc_name";
             this.dc_name.Visible = true;
             this.dc_name.VisibleIndex = 2;
-            this.dc_name.Width = 99;
+            this.dc_name.Width = 71;
             // 
             // dc_type
             // 
@@ -745,6 +750,7 @@ namespace UAS_DeviceMonitor
             this.dc_type.Name = "dc_type";
             this.dc_type.Visible = true;
             this.dc_type.VisibleIndex = 3;
+            this.dc_type.Width = 57;
             // 
             // dc_value
             // 
@@ -753,7 +759,7 @@ namespace UAS_DeviceMonitor
             this.dc_value.Name = "dc_value";
             this.dc_value.Visible = true;
             this.dc_value.VisibleIndex = 4;
-            this.dc_value.Width = 291;
+            this.dc_value.Width = 154;
             // 
             // dc_sendcoding
             // 
@@ -763,7 +769,7 @@ namespace UAS_DeviceMonitor
             this.dc_sendcoding.Name = "dc_sendcoding";
             this.dc_sendcoding.Visible = true;
             this.dc_sendcoding.VisibleIndex = 5;
-            this.dc_sendcoding.Width = 219;
+            this.dc_sendcoding.Width = 138;
             // 
             // CommandSetRepositoryItemComboBox1
             // 
@@ -780,7 +786,25 @@ namespace UAS_DeviceMonitor
             this.dc_receivecoding.Name = "dc_receivecoding";
             this.dc_receivecoding.Visible = true;
             this.dc_receivecoding.VisibleIndex = 6;
-            this.dc_receivecoding.Width = 231;
+            this.dc_receivecoding.Width = 139;
+            // 
+            // dc_man
+            // 
+            this.dc_man.Caption = "维护人员";
+            this.dc_man.FieldName = "DC_MAN";
+            this.dc_man.Name = "dc_man";
+            this.dc_man.Visible = true;
+            this.dc_man.VisibleIndex = 8;
+            this.dc_man.Width = 217;
+            // 
+            // dc_date
+            // 
+            this.dc_date.Caption = "维护时间";
+            this.dc_date.FieldName = "DC_DATE";
+            this.dc_date.Name = "dc_date";
+            this.dc_date.Visible = true;
+            this.dc_date.VisibleIndex = 9;
+            this.dc_date.Width = 52;
             // 
             // db_name
             // 
@@ -789,6 +813,7 @@ namespace UAS_DeviceMonitor
             this.db_name.Name = "db_name";
             this.db_name.Visible = true;
             this.db_name.VisibleIndex = 7;
+            this.db_name.Width = 57;
             // 
             // PageDeviceNetSetting
             // 
@@ -991,12 +1016,13 @@ namespace UAS_DeviceMonitor
             // 
             this.ButtonSaveCommandSet.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
             this.ButtonSaveCommandSet.Grid = null;
-            this.ButtonSaveCommandSet.HandlerOtherFirst = false;
+            this.ButtonSaveCommandSet.HandlerOtherFirst = true;
             this.ButtonSaveCommandSet.Location = new System.Drawing.Point(956, 549);
             this.ButtonSaveCommandSet.Name = "ButtonSaveCommandSet";
             this.ButtonSaveCommandSet.Size = new System.Drawing.Size(64, 23);
             this.ButtonSaveCommandSet.TabIndex = 7;
             this.ButtonSaveCommandSet.Text = "保存";
+            this.ButtonSaveCommandSet.Click += new System.EventHandler(this.ButtonSaveCommandSet_Click);
             // 
             // ButtonPausePolling
             // 
@@ -1052,6 +1078,7 @@ namespace UAS_DeviceMonitor
             this.dpc_dccode,
             this.dpc_function,
             this.dpc_enable,
+            this.em_name1,
             this.dpc_status,
             this.dpc_man,
             this.dpc_remark,
@@ -1173,6 +1200,15 @@ namespace UAS_DeviceMonitor
             this.dpc_enable.VisibleIndex = 5;
             this.dpc_enable.Width = 90;
             // 
+            // em_name1
+            // 
+            this.em_name1.Caption = "维护人";
+            this.em_name1.FieldName = "EM_NAME";
+            this.em_name1.Name = "em_name1";
+            this.em_name1.OptionsColumn.AllowEdit = false;
+            this.em_name1.Visible = true;
+            this.em_name1.VisibleIndex = 9;
+            // 
             // dpc_status
             // 
             this.dpc_status.Caption = "状态";
@@ -1188,8 +1224,7 @@ namespace UAS_DeviceMonitor
             this.dpc_man.Caption = "维护人";
             this.dpc_man.FieldName = "DPC_MAN";
             this.dpc_man.Name = "dpc_man";
-            this.dpc_man.Visible = true;
-            this.dpc_man.VisibleIndex = 7;
+            this.dpc_man.OptionsColumn.AllowEdit = false;
             // 
             // dpc_remark
             // 
@@ -1197,7 +1232,7 @@ namespace UAS_DeviceMonitor
             this.dpc_remark.FieldName = "DPC_REMARK";
             this.dpc_remark.Name = "dpc_remark";
             this.dpc_remark.Visible = true;
-            this.dpc_remark.VisibleIndex = 8;
+            this.dpc_remark.VisibleIndex = 7;
             this.dpc_remark.Width = 87;
             // 
             // POLLSETTINGSTATUSCOLUMN
@@ -1207,7 +1242,7 @@ namespace UAS_DeviceMonitor
             this.POLLSETTINGSTATUSCOLUMN.Name = "POLLSETTINGSTATUSCOLUMN";
             this.POLLSETTINGSTATUSCOLUMN.OptionsColumn.ReadOnly = true;
             this.POLLSETTINGSTATUSCOLUMN.Visible = true;
-            this.POLLSETTINGSTATUSCOLUMN.VisibleIndex = 9;
+            this.POLLSETTINGSTATUSCOLUMN.VisibleIndex = 8;
             this.POLLSETTINGSTATUSCOLUMN.Width = 98;
             // 
             // PollingSetItemLookUpEdit
@@ -1668,5 +1703,8 @@ namespace UAS_DeviceMonitor
         private DevExpress.XtraGrid.Columns.GridColumn dc_type;
         private DevExpress.XtraGrid.Columns.GridColumn db_name;
         private DevExpress.XtraGrid.Columns.GridColumn dpc_man;
+        private DevExpress.XtraGrid.Columns.GridColumn em_name1;
+        private DevExpress.XtraGrid.Columns.GridColumn dc_man;
+        private DevExpress.XtraGrid.Columns.GridColumn dc_date;
     }
 }

+ 25 - 13
UAS_DeviceMonitor/Main.cs

@@ -89,19 +89,19 @@ namespace UAS_DeviceMonitor
             //ButtonSavePolling.Grid = GridPolling;
             //ButtonAddPolling.Grid = GridPolling;
             //轮询配置界面
-            GridPollingSetting.GetDataSQL = "SELECT '' POLLSETTINGSTATUSCOLUMN,0 CHECKEDCOLUMN,DPC_MAN,DPC_ID,DPC_DECODE ,DPC_INTERVAL ,DPC_DCCODE ,DPC_FUNCTION , nvl(DPC_ENABLE,0)DPC_ENABLE,DPC_STATUS ,DPC_REMARK FROM DEVICEPOLLINGCONFIG ORDER BY DPC_ID";
+            GridPollingSetting.GetDataSQL = "SELECT '' POLLSETTINGSTATUSCOLUMN,0 CHECKEDCOLUMN,DPC_MAN,DPC_ID,DPC_DECODE ,DPC_INTERVAL ,DPC_DCCODE ,DPC_FUNCTION , nvl(DPC_ENABLE,0)DPC_ENABLE,DPC_STATUS,DPC_REMARK,EM_NAME FROM DEVICEPOLLINGCONFIG left join EMPLOYEE on em_code=dpc_man WHERE DPC_MAN='" + User.UserCode + "' ORDER BY DPC_ID";
             GridPollingSetting.ID = "DPC_ID";
             GridPollingSetting.TableName = "DEVICEPOLLINGCONFIG";
-            GridPollingSetting.InsertSQL = "insert into DEVICEPOLLINGCONFIG(DPC_ID,DPC_DECODE ,DPC_INTERVAL ,DPC_DCCODE ,DPC_FUNCTION , DPC_ENABLE,DPC_STATUS ,DPC_REMARK) values(DEVICEPOLLINGCONFIG_seq.nextval,:DPC_DECODE  ,:DPC_INTERVAL ,:DPC_DCCODE ,:DPC_FUNCTION , :DPC_ENABLE,:DPC_STATUS ,:DPC_REMARK)";
+            GridPollingSetting.InsertSQL = "insert into DEVICEPOLLINGCONFIG(DPC_ID,DPC_DECODE ,DPC_INTERVAL ,DPC_DCCODE ,DPC_FUNCTION , DPC_ENABLE,DPC_STATUS ,DPC_REMARK,DPC_MAN) values(DEVICEPOLLINGCONFIG_seq.nextval,:DPC_DECODE  ,:DPC_INTERVAL ,:DPC_DCCODE ,:DPC_FUNCTION , :DPC_ENABLE,:DPC_STATUS ,:DPC_REMARK,'" + User.UserCode + "')";
             ButtonSaveCommandSet.Grid = GridPollingSetting;
             ButtonNewCommandSet.Grid = GridPollingSetting;
             ButtonDeleteCommandSet.Grid = GridPollingSetting;
 
             //指令设置界面
-            GridCommandSetting.GetDataSQL = "select 0 CHECKEDCOLUMN,dc_id,dc_code,dc_name,dc_type,dc_value,dc_sendcoding,dc_receivecoding,db_name from devicecommand left join devicebrand on db_code=dc_debrand".ToUpper();
+            GridCommandSetting.GetDataSQL = "select 0 CHECKEDCOLUMN,dc_id,dc_code,dc_name,dc_type,dc_value,dc_sendcoding,dc_receivecoding,db_name,dc_man,to_char(dc_date,'YYYY-MM-DD HH:mi:ss')dc_date from devicecommand left join devicebrand on db_code=dc_debrand".ToUpper();
             GridCommandSetting.TableName = "devicecommand";
             GridCommandSetting.ID = "dc_id";
-            GridCommandSetting.InsertSQL = "insert into devicecommand(dc_id,dc_code,dc_name,dc_value,dc_debrand,dc_sendcoding,dc_receivecoding) values(devicecommand_seq.nextval,:dc_code,:dc_name,:dc_value,'" + BaseUtil.GetComboxEditValue(Brand) + "',:dc_sendcoding,:dc_receivecoding)";
+            GridCommandSetting.InsertSQL = "insert into devicecommand(dc_id,dc_code,dc_name,dc_value,dc_debrand,dc_sendcoding,dc_receivecoding,dc_man,dc_date) values(devicecommand_seq.nextval,:dc_code,:dc_name,:dc_value,'" + BaseUtil.GetComboxEditValue(Brand) + "',:dc_sendcoding,:dc_receivecoding,'" + User.UserName + "',sysdate)";
             ButtonSaveCommand.Grid = GridCommandSetting;
             ButtonDeleteCommand.Grid = GridCommandSetting;
             ButtonNewCommand.Grid = GridCommandSetting;
@@ -265,8 +265,12 @@ namespace UAS_DeviceMonitor
         /// <param name="e"></param>
         private void ButtonSaveCommand_Click(object sender, EventArgs e)
         {
-            GridCommandSetting.InsertSQL = "insert into devicecommand(dc_id,dc_code,dc_name,dc_value,dc_debrand,dc_sendcoding,dc_receivecoding) values(devicecommand_seq.nextval,:dc_code,:dc_name,:dc_value,'" + BaseUtil.GetComboxEditValue(Brand) + "',:dc_sendcoding,:dc_receivecoding)";
-            ButtonSaveCommand.DoSave();
+            GridCommandSetting.InsertSQL = "insert into devicecommand(dc_id,dc_code,dc_name,dc_value,dc_debrand,dc_sendcoding,dc_receivecoding,dc_man,dc_date) values(devicecommand_seq.nextval,:dc_code,:dc_name,:dc_value,'" + BaseUtil.GetComboxEditValue(Brand) + "',:dc_sendcoding,:dc_receivecoding,'" + User.UserName + "',sysdate)";
+            ButtonSaveCommand.DoSaveAfterHandler();
+            sql.Clear();
+            sql.Append("update devicecommand set dc_man='" + User.UserName + "',dc_date=sysdate where dc_id=:dc_id");
+            dh.BatchInsert(sql.ToString(), new string[] { "dc_id" }, ButtonSaveCommand.LastSaveID);
+            GridCommandSetting.RefreshData();
         }
 
         /// <summary>
@@ -451,14 +455,9 @@ namespace UAS_DeviceMonitor
 
         private void GridViewPollSetting_CellValueChanging(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
         {
-            GridViewPollSetting.SetRowCellValue(e.RowHandle, e.Column, e.Value);
-        }
-
-        private void GridViewPollSetting_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
-        {
-
             if (e.Column.Name.ToUpper() == "DPC_ENABLE")
             {
+                GridViewPollSetting.SetRowCellValue(e.RowHandle, e.Column, e.Value);
                 if (GridViewPollSetting.GetRowCellValue(e.RowHandle, "DPC_ENABLE").ToString() == "0")
                 {
                     //DialogResult cancel = XtraMessageBox.Show("确认禁用该轮询?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
@@ -478,7 +477,7 @@ namespace UAS_DeviceMonitor
                     //    GridViewPollSetting.SetRowCellValue(e.RowHandle, e.Column, -1);
                     //}
                 }
-                else 
+                else
                 {
                     Polling pl = new Polling();
                     pl.Id = int.Parse(GridViewPollSetting.GetRowCellValue(e.RowHandle, "DPC_ID").ToString());
@@ -494,6 +493,19 @@ namespace UAS_DeviceMonitor
             }
         }
 
+        private void GridViewPollSetting_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
+        {
+
+        }
+
+        private void ButtonSaveCommandSet_Click(object sender, EventArgs e)
+        {
+            ButtonSaveCommandSet.DoSaveAfterHandler();
+            sql.Clear();
+            sql.Append("update DEVICEPOLLINGCONFIG set dpc_man='" + User.UserCode + "' where dpc_id=:dpc_id");
+            dh.BatchInsert(sql.ToString(), new string[] { "dpc_id" }, ButtonSaveCommandSet.LastSaveID);
+            GridPollingSetting.RefreshData();
+        }
         /// <summary>
         /// 设置GridView多选放大镜
         /// </summary>