소스 검색

空指针BUG

章政 7 년 전
부모
커밋
c1ed5072c8
2개의 변경된 파일42개의 추가작업 그리고 24개의 파일을 삭제
  1. 22 13
      PLCDataReader/Main.Designer.cs
  2. 20 11
      PLCDataReader/Main.cs

+ 22 - 13
PLCDataReader/Main.Designer.cs

@@ -33,7 +33,6 @@ namespace UAS_PLCDataReader
         /// </summary>
         private void InitializeComponent()
         {
-            this.components = new System.ComponentModel.Container();
             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Main));
             this.RibbonNav = new DevExpress.XtraBars.Ribbon.RibbonControl();
             this.ButtonDeviceList = new DevExpress.XtraBars.BarButtonItem();
@@ -71,6 +70,7 @@ namespace UAS_PLCDataReader
             this.de_runstatus = new DevExpress.XtraGrid.Columns.GridColumn();
             this.de_stepcode = new DevExpress.XtraGrid.Columns.GridColumn();
             this.de_stepname = new DevExpress.XtraGrid.Columns.GridColumn();
+            this.de_sourcecode = new DevExpress.XtraGrid.Columns.GridColumn();
             this.de_indate = new DevExpress.XtraGrid.Columns.GridColumn();
             this.de_spec = new DevExpress.XtraGrid.Columns.GridColumn();
             this.de_inman = new DevExpress.XtraGrid.Columns.GridColumn();
@@ -164,8 +164,8 @@ namespace UAS_PLCDataReader
             this.PageWorkCenterStatus = new DevExpress.XtraTab.XtraTabPage();
             this.GridWorkCenterStatus = new UAS_PLCDataReader.CustomerControl.AutoDataGridControl.AutoDataGridControl();
             this.GridViewWorkCenterStatus = new UAS_PLCDataReader.CustomerControl.GridViewWithSerialNum.GridViewWithSerialNum();
-            this.TimerDeviceStatus = new System.Windows.Forms.Timer(this.components);
-            this.CommonTipController = new DevExpress.Utils.ToolTipController(this.components);
+            this.TimerDeviceStatus = new System.Windows.Forms.Timer();
+            this.CommonTipController = new DevExpress.Utils.ToolTipController();
             ((System.ComponentModel.ISupportInitialize)(this.RibbonNav)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.MainTabControl)).BeginInit();
             this.MainTabControl.SuspendLayout();
@@ -524,6 +524,7 @@ namespace UAS_PLCDataReader
             this.de_runstatus,
             this.de_stepcode,
             this.de_stepname,
+            this.de_sourcecode,
             this.de_indate,
             this.de_spec,
             this.de_inman,
@@ -600,7 +601,15 @@ namespace UAS_PLCDataReader
             this.de_stepname.FieldName = "DE_STEPNAME";
             this.de_stepname.Name = "de_stepname";
             this.de_stepname.Visible = true;
-            this.de_stepname.VisibleIndex = 6;
+            this.de_stepname.VisibleIndex = 7;
+            // 
+            // de_sourcecode
+            // 
+            this.de_sourcecode.Caption = "岗位资源";
+            this.de_sourcecode.FieldName = "DE_SOURCECODE";
+            this.de_sourcecode.Name = "de_sourcecode";
+            this.de_sourcecode.Visible = true;
+            this.de_sourcecode.VisibleIndex = 6;
             // 
             // de_indate
             // 
@@ -619,7 +628,7 @@ namespace UAS_PLCDataReader
             this.de_spec.FieldName = "DE_SPEC";
             this.de_spec.Name = "de_spec";
             this.de_spec.Visible = true;
-            this.de_spec.VisibleIndex = 7;
+            this.de_spec.VisibleIndex = 8;
             // 
             // de_inman
             // 
@@ -627,7 +636,7 @@ namespace UAS_PLCDataReader
             this.de_inman.FieldName = "DE_INMAN";
             this.de_inman.Name = "de_inman";
             this.de_inman.Visible = true;
-            this.de_inman.VisibleIndex = 8;
+            this.de_inman.VisibleIndex = 9;
             // 
             // de_vendcode
             // 
@@ -641,7 +650,7 @@ namespace UAS_PLCDataReader
             this.de_vendname.FieldName = "DE_VENDNAME";
             this.de_vendname.Name = "de_vendname";
             this.de_vendname.Visible = true;
-            this.de_vendname.VisibleIndex = 9;
+            this.de_vendname.VisibleIndex = 10;
             // 
             // de_address
             // 
@@ -649,7 +658,7 @@ namespace UAS_PLCDataReader
             this.de_address.FieldName = "DE_ADDRESS";
             this.de_address.Name = "de_address";
             this.de_address.Visible = true;
-            this.de_address.VisibleIndex = 10;
+            this.de_address.VisibleIndex = 11;
             // 
             // de_linecode
             // 
@@ -657,7 +666,7 @@ namespace UAS_PLCDataReader
             this.de_linecode.FieldName = "DE_LINECODE";
             this.de_linecode.Name = "de_linecode";
             this.de_linecode.Visible = true;
-            this.de_linecode.VisibleIndex = 11;
+            this.de_linecode.VisibleIndex = 12;
             // 
             // de_wccode
             // 
@@ -665,7 +674,7 @@ namespace UAS_PLCDataReader
             this.de_wccode.FieldName = "DE_WCCODE";
             this.de_wccode.Name = "de_wccode";
             this.de_wccode.Visible = true;
-            this.de_wccode.VisibleIndex = 12;
+            this.de_wccode.VisibleIndex = 13;
             // 
             // PageCommandSet
             // 
@@ -872,17 +881,16 @@ namespace UAS_PLCDataReader
             this.dc_man.OptionsColumn.AllowEdit = false;
             this.dc_man.Visible = true;
             this.dc_man.VisibleIndex = 8;
-            this.dc_man.Width = 217;
+            this.dc_man.Width = 151;
             // 
             // dc_date
             // 
             this.dc_date.Caption = "维护时间";
             this.dc_date.FieldName = "DC_DATE";
             this.dc_date.Name = "dc_date";
-            this.dc_date.OptionsColumn.AllowEdit = false;
             this.dc_date.Visible = true;
             this.dc_date.VisibleIndex = 9;
-            this.dc_date.Width = 52;
+            this.dc_date.Width = 118;
             // 
             // db_name
             // 
@@ -1781,5 +1789,6 @@ namespace UAS_PLCDataReader
         private CustomerControl.Button.ButtonDeleteRow ButtonDeleteDevice;
         private CustomerControl.Button.ButtonSaveGrid ButtonSaveDevice;
         private DevExpress.XtraGrid.Columns.GridColumn DeviceListCheckedColumn;
+        private DevExpress.XtraGrid.Columns.GridColumn de_sourcecode;
     }
 }

+ 20 - 11
PLCDataReader/Main.cs

@@ -79,10 +79,10 @@ namespace UAS_PLCDataReader
         private void Main_Load(object sender, EventArgs e)
         {
             //设备列表
-            GridDeviceList.GetDataSQL = "SELECT 0 CHECKEDCOLUMN,DE_ID,DE_CODE,DE_NAME,DE_SPEC,DE_INDATE,DE_RUNSTATUS,DE_ADDRESS,DE_INMAN,DE_LINECODE,DE_WCCODE,DE_VENDCODE,DE_VENDNAME,DE_STEPCODE,DE_STEPNAME FROM DEVICE ORDER BY DE_CODE".ToUpper();
+            GridDeviceList.GetDataSQL = "SELECT 0 CHECKEDCOLUMN,DE_ID,DE_CODE,DE_NAME,DE_SPEC,DE_INDATE,DE_RUNSTATUS,DE_ADDRESS,DE_INMAN,DE_LINECODE,DE_WCCODE,DE_VENDCODE,DE_VENDNAME,DE_STEPCODE,DE_STEPNAME,DE_SOURCECODE FROM DEVICE ORDER BY DE_CODE".ToUpper();
             GridDeviceList.TableName = "device";
             GridDeviceList.ID = "de_id";
-            GridDeviceList.InsertSQL = "INSERT INTO DEVICE(DE_ID,DE_CODE,DE_NAME,DE_SPEC,DE_INDATE,DE_RUNSTATUS,DE_ADDRESS,DE_INMAN,DE_LINECODE,DE_WCCODE,DE_VENDCODE,DE_VENDNAME,DE_STEPCODE,DE_STEPNAME) VALUES(DEVICE_SEQ.NEXTVAL,:DE_CODE,:DE_NAME,:DE_SPEC,:DE_INDATE,:DE_RUNSTATUS,:DE_ADDRESS,:DE_INMAN,:DE_LINECODE,:DE_WCCODE,:DE_VENDCODE,:DE_VENDNAME,:DE_STEPCODE,:DE_STEPNAME)";
+            GridDeviceList.InsertSQL = "INSERT INTO DEVICE(DE_ID,DE_CODE,DE_NAME,DE_SPEC,DE_INDATE,DE_RUNSTATUS,DE_ADDRESS,DE_INMAN,DE_LINECODE,DE_WCCODE,DE_VENDCODE,DE_VENDNAME,DE_STEPCODE,DE_STEPNAME,DE_SOURCECODE) VALUES(DEVICE_SEQ.NEXTVAL,:DE_CODE,:DE_NAME,:DE_SPEC,:DE_INDATE,:DE_RUNSTATUS,:DE_ADDRESS,:DE_INMAN,:DE_LINECODE,:DE_WCCODE,:DE_VENDCODE,:DE_VENDNAME,:DE_STEPCODE,:DE_STEPNAME,:DE_SOURCECODE)";
             ButtonAddDevice.Grid = GridDeviceList;
             ButtonSaveDevice.Grid = GridDeviceList;
             ButtonDeleteDevice.Grid = GridDeviceList;
@@ -105,7 +105,7 @@ namespace UAS_PLCDataReader
             ButtonDeleteCommandSet.Grid = GridPollingSetting;
 
             //指令设置界面
-            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.GetDataSQL = "select 0 CHECKEDCOLUMN,dc_id,dc_code,dc_name,dc_type,dc_value,dc_sendcoding,dc_receivecoding,db_name,dc_man,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,dc_man,dc_date) values(devicecommand_seq.nextval,:dc_code,:dc_name,:dc_value,'" + BaseUtil.GetComboxEditValue(Brand) + "',:dc_sendcoding,:dc_receivecoding,'" + User.UserName + "',sysdate)";
@@ -162,8 +162,11 @@ namespace UAS_PLCDataReader
             ButtonSaveDevice.DoSaveAfterHandler();
             sql.Clear();
             sql.Append("update device set de_inman='" + User.UserName + "' where de_id=:de_id");
-            dh.BatchInsert(sql.ToString(), new string[] { "de_id" }, ButtonSaveDevice.LastSaveID);
-            GridDeviceList.RefreshData();
+            if (ButtonSaveDevice.LastSaveID != null && ButtonSaveDevice.LastSaveID.Length > 0)
+            {
+                dh.BatchInsert(sql.ToString(), new string[] { "de_id" }, ButtonSaveDevice.LastSaveID);
+                GridDeviceList.RefreshData();
+            }
         }
 
         private void ComboxDeviceListWC_SelectedIndexChanged(object sender, EventArgs e)
@@ -171,7 +174,7 @@ namespace UAS_PLCDataReader
             DeviceListQuerySQL.Clear();
             string WC = BaseUtil.GetComboxEditValue(ComboxDeviceListWC);
             DeviceListQuerySQL.Append("select  0 CHECKEDCOLUMN,de_id,de_code,de_name,de_spec,de_indate,de_runstatus,de_address,de_wccode,de_inman,de_linecode");
-            DeviceListQuerySQL.Append("de_vendcode,de_vendname,de_stepcode,de_stepname from device where de_wccode='" + WC + "' order by de_code");
+            DeviceListQuerySQL.Append("de_vendcode,de_vendname,de_stepcode,de_stepname,DE_SOURCECODE from device where de_wccode='" + WC + "' order by de_code");
             sql.Clear();
             if (WC == "全部")
                 sql.Append("select li_code,li_name from line");
@@ -188,7 +191,7 @@ namespace UAS_PLCDataReader
             string WC = BaseUtil.GetComboxEditValue(ComboxDeviceListWC);
             string LC = BaseUtil.GetComboxEditValue(ComboxDeviceListLC);
             DeviceListQuerySQL.Append("select 0 CHECKEDCOLUMN,de_id,de_code,de_name,de_spec,de_indate,de_runstatus,de_address,de_wccode, ");
-            DeviceListQuerySQL.Append("de_vendcode,de_vendname,de_inman,de_linecode,de_stepcode,de_stepname from device ");
+            DeviceListQuerySQL.Append("de_vendcode,de_vendname,de_inman,de_linecode,de_stepcode,de_stepname,DE_SOURCECODE from device ");
             if (WC != "全部" && LC != "全部")
                 DeviceListQuerySQL.Append(" where de_wccode='" + WC + "' and de_linecode='" + LC + "' ");
             if (WC == "全部" && LC != "全部")
@@ -285,8 +288,11 @@ namespace UAS_PLCDataReader
             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();
+            if (ButtonSaveCommand.LastSaveID != null && ButtonSaveCommand.LastSaveID.Length > 0)
+            {
+                dh.BatchInsert(sql.ToString(), new string[] { "dc_id" }, ButtonSaveCommand.LastSaveID);
+                GridCommandSetting.RefreshData();
+            }
         }
 
         /// <summary>
@@ -519,8 +525,11 @@ namespace UAS_PLCDataReader
             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();
+            if (ButtonSaveCommandSet.LastSaveID != null && ButtonSaveCommandSet.LastSaveID.Length > 0)
+            {
+                dh.BatchInsert(sql.ToString(), new string[] { "dpc_id" }, ButtonSaveCommandSet.LastSaveID);
+                GridPollingSetting.RefreshData();
+            }
         }
         /// <summary>
         /// 设置GridView多选放大镜