章政 6 gadi atpakaļ
vecāks
revīzija
d75564a820

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

@@ -33,7 +33,6 @@
             this.pi_inoutno_label = new System.Windows.Forms.Label();
             this.label22 = new System.Windows.Forms.Label();
             this.label24 = new System.Windows.Forms.Label();
-            this.GenerateBarCode = new System.Windows.Forms.Button();
             this.LabelMainTain = new System.Windows.Forms.Button();
             this.CleanDetail = new System.Windows.Forms.Button();
             this.pib_id = new System.Windows.Forms.Label();
@@ -77,16 +76,17 @@
             this.SetPrintStatus = new System.Windows.Forms.Button();
             this.ExportData = new System.Windows.Forms.Button();
             this.PrintFooter = new System.Windows.Forms.Button();
+            this.SetPrintStatus_label = new System.Windows.Forms.Label();
             this.GridPrcode = new UAS_LabelMachine.CustomControl.DataGridViewWithSerialNum();
             this.pd_pdno = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.pjd_id = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.pd_prodcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.CollectedNum = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.pd_outqty = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.pr_unit = 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.SetPrintStatus_label = new System.Windows.Forms.Label();
             this.label18 = new System.Windows.Forms.Label();
             this.MidBoxEnd = new UAS_LabelMachine.CustomControl.EnterTextBox();
             this.MidBoxBegin = new UAS_LabelMachine.CustomControl.EnterTextBox();
@@ -194,18 +194,6 @@
             this.label24.TabIndex = 55;
             this.label24.Text = "输入框";
             // 
-            // GenerateBarCode
-            // 
-            this.GenerateBarCode.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.GenerateBarCode.Location = new System.Drawing.Point(320, 15);
-            this.GenerateBarCode.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
-            this.GenerateBarCode.Name = "GenerateBarCode";
-            this.GenerateBarCode.Size = new System.Drawing.Size(68, 26);
-            this.GenerateBarCode.TabIndex = 41;
-            this.GenerateBarCode.Text = "生成条码";
-            this.GenerateBarCode.UseVisualStyleBackColor = true;
-            this.GenerateBarCode.Click += new System.EventHandler(this.GenerateBarCode_Click);
-            // 
             // LabelMainTain
             // 
             this.LabelMainTain.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
@@ -221,7 +209,7 @@
             // CleanDetail
             // 
             this.CleanDetail.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.CleanDetail.Location = new System.Drawing.Point(320, 48);
+            this.CleanDetail.Location = new System.Drawing.Point(320, 15);
             this.CleanDetail.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.CleanDetail.Name = "CleanDetail";
             this.CleanDetail.Size = new System.Drawing.Size(68, 26);
@@ -490,7 +478,7 @@
             // 
             // ChooseAll
             // 
-            this.ChooseAll.Location = new System.Drawing.Point(4, 252);
+            this.ChooseAll.Location = new System.Drawing.Point(0, 365);
             this.ChooseAll.Margin = new System.Windows.Forms.Padding(2);
             this.ChooseAll.Name = "ChooseAll";
             this.ChooseAll.Size = new System.Drawing.Size(38, 22);
@@ -525,7 +513,7 @@
             // 
             this.label19.AutoSize = true;
             this.label19.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label19.Location = new System.Drawing.Point(9, 176);
+            this.label19.Location = new System.Drawing.Point(4, 178);
             this.label19.Name = "label19";
             this.label19.Size = new System.Drawing.Size(74, 21);
             this.label19.TabIndex = 87;
@@ -534,7 +522,7 @@
             // SetPrintStatus
             // 
             this.SetPrintStatus.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.SetPrintStatus.Location = new System.Drawing.Point(391, 114);
+            this.SetPrintStatus.Location = new System.Drawing.Point(320, 80);
             this.SetPrintStatus.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.SetPrintStatus.Name = "SetPrintStatus";
             this.SetPrintStatus.Size = new System.Drawing.Size(68, 26);
@@ -546,7 +534,7 @@
             // ExportData
             // 
             this.ExportData.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.ExportData.Location = new System.Drawing.Point(320, 79);
+            this.ExportData.Location = new System.Drawing.Point(320, 48);
             this.ExportData.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.ExportData.Name = "ExportData";
             this.ExportData.Size = new System.Drawing.Size(68, 26);
@@ -563,9 +551,20 @@
             this.PrintFooter.Name = "PrintFooter";
             this.PrintFooter.Size = new System.Drawing.Size(68, 26);
             this.PrintFooter.TabIndex = 89;
-            this.PrintFooter.Text = "打印页脚";
+            this.PrintFooter.Text = "打印唛头";
             this.PrintFooter.UseVisualStyleBackColor = true;
             // 
+            // SetPrintStatus_label
+            // 
+            this.SetPrintStatus_label.AutoSize = true;
+            this.SetPrintStatus_label.Font = new System.Drawing.Font("微软雅黑", 12F);
+            this.SetPrintStatus_label.ForeColor = System.Drawing.Color.Green;
+            this.SetPrintStatus_label.Location = new System.Drawing.Point(256, 82);
+            this.SetPrintStatus_label.Name = "SetPrintStatus_label";
+            this.SetPrintStatus_label.Size = new System.Drawing.Size(58, 21);
+            this.SetPrintStatus_label.TabIndex = 76;
+            this.SetPrintStatus_label.Text = "可打印";
+            // 
             // GridPrcode
             // 
             this.GridPrcode.AllowUserToAddRows = false;
@@ -575,12 +574,13 @@
             this.pd_pdno,
             this.pjd_id,
             this.pd_prodcode,
+            this.CollectedNum,
             this.pd_outqty,
             this.pr_unit,
             this.pd_brand,
             this.pjd_zxbzs_user});
             this.GridPrcode.GridColor = System.Drawing.SystemColors.Control;
-            this.GridPrcode.Location = new System.Drawing.Point(0, 204);
+            this.GridPrcode.Location = new System.Drawing.Point(0, 201);
             this.GridPrcode.Name = "GridPrcode";
             this.GridPrcode.RowTemplate.Height = 23;
             this.GridPrcode.Size = new System.Drawing.Size(1257, 158);
@@ -611,6 +611,12 @@
             this.pd_prodcode.ReadOnly = true;
             this.pd_prodcode.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
             // 
+            // CollectedNum
+            // 
+            this.CollectedNum.HeaderText = "已采数";
+            this.CollectedNum.Name = "CollectedNum";
+            this.CollectedNum.ReadOnly = true;
+            // 
             // pd_outqty
             // 
             this.pd_outqty.DataPropertyName = "pd_outqty";
@@ -644,7 +650,6 @@
             // 
             // groupBoxWithBorder1
             // 
-            this.groupBoxWithBorder1.Controls.Add(this.SetPrintStatus_label);
             this.groupBoxWithBorder1.Controls.Add(this.label18);
             this.groupBoxWithBorder1.Controls.Add(this.MidBoxEnd);
             this.groupBoxWithBorder1.Controls.Add(this.MidBoxBegin);
@@ -662,17 +667,6 @@
             this.groupBoxWithBorder1.TabStop = false;
             this.groupBoxWithBorder1.Text = " 打印参数设置";
             // 
-            // SetPrintStatus_label
-            // 
-            this.SetPrintStatus_label.AutoSize = true;
-            this.SetPrintStatus_label.Font = new System.Drawing.Font("微软雅黑", 12F);
-            this.SetPrintStatus_label.ForeColor = System.Drawing.Color.Green;
-            this.SetPrintStatus_label.Location = new System.Drawing.Point(8, 139);
-            this.SetPrintStatus_label.Name = "SetPrintStatus_label";
-            this.SetPrintStatus_label.Size = new System.Drawing.Size(58, 21);
-            this.SetPrintStatus_label.TabIndex = 76;
-            this.SetPrintStatus_label.Text = "可打印";
-            // 
             // label18
             // 
             this.label18.AutoSize = true;
@@ -1255,8 +1249,6 @@
             // MidLabelAutoPrint
             // 
             this.MidLabelAutoPrint.AutoSize = true;
-            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(6, 94);
             this.MidLabelAutoPrint.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
@@ -1409,6 +1401,7 @@
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(229)))), ((int)(((byte)(233)))), ((int)(((byte)(206)))));
             this.ClientSize = new System.Drawing.Size(1257, 711);
+            this.Controls.Add(this.SetPrintStatus_label);
             this.Controls.Add(this.PrintFooter);
             this.Controls.Add(this.SetPrintStatus);
             this.Controls.Add(this.GridPrcode);
@@ -1426,7 +1419,6 @@
             this.Controls.Add(this.CleanDetail);
             this.Controls.Add(this.CollectionProcess);
             this.Controls.Add(this.LabelMainTain);
-            this.Controls.Add(this.GenerateBarCode);
             this.Controls.Add(this.label24);
             this.Controls.Add(this.Input);
             this.Controls.Add(this.griddetno);
@@ -1512,7 +1504,6 @@
         private CustomControl.EnterTextBox griddetno;
         private CustomControl.EnterTextBox Input;
         private System.Windows.Forms.Label label24;
-        private System.Windows.Forms.Button GenerateBarCode;
         private System.Windows.Forms.Button LabelMainTain;
         private System.Windows.Forms.Label Process;
         private System.Windows.Forms.Label Installed;
@@ -1585,6 +1576,7 @@
         private System.Windows.Forms.DataGridViewTextBoxColumn pd_pdno;
         private System.Windows.Forms.DataGridViewTextBoxColumn pjd_id;
         private System.Windows.Forms.DataGridViewTextBoxColumn pd_prodcode;
+        private System.Windows.Forms.DataGridViewTextBoxColumn CollectedNum;
         private System.Windows.Forms.DataGridViewTextBoxColumn pd_outqty;
         private System.Windows.Forms.DataGridViewTextBoxColumn pr_unit;
         private System.Windows.Forms.DataGridViewTextBoxColumn pd_brand;

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

@@ -251,8 +251,8 @@ namespace UAS_LabelMachine
                     return;
                 }
                 CollectInputData();
-                Input.Clear();
             }
+            Input.Text = "";
         }
 
         /// <summary>
@@ -296,8 +296,19 @@ namespace UAS_LabelMachine
                         break;
                 }
             }
+            if (Data["PRCODE"] != CurrentPrCode)
+            {
+                MessageBox.Show("当前采集物料编号不对应,请重新采集");
+                return;
+            }
+            if (Data["BRAND"] != CurrentBrand)
+            {
+                MessageBox.Show("当前采集品牌不对应,请重新采集");
+                return;
+            }
             int CodeCount = 0;
             //如果单位是KPCS则需要除1000
+            int CollectNum = 0;
             if (CurrentUnit == "KPCS")
             {
                 if (int.Parse(Data["QTY"]) / 1000 % int.Parse(CurrentZXBZ) != 0)
@@ -306,6 +317,7 @@ namespace UAS_LabelMachine
                     return;
                 }
                 CodeCount = int.Parse(Data["QTY"]) / 1000 / int.Parse(CurrentZXBZ);
+                CollectNum = int.Parse(Data["QTY"]) / 1000;
             }
             else
             {
@@ -315,6 +327,7 @@ namespace UAS_LabelMachine
                     return;
                 }
                 CodeCount = int.Parse(Data["QTY"]) / int.Parse(CurrentZXBZ);
+                CollectNum = int.Parse(Data["QTY"]);
             }
 
             string pib_barcode = Data.ContainsKey("SERIAL") ? Data["SERIAL"] : "";
@@ -338,6 +351,14 @@ namespace UAS_LabelMachine
             {
                 pib_outboxcode2 = OutBoxNum.Text;
             }
+            //计算当前采集数量
+            string collectqty = (LabelInfDataTable.Compute("sum(pib_qty)", "pib_prodcode='" + CurrentPrCode + "' and pib_pdno='" + CurrentPDNO + "'").ToString());
+            int CollectQty = (collectqty == "" ? 0 : int.Parse(collectqty));
+            if (CollectQty + CollectNum > int.Parse(CurrentPrCount))
+            {
+                MessageBox.Show("采集后超出数量");
+                return;
+            }
             List<string> CustBarCode = new List<string>();
             List<string> CustOutBarCode = new List<string>();
             for (int i = 0; i < CodeCount; i++)
@@ -348,22 +369,30 @@ namespace UAS_LabelMachine
                     serialcode = "0" + serialcode;
                 }
                 CustBarCode.Add(SinglePrefix + serialcode + SingleSuffix);
-                serialcode = BaseUtil.DToAny(OutMaxNum, OutRadix);
-                for (int j = serialcode.ToString().Length; j < OutNumLength; j++)
+                if (OutPrefix != "")
                 {
-                    serialcode = "0" + serialcode;
+                    serialcode = BaseUtil.DToAny(OutMaxNum, OutRadix);
+                    for (int j = serialcode.ToString().Length; j < OutNumLength; j++)
+                    {
+                        serialcode = "0" + serialcode;
+                    }
+                    CustOutBarCode.Add(OutPrefix + serialcode + OutSuffix);
+                    SingleMaxNum = SingleMaxNum + 1;
+                    OutMaxNum = OutMaxNum + 1;
+                }
+                else
+                {
+                    CustOutBarCode.Add("");
                 }
-                CustOutBarCode.Add(OutPrefix + serialcode + OutSuffix);
-                SingleMaxNum = SingleMaxNum + 1;
-                OutMaxNum = OutMaxNum + 1;
             }
             sql.Clear();
             sql.Append("insert into prodiobarcode(PIB_ID,PIB_PRODCODE,PIB_INDATE,PIB_INOUTNO,PIB_PIID,PIB_PDNO, PIB_PDID,PIB_PICLASS,");
-            sql.Append("PIB_BARCODE,PIB_CUSTBARCODE,PIB_QTY,PIB_OUTBOXCODE1,PIB_OUTBOXCODE2,pib_custoutboxcode,PIB_IFPRINT,PIB_ORDERCODE,PIB_CUSTPO) ");
+            sql.Append("PIB_BARCODE,PIB_CUSTBARCODE,PIB_QTY,PIB_OUTBOXCODE1,pib_datecode,pib_lotno,PIB_OUTBOXCODE2,pib_custoutboxcode,PIB_IFPRINT,PIB_ORDERCODE,PIB_CUSTPO) ");
             sql.Append("select :PIB_ID,pd_prodcode,sysdate,pi_inoutno,pi_id,pd_pdno,pd_id,pi_class,");
-            sql.Append("'" + pib_barcode + "',:PIB_CUSTBARCODE,'" + CurrentZXBZ + "','','" + pib_outboxcode2 + "',:pib_custoutboxcode,0,pd_ordercode,pd_pocode ");
+            sql.Append("'" + pib_barcode + "',:PIB_CUSTBARCODE,'" + CurrentZXBZ + "','','" + Data["LOTNO"] + "','" + Data["DATECODE"] + "','" + pib_outboxcode2 + "',:pib_custoutboxcode,0,pd_ordercode,pd_pocode ");
             sql.Append("from prodinout left join prodiodetail on pi_id=pd_piid where pi_id='" + PI_ID + "' and pd_prodcode='" + CurrentPrCode + "'");
             dh.BatchInsert(sql.ToString(), new string[] { "PIB_ID", "PIB_CUSTBARCODE", "pib_custoutboxcode" }, PIBID, CustBarCode.ToArray(), CustOutBarCode.ToArray());
+            //更新流水号
             dh.UpdateByCondition("RULEMAXNUM", "rmn_maxnumber='" + (SingleMaxNum + CodeCount) + "'", "rmn_nrcode='" + pi_cardcode.Text + "' and rmn_type='Single' and rmn_prefix='" + SinglePrefix + "'");
             dh.UpdateByCondition("RULEMAXNUM", "rmn_maxnumber='" + (OutMaxNum + CodeCount) + "'", "rmn_nrcode='" + pi_cardcode.Text + "' and rmn_type='Out' and rmn_prefix='" + OutPrefix + "'");
             LoadGridData(new object(), new EventArgs());
@@ -372,6 +401,22 @@ namespace UAS_LabelMachine
             {
                 MessageBox.Show("箱号" + OutBoxNum.Text + "超出容量");
             }
+            if (SingleLabelAutoPrint.Checked)
+            {
+
+            }
+            //采集后重新计数,自动跳到下一行
+            collectqty = (LabelInfDataTable.Compute("sum(pib_qty)", "pib_prodcode='" + CurrentPrCode + "' and pib_pdno='" + CurrentPDNO + "'").ToString());
+            CollectQty = (collectqty == "" ? 0 : int.Parse(collectqty));
+            if (CollectQty == int.Parse(CurrentPrCount))
+            {
+                DataGridViewSelectedRowCollection dsc = GridPrcode.SelectedRows;
+                GridPrcode.Rows[dsc[0].Index + 1].Selected = true;
+                for (int i = 0; i < dsc.Count; i++)
+                {
+                    dsc[i].Selected = false;
+                }
+            }
         }
 
         private void AutoPrintSingleLabel(string la_id, string LabelUrl)
@@ -391,49 +436,14 @@ namespace UAS_LabelMachine
                         DataRow[] dr = SingleBoxCacheData.Select("pib_id=" + pib_id);
                         if (arg.Contains(SingleDoc.Variables.FreeVariables.Item(j + 1).Name))
                             SingleDoc.Variables.FreeVariables.Item(j + 1).Value = dr[0][SingleDoc.Variables.FreeVariables.Item(j + 1).Name].ToString();
-                        if (SingleDoc.Variables.FreeVariables.Item(j + 1).Name.Contains("datecode1"))
-                        {
-                            if (LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode1"].Value != null)
-                                SingleDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode1"].Value.ToString();
-                        }
-                        else if (SingleDoc.Variables.FreeVariables.Item(j + 1).Name.Contains("lotno"))
-                        {
-                            if (LabelInf.Rows[CurrentRowIndex].Cells["pib_lotno"].Value != null)
-                                SingleDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[CurrentRowIndex].Cells["pib_lotno"].Value.ToString();
-                        }
-                        else if (SingleDoc.Variables.FreeVariables.Item(j + 1).Name.Contains("datecode"))
-                        {
-                            if (LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode"].Value != null)
-                                SingleDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode"].Value.ToString();
-                        }
-                        else if (SingleDoc.Variables.FreeVariables.Item(j + 1).Name.Contains("产地"))
-                        {
-                            if (LabelInf.Rows[CurrentRowIndex].Cells["pib_madein"].Value != null)
-                                SingleDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[CurrentRowIndex].Cells["pib_madein"].Value.ToString();
-                        }
-                        else if (SingleDoc.Variables.FreeVariables.Item(j + 1).Name.Contains("pib_cusbarcode"))
-                        {
-                            if (LabelInf.Rows[CurrentRowIndex].Cells["pib_cusbarcode"].Value != null)
-                                SingleDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[CurrentRowIndex].Cells["pib_cusbarcode"].Value.ToString();
-                        }
                         if (SingleDoc.Variables.FreeVariables.Item(j + 1).Value == "")
                         {
-                            try
-                            {
-                                SingleDoc.Variables.FreeVariables.Item(j + 1).Value = SingleLabelParam.Select("lp_name='" + SingleDoc.Variables.FreeVariables.Item(j + 1).Name + "'")[0]["lp_sql"].ToString();
-                            }
-                            catch (Exception)
-                            {
-
-                            }
+                            DataRow[] drow = SingleLabelParam.Select("lp_name='" + SingleDoc.Variables.FreeVariables.Item(j + 1).Name + "'");
+                            if (drow.Length > 0)
+                                SingleDoc.Variables.FreeVariables.Item(j + 1).Value = drow[0]["lp_sql"].ToString();
                         }
                         ParamLog.AppendLine("pib_id:" + LabelInf.Rows[CurrentRowIndex].Cells["pib_id1"].Value.ToString() + ",SingleDoc打印参数【" + SingleDoc.Variables.FreeVariables.Item(j + 1).Name + "】赋值," + "取到值" + SingleDoc.Variables.FreeVariables.Item(j + 1).Value);
                     }
-                    else if (SingleDoc.Variables.FreeVariables.Item(j + 1).Name == "DateCode1")
-                    {
-                        if (LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode1"].Value != null)
-                            SingleDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode1"].Value.ToString();
-                    }
                 }
             }
             LogManager.DoLog(ParamLog.ToString());
@@ -575,6 +585,7 @@ namespace UAS_LabelMachine
                     pi_cardcode.Text = dt.Rows[0]["pi_cardcode"].ToString();
                     pi_date.Text = dt.Rows[0]["pi_date"].ToString();
                     PI_ID = dt.Rows[0]["pi_id"].ToString();
+                    LoadPrcodeData();
                     LoadGridData(sender, e);
                     //获取条码规则
                     GetBarCodeRule("Single", out SinglePrefix, out SingleSuffix, out SingleMaxNum, out SingleNumLength, out SingleRadix);
@@ -590,7 +601,6 @@ namespace UAS_LabelMachine
                     SingleID.Clear();
                     //获取外箱数据
                     OutBoxNum_Click(sender, new EventArgs());
-                    LoadPrcodeData();
                     thread = new Thread(GetInOutInfAndLabelFile);
                     stw = new SetLoadingWindow(thread, "正在获取打印标签");
                     BaseUtil.SetFormCenter(stw);
@@ -683,79 +693,49 @@ namespace UAS_LabelMachine
                         CheckedRowCount = CheckedRowCount + 1;
                         CurrentRowIndex = i;
                         //以标签模板的参数为基准,循环取数
-                        try
+                        //try
+                        //{
+                        string pib_id = LabelInf.Rows[i].Cells["pib_id1"].Value.ToString();
+                        DataRow[] dr = SingleBoxCacheData.Select("pib_id=" + pib_id);
+                        StringBuilder ParamLog = new StringBuilder();
+                        for (int j = 0; j < SingleDoc.Variables.FreeVariables.Count; j++)
                         {
-                            string pib_id = LabelInf.Rows[i].Cells["pib_id1"].Value.ToString();
-                            DataRow[] dr = SingleBoxCacheData.Select("pib_id=" + pib_id);
-                            StringBuilder ParamLog = new StringBuilder();
-                            for (int j = 0; j < SingleDoc.Variables.FreeVariables.Count; j++)
-                            {
-                                if (arg.Contains(SingleDoc.Variables.FreeVariables.Item(j + 1).Name))
-                                    SingleDoc.Variables.FreeVariables.Item(j + 1).Value = dr[0][SingleDoc.Variables.FreeVariables.Item(j + 1).Name].ToString();
-                                if (SingleDoc.Variables.FreeVariables.Item(j + 1).Name.ToLower().Contains("datecode1"))
-                                {
-                                    if (LabelInf.Rows[i].Cells["pib_datecode1"].Value != null)
-                                        SingleDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[i].Cells["pib_datecode1"].Value.ToString();
-                                }
-                                else if (SingleDoc.Variables.FreeVariables.Item(j + 1).Name.ToLower().Contains("lotno"))
-                                {
-                                    if (LabelInf.Rows[i].Cells["pib_lotno"].Value != null)
-                                        SingleDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[i].Cells["pib_lotno"].Value.ToString();
-                                }
-                                else if (SingleDoc.Variables.FreeVariables.Item(j + 1).Name.ToLower().Contains("datecode"))
-                                {
-                                    if (LabelInf.Rows[i].Cells["pib_datecode"].Value != null)
-                                        SingleDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[i].Cells["pib_datecode"].Value.ToString();
-                                }
-                                else if (SingleDoc.Variables.FreeVariables.Item(j + 1).Name.ToLower().Contains("产地"))
-                                {
-                                    if (LabelInf.Rows[i].Cells["pib_madein"].Value != null)
-                                        SingleDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[i].Cells["pib_madein"].Value.ToString();
-                                }
-                                else if (SingleDoc.Variables.FreeVariables.Item(j + 1).Name.ToLower().Contains("pib_cusbarcode"))
-                                {
-                                    if (LabelInf.Rows[i].Cells["pib_cusbarcode"].Value != null)
-                                        SingleDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[i].Cells["pib_cusbarcode"].Value.ToString();
-                                }
-                                if (SingleDoc.Variables.FreeVariables.Item(j + 1).Value == "")
-                                {
-                                    try
-                                    {
-                                        SingleDoc.Variables.FreeVariables.Item(j + 1).Value = SingleLabelParam.Select("lp_name='" + SingleDoc.Variables.FreeVariables.Item(j + 1).Name + "'")[0]["lp_sql"].ToString();
-                                    }
-                                    catch (Exception)
-                                    {
-
-                                    }
-                                }
-                                ParamLog.AppendLine("pib_id:" + LabelInf.Rows[i].Cells["pib_id1"].Value.ToString() + ",SingleDoc打印参数【" + SingleDoc.Variables.FreeVariables.Item(j + 1).Name + "】赋值," + "取到值" + SingleDoc.Variables.FreeVariables.Item(j + 1).Value);
-                            }
-                            LogManager.DoLog(ParamLog.ToString());
-                            //保存参数打印
-                            if (EnablePrint)
+                            if (arg.Contains(SingleDoc.Variables.FreeVariables.Item(j + 1).Name))
+                                SingleDoc.Variables.FreeVariables.Item(j + 1).Value = dr[0][SingleDoc.Variables.FreeVariables.Item(j + 1).Name].ToString();
+                            if (SingleDoc.Variables.FreeVariables.Item(j + 1).Value == "")
                             {
-                                SingleDoc.Printer.SwitchTo(SingleLabelPrinter.Text);
-                                SingleDoc.PrintDocument();
+                                DataRow[] drow = SingleLabelParam.Select("lp_name='" + SingleDoc.Variables.FreeVariables.Item(j + 1).Name + "'");
+                                if (drow.Length > 0)
+                                    SingleDoc.Variables.FreeVariables.Item(j + 1).Value = drow[0]["lp_sql"].ToString();
                             }
-                            if (MidLabelAutoPrint.Checked)
+                            ParamLog.AppendLine("pib_id:" + LabelInf.Rows[i].Cells["pib_id1"].Value.ToString() + ",SingleDoc打印参数【" + SingleDoc.Variables.FreeVariables.Item(j + 1).Name + "】赋值," + "取到值" + SingleDoc.Variables.FreeVariables.Item(j + 1).Value);
+                        }
+                        LogManager.DoLog(ParamLog.ToString());
+                        //保存参数打印
+                        if (EnablePrint)
+                        {
+                            SingleDoc.Printer.SwitchTo(SingleLabelPrinter.Text);
+                            SingleDoc.PrintDocument();
+                        }
+                        if (MidLabelAutoPrint.Checked)
+                        {
+                            //判断当前行的盒号和下一行不相等或者已经是最后一行了
+                            if (i + 1 == LabelInf.RowCount || LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString() != LabelInf.Rows[i + 1 == LabelInf.RowCount ? i : i + 1].Cells["pib_outboxcode1"].Value.ToString())
                             {
-                                //判断当前行的盒号和下一行不相等或者已经是最后一行了
-                                if (i + 1 == LabelInf.RowCount || LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString() != LabelInf.Rows[i + 1 == LabelInf.RowCount ? i : i + 1].Cells["pib_outboxcode1"].Value.ToString())
+                                if (outboxcode1[LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString()])
                                 {
-                                    if (outboxcode1[LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString()])
+                                    if (MidLabelCombox.SelectedValue != null)
                                     {
-                                        if (MidLabelCombox.SelectedValue != null)
-                                        {
-                                            string la_id_mid = MidLabelCombox.SelectedValue.ToString().Split('#')[0];
-                                            MidBoxCodePrint(la_id_mid, CurrentRowIndex);
-                                        }
+                                        string la_id_mid = MidLabelCombox.SelectedValue.ToString().Split('#')[0];
+                                        MidBoxCodePrint(la_id_mid, CurrentRowIndex);
                                     }
                                 }
                             }
-                            //勾选为已打印
-                            LabelInf.Rows[i].Cells["pib_ifprint"].Value = true;
                         }
-                        catch (Exception ex) { LogManager.DoLog(ex.Message); }
+                        //勾选为已打印
+                        LabelInf.Rows[i].Cells["pib_ifprint"].Value = true;
+                        //}
+                        //catch (Exception ex) { LogManager.DoLog(ex.StackTrace); }
                     }
                 }
                 dh.BatchInsert("update prodiobarcode set pib_printdate=sysdate where pib_id=:pib_id", new string[] { "pib_id" }, SingleID.ToArray());
@@ -1186,22 +1166,7 @@ namespace UAS_LabelMachine
                             else
                             {
                                 DataRow[] dr = MidBoxCacheData.Select("pib_outboxcode1='" + pib_outboxcode1 + "'");
-                                if (MidDoc.Variables.FreeVariables.Item(j + 1).Name.ToLower().Contains("datecode1"))
-                                {
-                                    if (LabelInf.Rows[rowindex].Cells["pib_datecode1"].Value != null)
-                                        MidDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[rowindex].Cells["pib_datecode1"].Value.ToString();
-                                }
-                                else if (MidDoc.Variables.FreeVariables.Item(j + 1).Name.ToLower().Contains("lotno"))
-                                {
-                                    if (LabelInf.Rows[rowindex].Cells["pib_lotno"].Value != null)
-                                        MidDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[rowindex].Cells["pib_lotno"].Value.ToString();
-                                }
-                                else if (MidDoc.Variables.FreeVariables.Item(j + 1).Name.ToLower().Contains("datecode"))
-                                {
-                                    if (LabelInf.Rows[rowindex].Cells["pib_datecode"].Value != null)
-                                        MidDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[rowindex].Cells["pib_datecode"].Value.ToString();
-                                }
-                                else if (arg.Contains(MidDoc.Variables.FreeVariables.Item(j + 1).Name))
+                                if (arg.Contains(MidDoc.Variables.FreeVariables.Item(j + 1).Name))
                                 {
                                     if (dr.Length > 0)
                                     {
@@ -1210,14 +1175,9 @@ namespace UAS_LabelMachine
                                 }
                                 if (MidDoc.Variables.FreeVariables.Item(j + 1).Value == "")
                                 {
-                                    try
-                                    {
-                                        MidDoc.Variables.FreeVariables.Item(j + 1).Value = MidLabelParam.Select("lp_name='" + MidDoc.Variables.FreeVariables.Item(j + 1).Name + "'")[0]["lp_sql"].ToString();
-                                    }
-                                    catch (Exception)
-                                    {
-
-                                    }
+                                    DataRow[] drow = MidLabelParam.Select("lp_name='" + MidDoc.Variables.FreeVariables.Item(j + 1).Name + "'");
+                                    if (drow.Length > 0)
+                                        MidDoc.Variables.FreeVariables.Item(j + 1).Value = drow[0]["lp_sql"].ToString();
                                 }
                                 LogManager.DoLog("打印参数【" + MidDoc.Variables.FreeVariables.Item(j + 1).Name + "】赋值," + "取值SQL:" + sql + ",取到值" + MidDoc.Variables.FreeVariables.Item(j + 1).Value);
                             }
@@ -1295,14 +1255,9 @@ namespace UAS_LabelMachine
                                 }
                                 if (MidDoc.Variables.FreeVariables.Item(j + 1).Value == "")
                                 {
-                                    try
-                                    {
-                                        MidDoc.Variables.FreeVariables.Item(j + 1).Value = MidLabelParam.Select("lp_name='" + MidDoc.Variables.FreeVariables.Item(j + 1).Name + "'")[0]["lp_sql"].ToString();
-                                    }
-                                    catch (Exception)
-                                    {
-
-                                    }
+                                    DataRow[] drow = MidLabelParam.Select("lp_name='" + MidDoc.Variables.FreeVariables.Item(j + 1).Name + "'");
+                                    if (drow.Length > 0)
+                                        MidDoc.Variables.FreeVariables.Item(j + 1).Value = drow[0]["lp_sql"].ToString();
                                 }
                                 LogManager.DoLog("打印参数【" + MidDoc.Variables.FreeVariables.Item(j + 1).Name + "】赋值," + "取值SQL:" + sql + ",取到值" + MidDoc.Variables.FreeVariables.Item(j + 1).Value);
                             }
@@ -1347,36 +1302,17 @@ namespace UAS_LabelMachine
                             string pib_outboxcode2 = LabelInf.Rows[rowindex].Cells["pib_outboxcode2"].Value.ToString();
                             //获取打印执行的SQL
                             string sql = OutLabelParam.Rows[k]["lp_sql"].ToString();
-                            //select * from productiobarcode where pib_id={pib_id} and pib_outboxcode1={pib_outboxcode1}
                             try
                             {
                                 string ExeSQL = "";
-                                if (sql.ToLower().Contains("pib_lotno"))
-                                    OutBoxDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[rowindex].Cells["pib_lotno"].Value.ToString();
-                                else if (sql.ToLower().Contains("pib_datecode"))
-                                    OutBoxDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[rowindex].Cells["pib_datecode"].Value.ToString();
-                                else if (sql.ToLower().Contains("pib_madein"))
-                                    OutBoxDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[rowindex].Cells["pib_madein"].Value.ToString();
-                                else if (sql.ToLower().Contains("pib_cusbarcode"))
-                                    OutBoxDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[rowindex].Cells["pib_cusbarcode"].Value.ToString();
-                                else if (sql.ToLower().Contains("pib_cusoutboxcode"))
-                                    OutBoxDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[rowindex].Cells["pib_cusoutboxcode"].Value.ToString();
-                                else
-                                {
-                                    ExeSQL = sql.ToLower().Replace("{pib_id}", "'" + pib_id + "'");
-                                    ExeSQL = ExeSQL.Replace("{pib_outboxcode2}", "'" + pib_outboxcode2 + "'");
-                                    OutBoxDoc.Variables.FreeVariables.Item(j + 1).Value = dh.GetLabelParam(ExeSQL).ToString();
-                                }
+                                ExeSQL = sql.ToLower().Replace("{pib_id}", "'" + pib_id + "'");
+                                ExeSQL = ExeSQL.Replace("{pib_outboxcode2}", "'" + pib_outboxcode2 + "'");
+                                OutBoxDoc.Variables.FreeVariables.Item(j + 1).Value = dh.GetLabelParam(ExeSQL).ToString();
                                 if (OutBoxDoc.Variables.FreeVariables.Item(j + 1).Value == "")
                                 {
-                                    try
-                                    {
-                                        OutBoxDoc.Variables.FreeVariables.Item(j + 1).Value = OutLabelParam.Select("lp_name='" + OutBoxDoc.Variables.FreeVariables.Item(j + 1).Name + "'")[0]["lp_sql"].ToString();
-                                    }
-                                    catch (Exception)
-                                    {
-
-                                    }
+                                    DataRow[] drow = OutLabelParam.Select("lp_name='" + OutBoxDoc.Variables.FreeVariables.Item(j + 1).Name + "'");
+                                    if (drow.Length > 0)
+                                        OutBoxDoc.Variables.FreeVariables.Item(j + 1).Value = drow[0]["lp_sql"].ToString();
                                 }
                                 LogManager.DoLog("打印参数【" + OutBoxDoc.Variables.FreeVariables.Item(j + 1).Name + "】赋值," + "取值SQL:" + ExeSQL + ",取到值" + OutBoxDoc.Variables.FreeVariables.Item(j + 1).Value);
                             }
@@ -1460,13 +1396,21 @@ namespace UAS_LabelMachine
             sql.Append("pib_lotno,pib_datecode,pib_qty,pr_spec,pr_zxbzs,pr_unit,pib_barcode,pib_outboxcode1,pib_outboxcode2,nvl(pib_ifprint,0)pib_ifprint");
             sql.Append(" from prodiobarcode left join prodiodetail on pib_piid=pd_piid and pd_pdno=pib_pdno and ");
             sql.Append(" pd_prodcode=pib_prodcode left join product on pr_code=pib_prodcode left join sale on sa_code=pib_ordercode ");
-            sql.Append("where pib_piid='" + PI_ID + "' order by to_number(pib_outboxcode1),pib_id,pd_prodcode");
+            sql.Append("where pib_piid='" + PI_ID + "' order by to_number(pib_outboxcode2),pib_id,pd_prodcode");
             LabelInfDataTable = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
             BaseUtil.FillDgvWithDataTable(LabelInf, LabelInfDataTable);
             //有数据的话默认取第一条的品牌去取采集策略
             TotalCount.Text = LabelInf.RowCount.ToString();
             if (LabelInf.Rows.Count > 0)
                 LabelInf.FirstDisplayedScrollingRowIndex = LabelInf.Rows.Count - 1;
+
+            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 collectqty = (LabelInfDataTable.Compute("sum(pib_qty)", "pib_prodcode='" + CurrentPrCode + "' and pib_pdno='" + CurrentPDNO + "'").ToString());
+                GridPrcode.Rows[i].Cells["CollectedNum"].Value = collectqty;
+            }
         }
 
         private void Refresh_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
@@ -1744,6 +1688,7 @@ namespace UAS_LabelMachine
                 CurrentPDNO = GridPrcode.Rows[0].Cells["pd_pdno"].Value.ToString();
                 CurrentPrCount = GridPrcode.Rows[0].Cells["pd_outqty"].Value.ToString();
                 CurrentBrand = GridPrcode.Rows[0].Cells["pd_brand"].Value.ToString();
+                GridPrcode.Rows[0].Selected = true;
             }
         }
 
@@ -1758,6 +1703,7 @@ namespace UAS_LabelMachine
                 CurrentPDNO = GridPrcode.Rows[e.RowIndex].Cells["pd_pdno"].Value.ToString();
                 CurrentPrCount = GridPrcode.Rows[e.RowIndex].Cells["pd_outqty"].Value.ToString();
                 CurrentBrand = GridPrcode.Rows[e.RowIndex].Cells["pd_brand"].Value.ToString();
+                GridPrcode.Rows[e.RowIndex].Selected = true;
             }
         }
 

+ 3 - 0
UAS-出货标签管理(泽天)/UAS_出货标签管理.resx

@@ -135,6 +135,9 @@
   <metadata name="pd_prodcode.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>
+  <metadata name="CollectedNum.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
   <metadata name="pd_outqty.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>