浏览代码

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

Hcsy 7 年之前
父节点
当前提交
f18eed005b

+ 47 - 47
PLCDataReader/Device/Information/DeviceStatusInfo.Designer.cs

@@ -31,8 +31,12 @@ namespace UAS_PLCDataReader.Device.Infomation
         private void InitializeComponent()
         {
             this.groupControl1 = new DevExpress.XtraEditors.GroupControl();
+            this.de_linecode = new UAS_PLCDataReader.CustomerControl.ValueLabel.ValueLabel();
+            this.de_address = new UAS_PLCDataReader.CustomerControl.ValueLabel.ValueLabel();
             this.labelControl4 = new DevExpress.XtraEditors.LabelControl();
+            this.de_wccode = new UAS_PLCDataReader.CustomerControl.ValueLabel.ValueLabel();
             this.labelControl3 = new DevExpress.XtraEditors.LabelControl();
+            this.de_name = new UAS_PLCDataReader.CustomerControl.ValueLabel.ValueLabel();
             this.labelControl2 = new DevExpress.XtraEditors.LabelControl();
             this.labelControl1 = new DevExpress.XtraEditors.LabelControl();
             this.groupControl2 = new DevExpress.XtraEditors.GroupControl();
@@ -46,15 +50,11 @@ namespace UAS_PLCDataReader.Device.Infomation
             this.labelControl9 = new DevExpress.XtraEditors.LabelControl();
             this.labelControl14 = new DevExpress.XtraEditors.LabelControl();
             this.groupControl3 = new DevExpress.XtraEditors.GroupControl();
+            this.dpg_runtime = new UAS_PLCDataReader.CustomerControl.ValueLabel.ValueLabel();
             this.dpg_count = new UAS_PLCDataReader.CustomerControl.ValueLabel.ValueLabel();
             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.de_linecode = new UAS_PLCDataReader.CustomerControl.ValueLabel.ValueLabel();
-            this.de_address = new UAS_PLCDataReader.CustomerControl.ValueLabel.ValueLabel();
-            this.de_wccode = new UAS_PLCDataReader.CustomerControl.ValueLabel.ValueLabel();
-            this.de_name = new UAS_PLCDataReader.CustomerControl.ValueLabel.ValueLabel();
-            this.dpg_runtime = new UAS_PLCDataReader.CustomerControl.ValueLabel.ValueLabel();
             ((System.ComponentModel.ISupportInitialize)(this.groupControl1)).BeginInit();
             this.groupControl1.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.groupControl2)).BeginInit();
@@ -79,6 +79,22 @@ namespace UAS_PLCDataReader.Device.Infomation
             this.groupControl1.TabIndex = 0;
             this.groupControl1.Text = "设备信息";
             // 
+            // de_linecode
+            // 
+            this.de_linecode.Appearance.Font = new System.Drawing.Font("黑体", 12F);
+            this.de_linecode.Location = new System.Drawing.Point(70, 137);
+            this.de_linecode.Name = "de_linecode";
+            this.de_linecode.Size = new System.Drawing.Size(0, 16);
+            this.de_linecode.TabIndex = 19;
+            // 
+            // de_address
+            // 
+            this.de_address.Appearance.Font = new System.Drawing.Font("黑体", 12F);
+            this.de_address.Location = new System.Drawing.Point(70, 106);
+            this.de_address.Name = "de_address";
+            this.de_address.Size = new System.Drawing.Size(0, 16);
+            this.de_address.TabIndex = 18;
+            // 
             // labelControl4
             // 
             this.labelControl4.Appearance.Font = new System.Drawing.Font("黑体", 12F);
@@ -88,6 +104,14 @@ namespace UAS_PLCDataReader.Device.Infomation
             this.labelControl4.TabIndex = 6;
             this.labelControl4.Text = "线体";
             // 
+            // de_wccode
+            // 
+            this.de_wccode.Appearance.Font = new System.Drawing.Font("黑体", 12F);
+            this.de_wccode.Location = new System.Drawing.Point(70, 74);
+            this.de_wccode.Name = "de_wccode";
+            this.de_wccode.Size = new System.Drawing.Size(0, 16);
+            this.de_wccode.TabIndex = 17;
+            // 
             // labelControl3
             // 
             this.labelControl3.Appearance.Font = new System.Drawing.Font("黑体", 12F);
@@ -97,6 +121,14 @@ namespace UAS_PLCDataReader.Device.Infomation
             this.labelControl3.TabIndex = 5;
             this.labelControl3.Text = "区域";
             // 
+            // de_name
+            // 
+            this.de_name.Appearance.Font = new System.Drawing.Font("黑体", 12F);
+            this.de_name.Location = new System.Drawing.Point(70, 41);
+            this.de_name.Name = "de_name";
+            this.de_name.Size = new System.Drawing.Size(0, 16);
+            this.de_name.TabIndex = 16;
+            // 
             // labelControl2
             // 
             this.labelControl2.Appearance.Font = new System.Drawing.Font("黑体", 12F);
@@ -222,10 +254,18 @@ namespace UAS_PLCDataReader.Device.Infomation
             this.groupControl3.Controls.Add(this.labelControl11);
             this.groupControl3.Location = new System.Drawing.Point(216, 12);
             this.groupControl3.Name = "groupControl3";
-            this.groupControl3.Size = new System.Drawing.Size(250, 349);
+            this.groupControl3.Size = new System.Drawing.Size(328, 349);
             this.groupControl3.TabIndex = 2;
             this.groupControl3.Text = "运行信息";
             // 
+            // dpg_runtime
+            // 
+            this.dpg_runtime.Appearance.Font = new System.Drawing.Font("黑体", 12F);
+            this.dpg_runtime.Location = new System.Drawing.Point(101, 74);
+            this.dpg_runtime.Name = "dpg_runtime";
+            this.dpg_runtime.Size = new System.Drawing.Size(0, 16);
+            this.dpg_runtime.TabIndex = 16;
+            // 
             // dpg_count
             // 
             this.dpg_count.Appearance.Font = new System.Drawing.Font("黑体", 12F);
@@ -258,51 +298,11 @@ namespace UAS_PLCDataReader.Device.Infomation
             this.dpg_starttime.Size = new System.Drawing.Size(0, 16);
             this.dpg_starttime.TabIndex = 0;
             // 
-            // de_linecode
-            // 
-            this.de_linecode.Appearance.Font = new System.Drawing.Font("黑体", 12F);
-            this.de_linecode.Location = new System.Drawing.Point(70, 137);
-            this.de_linecode.Name = "de_linecode";
-            this.de_linecode.Size = new System.Drawing.Size(0, 16);
-            this.de_linecode.TabIndex = 19;
-            // 
-            // de_address
-            // 
-            this.de_address.Appearance.Font = new System.Drawing.Font("黑体", 12F);
-            this.de_address.Location = new System.Drawing.Point(70, 106);
-            this.de_address.Name = "de_address";
-            this.de_address.Size = new System.Drawing.Size(0, 16);
-            this.de_address.TabIndex = 18;
-            // 
-            // de_wccode
-            // 
-            this.de_wccode.Appearance.Font = new System.Drawing.Font("黑体", 12F);
-            this.de_wccode.Location = new System.Drawing.Point(70, 74);
-            this.de_wccode.Name = "de_wccode";
-            this.de_wccode.Size = new System.Drawing.Size(0, 16);
-            this.de_wccode.TabIndex = 17;
-            // 
-            // de_name
-            // 
-            this.de_name.Appearance.Font = new System.Drawing.Font("黑体", 12F);
-            this.de_name.Location = new System.Drawing.Point(70, 41);
-            this.de_name.Name = "de_name";
-            this.de_name.Size = new System.Drawing.Size(0, 16);
-            this.de_name.TabIndex = 16;
-            // 
-            // dpg_runtime
-            // 
-            this.dpg_runtime.Appearance.Font = new System.Drawing.Font("黑体", 12F);
-            this.dpg_runtime.Location = new System.Drawing.Point(101, 74);
-            this.dpg_runtime.Name = "dpg_runtime";
-            this.dpg_runtime.Size = new System.Drawing.Size(0, 16);
-            this.dpg_runtime.TabIndex = 16;
-            // 
             // DeviceStatusInfo
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 14F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.ClientSize = new System.Drawing.Size(478, 373);
+            this.ClientSize = new System.Drawing.Size(556, 373);
             this.Controls.Add(this.groupControl3);
             this.Controls.Add(this.groupControl2);
             this.Controls.Add(this.groupControl1);

+ 11 - 3
PLCDataReader/Device/Information/DeviceStatusInfo.cs

@@ -39,11 +39,19 @@ namespace UAS_PLCDataReader.Device.Infomation
             {
                 BaseUtil.SetFormValue(Controls, dt);
             }
-            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)
+            if (Main.ReturnData.ContainsKey(de_code))
             {
-                BaseUtil.SetFormValue(Controls, dt);
+                dpg_count.Text = Main.ReturnData[de_code].SendCount.ToString();
+                dpg_runtime.Text = (DateTime.Now - Main.ReturnData[de_code].StartTime).TotalMinutes.ToString().Substring(0, 3) + "分钟";
+                dpg_starttime.Text = Main.ReturnData[de_code].StartTime.ToString("yyyy-MM-dd HH:mm:ss");
+                dpg_senddatasize.Text = Main.ReturnData[de_code].SendDataSize.ToString();
+                dpg_receivedatasize.Text = Main.ReturnData[de_code].ReceiveDataSize.ToString();
             }
+            //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)

+ 198 - 0
PLCDataReader/Entity/Device.cs

@@ -0,0 +1,198 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace UAS_PLCDataReader.Entity
+{
+    public class Device
+    {
+        /// <summary>
+        /// 设备名称
+        /// </summary>
+        private string decode;
+        /// <summary>
+        /// 设备名称
+        /// </summary>
+        private string dename;
+        /// <summary>
+        /// 运行状态
+        /// </summary>
+        private string runStatus;
+        /// <summary>
+        /// 发送数据字节
+        /// </summary>
+        private int sendDataSize;
+        /// <summary>
+        /// 接收数据字节
+        /// </summary>
+        private int receiveDataSize;
+        /// <summary>
+        /// 发送数据次数
+        /// </summary>
+        private int sendCount;
+        /// <summary>
+        /// 温度
+        /// </summary>
+        private float temperature;
+        /// <summary>
+        /// 投产数
+        /// </summary>
+        private int inQTY;
+        /// <summary>
+        /// 合格数
+        /// </summary>
+        private int okQTY;
+        /// <summary>
+        /// 启动时间
+        /// </summary>
+        private DateTime startTime;
+        /// <summary>
+        /// 返回参数
+        /// </summary>
+        private Dictionary<string, string> itemData;
+
+        public string Decode
+        {
+            get
+            {
+                return decode;
+            }
+
+            set
+            {
+                decode = value;
+            }
+        }
+
+        public string Dename
+        {
+            get
+            {
+                return dename;
+            }
+
+            set
+            {
+                dename = value;
+            }
+        }
+
+        public string RunStatus
+        {
+            get
+            {
+                return runStatus;
+            }
+
+            set
+            {
+                runStatus = value;
+            }
+        }
+
+        public int SendDataSize
+        {
+            get
+            {
+                return sendDataSize;
+            }
+
+            set
+            {
+                sendDataSize = value;
+            }
+        }
+
+        public int ReceiveDataSize
+        {
+            get
+            {
+                return receiveDataSize;
+            }
+
+            set
+            {
+                receiveDataSize = value;
+            }
+        }
+
+        public int SendCount
+        {
+            get
+            {
+                return sendCount;
+            }
+
+            set
+            {
+                sendCount = value;
+            }
+        }
+
+        public Dictionary<string, string> ItemData
+        {
+            get
+            {
+                return itemData;
+            }
+
+            set
+            {
+                itemData = value;
+            }
+        }
+
+        public DateTime StartTime
+        {
+            get
+            {
+                return startTime;
+            }
+
+            set
+            {
+                startTime = value;
+            }
+        }
+
+        public float Temperature
+        {
+            get
+            {
+                return temperature;
+            }
+
+            set
+            {
+                temperature = value;
+            }
+        }
+
+        public int InQTY
+        {
+            get
+            {
+                return inQTY;
+            }
+
+            set
+            {
+                inQTY = value;
+            }
+        }
+
+        public int OkQTY
+        {
+            get
+            {
+                return okQTY;
+            }
+
+            set
+            {
+                okQTY = value;
+            }
+        }
+    }
+}

+ 42 - 26
PLCDataReader/Main.cs

@@ -30,7 +30,7 @@ namespace UAS_PLCDataReader
         ModeBusTCPServer mbt = new ModeBusTCPServer();
         List<string> SQL = new List<string>();
         //存放所有的设备返回的数据,用于比较
-        public static Dictionary<string, Dictionary<string, string>> ReturnData = new Dictionary<string, Dictionary<string, string>>();
+        public static Dictionary<string, Entity.Device> ReturnData = new Dictionary<string, Entity.Device>();
 
         #region 初始化代码
         public Main()
@@ -426,10 +426,13 @@ namespace UAS_PLCDataReader
                     Command = dt1.Rows[0]["dc_value"].ToString();
                     SendCommandByteSize = Encoding.Default.GetBytes(Command.ToCharArray()).Length;
                 }
+                //发送指令
                 mbt.Send(IP, SendCoding, ReceiveCoding, Command);
+                //成功返回了信息
                 if (mbt.Returnvalue.ContainsKey(IP))
                 {
                     int ReceiveCommandByteSize = Encoding.Default.GetBytes(mbt.Returnvalue[IP].ToCharArray()).Length;
+                    //存放返回的所有数据
                     Dictionary<string, string> ItemData = new Dictionary<string, string>();
                     int[] Arr = BaseUtil.GetDecimalData(BaseUtil.ASCIIToString(mbt.Returnvalue[IP]), 8);
                     for (int i = 0; i < Arr.Length; i++)
@@ -439,42 +442,55 @@ namespace UAS_PLCDataReader
                     //如果不包含该项数据则在键值对中添加
                     if (!ReturnData.ContainsKey(Decode))
                     {
-                        ReturnData.Add(Decode, ItemData);
+                        //添加本地数据内容
+                        Entity.Device device = new Entity.Device();
+                        device.Decode = pl.DeviceCode;
+                        device.Dename = pl.DeviceName;
+                        device.StartTime = DateTime.Now;
+                        device.RunStatus = "Running";
+                        device.ReceiveDataSize += ReceiveCommandByteSize;
+                        device.SendDataSize += SendCommandByteSize;
+                        device.SendCount += 1;
+                        device.ItemData = ItemData;
+                        ReturnData.Add(Decode, device);
                     }
                     else
                     {
+                        ReturnData[Decode].ReceiveDataSize += ReceiveCommandByteSize;
+                        ReturnData[Decode].SendDataSize += SendCommandByteSize;
+                        ReturnData[Decode].SendCount += 1;
                         //检测键值对是否发生变化,发生变化时赋予新值
-                        if ((BaseUtil.CheckDicDiff(ReturnData[Decode], ItemData)))
+                        if ((BaseUtil.CheckDicDiff(ReturnData[Decode].ItemData, ItemData)))
                         {
-                            ReturnData[Decode] = ItemData;
+                            ReturnData[Decode].ItemData = ItemData;
                         }
                     }
                     mbt.Returnvalue.Remove(IP);
-                    SQL.Clear();
-                    //更新轮询状态
-                    sql.Clear();
-                    sql.Append("update DEVICEPOLLINGCONFIG set dpc_status='Running' where dpc_decode='" + Decode + "' and dpc_dccode='" + Dccode + "'");
-                    dh.ExecuteSql(sql.ToString(), "update");
-                    //更新轮询日志状态
-                    sql.Clear();
-                    sql.Append("update DEVICEPOLLINGLOG set dpg_status='Running',dpg_senddatasize=nvl(dpg_senddatasize,0)+" + SendCommandByteSize);
-                    sql.Append(",dpg_receivedatasize=nvl(dpg_receivedatasize,0)+" + ReceiveCommandByteSize + ",dpg_count=nvl(dpg_count,0)+1 ");
-                    sql.Append(" where dpg_id=(select max(dpg_id) from DEVICEPOLLINGLOG where dpg_decode='" + Decode + "')");
-                    dh.ExecuteSql(sql.ToString(), "update");
+                    //SQL.Clear();
+                    ////更新轮询状态
+                    //sql.Clear();
+                    //sql.Append("update DEVICEPOLLINGCONFIG set dpc_status='Running' where dpc_decode='" + Decode + "' and dpc_dccode='" + Dccode + "'");
+                    //dh.ExecuteSql(sql.ToString(), "update");
+                    ////更新轮询日志状态
+                    //sql.Clear();
+                    //sql.Append("update DEVICEPOLLINGLOG set dpg_status='Running',dpg_senddatasize=nvl(dpg_senddatasize,0)+" + SendCommandByteSize);
+                    //sql.Append(",dpg_receivedatasize=nvl(dpg_receivedatasize,0)+" + ReceiveCommandByteSize + ",dpg_count=nvl(dpg_count,0)+1 ");
+                    //sql.Append(" where dpg_id=(select max(dpg_id) from DEVICEPOLLINGLOG where dpg_decode='" + Decode + "')");
+                    //dh.ExecuteSql(sql.ToString(), "update");
                 }
                 else
                 {
-                    SQL.Clear();
-                    //更新轮询状态
-                    sql.Clear();
-                    sql.Append("update DEVICEPOLLINGCONFIG set dpc_status='Stop' where dpc_decode='" + Decode + "' and dpc_dccode='" + Dccode + "'");
-                    dh.ExecuteSql(sql.ToString(), "update");
-                    //更新轮询日志状态
-                    sql.Clear();
-                    sql.Append("update DEVICEPOLLINGLOG set dpg_status='Running',dpg_senddatasize=nvl(dpg_senddatasize,0)+");
-                    sql.Append(SendCommandByteSize + ",dpg_count=nvl(dpg_count,0)+1 ");
-                    sql.Append("where dpg_id=(select max(dpg_id) from DEVICEPOLLINGLOG where dpg_decode='" + Decode + "')");
-                    dh.ExecuteSql(sql.ToString(), "update");
+                    //SQL.Clear();
+                    ////更新轮询状态
+                    //sql.Clear();
+                    //sql.Append("update DEVICEPOLLINGCONFIG set dpc_status='Stop' where dpc_decode='" + Decode + "' and dpc_dccode='" + Dccode + "'");
+                    //dh.ExecuteSql(sql.ToString(), "update");
+                    ////更新轮询日志状态
+                    //sql.Clear();
+                    //sql.Append("update DEVICEPOLLINGLOG set dpg_status='Running',dpg_senddatasize=nvl(dpg_senddatasize,0)+");
+                    //sql.Append(SendCommandByteSize + ",dpg_count=nvl(dpg_count,0)+1 ");
+                    //sql.Append("where dpg_id=(select max(dpg_id) from DEVICEPOLLINGLOG where dpg_decode='" + Decode + "')");
+                    //dh.ExecuteSql(sql.ToString(), "update");
                 }
             }
         }

+ 1 - 1
UAS-出货标签管理(泽天)/CustomControl/DataGridViewWithSerialNum.cs

@@ -15,7 +15,7 @@ namespace UAS_LabelMachine.CustomControl
 
         protected override void OnRowPostPaint(DataGridViewRowPostPaintEventArgs e)
         {
-            e.Graphics.DrawString((e.RowIndex + 1).ToString(), e.InheritedRowStyle.Font, solidBrush, e.RowBounds.Location.X + 15, e.RowBounds.Location.Y + 5);
+            e.Graphics.DrawString((e.RowIndex + 1).ToString(), e.InheritedRowStyle.Font, solidBrush, e.RowBounds.Location.X + 5, e.RowBounds.Location.Y);
             base.OnRowPostPaint(e);
         }
 

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

@@ -29,6 +29,7 @@
         private void InitializeComponent()
         {
             this.components = new System.ComponentModel.Container();
+            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(UAS_出货标签打印));
             this.pi_inoutno_label = new System.Windows.Forms.Label();
             this.label24 = new System.Windows.Forms.Label();
@@ -218,7 +219,7 @@
             // 
             this.pib_id.AutoSize = true;
             this.pib_id.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.pib_id.Location = new System.Drawing.Point(142, 160);
+            this.pib_id.Location = new System.Drawing.Point(146, 160);
             this.pib_id.Name = "pib_id";
             this.pib_id.Size = new System.Drawing.Size(0, 20);
             this.pib_id.TabIndex = 69;
@@ -237,7 +238,7 @@
             // Fresh
             // 
             this.Fresh.AutoSize = true;
-            this.Fresh.Location = new System.Drawing.Point(234, 14);
+            this.Fresh.Location = new System.Drawing.Point(241, 14);
             this.Fresh.Name = "Fresh";
             this.Fresh.Size = new System.Drawing.Size(29, 12);
             this.Fresh.TabIndex = 73;
@@ -595,7 +596,7 @@
             // 
             this.label3.AutoSize = true;
             this.label3.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label3.Location = new System.Drawing.Point(232, 148);
+            this.label3.Location = new System.Drawing.Point(237, 148);
             this.label3.Name = "label3";
             this.label3.Size = new System.Drawing.Size(51, 20);
             this.label3.TabIndex = 98;
@@ -605,7 +606,7 @@
             // 
             this.label4.AutoSize = true;
             this.label4.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label4.Location = new System.Drawing.Point(232, 178);
+            this.label4.Location = new System.Drawing.Point(237, 178);
             this.label4.Name = "label4";
             this.label4.Size = new System.Drawing.Size(51, 20);
             this.label4.TabIndex = 99;
@@ -710,7 +711,7 @@
             // DCCheck
             // 
             this.DCCheck.ID = null;
-            this.DCCheck.Location = new System.Drawing.Point(83, 170);
+            this.DCCheck.Location = new System.Drawing.Point(87, 170);
             this.DCCheck.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.DCCheck.Name = "DCCheck";
             this.DCCheck.Size = new System.Drawing.Size(60, 21);
@@ -738,6 +739,14 @@
             this.pr_spec1,
             this.pd_brand,
             this.pjd_zxbzs_user});
+            dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
+            dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Window;
+            dataGridViewCellStyle1.Font = new System.Drawing.Font("微软雅黑", 12.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.ControlText;
+            dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.ControlDark;
+            dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.ControlText;
+            dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
+            this.GridPrcode.DefaultCellStyle = dataGridViewCellStyle1;
             this.GridPrcode.GridColor = System.Drawing.SystemColors.Control;
             this.GridPrcode.Location = new System.Drawing.Point(0, 222);
             this.GridPrcode.MultiSelect = false;
@@ -753,10 +762,12 @@
             // 
             // pd_pdno
             // 
+            this.pd_pdno.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
             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 = 80;
             // 
             // pjd_id
             // 
@@ -767,22 +778,27 @@
             // 
             // 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.DisplayedCells;
             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;
             // 
             // pd_whcode
             // 
             this.pd_whcode.DataPropertyName = "pd_whcode";
             this.pd_whcode.HeaderText = "仓别";
             this.pd_whcode.Name = "pd_whcode";
+            this.pd_whcode.Visible = false;
             // 
             // CollectedNum
             // 
@@ -797,6 +813,7 @@
             this.UnCollectedNum.HeaderText = "未采集";
             this.UnCollectedNum.Name = "UnCollectedNum";
             this.UnCollectedNum.ReadOnly = true;
+            this.UnCollectedNum.Visible = false;
             // 
             // pd_outqty
             // 
@@ -816,9 +833,11 @@
             // 
             // pr_spec1
             // 
+            this.pr_spec1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
             this.pr_spec1.DataPropertyName = "pr_spec";
             this.pr_spec1.HeaderText = "规格";
             this.pr_spec1.Name = "pr_spec1";
+            this.pr_spec1.Width = 54;
             // 
             // pd_brand
             // 
@@ -833,6 +852,7 @@
             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;
             // 
@@ -859,7 +879,7 @@
             // 
             this.label18.AutoSize = true;
             this.label18.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label18.Location = new System.Drawing.Point(61, 120);
+            this.label18.Location = new System.Drawing.Point(59, 118);
             this.label18.Name = "label18";
             this.label18.Size = new System.Drawing.Size(13, 17);
             this.label18.TabIndex = 90;
@@ -893,7 +913,7 @@
             // 
             this.label16.AutoSize = true;
             this.label16.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label16.Location = new System.Drawing.Point(60, 57);
+            this.label16.Location = new System.Drawing.Point(58, 55);
             this.label16.Name = "label16";
             this.label16.Size = new System.Drawing.Size(13, 17);
             this.label16.TabIndex = 87;
@@ -927,7 +947,7 @@
             // 
             this.label12.AutoSize = true;
             this.label12.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label12.Location = new System.Drawing.Point(3, 94);
+            this.label12.Location = new System.Drawing.Point(9, 92);
             this.label12.Name = "label12";
             this.label12.Size = new System.Drawing.Size(56, 17);
             this.label12.TabIndex = 77;
@@ -937,7 +957,7 @@
             // 
             this.label7.AutoSize = true;
             this.label7.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label7.Location = new System.Drawing.Point(3, 32);
+            this.label7.Location = new System.Drawing.Point(7, 30);
             this.label7.Name = "label7";
             this.label7.Size = new System.Drawing.Size(56, 17);
             this.label7.TabIndex = 76;
@@ -946,7 +966,7 @@
             // Input
             // 
             this.Input.ID = null;
-            this.Input.Location = new System.Drawing.Point(82, 96);
+            this.Input.Location = new System.Drawing.Point(86, 96);
             this.Input.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.Input.Multiline = true;
             this.Input.Name = "Input";
@@ -1168,7 +1188,7 @@
             // pi_inoutno
             // 
             this.pi_inoutno.ID = null;
-            this.pi_inoutno.Location = new System.Drawing.Point(82, 10);
+            this.pi_inoutno.Location = new System.Drawing.Point(86, 10);
             this.pi_inoutno.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.pi_inoutno.Name = "pi_inoutno";
             this.pi_inoutno.Size = new System.Drawing.Size(150, 21);
@@ -1207,7 +1227,7 @@
             // 
             this.SingleLabelPrint.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
             this.SingleLabelPrint.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.SingleLabelPrint.Location = new System.Drawing.Point(85, 178);
+            this.SingleLabelPrint.Location = new System.Drawing.Point(88, 178);
             this.SingleLabelPrint.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.SingleLabelPrint.Name = "SingleLabelPrint";
             this.SingleLabelPrint.Size = new System.Drawing.Size(68, 26);
@@ -1222,7 +1242,7 @@
             this.SingleLabelAutoPrint.Checked = true;
             this.SingleLabelAutoPrint.CheckState = System.Windows.Forms.CheckState.Checked;
             this.SingleLabelAutoPrint.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.SingleLabelAutoPrint.Location = new System.Drawing.Point(10, 97);
+            this.SingleLabelAutoPrint.Location = new System.Drawing.Point(8, 95);
             this.SingleLabelAutoPrint.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.SingleLabelAutoPrint.Name = "SingleLabelAutoPrint";
             this.SingleLabelAutoPrint.Size = new System.Drawing.Size(75, 21);
@@ -1280,7 +1300,7 @@
             // 
             this.label2.AutoSize = true;
             this.label2.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label2.Location = new System.Drawing.Point(6, 118);
+            this.label2.Location = new System.Drawing.Point(4, 116);
             this.label2.Name = "label2";
             this.label2.Size = new System.Drawing.Size(32, 17);
             this.label2.TabIndex = 92;
@@ -1303,7 +1323,7 @@
             // 
             this.label5.AutoSize = true;
             this.label5.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label5.Location = new System.Drawing.Point(6, 151);
+            this.label5.Location = new System.Drawing.Point(4, 149);
             this.label5.Name = "label5";
             this.label5.Size = new System.Drawing.Size(32, 17);
             this.label5.TabIndex = 50;
@@ -1336,7 +1356,7 @@
             this.MidLabelAutoPrint.Checked = true;
             this.MidLabelAutoPrint.CheckState = System.Windows.Forms.CheckState.Checked;
             this.MidLabelAutoPrint.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.MidLabelAutoPrint.Location = new System.Drawing.Point(9, 94);
+            this.MidLabelAutoPrint.Location = new System.Drawing.Point(7, 92);
             this.MidLabelAutoPrint.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.MidLabelAutoPrint.Name = "MidLabelAutoPrint";
             this.MidLabelAutoPrint.Size = new System.Drawing.Size(75, 21);
@@ -1379,7 +1399,7 @@
             // LogingOut
             // 
             this.LogingOut.AutoSize = true;
-            this.LogingOut.Location = new System.Drawing.Point(106, 7);
+            this.LogingOut.Location = new System.Drawing.Point(104, 10);
             this.LogingOut.Name = "LogingOut";
             this.LogingOut.Size = new System.Drawing.Size(42, 21);
             this.LogingOut.TabIndex = 77;
@@ -1405,7 +1425,7 @@
             // 
             this.label10.AutoSize = true;
             this.label10.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label10.Location = new System.Drawing.Point(10, 144);
+            this.label10.Location = new System.Drawing.Point(8, 142);
             this.label10.Name = "label10";
             this.label10.Size = new System.Drawing.Size(32, 17);
             this.label10.TabIndex = 90;
@@ -1415,7 +1435,7 @@
             // 
             this.label6.AutoSize = true;
             this.label6.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label6.Location = new System.Drawing.Point(10, 110);
+            this.label6.Location = new System.Drawing.Point(8, 108);
             this.label6.Name = "label6";
             this.label6.Size = new System.Drawing.Size(32, 17);
             this.label6.TabIndex = 87;
@@ -1521,18 +1541,18 @@
             ((System.ComponentModel.ISupportInitialize)(this.MidSource)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.GridPrcode)).EndInit();
-            this.groupBoxWithBorder1.ResumeLayout(true);
+            this.groupBoxWithBorder1.ResumeLayout(false);
             this.groupBoxWithBorder1.PerformLayout();
             ((System.ComponentModel.ISupportInitialize)(this.LabelInf)).EndInit();
-            this.SingleLabel.ResumeLayout(true);
+            this.SingleLabel.ResumeLayout(false);
             this.SingleLabel.PerformLayout();
-            this.MidLabel.ResumeLayout(true);
+            this.MidLabel.ResumeLayout(false);
             this.MidLabel.PerformLayout();
             ((System.ComponentModel.ISupportInitialize)(this.MidboxCapacity)).EndInit();
-            this.OutBoxLabel.ResumeLayout(true);
+            this.OutBoxLabel.ResumeLayout(false);
             this.OutBoxLabel.PerformLayout();
             ((System.ComponentModel.ISupportInitialize)(this.OutboxCapacity)).EndInit();
-            this.ResumeLayout(true);
+            this.ResumeLayout(false);
             this.PerformLayout();
 
         }
@@ -1634,18 +1654,6 @@
         private System.Windows.Forms.Label pi_title;
         private System.Windows.Forms.Label label9;
         private System.Windows.Forms.Label ProcessCount;
-        private System.Windows.Forms.DataGridViewTextBoxColumn pd_pdno;
-        private System.Windows.Forms.DataGridViewTextBoxColumn pjd_id;
-        private System.Windows.Forms.DataGridViewTextBoxColumn pd_custprodcode1;
-        private System.Windows.Forms.DataGridViewTextBoxColumn pd_prodcode;
-        private System.Windows.Forms.DataGridViewTextBoxColumn pd_whcode;
-        private System.Windows.Forms.DataGridViewTextBoxColumn CollectedNum;
-        private System.Windows.Forms.DataGridViewTextBoxColumn UnCollectedNum;
-        private System.Windows.Forms.DataGridViewTextBoxColumn pd_outqty;
-        private System.Windows.Forms.DataGridViewTextBoxColumn pr_unit;
-        private System.Windows.Forms.DataGridViewTextBoxColumn pr_spec1;
-        private System.Windows.Forms.DataGridViewTextBoxColumn pd_brand;
-        private System.Windows.Forms.DataGridViewTextBoxColumn pjd_zxbzs_user;
         private System.Windows.Forms.DataGridViewCheckBoxColumn Choose;
         private System.Windows.Forms.DataGridViewCheckBoxColumn pib_ifprint;
         private System.Windows.Forms.DataGridViewTextBoxColumn pib_id1;
@@ -1666,5 +1674,17 @@
         private System.Windows.Forms.DataGridViewTextBoxColumn pr_spec;
         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 pjd_id;
+        private System.Windows.Forms.DataGridViewTextBoxColumn pd_custprodcode1;
+        private System.Windows.Forms.DataGridViewTextBoxColumn pd_prodcode;
+        private System.Windows.Forms.DataGridViewTextBoxColumn pd_whcode;
+        private System.Windows.Forms.DataGridViewTextBoxColumn CollectedNum;
+        private System.Windows.Forms.DataGridViewTextBoxColumn UnCollectedNum;
+        private System.Windows.Forms.DataGridViewTextBoxColumn pd_outqty;
+        private System.Windows.Forms.DataGridViewTextBoxColumn pr_unit;
+        private System.Windows.Forms.DataGridViewTextBoxColumn pr_spec1;
+        private System.Windows.Forms.DataGridViewTextBoxColumn pd_brand;
+        private System.Windows.Forms.DataGridViewTextBoxColumn pjd_zxbzs_user;
     }
 }

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

@@ -67,6 +67,8 @@ namespace UAS_LabelMachine
         /// </summary>
         bool AllChecked = false;
 
+        DataTable SumQty;
+
         /// <summary>
         /// 是否通过选择Combox来改变打开的文件
         /// </summary>
@@ -314,7 +316,7 @@ namespace UAS_LabelMachine
                 return;
             }
             //计算当前采集数量
-            string collectqty = (LabelInfDataTable.Compute("sum(pib_qty)", "pib_prodcode='" + CurrentPrCode + "' and pib_pdno='" + CurrentPDNO + "'").ToString());
+            string collectqty = dh.getFieldDataByCondition("prodiobarcode", "sum(pib_qty)", "pib_inoutno='" + pi_inoutno.Text + "' and pib_prodcode='" + CurrentPrCode + "' and pib_pdno='" + CurrentPDNO + "'").ToString();
             double CollectQty = (collectqty == "" ? 0 : double.Parse(collectqty));
             if (Convert.ToDouble((CollectQty + CollectNum).ToString("0.000")) > Convert.ToDouble(double.Parse(CurrentPrCount).ToString("0.000")))
             {
@@ -371,7 +373,7 @@ namespace UAS_LabelMachine
                 stw.ShowDialog();
             }
             //采集后重新计数,自动跳到下一行
-            collectqty = (LabelInfDataTable.Compute("sum(pib_qty)", "pib_prodcode='" + CurrentPrCode + "' and pib_pdno='" + CurrentPDNO + "'").ToString());
+            collectqty = (SumQty.Compute("sum(pib_qty)", "pib_prodcode='" + CurrentPrCode + "' and pib_pdno='" + CurrentPDNO + "'").ToString());
             CollectQty = (collectqty == "" ? 0 : double.Parse(collectqty));
             //采集达到了数量进行换行
             if (CollectQty == double.Parse(CurrentPrCount))
@@ -406,7 +408,7 @@ namespace UAS_LabelMachine
                     OutBoxNum.Items.Add(io);
                 }
                 if (OutBoxNum.Items.Count > 2)
-                    OutBoxNum.SelectedIndex = 0;
+                    OutBoxNum.SelectedIndex = 2;
             }
         }
 
@@ -1013,6 +1015,11 @@ namespace UAS_LabelMachine
 
         private void CleanDetail_Click(object sender, EventArgs e)
         {
+            if (dh.getFieldDataByCondition("prodinout", "pi_statuscode", "pi_inoutno='" + pi_inoutno.Text + "'").ToString() == "POSTED")
+            {
+                MessageBox.Show("单据" + pi_inoutno.Text + "已过账,不允许删除条码");
+                return;
+            }
             ArrayList<string> DeleteID = new ArrayList<string>();
             for (int i = 0; i < LabelInf.RowCount; i++)
             {
@@ -1031,6 +1038,7 @@ namespace UAS_LabelMachine
                     Input.Clear();
                     LoadPrcodeData();
                     LoadGridData(sender, e);
+                    dh.UpdateByCondition("prodinout", "pi_user_packingstatus='Packing'", "pi_inoutno='" + pi_inoutno.Text + "'");
                 }
             }
             else
@@ -1071,29 +1079,39 @@ namespace UAS_LabelMachine
             sql.Append("pr_zxbzs,pr_unit,pib_barcode,pib_outboxcode1,pib_outboxcode2,nvl(pib_ifprint,0)pib_ifprint from prodiobarcode left join ");
             sql.Append("prodiodetail on pib_piid=pd_piid and pd_pdno=pib_pdno and pd_prodcode=pib_prodcode left join product on pr_code=pib_prodcode  ");
             sql.Append("left join sale on sa_code=pib_ordercode left join PRODJOINVENDDETAIL on pjd_brand =pd_brand and pjd_prodcode=pd_prodcode where pib_piid='" + PI_ID + "' ");
-            if (OutBoxNum.Text != "全部")
-            {
-                sql.Append(" and pib_outboxcode2 ='" + OutBoxNum.Text + "' ");
+            if (OutBoxNum.Text != "全部") {
+                sql.Append(" and pib_outboxcode2='" + OutBoxNum.Text + "' ");
             }
             sql.Append(" order by to_number(pib_outboxcode2),pib_id,pd_prodcode");
             LabelInfDataTable = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
             BaseUtil.FillDgvWithDataTable(LabelInf, LabelInfDataTable);
             if (LabelInf.Rows.Count > 0)
+            {
                 LabelInf.FirstDisplayedScrollingRowIndex = LabelInf.Rows.Count - 1;
+                LabelInf.Rows[LabelInf.Rows.Count - 1].Selected = true;
+            }
             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 = (LabelInfDataTable.Compute("sum(pib_qty)", "pib_prodcode='" + CurrentPrCode + "' and pib_pdno='" + CurrentPDNO + "'").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;
+                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)
@@ -1285,7 +1303,7 @@ namespace UAS_LabelMachine
                     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 = (LabelInfDataTable.Compute("sum(pib_qty)", "pib_prodcode='" + CurrentPrCode + "' and pib_pdno='" + CurrentPDNO + "'").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;
@@ -1331,7 +1349,7 @@ namespace UAS_LabelMachine
                     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 = (LabelInfDataTable.Compute("sum(pib_qty)", "pib_prodcode='" + CurrentPrCode + "' and pib_pdno='" + CurrentPDNO + "'").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;
@@ -1369,7 +1387,7 @@ namespace UAS_LabelMachine
             if (OutBoxNum.Text == "新增" || OutBoxNum.Text == "")
             {
                 if (dt.Rows.Count > 0)
-                    OutBoxNum.SelectedIndex = 0;
+                    OutBoxNum.SelectedIndex = 2;
                 else
                     OutBoxNum.SelectedIndex = 0;
             }
@@ -1577,23 +1595,13 @@ namespace UAS_LabelMachine
             bool mouseOver = e.CellBounds.Contains(this.PointToClient(Cursor.Position));
             if (e.ColumnIndex > 0 && e.RowIndex >= 0)
             {
-                if (GridPrcode.Columns[e.ColumnIndex].Name == "pd_outqty")
-                {
-                    SolidBrush solidBrush = new SolidBrush(Color.FromArgb(51, 153, 255));
-                    e.Graphics.FillRectangle(mouseOver ? solidBrush : Brushes.LightSeaGreen, e.CellBounds);
-                    Rectangle border = e.CellBounds;
-                    border.Width -= 1;
-                    e.Graphics.DrawRectangle(Pens.White, border);
-                    e.PaintContent(e.CellBounds);
-                    e.Handled = true;
-                }
-                if (GridPrcode.Columns[e.ColumnIndex].Name == "UnCollectedNum")
+                if (GridPrcode.Columns[e.ColumnIndex].Name == "CollectedNum")
                 {
                     SolidBrush solidBrush = new SolidBrush(Color.FromArgb(51, 153, 255));
-                    if (GridPrcode.Rows[e.RowIndex].Cells["UnCollectedNum"].Value.ToString() == "0.000")
-                        e.Graphics.FillRectangle(mouseOver ? solidBrush : Brushes.LightSeaGreen, e.CellBounds);
+                    if (GridPrcode.Rows[e.RowIndex].Cells["CollectedNum"].Value.ToString() != GridPrcode.Rows[e.RowIndex].Cells["pd_outqty"].Value.ToString())
+                        e.Graphics.FillRectangle(mouseOver ? solidBrush : Brushes.Yellow, e.CellBounds);
                     else
-                        e.Graphics.FillRectangle(mouseOver ? solidBrush : Brushes.Red, e.CellBounds);
+                        e.Graphics.FillRectangle(mouseOver ? solidBrush : Brushes.White, e.CellBounds);
                     Rectangle border = e.CellBounds;
                     border.Width -= 1;
                     e.Graphics.DrawRectangle(Pens.White, border);