Browse Source

修改大单打印慢的BUG

章政 7 năm trước cách đây
mục cha
commit
a9635870f2

+ 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;