Pārlūkot izejas kodu

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

Hcsy 7 gadi atpakaļ
vecāks
revīzija
ee343550e9

+ 71 - 23
PLCDataReader/Device/Information/DeviceStatusInfo.Designer.cs

@@ -40,6 +40,9 @@ namespace UAS_PLCDataReader.Device.Infomation
             this.labelControl2 = new DevExpress.XtraEditors.LabelControl();
             this.labelControl1 = new DevExpress.XtraEditors.LabelControl();
             this.groupControl2 = new DevExpress.XtraEditors.GroupControl();
+            this.OUTQTY = new UAS_PLCDataReader.CustomerControl.ValueLabel.ValueLabel();
+            this.INQTY = new UAS_PLCDataReader.CustomerControl.ValueLabel.ValueLabel();
+            this.labelControl13 = new DevExpress.XtraEditors.LabelControl();
             this.labelControl5 = new DevExpress.XtraEditors.LabelControl();
             this.labelControl6 = new DevExpress.XtraEditors.LabelControl();
             this.labelControl8 = new DevExpress.XtraEditors.LabelControl();
@@ -55,15 +58,18 @@ namespace UAS_PLCDataReader.Device.Infomation
             this.dpg_receivedatasize = new UAS_PLCDataReader.CustomerControl.ValueLabel.ValueLabel();
             this.dpg_senddatasize = new UAS_PLCDataReader.CustomerControl.ValueLabel.ValueLabel();
             this.dpg_starttime = new UAS_PLCDataReader.CustomerControl.ValueLabel.ValueLabel();
-            this.labelControl13 = new DevExpress.XtraEditors.LabelControl();
-            this.INQTY = new UAS_PLCDataReader.CustomerControl.ValueLabel.ValueLabel();
-            this.OUTQTY = new UAS_PLCDataReader.CustomerControl.ValueLabel.ValueLabel();
+            this.GridDeivceStatusInfo = new DevExpress.XtraGrid.GridControl();
+            this.GridViewDeviceStatusInfo = new DevExpress.XtraGrid.Views.Grid.GridView();
+            this.dc_name = new DevExpress.XtraGrid.Columns.GridColumn();
+            this.data = new DevExpress.XtraGrid.Columns.GridColumn();
             ((System.ComponentModel.ISupportInitialize)(this.groupControl1)).BeginInit();
             this.groupControl1.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.groupControl2)).BeginInit();
             this.groupControl2.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.groupControl3)).BeginInit();
             this.groupControl3.SuspendLayout();
+            ((System.ComponentModel.ISupportInitialize)(this.GridDeivceStatusInfo)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.GridViewDeviceStatusInfo)).BeginInit();
             this.SuspendLayout();
             // 
             // groupControl1
@@ -165,6 +171,31 @@ namespace UAS_PLCDataReader.Device.Infomation
             this.groupControl2.TabIndex = 1;
             this.groupControl2.Text = "生产信息";
             // 
+            // OUTQTY
+            // 
+            this.OUTQTY.Appearance.Font = new System.Drawing.Font("黑体", 12F);
+            this.OUTQTY.Location = new System.Drawing.Point(69, 156);
+            this.OUTQTY.Name = "OUTQTY";
+            this.OUTQTY.Size = new System.Drawing.Size(0, 16);
+            this.OUTQTY.TabIndex = 21;
+            // 
+            // INQTY
+            // 
+            this.INQTY.Appearance.Font = new System.Drawing.Font("黑体", 12F);
+            this.INQTY.Location = new System.Drawing.Point(69, 128);
+            this.INQTY.Name = "INQTY";
+            this.INQTY.Size = new System.Drawing.Size(0, 16);
+            this.INQTY.TabIndex = 20;
+            // 
+            // labelControl13
+            // 
+            this.labelControl13.Appearance.Font = new System.Drawing.Font("黑体", 12F);
+            this.labelControl13.Location = new System.Drawing.Point(13, 156);
+            this.labelControl13.Name = "labelControl13";
+            this.labelControl13.Size = new System.Drawing.Size(32, 16);
+            this.labelControl13.TabIndex = 11;
+            this.labelControl13.Text = "产出";
+            // 
             // labelControl5
             // 
             this.labelControl5.Appearance.Font = new System.Drawing.Font("黑体", 12F);
@@ -304,36 +335,47 @@ namespace UAS_PLCDataReader.Device.Infomation
             this.dpg_starttime.Size = new System.Drawing.Size(0, 16);
             this.dpg_starttime.TabIndex = 0;
             // 
-            // labelControl13
+            // GridDeivceStatusInfo
             // 
-            this.labelControl13.Appearance.Font = new System.Drawing.Font("黑体", 12F);
-            this.labelControl13.Location = new System.Drawing.Point(13, 156);
-            this.labelControl13.Name = "labelControl13";
-            this.labelControl13.Size = new System.Drawing.Size(32, 16);
-            this.labelControl13.TabIndex = 11;
-            this.labelControl13.Text = "产出";
+            this.GridDeivceStatusInfo.Location = new System.Drawing.Point(550, 12);
+            this.GridDeivceStatusInfo.MainView = this.GridViewDeviceStatusInfo;
+            this.GridDeivceStatusInfo.Name = "GridDeivceStatusInfo";
+            this.GridDeivceStatusInfo.Size = new System.Drawing.Size(207, 372);
+            this.GridDeivceStatusInfo.TabIndex = 3;
+            this.GridDeivceStatusInfo.ViewCollection.AddRange(new DevExpress.XtraGrid.Views.Base.BaseView[] {
+            this.GridViewDeviceStatusInfo});
             // 
-            // INQTY
+            // GridViewDeviceStatusInfo
             // 
-            this.INQTY.Appearance.Font = new System.Drawing.Font("黑体", 12F);
-            this.INQTY.Location = new System.Drawing.Point(69, 128);
-            this.INQTY.Name = "INQTY";
-            this.INQTY.Size = new System.Drawing.Size(0, 16);
-            this.INQTY.TabIndex = 20;
+            this.GridViewDeviceStatusInfo.Columns.AddRange(new DevExpress.XtraGrid.Columns.GridColumn[] {
+            this.dc_name,
+            this.data});
+            this.GridViewDeviceStatusInfo.GridControl = this.GridDeivceStatusInfo;
+            this.GridViewDeviceStatusInfo.Name = "GridViewDeviceStatusInfo";
+            this.GridViewDeviceStatusInfo.OptionsView.ShowGroupPanel = false;
             // 
-            // OUTQTY
+            // dc_name
             // 
-            this.OUTQTY.Appearance.Font = new System.Drawing.Font("黑体", 12F);
-            this.OUTQTY.Location = new System.Drawing.Point(69, 156);
-            this.OUTQTY.Name = "OUTQTY";
-            this.OUTQTY.Size = new System.Drawing.Size(0, 16);
-            this.OUTQTY.TabIndex = 21;
+            this.dc_name.Caption = "参数";
+            this.dc_name.FieldName = "DC_NAME";
+            this.dc_name.Name = "dc_name";
+            this.dc_name.Visible = true;
+            this.dc_name.VisibleIndex = 0;
+            // 
+            // data
+            // 
+            this.data.Caption = "上一次更新值";
+            this.data.FieldName = "DATA";
+            this.data.Name = "data";
+            this.data.Visible = true;
+            this.data.VisibleIndex = 1;
             // 
             // DeviceStatusInfo
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 14F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.ClientSize = new System.Drawing.Size(556, 396);
+            this.ClientSize = new System.Drawing.Size(769, 396);
+            this.Controls.Add(this.GridDeivceStatusInfo);
             this.Controls.Add(this.groupControl3);
             this.Controls.Add(this.groupControl2);
             this.Controls.Add(this.groupControl1);
@@ -354,6 +396,8 @@ namespace UAS_PLCDataReader.Device.Infomation
             ((System.ComponentModel.ISupportInitialize)(this.groupControl3)).EndInit();
             this.groupControl3.ResumeLayout(false);
             this.groupControl3.PerformLayout();
+            ((System.ComponentModel.ISupportInitialize)(this.GridDeivceStatusInfo)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.GridViewDeviceStatusInfo)).EndInit();
             this.ResumeLayout(false);
 
         }
@@ -388,5 +432,9 @@ namespace UAS_PLCDataReader.Device.Infomation
         private DevExpress.XtraEditors.LabelControl labelControl13;
         private ValueLabel OUTQTY;
         private ValueLabel INQTY;
+        private DevExpress.XtraGrid.GridControl GridDeivceStatusInfo;
+        private DevExpress.XtraGrid.Views.Grid.GridView GridViewDeviceStatusInfo;
+        private DevExpress.XtraGrid.Columns.GridColumn dc_name;
+        private DevExpress.XtraGrid.Columns.GridColumn data;
     }
 }

+ 20 - 17
PLCDataReader/Device/Information/DeviceStatusInfo.cs

@@ -40,6 +40,11 @@ namespace UAS_PLCDataReader.Device.Infomation
             {
                 BaseUtil.SetFormValue(Controls, dt);
             }
+            sql.Clear();
+            sql.Append("select dc_name,case when dc_type='INQTY' then dr_qty when dc_type='OUTQTY' then dr_okqty end data ");
+            sql.Append("from DEVICEPOLLINGCONFIG left join devicecommand on dpc_dccode = dc_code left join DEVICERUNSTATUS ");
+            sql.Append("on dpc_decode = dr_decode where dpc_decode = '" + de_code + "'");
+            GridDeivceStatusInfo.DataSource = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
             if (Main.ReturnData.ContainsKey(de_code))
             {
                 dpg_count.Text = Main.ReturnData[de_code].SendCount.ToString();
@@ -49,28 +54,26 @@ namespace UAS_PLCDataReader.Device.Infomation
                 dpg_senddatasize.Text = Main.ReturnData[de_code].SendDataSize.ToString();
                 dpg_receivedatasize.Text = Main.ReturnData[de_code].ReceiveDataSize.ToString();
                 Dictionary<string, string> ItemData = Main.ReturnData[de_code].ItemData;
-                foreach (var item in ItemData)
+                if (ItemData != null && ItemData.Count > 0)
                 {
-                    switch (item.Key)
+                    foreach (var item in ItemData)
                     {
-                        case "INQTY":
-                            INQTY.Text = item.Value;
-                            break;
-                        case "OUTQTY":
-                            OUTQTY.Text = item.Value;
-                            break;
-                        case "TEMPERATURE":
-                            break;
-                        default:
-                            break;
+                        switch (item.Key)
+                        {
+                            case "INQTY":
+                                INQTY.Text = item.Value;
+                                break;
+                            case "OUTQTY":
+                                OUTQTY.Text = item.Value;
+                                break;
+                            case "TEMPERATURE":
+                                break;
+                            default:
+                                break;
+                        }
                     }
                 }
             }
-            //dt = (DataTable)dh.ExecuteSql("select dpg_count,round((sysdate-dpg_starttime)*1440)||'分钟' dpg_runtime,dpg_starttime,dpg_senddatasize,dpg_receivedatasize from DEVICEPOLLINGLOG where dpg_id=(select max(dpg_id) from DEVICEPOLLINGLOG where dpg_decode='" + de_code + "') and dpg_status='Running'", "select");
-            //if (dt.Rows.Count > 0)
-            //{
-            //    BaseUtil.SetFormValue(Controls, dt);
-            //}
         }
 
         private void DeviceStatusInfo_KeyDown(object sender, KeyEventArgs e)

+ 209 - 6
PLCDataReader/Main.Designer.cs

@@ -33,6 +33,7 @@ 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();
@@ -42,6 +43,7 @@ namespace UAS_PLCDataReader
             this.ButtionPolling = new DevExpress.XtraBars.BarButtonItem();
             this.ButtonDeviceStatus = new DevExpress.XtraBars.BarButtonItem();
             this.ButtonWorkCenterStatus = new DevExpress.XtraBars.BarButtonItem();
+            this.ButtonDeviceRunLog = new DevExpress.XtraBars.BarButtonItem();
             this.DeviceInf = new DevExpress.XtraBars.Ribbon.RibbonPage();
             this.RibDeviceInf = new DevExpress.XtraBars.Ribbon.RibbonPageGroup();
             this.DeviceCommandSetting = new DevExpress.XtraBars.Ribbon.RibbonPage();
@@ -172,9 +174,23 @@ 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.CommonTipController = new DevExpress.Utils.ToolTipController();
-            this.TimerUpdateDevice = new System.Windows.Forms.Timer();
+            this.PageDeviceRunLog = new DevExpress.XtraTab.XtraTabPage();
+            this.ButtonSearchDeviceRunLog = new DevExpress.XtraEditors.SimpleButton();
+            this.TextDrrDeCode = new DevExpress.XtraEditors.TextEdit();
+            this.LabelDrrDeCode = new DevExpress.XtraEditors.LabelControl();
+            this.GridDeviceRunLog = new UAS_PLCDataReader.CustomerControl.AutoDataGridControl.AutoDataGridControl();
+            this.GirdViewDeviceRunLog = new UAS_PLCDataReader.CustomerControl.GridViewWithSerialNum.GridViewWithSerialNum();
+            this.主键 = new DevExpress.XtraGrid.Columns.GridColumn();
+            this.drr_decode = new DevExpress.XtraGrid.Columns.GridColumn();
+            this.drr_dename = new DevExpress.XtraGrid.Columns.GridColumn();
+            this.drr_command = new DevExpress.XtraGrid.Columns.GridColumn();
+            this.drr_date = new DevExpress.XtraGrid.Columns.GridColumn();
+            this.drr_commandfrom = new DevExpress.XtraGrid.Columns.GridColumn();
+            this.drr_doman = new DevExpress.XtraGrid.Columns.GridColumn();
+            this.drr_remark = new DevExpress.XtraGrid.Columns.GridColumn();
+            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);
             ((System.ComponentModel.ISupportInitialize)(this.RibbonNav)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.MainTabControl)).BeginInit();
             this.MainTabControl.SuspendLayout();
@@ -214,6 +230,10 @@ namespace UAS_PLCDataReader
             this.PageWorkCenterStatus.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.GridWorkCenterStatus)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.GridViewWorkCenterStatus)).BeginInit();
+            this.PageDeviceRunLog.SuspendLayout();
+            ((System.ComponentModel.ISupportInitialize)(this.TextDrrDeCode.Properties)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.GridDeviceRunLog)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.GirdViewDeviceRunLog)).BeginInit();
             this.SuspendLayout();
             // 
             // RibbonNav
@@ -229,9 +249,10 @@ namespace UAS_PLCDataReader
             this.ButtonPollingSetting,
             this.ButtionPolling,
             this.ButtonDeviceStatus,
-            this.ButtonWorkCenterStatus});
+            this.ButtonWorkCenterStatus,
+            this.ButtonDeviceRunLog});
             this.RibbonNav.Location = new System.Drawing.Point(0, 0);
-            this.RibbonNav.MaxItemId = 15;
+            this.RibbonNav.MaxItemId = 16;
             this.RibbonNav.Name = "RibbonNav";
             this.RibbonNav.Pages.AddRange(new DevExpress.XtraBars.Ribbon.RibbonPage[] {
             this.DeviceInf,
@@ -307,6 +328,16 @@ namespace UAS_PLCDataReader
             this.ButtonWorkCenterStatus.Tag = "PageWorkCenterStatus";
             this.ButtonWorkCenterStatus.ItemClick += new DevExpress.XtraBars.ItemClickEventHandler(this.ButtonItem_ItemClick);
             // 
+            // ButtonDeviceRunLog
+            // 
+            this.ButtonDeviceRunLog.Caption = "设备运行日志";
+            this.ButtonDeviceRunLog.Glyph = global::UAS_PLCDataReader.Properties.Resources.Png_Device;
+            this.ButtonDeviceRunLog.Id = 15;
+            this.ButtonDeviceRunLog.LargeGlyph = global::UAS_PLCDataReader.Properties.Resources.Png_Device;
+            this.ButtonDeviceRunLog.Name = "ButtonDeviceRunLog";
+            this.ButtonDeviceRunLog.Tag = "PageDeviceRunLog";
+            this.ButtonDeviceRunLog.ItemClick += new DevExpress.XtraBars.ItemClickEventHandler(this.ButtonItem_ItemClick);
+            // 
             // DeviceInf
             // 
             this.DeviceInf.Groups.AddRange(new DevExpress.XtraBars.Ribbon.RibbonPageGroup[] {
@@ -334,6 +365,7 @@ namespace UAS_PLCDataReader
             // RibDeviceCommand
             // 
             this.RibDeviceCommand.ItemLinks.Add(this.ButtonDeviceStatus);
+            this.RibDeviceCommand.ItemLinks.Add(this.ButtonDeviceRunLog);
             this.RibDeviceCommand.Name = "RibDeviceCommand";
             this.RibDeviceCommand.Text = "ribbonPageGroup3";
             // 
@@ -353,7 +385,8 @@ namespace UAS_PLCDataReader
             this.PagePollingSetting,
             this.PagePolling,
             this.PageDeviceStatus,
-            this.PageWorkCenterStatus});
+            this.PageWorkCenterStatus,
+            this.PageDeviceRunLog});
             // 
             // PageDeviceList
             // 
@@ -1666,6 +1699,156 @@ namespace UAS_PLCDataReader
             this.GridViewWorkCenterStatus.Name = "GridViewWorkCenterStatus";
             this.GridViewWorkCenterStatus.OptionsView.ShowGroupPanel = false;
             // 
+            // PageDeviceRunLog
+            // 
+            this.PageDeviceRunLog.Controls.Add(this.ButtonSearchDeviceRunLog);
+            this.PageDeviceRunLog.Controls.Add(this.TextDrrDeCode);
+            this.PageDeviceRunLog.Controls.Add(this.LabelDrrDeCode);
+            this.PageDeviceRunLog.Controls.Add(this.GridDeviceRunLog);
+            this.PageDeviceRunLog.Name = "PageDeviceRunLog";
+            this.PageDeviceRunLog.PageVisible = false;
+            this.PageDeviceRunLog.Size = new System.Drawing.Size(1027, 577);
+            this.PageDeviceRunLog.Text = "设备运行日志";
+            // 
+            // ButtonSearchDeviceRunLog
+            // 
+            this.ButtonSearchDeviceRunLog.Location = new System.Drawing.Point(170, 4);
+            this.ButtonSearchDeviceRunLog.Name = "ButtonSearchDeviceRunLog";
+            this.ButtonSearchDeviceRunLog.Size = new System.Drawing.Size(64, 23);
+            this.ButtonSearchDeviceRunLog.TabIndex = 3;
+            this.ButtonSearchDeviceRunLog.Text = "查询";
+            this.ButtonSearchDeviceRunLog.Click += new System.EventHandler(this.ButtonSearchDeviceRunLog_Click);
+            // 
+            // TextDrrDeCode
+            // 
+            this.TextDrrDeCode.Location = new System.Drawing.Point(64, 5);
+            this.TextDrrDeCode.MenuManager = this.RibbonNav;
+            this.TextDrrDeCode.Name = "TextDrrDeCode";
+            this.TextDrrDeCode.Size = new System.Drawing.Size(100, 20);
+            this.TextDrrDeCode.TabIndex = 2;
+            // 
+            // LabelDrrDeCode
+            // 
+            this.LabelDrrDeCode.Appearance.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+            this.LabelDrrDeCode.Location = new System.Drawing.Point(10, 7);
+            this.LabelDrrDeCode.Name = "LabelDrrDeCode";
+            this.LabelDrrDeCode.Size = new System.Drawing.Size(48, 17);
+            this.LabelDrrDeCode.TabIndex = 1;
+            this.LabelDrrDeCode.Text = "设备编号";
+            // 
+            // GridDeviceRunLog
+            // 
+            this.GridDeviceRunLog.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.GridDeviceRunLog.Condition = null;
+            this.GridDeviceRunLog.GetDataSQL = null;
+            this.GridDeviceRunLog.ID = null;
+            this.GridDeviceRunLog.InsertSQL = null;
+            this.GridDeviceRunLog.Location = new System.Drawing.Point(-1, 29);
+            this.GridDeviceRunLog.MainView = this.GirdViewDeviceRunLog;
+            this.GridDeviceRunLog.MenuManager = this.RibbonNav;
+            this.GridDeviceRunLog.Name = "GridDeviceRunLog";
+            this.GridDeviceRunLog.RowCount = 0;
+            this.GridDeviceRunLog.Size = new System.Drawing.Size(1028, 553);
+            this.GridDeviceRunLog.TabIndex = 0;
+            this.GridDeviceRunLog.TableName = null;
+            this.GridDeviceRunLog.ViewCollection.AddRange(new DevExpress.XtraGrid.Views.Base.BaseView[] {
+            this.GirdViewDeviceRunLog});
+            // 
+            // GirdViewDeviceRunLog
+            // 
+            this.GirdViewDeviceRunLog.Columns.AddRange(new DevExpress.XtraGrid.Columns.GridColumn[] {
+            this.主键,
+            this.drr_decode,
+            this.drr_dename,
+            this.drr_command,
+            this.drr_date,
+            this.drr_commandfrom,
+            this.drr_doman,
+            this.drr_remark});
+            this.GirdViewDeviceRunLog.GridControl = this.GridDeviceRunLog;
+            this.GirdViewDeviceRunLog.IndicatorWidth = 30;
+            this.GirdViewDeviceRunLog.Name = "GirdViewDeviceRunLog";
+            this.GirdViewDeviceRunLog.OptionsView.ShowGroupPanel = false;
+            // 
+            // 主键
+            // 
+            this.主键.Caption = "drr_id";
+            this.主键.FieldName = "DRR_ID";
+            this.主键.Name = "主键";
+            this.主键.OptionsColumn.AllowEdit = false;
+            // 
+            // drr_decode
+            // 
+            this.drr_decode.Caption = "设备编号";
+            this.drr_decode.FieldName = "DRR_DECODE";
+            this.drr_decode.Name = "drr_decode";
+            this.drr_decode.OptionsColumn.AllowEdit = false;
+            this.drr_decode.Visible = true;
+            this.drr_decode.VisibleIndex = 0;
+            this.drr_decode.Width = 142;
+            // 
+            // drr_dename
+            // 
+            this.drr_dename.Caption = "设备名称";
+            this.drr_dename.FieldName = "DRR_DENAME";
+            this.drr_dename.Name = "drr_dename";
+            this.drr_dename.OptionsColumn.AllowEdit = false;
+            this.drr_dename.Visible = true;
+            this.drr_dename.VisibleIndex = 1;
+            this.drr_dename.Width = 142;
+            // 
+            // drr_command
+            // 
+            this.drr_command.Caption = "指令类型";
+            this.drr_command.FieldName = "DRR_COMMAND";
+            this.drr_command.Name = "drr_command";
+            this.drr_command.OptionsColumn.AllowEdit = false;
+            this.drr_command.Visible = true;
+            this.drr_command.VisibleIndex = 2;
+            this.drr_command.Width = 142;
+            // 
+            // drr_date
+            // 
+            this.drr_date.Caption = "日期";
+            this.drr_date.FieldName = "DRR_DATE";
+            this.drr_date.Name = "drr_date";
+            this.drr_date.OptionsColumn.AllowEdit = false;
+            this.drr_date.Visible = true;
+            this.drr_date.VisibleIndex = 3;
+            this.drr_date.Width = 142;
+            // 
+            // drr_commandfrom
+            // 
+            this.drr_commandfrom.Caption = "指令来源";
+            this.drr_commandfrom.FieldName = "DRR_COMMANDFROM";
+            this.drr_commandfrom.Name = "drr_commandfrom";
+            this.drr_commandfrom.OptionsColumn.AllowEdit = false;
+            this.drr_commandfrom.Visible = true;
+            this.drr_commandfrom.VisibleIndex = 4;
+            this.drr_commandfrom.Width = 142;
+            // 
+            // drr_doman
+            // 
+            this.drr_doman.Caption = "执行人";
+            this.drr_doman.FieldName = "DRR_DOMAN";
+            this.drr_doman.Name = "drr_doman";
+            this.drr_doman.OptionsColumn.AllowEdit = false;
+            this.drr_doman.Visible = true;
+            this.drr_doman.VisibleIndex = 5;
+            this.drr_doman.Width = 142;
+            // 
+            // drr_remark
+            // 
+            this.drr_remark.Caption = "备注";
+            this.drr_remark.FieldName = "DRR_REMARK";
+            this.drr_remark.Name = "drr_remark";
+            this.drr_remark.OptionsColumn.AllowEdit = false;
+            this.drr_remark.Visible = true;
+            this.drr_remark.VisibleIndex = 6;
+            this.drr_remark.Width = 144;
+            // 
             // TimerDeviceStatus
             // 
             this.TimerDeviceStatus.Interval = 10000;
@@ -1738,6 +1921,11 @@ namespace UAS_PLCDataReader
             this.PageWorkCenterStatus.ResumeLayout(false);
             ((System.ComponentModel.ISupportInitialize)(this.GridWorkCenterStatus)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.GridViewWorkCenterStatus)).EndInit();
+            this.PageDeviceRunLog.ResumeLayout(false);
+            this.PageDeviceRunLog.PerformLayout();
+            ((System.ComponentModel.ISupportInitialize)(this.TextDrrDeCode.Properties)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.GridDeviceRunLog)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.GirdViewDeviceRunLog)).EndInit();
             this.ResumeLayout(false);
             this.PerformLayout();
 
@@ -1886,5 +2074,20 @@ namespace UAS_PLCDataReader
         private DevExpress.XtraGrid.Columns.GridColumn de_item3;
         private DevExpress.XtraEditors.Repository.RepositoryItemComboBox DataItemRepositoryItemComboBox1;
         private DevExpress.XtraGrid.Columns.GridColumn dc_type;
+        private DevExpress.XtraBars.BarButtonItem ButtonDeviceRunLog;
+        private DevExpress.XtraTab.XtraTabPage PageDeviceRunLog;
+        private AutoDataGridControl GridDeviceRunLog;
+        private GridViewWithSerialNum GirdViewDeviceRunLog;
+        private DevExpress.XtraGrid.Columns.GridColumn 主键;
+        private DevExpress.XtraGrid.Columns.GridColumn drr_decode;
+        private DevExpress.XtraGrid.Columns.GridColumn drr_dename;
+        private DevExpress.XtraGrid.Columns.GridColumn drr_command;
+        private DevExpress.XtraGrid.Columns.GridColumn drr_date;
+        private DevExpress.XtraGrid.Columns.GridColumn drr_commandfrom;
+        private DevExpress.XtraGrid.Columns.GridColumn drr_doman;
+        private DevExpress.XtraGrid.Columns.GridColumn drr_remark;
+        private LabelControl LabelDrrDeCode;
+        private SimpleButton ButtonSearchDeviceRunLog;
+        private TextEdit TextDrrDeCode;
     }
 }

+ 33 - 4
PLCDataReader/Main.cs

@@ -71,10 +71,21 @@ namespace UAS_PLCDataReader
             ComboBoxData cbd5 = new ComboBoxData();
             cbd5.Text = "温度";
             cbd5.Value = "TEMPERATURE";
+            ComboBoxData cbd6 = new ComboBoxData();
+            cbd6.Text = "参数1";
+            cbd6.Value = "PARAM1";
+            ComboBoxData cbd7 = new ComboBoxData();
+            cbd7.Text = "参数2";
+            cbd7.Value = "PARAM2";
+            ComboBoxData cbd8 = new ComboBoxData();
+            cbd8.Text = "参数3";
+            cbd8.Value = "PARAM3";
             DataItemRepositoryItemComboBox1.Items.Add(cbd3);
             DataItemRepositoryItemComboBox1.Items.Add(cbd4);
             DataItemRepositoryItemComboBox1.Items.Add(cbd5);
-
+            DataItemRepositoryItemComboBox1.Items.Add(cbd6);
+            DataItemRepositoryItemComboBox1.Items.Add(cbd7);
+            DataItemRepositoryItemComboBox1.Items.Add(cbd8);
             #endregion
         }
 
@@ -146,7 +157,7 @@ namespace UAS_PLCDataReader
             ButtonDeleteCommandSet.Grid = GridPollingSetting;
 
             //指令设置界面
-            GridCommandSetting.GetDataSQL = "select 0 CHECKEDCOLUMN,dc_id,dc_code,dc_name,dc_type,case when dc_type='INQTY' then '投入' when dc_type='OUTQTY' then '产出' when dc_type='TEMPERATURE' then '温度' end dc_typename,dc_value,dc_dataindex,dc_sendcoding,dc_receivecoding,db_name,dc_man,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,case when dc_type='INQTY' then '投入' when dc_type='OUTQTY' then '产出' when dc_type='TEMPERATURE' then '温度' when dc_type='PARAM1' then '参数1' when dc_type='PARAM2' then '参数2' when dc_type='PARAM3' then '参数3'  end dc_typename,dc_value,dc_dataindex,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,dc_dataindex) values(devicecommand_seq.nextval,:dc_code,:dc_name,:dc_value,'" + BaseUtil.GetComboxEditValue(Brand) + "',:dc_sendcoding,:dc_receivecoding,'" + User.UserName + "',sysdate,:dc_dataindex)";
@@ -163,6 +174,9 @@ namespace UAS_PLCDataReader
             ButtonAddNetConfig.Grid = GridDeviceNetSetting;
             ButtonSaveNetConfig.Grid = GridDeviceNetSetting;
 
+            GridDeviceRunLog.GetDataSQL = "SELECT * FROM DEVICERUNRECORD";
+            GridDeviceRunLog.ID = "drr_id";
+            GridDeviceRunLog.TableName = "DEVICERUNRECORD";
             TimerUpdateDevice.Start();
 
             Ptime = new Dictionary<int, PollingTimer>();
@@ -513,7 +527,7 @@ namespace UAS_PLCDataReader
                     Dictionary<string, string> ItemData = new Dictionary<string, string>();
                     int[] Arr = BaseUtil.GetDecimalData(BaseUtil.ASCIIToString(client[DpcID].Returnvalue[IP]), 8);
                     //返回的参数个数和定义的参数个数相等或者小于的时候
-                    if (Arr.Length == DC.Rows.Count|| DC.Rows.Count > Arr.Length)
+                    if (Arr.Length == DC.Rows.Count || DC.Rows.Count > Arr.Length)
                     {
                         for (int i = 0; i < Arr.Length; i++)
                         {
@@ -556,7 +570,7 @@ namespace UAS_PLCDataReader
                             ReturnData[Decode].ItemData = ItemData;
                             LogicHandler.UpdateDeviceData(dh, Decode, ItemData);
                             QueueUpdateDevice.Enqueue(ReturnData[Decode]);
-                            LogicHandler.DoDeviceDataDiffLog(dh, pl.DeviceCode, pl.DeviceName, pl.CommandCode, User.UserName);
+                            LogicHandler.DoDeviceDataDiffLog(dh, pl.DeviceCode, pl.DeviceName, Command, pl.CommandCode, User.UserName);
                         }
                     }
                     client[DpcID].Returnvalue.Remove(IP);
@@ -851,5 +865,20 @@ namespace UAS_PLCDataReader
             }
         }
         #endregion
+
+        #region 设备运行日志查看
+        private void ButtonSearchDeviceRunLog_Click(object sender, EventArgs e)
+        {
+            if (TextDrrDeCode.Text != "")
+            {
+                GridDeviceRunLog.GetDataSQL = "SELECT * FROM DEVICERUNRECORD WHERE drr_decode like '%" + TextDrrDeCode.Text + "%'";
+            }
+            else
+            {
+                GridDeviceRunLog.GetDataSQL = "SELECT * FROM DEVICERUNRECORD";
+            }
+            GridDeviceRunLog.RefreshData();
+        }
+        #endregion
     }
 }

+ 19 - 6
PLCDataReader/PublicMethod/LogicHandler.cs

@@ -41,16 +41,16 @@ namespace UAS_PLCDataReader.PublicMethod
         /// <summary>
         /// 进行差异日志记录
         /// </summary>
-        public static void DoDeviceDataDiffLog(DataHelper dh, string iDeCode, string iDeName, string iCommand, string iMan)
+        public static void DoDeviceDataDiffLog(DataHelper dh, string iDeCode, string iDeName, string iCommand, string iCommandFrom, string iMan)
         {
             sql.Clear();
-            sql.Append("insert into DeviceRunRecord(drr_id,drr_decode,drr_dename,drr_command,drr_date,drr_doman,drr_remark)");
-            sql.Append("values(DeviceRunRecord_seq.nextval,'" + iDeCode + "','" + iDeName + "','" + iCommand + "',sysdate,'" + iMan + "','')");
+            sql.Append("insert into DeviceRunRecord(drr_id,drr_decode,drr_dename,drr_command,drr_commandfrom,drr_date,drr_doman,drr_remark)");
+            sql.Append("values(DeviceRunRecord_seq.nextval,'" + iDeCode + "','" + iDeName + "','" + iCommand + "','" + iCommandFrom + "',sysdate,'" + iMan + "','')");
             dh.ExecuteSql(sql.ToString(), "insert");
         }
 
         /// <summary>
-        /// 更新设备数据
+        /// 更新设备数据投入,产出等数据
         /// </summary>
         /// <param name="Decode"></param>
         /// <param name="ItemData"></param>
@@ -59,6 +59,9 @@ namespace UAS_PLCDataReader.PublicMethod
             string INQTY = "";
             string OUTQTY = "";
             string TEMPERATURE = "";
+            string PARAM1 = "";
+            string PARAM2 = "";
+            string PARAM3 = "";
             foreach (var item in ItemData)
             {
                 switch (item.Key)
@@ -72,13 +75,23 @@ namespace UAS_PLCDataReader.PublicMethod
                     case "TEMPERATURE":
                         TEMPERATURE = item.Value;
                         break;
+                    case "PARAM1":
+                        PARAM1 = item.Value;
+                        break;
+                    case "PARAM2":
+                        PARAM2 = item.Value;
+                        break;
+                    case "PARAM3":
+                        PARAM3 = item.Value;
+                        break;
                     default:
                         break;
                 }
             }
             sql.Clear();
-            sql.Append("update DeviceRunstatus set dr_qty=:dr_inqty,dr_okqty=:dr_okqty,dr_TEMPERATURE=:dr_TEMPERATURE where dr_decode='" + Decode + "'");
-            dh.ExecuteSql(sql.ToString(), "update", INQTY, OUTQTY, TEMPERATURE);
+            sql.Append("update DeviceRunstatus set dr_qty=:dr_inqty,dr_okqty=:dr_okqty,dr_TEMPERATURE=:dr_TEMPERATURE,");
+            sql.Append("dr_value1=:dr_value1,dr_value2=:dr_value2,dr_value3=:dr_value3 where dr_decode='" + Decode + "'");
+            dh.ExecuteSql(sql.ToString(), "update", INQTY, OUTQTY, TEMPERATURE, PARAM1, PARAM2, PARAM3);
         }
 
         /// <summary>

+ 31 - 31
UAS-出货标签管理(泽天)/PublicMethod/DataHelper.cs

@@ -563,43 +563,43 @@ namespace UAS_LabelMachine
                             {
                                 param_array[j][num] = dt.Rows[i][param[j]].ToString();
                             }
-                            dt.Rows.RemoveAt(i);
+                            //dt.Rows.RemoveAt(i);
                             num++;
                         }
                     }
                     BatchInsertDataTable(sql[0], param, param_array);
                 }
             }
-            sb.Clear();
-            sb.Append("update " + TableName + " set ");
-            int ColumnCount = dt.Columns.Count;
-            int RowCount = dt.Rows.Count;
-            //存数据的参数
-            List<string[]> Parameter = new List<string[]>();
-            //存参数名的参数
-            string[] ParName = new string[ColumnCount];
-            for (int i = 0; i < ColumnCount; i++)
-            {
-                ParName[i] = dt.Columns[i].ColumnName;
-                if (i == dt.Columns.Count - 1)
-                    sb.Append(dt.Columns[i].ColumnName + "=:" + dt.Columns[i].ColumnName);
-                else
-                    sb.Append(dt.Columns[i].ColumnName + "=:" + dt.Columns[i].ColumnName + ",");
-            }
-            sb.Append(" where " + ID + " =:" + ID);
-            //先添加参数
-            Parameter.Add(ParName);
-            //添加参数的具体内容
-            for (int i = 0; i < ColumnCount; i++)
-            {
-                string[] par = new string[RowCount];
-                for (int j = 0; j < RowCount; j++)
-                {
-                    par[j] = dt.Rows[j][i].ToString();
-                }
-                Parameter.Add(par);
-            }
-            BatchInsert(sb.ToString(), Parameter.ToArray());
+            //sb.Clear();
+            //sb.Append("update " + TableName + " set ");
+            //int ColumnCount = dt.Columns.Count;
+            //int RowCount = dt.Rows.Count;
+            ////存数据的参数
+            //List<string[]> Parameter = new List<string[]>();
+            ////存参数名的参数
+            //string[] ParName = new string[ColumnCount];
+            //for (int i = 0; i < ColumnCount; i++)
+            //{
+            //    ParName[i] = dt.Columns[i].ColumnName;
+            //    if (i == dt.Columns.Count - 1)
+            //        sb.Append(dt.Columns[i].ColumnName + "=:" + dt.Columns[i].ColumnName);
+            //    else
+            //        sb.Append(dt.Columns[i].ColumnName + "=:" + dt.Columns[i].ColumnName + ",");
+            //}
+            //sb.Append(" where " + ID + " =:" + ID);
+            ////先添加参数
+            //Parameter.Add(ParName);
+            ////添加参数的具体内容
+            //for (int i = 0; i < ColumnCount; i++)
+            //{
+            //    string[] par = new string[RowCount];
+            //    for (int j = 0; j < RowCount; j++)
+            //    {
+            //        par[j] = dt.Rows[j][i].ToString();
+            //    }
+            //    Parameter.Add(par);
+            //}
+            //BatchInsert(sb.ToString(), Parameter.ToArray());
         }
 
         /// <summary>

+ 139 - 118
UAS-出货标签管理(泽天)/UAS_出货标签管理.Designer.cs

@@ -91,18 +91,6 @@
             this.ProcessCount = new System.Windows.Forms.Label();
             this.DCCheck = new UAS_LabelMachine.CustomControl.EnterTextBox();
             this.GridPrcode = new UAS_LabelMachine.CustomControl.DataGridViewWithSerialNum();
-            this.pd_pdno = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pd_whcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pjd_id = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pd_custprodcode1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pd_prodcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.CollectedNum = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.UnCollectedNum = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pd_outqty = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pr_unit = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pr_spec1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pd_brand = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pjd_zxbzs_user = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.groupBoxWithBorder1 = new UAS_LabelMachine.CustomControl.GroupBoxWithBorder.GroupBoxWithBorder();
             this.label18 = new System.Windows.Forms.Label();
             this.MidBoxEnd = new UAS_LabelMachine.CustomControl.EnterTextBox();
@@ -158,6 +146,20 @@
             this.OutboxCapacity = new System.Windows.Forms.NumericUpDown();
             this.OutBoxLabelPrint = new System.Windows.Forms.Button();
             this.OutBoxCombox = new System.Windows.Forms.ComboBox();
+            this.pd_pdno = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pd_piid = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pd_inoutno = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pd_whcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pjd_id = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pd_custprodcode1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pd_prodcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.CollectedNum = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.UnCollectedNum = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pd_outqty = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pr_unit = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pr_spec1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pd_brand = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pjd_zxbzs_user = new System.Windows.Forms.DataGridViewTextBoxColumn();
             ((System.ComponentModel.ISupportInitialize)(this.MidSource)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.GridPrcode)).BeginInit();
@@ -715,6 +717,8 @@
             this.GridPrcode.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
             this.GridPrcode.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
             this.pd_pdno,
+            this.pd_piid,
+            this.pd_inoutno,
             this.pd_whcode,
             this.pjd_id,
             this.pd_custprodcode1,
@@ -747,112 +751,6 @@
             this.GridPrcode.CellPainting += new System.Windows.Forms.DataGridViewCellPaintingEventHandler(this.GridPrcode_CellPainting);
             this.GridPrcode.SelectionChanged += new System.EventHandler(this.GridPrcode_SelectionChanged);
             // 
-            // pd_pdno
-            // 
-            this.pd_pdno.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.ColumnHeader;
-            this.pd_pdno.DataPropertyName = "pd_pdno";
-            this.pd_pdno.HeaderText = "序号";
-            this.pd_pdno.Name = "pd_pdno";
-            this.pd_pdno.ReadOnly = true;
-            this.pd_pdno.Width = 54;
-            // 
-            // pd_whcode
-            // 
-            this.pd_whcode.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.ColumnHeader;
-            this.pd_whcode.DataPropertyName = "pd_whcode";
-            this.pd_whcode.HeaderText = "仓别";
-            this.pd_whcode.Name = "pd_whcode";
-            this.pd_whcode.Width = 54;
-            // 
-            // pjd_id
-            // 
-            this.pjd_id.DataPropertyName = "pjd_id";
-            this.pjd_id.HeaderText = "pjd_id";
-            this.pjd_id.Name = "pjd_id";
-            this.pjd_id.Visible = false;
-            // 
-            // pd_custprodcode1
-            // 
-            this.pd_custprodcode1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
-            this.pd_custprodcode1.DataPropertyName = "pd_custprodcode";
-            this.pd_custprodcode1.HeaderText = "客户料号";
-            this.pd_custprodcode1.Name = "pd_custprodcode1";
-            this.pd_custprodcode1.Width = 78;
-            // 
-            // pd_prodcode
-            // 
-            this.pd_prodcode.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCells;
-            this.pd_prodcode.DataPropertyName = "pd_prodcode";
-            this.pd_prodcode.HeaderText = "物料编号";
-            this.pd_prodcode.Name = "pd_prodcode";
-            this.pd_prodcode.ReadOnly = true;
-            this.pd_prodcode.Width = 78;
-            // 
-            // CollectedNum
-            // 
-            this.CollectedNum.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCells;
-            this.CollectedNum.DataPropertyName = "CollectedNum";
-            this.CollectedNum.HeaderText = "已采数";
-            this.CollectedNum.Name = "CollectedNum";
-            this.CollectedNum.ReadOnly = true;
-            this.CollectedNum.Width = 66;
-            // 
-            // UnCollectedNum
-            // 
-            this.UnCollectedNum.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCells;
-            this.UnCollectedNum.DataPropertyName = "UnCollectedNum";
-            this.UnCollectedNum.HeaderText = "未采集";
-            this.UnCollectedNum.Name = "UnCollectedNum";
-            this.UnCollectedNum.ReadOnly = true;
-            this.UnCollectedNum.Visible = false;
-            // 
-            // pd_outqty
-            // 
-            this.pd_outqty.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCells;
-            this.pd_outqty.DataPropertyName = "pd_outqty";
-            this.pd_outqty.HeaderText = "出库数量";
-            this.pd_outqty.Name = "pd_outqty";
-            this.pd_outqty.ReadOnly = true;
-            this.pd_outqty.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
-            this.pd_outqty.Width = 59;
-            // 
-            // pr_unit
-            // 
-            this.pr_unit.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.ColumnHeader;
-            this.pr_unit.DataPropertyName = "pr_unit";
-            this.pr_unit.HeaderText = "单位";
-            this.pr_unit.Name = "pr_unit";
-            this.pr_unit.ReadOnly = true;
-            this.pr_unit.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
-            this.pr_unit.Width = 35;
-            // 
-            // pr_spec1
-            // 
-            this.pr_spec1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCellsExceptHeader;
-            this.pr_spec1.DataPropertyName = "pr_spec";
-            this.pr_spec1.HeaderText = "规格";
-            this.pr_spec1.MinimumWidth = 100;
-            this.pr_spec1.Name = "pr_spec1";
-            // 
-            // pd_brand
-            // 
-            this.pd_brand.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.ColumnHeader;
-            this.pd_brand.DataPropertyName = "pd_brand";
-            this.pd_brand.HeaderText = "品牌";
-            this.pd_brand.Name = "pd_brand";
-            this.pd_brand.ReadOnly = true;
-            this.pd_brand.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
-            this.pd_brand.Width = 35;
-            // 
-            // pjd_zxbzs_user
-            // 
-            this.pjd_zxbzs_user.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
-            this.pjd_zxbzs_user.DataPropertyName = "pjd_zxbzs_user";
-            this.pjd_zxbzs_user.HeaderText = "最小包装";
-            this.pjd_zxbzs_user.MinimumWidth = 80;
-            this.pjd_zxbzs_user.Name = "pjd_zxbzs_user";
-            this.pjd_zxbzs_user.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
-            // 
             // groupBoxWithBorder1
             // 
             this.groupBoxWithBorder1.Controls.Add(this.label18);
@@ -1483,6 +1381,127 @@
             this.OutBoxCombox.TabIndex = 78;
             this.OutBoxCombox.SelectedIndexChanged += new System.EventHandler(this.OutBoxCombox_SelectedIndexChanged);
             // 
+            // pd_pdno
+            // 
+            this.pd_pdno.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.ColumnHeader;
+            this.pd_pdno.DataPropertyName = "pd_pdno";
+            this.pd_pdno.HeaderText = "序号";
+            this.pd_pdno.Name = "pd_pdno";
+            this.pd_pdno.ReadOnly = true;
+            this.pd_pdno.Width = 54;
+            // 
+            // pd_piid
+            // 
+            this.pd_piid.DataPropertyName = "pd_piid";
+            this.pd_piid.HeaderText = "Column1";
+            this.pd_piid.Name = "pd_piid";
+            this.pd_piid.Visible = false;
+            // 
+            // pd_inoutno
+            // 
+            this.pd_inoutno.DataPropertyName = "pd_inoutno";
+            this.pd_inoutno.HeaderText = "Column1";
+            this.pd_inoutno.Name = "pd_inoutno";
+            this.pd_inoutno.Visible = false;
+            // 
+            // pd_whcode
+            // 
+            this.pd_whcode.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.ColumnHeader;
+            this.pd_whcode.DataPropertyName = "pd_whcode";
+            this.pd_whcode.HeaderText = "仓别";
+            this.pd_whcode.Name = "pd_whcode";
+            this.pd_whcode.Width = 54;
+            // 
+            // pjd_id
+            // 
+            this.pjd_id.DataPropertyName = "pjd_id";
+            this.pjd_id.HeaderText = "pjd_id";
+            this.pjd_id.Name = "pjd_id";
+            this.pjd_id.Visible = false;
+            // 
+            // pd_custprodcode1
+            // 
+            this.pd_custprodcode1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
+            this.pd_custprodcode1.DataPropertyName = "pd_custprodcode";
+            this.pd_custprodcode1.HeaderText = "客户料号";
+            this.pd_custprodcode1.Name = "pd_custprodcode1";
+            this.pd_custprodcode1.Width = 78;
+            // 
+            // pd_prodcode
+            // 
+            this.pd_prodcode.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCells;
+            this.pd_prodcode.DataPropertyName = "pd_prodcode";
+            this.pd_prodcode.HeaderText = "物料编号";
+            this.pd_prodcode.Name = "pd_prodcode";
+            this.pd_prodcode.ReadOnly = true;
+            this.pd_prodcode.Width = 78;
+            // 
+            // CollectedNum
+            // 
+            this.CollectedNum.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCells;
+            this.CollectedNum.DataPropertyName = "CollectedNum";
+            this.CollectedNum.HeaderText = "已采数";
+            this.CollectedNum.Name = "CollectedNum";
+            this.CollectedNum.ReadOnly = true;
+            this.CollectedNum.Width = 66;
+            // 
+            // UnCollectedNum
+            // 
+            this.UnCollectedNum.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCells;
+            this.UnCollectedNum.DataPropertyName = "UnCollectedNum";
+            this.UnCollectedNum.HeaderText = "未采集";
+            this.UnCollectedNum.Name = "UnCollectedNum";
+            this.UnCollectedNum.ReadOnly = true;
+            this.UnCollectedNum.Visible = false;
+            this.UnCollectedNum.Width = 66;
+            // 
+            // pd_outqty
+            // 
+            this.pd_outqty.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCells;
+            this.pd_outqty.DataPropertyName = "pd_outqty";
+            this.pd_outqty.HeaderText = "出库数量";
+            this.pd_outqty.Name = "pd_outqty";
+            this.pd_outqty.ReadOnly = true;
+            this.pd_outqty.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
+            this.pd_outqty.Width = 59;
+            // 
+            // pr_unit
+            // 
+            this.pr_unit.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.ColumnHeader;
+            this.pr_unit.DataPropertyName = "pr_unit";
+            this.pr_unit.HeaderText = "单位";
+            this.pr_unit.Name = "pr_unit";
+            this.pr_unit.ReadOnly = true;
+            this.pr_unit.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
+            this.pr_unit.Width = 35;
+            // 
+            // pr_spec1
+            // 
+            this.pr_spec1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCellsExceptHeader;
+            this.pr_spec1.DataPropertyName = "pr_spec";
+            this.pr_spec1.HeaderText = "规格";
+            this.pr_spec1.MinimumWidth = 100;
+            this.pr_spec1.Name = "pr_spec1";
+            // 
+            // pd_brand
+            // 
+            this.pd_brand.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.ColumnHeader;
+            this.pd_brand.DataPropertyName = "pd_brand";
+            this.pd_brand.HeaderText = "品牌";
+            this.pd_brand.Name = "pd_brand";
+            this.pd_brand.ReadOnly = true;
+            this.pd_brand.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
+            this.pd_brand.Width = 35;
+            // 
+            // pjd_zxbzs_user
+            // 
+            this.pjd_zxbzs_user.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
+            this.pjd_zxbzs_user.DataPropertyName = "pjd_zxbzs_user";
+            this.pjd_zxbzs_user.HeaderText = "最小包装";
+            this.pjd_zxbzs_user.MinimumWidth = 80;
+            this.pjd_zxbzs_user.Name = "pjd_zxbzs_user";
+            this.pjd_zxbzs_user.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
+            // 
             // UAS_出货标签打印
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
@@ -1672,6 +1691,8 @@
         private System.Windows.Forms.DataGridViewTextBoxColumn pib_outboxcode1;
         private System.Windows.Forms.DataGridViewTextBoxColumn pib_outboxcode2;
         private System.Windows.Forms.DataGridViewTextBoxColumn pd_pdno;
+        private System.Windows.Forms.DataGridViewTextBoxColumn pd_piid;
+        private System.Windows.Forms.DataGridViewTextBoxColumn pd_inoutno;
         private System.Windows.Forms.DataGridViewTextBoxColumn pd_whcode;
         private System.Windows.Forms.DataGridViewTextBoxColumn pjd_id;
         private System.Windows.Forms.DataGridViewTextBoxColumn pd_custprodcode1;

+ 88 - 68
UAS-出货标签管理(泽天)/UAS_出货标签管理.cs

@@ -381,6 +381,20 @@ namespace UAS_LabelMachine
             //采集后重新计数,自动跳到下一行
             collectqty = (SumQty.Compute("sum(pib_qty)", "pib_prodcode='" + CurrentPrCode + "' and pib_pdno='" + CurrentPDNO + "'").ToString());
             CollectQty = (collectqty == "" ? 0 : double.Parse(collectqty));
+            dh.UpdateByCondition("CS$InoutPrcode", "Collectednum='" + collectqty + "'", "pd_inoutno='" + pi_inoutno.Text + "' and pd_pdno='" + CurrentPDNO + "' and combined=" + (Combindetail.Checked ? -1 : 0));
+            CollectNum = 0;
+            double OutNum = 0;
+            if (GridPrcode.SelectedRows.Count > 0)
+            {
+                GridPrcode.Rows[GridPrcode.SelectedRows[0].Index].Cells["CollectedNum"].Value = collectqty;
+                CollectNum = int.Parse(CSPrcode.Compute("sum(CollectedNum)", "1=1").ToString());
+                OutNum = int.Parse(CSPrcode.Compute("sum(pd_outqty)", "1=1").ToString());
+            }
+            ProcessCount.Text = CollectNum + "/" + OutNum;
+            if (CollectNum == OutNum)
+            {
+                dh.UpdateByCondition("prodinout", "pi_user_packingstatus='Packed'", "pi_inoutno='" + pi_inoutno.Text + "'");
+            }
             //采集达到了数量进行换行
             if (CollectQty == double.Parse(CurrentPrCount))
             {
@@ -1029,6 +1043,7 @@ namespace UAS_LabelMachine
                 if (close.ToString() == "Yes")
                 {
                     dh.BatchInsert("delete from prodiobarcode where pib_id=:pib_id", new string[] { "pib_id" }, DeleteID.ToArray());
+                    dh.UpdateByCondition("CS$InoutPrcode", "collectednum=(select nvl(sum(pib_qty),0) from prodiobarcode where pib_inoutno=pd_inoutno and pib_pdno=pd_pdno)", "pd_inoutno='" + pi_inoutno.Text + "'");
                     LogManager.DoCommandLog(pi_inoutno.Text, User.UserCode, "删除明细", "删除明细成功");
                     MessageBox.Show("删除成功", "提示");
                     Input.Clear();
@@ -1081,28 +1096,12 @@ namespace UAS_LabelMachine
             {
                 LabelInf.FirstDisplayedScrollingRowIndex = LabelInf.Rows.Count - 1;
             }
-            double CollectNum = 0;
-            double OutNum = 0;
+
             sql.Clear();
             sql.Append("select pib_pdno,pib_prodcode,sum(pib_qty) pib_qty from  prodiodetail left join prodiobarcode on pd_id=pib_pdid and pd_pdno=pib_pdno ");
             sql.Append("where pib_inoutno='" + pi_inoutno.Text + "' group by pib_prodcode,pib_pdno order by pib_pdno ");
             SumQty = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
-            for (int i = 0; i < GridPrcode.Rows.Count; i++)
-            {
-                string CurrentPrCode = GridPrcode.Rows[i].Cells["pd_prodcode"].Value.ToString();
-                string CurrentPDNO = GridPrcode.Rows[i].Cells["pd_pdno"].Value.ToString();
-                string CurrentOutQTY = GridPrcode.Rows[i].Cells["pd_outqty"].Value.ToString();
-                string collectqty = (SumQty.Compute("sum(pib_qty)", "pib_prodcode='" + CurrentPrCode + "' and pib_pdno='" + CurrentPDNO + "'").ToString());
-                CollectNum += double.Parse(collectqty == "" ? "0" : collectqty);
-                OutNum += double.Parse(CurrentOutQTY);
-                GridPrcode.Rows[i].Cells["CollectedNum"].Value = collectqty == "" ? "0" : collectqty; ;
-                GridPrcode.Rows[i].Cells["UnCollectedNum"].Value = Convert.ToDouble(double.Parse(GridPrcode.Rows[i].Cells["pd_outqty"].Value.ToString()) - double.Parse(collectqty == "" ? "0" : collectqty)).ToString("0.000");
-            }
-            ProcessCount.Text = CollectNum + "/" + OutNum;
-            if (CollectNum == OutNum)
-            {
-                dh.UpdateByCondition("prodinout", "pi_user_packingstatus='Packed'", "pi_inoutno='" + pi_inoutno.Text + "'");
-            }
+
         }
 
         private void Refresh_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
@@ -1279,73 +1278,94 @@ namespace UAS_LabelMachine
         {
             dh.ExecuteSql("select sysdate from dual", "select");
         }
-
+        DataTable CSPrcode;
         private void LoadPrcodeData()
         {
-            GridPrcode.DataSource = (DataTable)dh.ExecuteSql("select pd_pdno,pd_custprodcode,pd_whcode,pd_prodcode,'0' CollectedNum,'0' UnCollectedNum,pd_outqty,pr_unit,pr_spec,pd_brand,pjd_zxbzs_user,pjd_id from prodiodetail left join prodinout on pi_id=pd_piid left join PRODJOINVENDDETAIL on pjd_brand =pd_brand and pjd_prodcode=pd_prodcode left join product on pd_prodcode=pr_code where pi_id='" + PI_ID + "' order by pd_pdno", "select");
+            DataTable Prcode = (DataTable)dh.ExecuteSql("select '' pd_piid,pd_inoutno,pd_pdno,pd_custprodcode,pd_whcode,pd_prodcode,'0' CollectedNum,'0' UnCollectedNum,pd_outqty,pr_unit,pr_spec,pd_brand,pjd_zxbzs_user,pjd_id from prodiodetail left join prodinout on pi_id=pd_piid left join PRODJOINVENDDETAIL on pjd_brand =pd_brand and pjd_prodcode=pd_prodcode left join product on pd_prodcode=pr_code where pi_id='" + PI_ID + "' order by pd_pdno", "select");
+            GridPrcode.DataSource = Prcode;
             List<int> RemoveIndex = new List<int>();
             double CollectNum = 0;
             double OutNum = 0;
             if (Combindetail.Checked)
             {
-                int CurrentIndex = 0;
-                for (int i = 0; i < GridPrcode.Rows.Count; i++)
+                CSPrcode = (DataTable)dh.ExecuteSql("select * from CS$InoutPrcode where pd_inoutno='" + pi_inoutno.Text + "' and combined=-1 order by  pd_pdno", "select");
+                if (CSPrcode.Rows.Count == 0)
                 {
-                    string CurrentPrCode = GridPrcode.Rows[i].Cells["pd_prodcode"].Value.ToString();
-                    string CurrentPDNO = GridPrcode.Rows[i].Cells["pd_pdno"].Value.ToString();
-                    string CurrentOutQTY = GridPrcode.Rows[i].Cells["pd_outqty"].Value.ToString();
-                    string collectqty = (SumQty.Compute("sum(pib_qty)", "pib_prodcode='" + CurrentPrCode + "' and pib_pdno='" + CurrentPDNO + "'").ToString());
-                    CollectNum += double.Parse(collectqty == "" ? "0" : collectqty);
-                    OutNum += double.Parse(CurrentOutQTY);
-                    GridPrcode.Rows[i].Cells["CollectedNum"].Value = collectqty == "" ? "0" : collectqty;
-                    GridPrcode.Rows[i].Cells["UnCollectedNum"].Value = Convert.ToDouble(double.Parse(GridPrcode.Rows[i].Cells["pd_outqty"].Value.ToString()) - double.Parse(collectqty == "" ? "0" : collectqty)).ToString("0.000");
-                }
-                for (int i = 0; i < GridPrcode.Rows.Count; i++)
-                {
-                    if (i + 1 < GridPrcode.Rows.Count)
+                    int CurrentIndex = 0;
+                    for (int i = 0; i < GridPrcode.Rows.Count; i++)
                     {
-                        string BProdCode = GridPrcode.Rows[i].Cells["pd_prodcode"].Value.ToString();
-                        string BCustProdCode = GridPrcode.Rows[i].Cells["pd_custprodcode1"].Value.ToString();
-                        string BWhCode = GridPrcode.Rows[i].Cells["pd_whcode"].Value.ToString();
-                        string BPrUnit = GridPrcode.Rows[i].Cells["pr_unit"].Value.ToString();
-                        string BPrBrand = GridPrcode.Rows[i].Cells["pd_brand"].Value.ToString();
-                        string FProdCode = GridPrcode.Rows[i + 1].Cells["pd_prodcode"].Value.ToString();
-                        string FCustProdCode = GridPrcode.Rows[i + 1].Cells["pd_custprodcode1"].Value.ToString();
-                        string FPrUnit = GridPrcode.Rows[i + 1].Cells["pr_unit"].Value.ToString();
-                        string FrBrand = GridPrcode.Rows[i + 1].Cells["pd_brand"].Value.ToString();
-                        string FWhCode = GridPrcode.Rows[i + 1].Cells["pd_whcode"].Value.ToString();
-                        if (BProdCode == FProdCode && BPrBrand == FrBrand && BCustProdCode == FCustProdCode)
-                        {
-                            GridPrcode.Rows[CurrentIndex].Cells["pd_outqty"].Value = double.Parse(GridPrcode.Rows[CurrentIndex].Cells["pd_outqty"].Value.ToString()) + double.Parse(GridPrcode.Rows[i + 1].Cells["pd_outqty"].Value.ToString());
-                            GridPrcode.Rows[CurrentIndex].Cells["CollectedNum"].Value = double.Parse(GridPrcode.Rows[CurrentIndex].Cells["CollectedNum"].Value.ToString()) + double.Parse(GridPrcode.Rows[i + 1].Cells["CollectedNum"].Value.ToString());
-                            GridPrcode.Rows[CurrentIndex].Cells["UnCollectedNum"].Value = (double.Parse(GridPrcode.Rows[CurrentIndex].Cells["UnCollectedNum"].Value.ToString()) + double.Parse(GridPrcode.Rows[i + 1].Cells["UnCollectedNum"].Value.ToString())).ToString("0.000");
-                            RemoveIndex.Add(i + 1);
-                        }
-                        else
+                        string CurrentPrCode = GridPrcode.Rows[i].Cells["pd_prodcode"].Value.ToString();
+                        string CurrentPDNO = GridPrcode.Rows[i].Cells["pd_pdno"].Value.ToString();
+                        string CurrentOutQTY = GridPrcode.Rows[i].Cells["pd_outqty"].Value.ToString();
+                        string collectqty = (SumQty.Compute("sum(pib_qty)", "pib_prodcode='" + CurrentPrCode + "' and pib_pdno='" + CurrentPDNO + "'").ToString());
+                        CollectNum += double.Parse(collectqty == "" ? "0" : collectqty);
+                        OutNum += double.Parse(CurrentOutQTY);
+                        GridPrcode.Rows[i].Cells["CollectedNum"].Value = collectqty == "" ? "0" : collectqty;
+                    }
+                    for (int i = 0; i < GridPrcode.Rows.Count; i++)
+                    {
+                        if (i + 1 < GridPrcode.Rows.Count)
                         {
-                            CurrentIndex = i + 1;
-                        }
+                            string BProdCode = GridPrcode.Rows[i].Cells["pd_prodcode"].Value.ToString();
+                            string BCustProdCode = GridPrcode.Rows[i].Cells["pd_custprodcode1"].Value.ToString();
+                            string BWhCode = GridPrcode.Rows[i].Cells["pd_whcode"].Value.ToString();
+                            string BPrUnit = GridPrcode.Rows[i].Cells["pr_unit"].Value.ToString();
+                            string BPrBrand = GridPrcode.Rows[i].Cells["pd_brand"].Value.ToString();
+                            string FProdCode = GridPrcode.Rows[i + 1].Cells["pd_prodcode"].Value.ToString();
+                            string FCustProdCode = GridPrcode.Rows[i + 1].Cells["pd_custprodcode1"].Value.ToString();
+                            string FPrUnit = GridPrcode.Rows[i + 1].Cells["pr_unit"].Value.ToString();
+                            string FrBrand = GridPrcode.Rows[i + 1].Cells["pd_brand"].Value.ToString();
+                            string FWhCode = GridPrcode.Rows[i + 1].Cells["pd_whcode"].Value.ToString();
+                            if (BProdCode == FProdCode && BPrBrand == FrBrand && BCustProdCode == FCustProdCode)
+                            {
+                                GridPrcode.Rows[CurrentIndex].Cells["pd_outqty"].Value = double.Parse(GridPrcode.Rows[CurrentIndex].Cells["pd_outqty"].Value.ToString()) + double.Parse(GridPrcode.Rows[i + 1].Cells["pd_outqty"].Value.ToString());
+                                GridPrcode.Rows[CurrentIndex].Cells["CollectedNum"].Value = double.Parse(GridPrcode.Rows[CurrentIndex].Cells["CollectedNum"].Value.ToString()) + double.Parse(GridPrcode.Rows[i + 1].Cells["CollectedNum"].Value.ToString());
+                                RemoveIndex.Add(i + 1);
+                            }
+                            else
+                            {
+                                CurrentIndex = i + 1;
+                            }
 
+                        }
+                    }
+                    foreach (int item in RemoveIndex.OrderByDescending(x => x))
+                    {
+                        (GridPrcode.DataSource as DataTable).Rows.RemoveAt(item);
                     }
                 }
-                foreach (int item in RemoveIndex.OrderByDescending(x => x))
-                {
-                    GridPrcode.Rows.RemoveAt(item);
-                }
+                else GridPrcode.DataSource = CSPrcode;
             }
             else
             {
-                for (int i = 0; i < GridPrcode.Rows.Count; i++)
+                CSPrcode = (DataTable)dh.ExecuteSql("select * from CS$InoutPrcode where pd_inoutno='" + pi_inoutno.Text + "' and combined=0 order by pd_pdno", "select");
+                if (CSPrcode.Rows.Count == 0)
                 {
-                    string CurrentPrCode = GridPrcode.Rows[i].Cells["pd_prodcode"].Value.ToString();
-                    string CurrentPDNO = GridPrcode.Rows[i].Cells["pd_pdno"].Value.ToString();
-                    string CurrentOutQTY = GridPrcode.Rows[i].Cells["pd_outqty"].Value.ToString();
-                    string collectqty = (SumQty.Compute("sum(pib_qty)", "pib_prodcode='" + CurrentPrCode + "' and pib_pdno='" + CurrentPDNO + "'").ToString());
-                    CollectNum += double.Parse(collectqty == "" ? "0" : collectqty);
-                    OutNum += double.Parse(CurrentOutQTY);
-                    GridPrcode.Rows[i].Cells["CollectedNum"].Value = collectqty == "" ? "0" : collectqty;
-                    GridPrcode.Rows[i].Cells["UnCollectedNum"].Value = Convert.ToDouble(double.Parse(GridPrcode.Rows[i].Cells["pd_outqty"].Value.ToString()) - double.Parse(collectqty == "" ? "0" : collectqty)).ToString("0.000");
+                    for (int i = 0; i < GridPrcode.Rows.Count; i++)
+                    {
+                        string CurrentPrCode = GridPrcode.Rows[i].Cells["pd_prodcode"].Value.ToString();
+                        string CurrentPDNO = GridPrcode.Rows[i].Cells["pd_pdno"].Value.ToString();
+                        string CurrentOutQTY = GridPrcode.Rows[i].Cells["pd_outqty"].Value.ToString();
+                        string collectqty = (SumQty.Compute("sum(pib_qty)", "pib_prodcode='" + CurrentPrCode + "' and pib_pdno='" + CurrentPDNO + "'").ToString());
+                        CollectNum += double.Parse(collectqty == "" ? "0" : collectqty);
+                        OutNum += double.Parse(CurrentOutQTY);
+                        GridPrcode.Rows[i].Cells["CollectedNum"].Value = collectqty == "" ? "0" : collectqty;
+                    }
                 }
+                else GridPrcode.DataSource = CSPrcode;
+            }
+            if (CSPrcode.Rows.Count == 0)
+            {
+                sql.Clear();
+                sql.Append("insert into CS$InoutPrcode (pd_piid,pd_pdno,pd_custprodcode,pd_whcode,pd_prodcode,");
+                sql.Append("CollectedNum,UnCollectedNum,pd_outqty,pr_unit,pr_spec,pd_brand,pjd_zxbzs_user,pjd_id,pd_inoutno,combined)");
+                sql.Append("values ('',:pd_pdno,:pd_custprodcode,:pd_whcode,:pd_prodcode,:CollectedNum,:UnCollectedNum,:pd_outqty,:pr_unit,:pr_spec,:pd_brand,:pjd_zxbzs_user,:pjd_id,:pd_inoutno,'" + (Combindetail.Checked ? -1 : 0) + "')");
+                dh.SaveDataTable((GridPrcode.DataSource as DataTable), "CS$InoutPrcode", "pd_piid", sql.ToString());
+            }
+            else
+            {
+                CollectNum = int.Parse(CSPrcode.Compute("sum(CollectedNum)", "1=1").ToString());
+                OutNum = int.Parse(CSPrcode.Compute("sum(pd_outqty)", "1=1").ToString());
             }
             ProcessCount.Text = CollectNum + "/" + OutNum;
             if (GridPrcode.Rows.Count > 0)
@@ -1680,7 +1700,7 @@ namespace UAS_LabelMachine
                     int tencount = 0;
                     for (int j = 0; j < dt1.Rows.Count; j++)
                     {
-                        if (tencount % MidboxCapacity.Value == 0 || (dt1.Rows[j]["pib_prodcode"].ToString() != dt1.Rows[j - 1]["pib_prodcode"].ToString())|| (dt1.Rows[j]["pd_custprodcode"].ToString() != dt1.Rows[j - 1]["pd_custprodcode"].ToString()))
+                        if (tencount % MidboxCapacity.Value == 0 || (dt1.Rows[j]["pib_prodcode"].ToString() != dt1.Rows[j - 1]["pib_prodcode"].ToString()) || (dt1.Rows[j]["pd_custprodcode"].ToString() != dt1.Rows[j - 1]["pd_custprodcode"].ToString()))
                         {
                             pib_outboxcode1 = pib_outboxcode1 + 1;
                             MaxNum = MaxNum + 1;