Browse Source

调整参数打印,箱号增加问题

章政 6 years ago
parent
commit
86e68ce046

+ 394 - 394
UAS-出货标签管理(吉利通)/UAS_出货标签管理.Designer.cs

@@ -137,37 +137,6 @@
             this.BackCheck = new UAS_LabelMachine.CustomControl.EnterTextBox();
             this.MessageLog = new UAS_LabelMachine.CustomControl.RichText.RichTextAutoBottom();
             this.LabelInf = new UAS_LabelMachine.CustomControl.DataGridViewWithSerialNum();
-            this.Choose = new System.Windows.Forms.DataGridViewCheckBoxColumn();
-            this.pd_id = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pib_id1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.rownum = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pib_pdno = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pib_prodcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pib_ifmodify = new System.Windows.Forms.DataGridViewCheckBoxColumn();
-            this.pib_ifupload = new System.Windows.Forms.DataGridViewCheckBoxColumn();
-            this.pr_vendprodcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pib_brand = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pib_madein = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pr_orispeccode = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pr_zxbzs = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pr_unit = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pib_lotno = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pib_datecode = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pib_ifpick = new System.Windows.Forms.DataGridViewCheckBoxColumn();
-            this.pib_ifprint = new System.Windows.Forms.DataGridViewCheckBoxColumn();
-            this.pib_ifrecheck = new System.Windows.Forms.DataGridViewCheckBoxColumn();
-            this.pib_datecode1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pib_qty = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pib_barcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pib_custbarcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pib_custmidboxcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pib_custoutboxcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pd_pocode = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pd_custprodcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pd_custprodspec = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pr_spec = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pib_outboxcode1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pib_outboxcode2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.pi_inoutno = new UAS_LabelMachine.CustomControl.EnterTextBox();
             this.SingleLabel = new UAS_LabelMachine.CustomControl.GroupBoxWithBorder.GroupBoxWithBorder();
             this.SingleDocRefresh = new System.Windows.Forms.LinkLabel();
@@ -237,6 +206,37 @@
             this.BackendCheck = new UAS_LabelMachine.CustomControl.SerialPortWithTag();
             this.FrontendCheck = new UAS_LabelMachine.CustomControl.SerialPortWithTag();
             this.PLC1 = new UAS_LabelMachine.CustomControl.SerialPortWithTag();
+            this.pib_outboxcode2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pib_outboxcode1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pr_spec = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pd_custprodspec = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pd_custprodcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pd_pocode = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pib_custoutboxcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pib_custmidboxcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pib_custbarcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pib_barcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pib_qty = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pib_datecode1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pib_ifrecheck = new System.Windows.Forms.DataGridViewCheckBoxColumn();
+            this.pib_ifprint = new System.Windows.Forms.DataGridViewCheckBoxColumn();
+            this.pib_ifpick = new System.Windows.Forms.DataGridViewCheckBoxColumn();
+            this.pib_datecode = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pib_lotno = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pr_unit = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pr_zxbzs = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pr_orispeccode = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pib_madein = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pib_brand = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pr_vendprodcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pib_ifupload = new System.Windows.Forms.DataGridViewCheckBoxColumn();
+            this.pib_ifmodify = new System.Windows.Forms.DataGridViewCheckBoxColumn();
+            this.pib_prodcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pib_pdno = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.rownum = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pib_id1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pd_id = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.Choose = new System.Windows.Forms.DataGridViewCheckBoxColumn();
             this.LogMenu.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.PageSizeNum)).BeginInit();
             this.CollectionProcess.SuspendLayout();
@@ -1410,392 +1410,146 @@
             this.LabelInf.CellPainting += new System.Windows.Forms.DataGridViewCellPaintingEventHandler(this.LabelInf_CellPainting);
             this.LabelInf.DataError += new System.Windows.Forms.DataGridViewDataErrorEventHandler(this.LabelInf_DataError);
             // 
-            // Choose
+            // pi_inoutno
             // 
-            this.Choose.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
-            this.Choose.HeaderText = "勾选";
-            this.Choose.Name = "Choose";
-            this.Choose.Resizable = System.Windows.Forms.DataGridViewTriState.True;
-            this.Choose.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
-            this.Choose.Visible = false;
-            this.Choose.Width = 55;
+            this.pi_inoutno.ID = null;
+            this.pi_inoutno.Location = new System.Drawing.Point(76, 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);
+            this.pi_inoutno.Str = null;
+            this.pi_inoutno.Str1 = null;
+            this.pi_inoutno.Str2 = null;
+            this.pi_inoutno.TabIndex = 2;
+            this.pi_inoutno.KeyDown += new System.Windows.Forms.KeyEventHandler(this.pi_inoutno_KeyDown);
             // 
-            // pd_id
+            // SingleLabel
             // 
-            this.pd_id.DataPropertyName = "pd_id";
-            this.pd_id.HeaderText = "pd_id";
-            this.pd_id.Name = "pd_id";
-            this.pd_id.Visible = false;
-            this.pd_id.Width = 60;
+            this.SingleLabel.Controls.Add(this.SingleDocRefresh);
+            this.SingleLabel.Controls.Add(this.label17);
+            this.SingleLabel.Controls.Add(this.groupBoxWithBorder4);
+            this.SingleLabel.Controls.Add(this.label7);
+            this.SingleLabel.Controls.Add(this.label16);
+            this.SingleLabel.Controls.Add(this.SingleLabelPrinter);
+            this.SingleLabel.Controls.Add(this.SingleBoxEnd);
+            this.SingleLabel.Controls.Add(this.SingleBoxBegin);
+            this.SingleLabel.Controls.Add(this.SingleLabelPrint);
+            this.SingleLabel.Controls.Add(this.SingleLabelAutoPrint);
+            this.SingleLabel.Controls.Add(this.SingleLabelCombox);
+            this.SingleLabel.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.SingleLabel.Location = new System.Drawing.Point(638, 6);
+            this.SingleLabel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+            this.SingleLabel.Name = "SingleLabel";
+            this.SingleLabel.Padding = new System.Windows.Forms.Padding(2);
+            this.SingleLabel.Size = new System.Drawing.Size(180, 269);
+            this.SingleLabel.TabIndex = 77;
+            this.SingleLabel.TabStop = false;
+            this.SingleLabel.Text = "单盘标签";
             // 
-            // pib_id1
+            // SingleDocRefresh
             // 
-            this.pib_id1.DataPropertyName = "pib_id";
-            this.pib_id1.HeaderText = "pib_id";
-            this.pib_id1.Name = "pib_id1";
-            this.pib_id1.Visible = false;
-            this.pib_id1.Width = 66;
+            this.SingleDocRefresh.AutoSize = true;
+            this.SingleDocRefresh.Font = new System.Drawing.Font("微软雅黑", 10F);
+            this.SingleDocRefresh.Location = new System.Drawing.Point(67, 24);
+            this.SingleDocRefresh.Name = "SingleDocRefresh";
+            this.SingleDocRefresh.Size = new System.Drawing.Size(37, 20);
+            this.SingleDocRefresh.TabIndex = 118;
+            this.SingleDocRefresh.TabStop = true;
+            this.SingleDocRefresh.Text = "刷新";
+            this.SingleDocRefresh.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.DocRefresh_LinkClicked);
             // 
-            // rownum
+            // label17
             // 
-            this.rownum.DataPropertyName = "rownum";
-            this.rownum.HeaderText = "行号";
-            this.rownum.Name = "rownum";
-            this.rownum.Width = 54;
+            this.label17.AutoSize = true;
+            this.label17.Font = new System.Drawing.Font("微软雅黑", 10F);
+            this.label17.Location = new System.Drawing.Point(9, 24);
+            this.label17.Name = "label17";
+            this.label17.Size = new System.Drawing.Size(55, 20);
+            this.label17.TabIndex = 115;
+            this.label17.Text = "格式(T)";
             // 
-            // pib_pdno
+            // groupBoxWithBorder4
             // 
-            this.pib_pdno.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.ColumnHeader;
-            this.pib_pdno.DataPropertyName = "pib_pdno";
-            this.pib_pdno.HeaderText = "明细序号";
-            this.pib_pdno.Name = "pib_pdno";
-            this.pib_pdno.ReadOnly = true;
-            this.pib_pdno.Width = 78;
+            this.groupBoxWithBorder4.Controls.Add(this.label20);
+            this.groupBoxWithBorder4.Controls.Add(this.BackCombo);
+            this.groupBoxWithBorder4.Controls.Add(this.label19);
+            this.groupBoxWithBorder4.Controls.Add(this.FrontCombo);
+            this.groupBoxWithBorder4.Font = new System.Drawing.Font("微软雅黑", 10F);
+            this.groupBoxWithBorder4.Location = new System.Drawing.Point(7, 186);
+            this.groupBoxWithBorder4.Name = "groupBoxWithBorder4";
+            this.groupBoxWithBorder4.Size = new System.Drawing.Size(165, 78);
+            this.groupBoxWithBorder4.TabIndex = 41;
+            this.groupBoxWithBorder4.TabStop = false;
+            this.groupBoxWithBorder4.Text = "扫描区域";
             // 
-            // pib_prodcode
+            // label20
             // 
-            this.pib_prodcode.DataPropertyName = "pib_prodcode";
-            this.pib_prodcode.HeaderText = "物料编号";
-            this.pib_prodcode.Name = "pib_prodcode";
-            this.pib_prodcode.ReadOnly = true;
-            this.pib_prodcode.Width = 78;
+            this.label20.AutoSize = true;
+            this.label20.Font = new System.Drawing.Font("微软雅黑", 10F);
+            this.label20.Location = new System.Drawing.Point(8, 49);
+            this.label20.Name = "label20";
+            this.label20.Size = new System.Drawing.Size(37, 20);
+            this.label20.TabIndex = 94;
+            this.label20.Text = "后端";
             // 
-            // pib_ifmodify
+            // BackCombo
             // 
-            this.pib_ifmodify.DataPropertyName = "pib_ifmodify";
-            this.pib_ifmodify.HeaderText = "已修改";
-            this.pib_ifmodify.Name = "pib_ifmodify";
-            this.pib_ifmodify.Resizable = System.Windows.Forms.DataGridViewTriState.True;
-            this.pib_ifmodify.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
-            this.pib_ifmodify.Width = 66;
+            this.BackCombo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+            this.BackCombo.Font = new System.Drawing.Font("微软雅黑", 8F);
+            this.BackCombo.FormattingEnabled = true;
+            this.BackCombo.Location = new System.Drawing.Point(52, 48);
+            this.BackCombo.Name = "BackCombo";
+            this.BackCombo.Size = new System.Drawing.Size(105, 24);
+            this.BackCombo.TabIndex = 93;
             // 
-            // pib_ifupload
+            // label19
             // 
-            this.pib_ifupload.DataPropertyName = "pib_ifupload";
-            this.pib_ifupload.HeaderText = "已上传";
-            this.pib_ifupload.Name = "pib_ifupload";
-            this.pib_ifupload.Resizable = System.Windows.Forms.DataGridViewTriState.True;
-            this.pib_ifupload.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
-            this.pib_ifupload.Width = 66;
+            this.label19.AutoSize = true;
+            this.label19.Font = new System.Drawing.Font("微软雅黑", 10F);
+            this.label19.Location = new System.Drawing.Point(8, 24);
+            this.label19.Name = "label19";
+            this.label19.Size = new System.Drawing.Size(37, 20);
+            this.label19.TabIndex = 92;
+            this.label19.Text = "前端";
             // 
-            // pr_vendprodcode
+            // FrontCombo
             // 
-            this.pr_vendprodcode.DataPropertyName = "pr_vendprodcode";
-            this.pr_vendprodcode.HeaderText = "MPN";
-            this.pr_vendprodcode.Name = "pr_vendprodcode";
-            this.pr_vendprodcode.ReadOnly = true;
-            this.pr_vendprodcode.Visible = false;
-            this.pr_vendprodcode.Width = 48;
+            this.FrontCombo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+            this.FrontCombo.Font = new System.Drawing.Font("微软雅黑", 8F);
+            this.FrontCombo.FormattingEnabled = true;
+            this.FrontCombo.Location = new System.Drawing.Point(52, 22);
+            this.FrontCombo.Name = "FrontCombo";
+            this.FrontCombo.Size = new System.Drawing.Size(105, 24);
+            this.FrontCombo.TabIndex = 0;
             // 
-            // pib_brand
+            // label7
             // 
-            this.pib_brand.DataPropertyName = "pib_brand";
-            this.pib_brand.HeaderText = "品牌";
-            this.pib_brand.Name = "pib_brand";
-            this.pib_brand.ReadOnly = true;
-            this.pib_brand.Width = 54;
+            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(8, 139);
+            this.label7.Name = "label7";
+            this.label7.Size = new System.Drawing.Size(56, 17);
+            this.label7.TabIndex = 76;
+            this.label7.Text = "单盘范围";
             // 
-            // pib_madein
+            // label16
             // 
-            this.pib_madein.DataPropertyName = "pib_madein";
-            this.pib_madein.HeaderText = "产地";
-            this.pib_madein.Name = "pib_madein";
-            this.pib_madein.Visible = false;
-            this.pib_madein.Width = 54;
+            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(68, 165);
+            this.label16.Name = "label16";
+            this.label16.Size = new System.Drawing.Size(13, 17);
+            this.label16.TabIndex = 87;
+            this.label16.Text = "-";
             // 
-            // pr_orispeccode
+            // SingleLabelPrinter
             // 
-            this.pr_orispeccode.DataPropertyName = "pr_orispeccode";
-            this.pr_orispeccode.HeaderText = "原厂型号";
-            this.pr_orispeccode.Name = "pr_orispeccode";
-            this.pr_orispeccode.Width = 78;
-            // 
-            // pr_zxbzs
-            // 
-            this.pr_zxbzs.DataPropertyName = "pr_zxbzs";
-            this.pr_zxbzs.HeaderText = "最小包装数";
-            this.pr_zxbzs.Name = "pr_zxbzs";
-            this.pr_zxbzs.Visible = false;
-            this.pr_zxbzs.Width = 90;
-            // 
-            // pr_unit
-            // 
-            this.pr_unit.DataPropertyName = "pr_unit";
-            this.pr_unit.HeaderText = "单位";
-            this.pr_unit.Name = "pr_unit";
-            this.pr_unit.Width = 54;
-            // 
-            // pib_lotno
-            // 
-            this.pib_lotno.DataPropertyName = "pib_lotno";
-            this.pib_lotno.HeaderText = "LotNo";
-            this.pib_lotno.Name = "pib_lotno";
-            this.pib_lotno.Width = 60;
-            // 
-            // pib_datecode
-            // 
-            this.pib_datecode.DataPropertyName = "pib_datecode";
-            this.pib_datecode.HeaderText = "DateCode";
-            this.pib_datecode.Name = "pib_datecode";
-            this.pib_datecode.Width = 78;
-            // 
-            // pib_ifpick
-            // 
-            this.pib_ifpick.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
-            this.pib_ifpick.DataPropertyName = "pib_ifpick";
-            this.pib_ifpick.HeaderText = "已扫描";
-            this.pib_ifpick.Name = "pib_ifpick";
-            this.pib_ifpick.Width = 60;
-            // 
-            // pib_ifprint
-            // 
-            this.pib_ifprint.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
-            this.pib_ifprint.DataPropertyName = "pib_ifprint";
-            this.pib_ifprint.HeaderText = "已打标";
-            this.pib_ifprint.Name = "pib_ifprint";
-            this.pib_ifprint.Width = 60;
-            // 
-            // pib_ifrecheck
-            // 
-            this.pib_ifrecheck.DataPropertyName = "pib_ifrecheck";
-            this.pib_ifrecheck.HeaderText = "已复核";
-            this.pib_ifrecheck.Name = "pib_ifrecheck";
-            this.pib_ifrecheck.Width = 47;
-            // 
-            // pib_datecode1
-            // 
-            this.pib_datecode1.DataPropertyName = "pib_datecode1";
-            this.pib_datecode1.HeaderText = "DateCode1";
-            this.pib_datecode1.Name = "pib_datecode1";
-            this.pib_datecode1.Visible = false;
-            this.pib_datecode1.Width = 84;
-            // 
-            // pib_qty
-            // 
-            this.pib_qty.DataPropertyName = "pib_qty";
-            this.pib_qty.HeaderText = "数量";
-            this.pib_qty.Name = "pib_qty";
-            this.pib_qty.ReadOnly = true;
-            this.pib_qty.Width = 54;
-            // 
-            // pib_barcode
-            // 
-            this.pib_barcode.DataPropertyName = "pib_barcode";
-            this.pib_barcode.HeaderText = "唯一条码";
-            this.pib_barcode.Name = "pib_barcode";
-            this.pib_barcode.ReadOnly = true;
-            this.pib_barcode.Visible = false;
-            this.pib_barcode.Width = 78;
-            // 
-            // pib_custbarcode
-            // 
-            this.pib_custbarcode.DataPropertyName = "pib_custbarcode";
-            this.pib_custbarcode.HeaderText = "唯一条码";
-            this.pib_custbarcode.Name = "pib_custbarcode";
-            this.pib_custbarcode.ReadOnly = true;
-            this.pib_custbarcode.Width = 78;
-            // 
-            // pib_custmidboxcode
-            // 
-            this.pib_custmidboxcode.DataPropertyName = "pib_custmidboxcode";
-            this.pib_custmidboxcode.HeaderText = "中盒条码";
-            this.pib_custmidboxcode.Name = "pib_custmidboxcode";
-            this.pib_custmidboxcode.Width = 78;
-            // 
-            // pib_custoutboxcode
-            // 
-            this.pib_custoutboxcode.DataPropertyName = "pib_custoutboxcode";
-            this.pib_custoutboxcode.HeaderText = "外箱条码";
-            this.pib_custoutboxcode.Name = "pib_custoutboxcode";
-            this.pib_custoutboxcode.Width = 78;
-            // 
-            // pd_pocode
-            // 
-            this.pd_pocode.DataPropertyName = "pd_pocode";
-            this.pd_pocode.HeaderText = "客户PO";
-            this.pd_pocode.Name = "pd_pocode";
-            this.pd_pocode.ReadOnly = true;
-            this.pd_pocode.Width = 66;
-            // 
-            // pd_custprodcode
-            // 
-            this.pd_custprodcode.DataPropertyName = "pd_custprodcode";
-            this.pd_custprodcode.HeaderText = "客户料号";
-            this.pd_custprodcode.Name = "pd_custprodcode";
-            this.pd_custprodcode.ReadOnly = true;
-            this.pd_custprodcode.Width = 78;
-            // 
-            // pd_custprodspec
-            // 
-            this.pd_custprodspec.DataPropertyName = "pd_custprodspec";
-            this.pd_custprodspec.HeaderText = "客户型号";
-            this.pd_custprodspec.Name = "pd_custprodspec";
-            this.pd_custprodspec.ReadOnly = true;
-            this.pd_custprodspec.Width = 78;
-            // 
-            // pr_spec
-            // 
-            this.pr_spec.DataPropertyName = "pr_spec";
-            this.pr_spec.HeaderText = "规格";
-            this.pr_spec.Name = "pr_spec";
-            this.pr_spec.Width = 54;
-            // 
-            // pib_outboxcode1
-            // 
-            this.pib_outboxcode1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.ColumnHeader;
-            this.pib_outboxcode1.DataPropertyName = "pib_outboxcode1";
-            this.pib_outboxcode1.HeaderText = "中盒号";
-            this.pib_outboxcode1.Name = "pib_outboxcode1";
-            this.pib_outboxcode1.Width = 66;
-            // 
-            // pib_outboxcode2
-            // 
-            this.pib_outboxcode2.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.ColumnHeader;
-            this.pib_outboxcode2.DataPropertyName = "pib_outboxcode2";
-            this.pib_outboxcode2.HeaderText = "外箱号";
-            this.pib_outboxcode2.Name = "pib_outboxcode2";
-            this.pib_outboxcode2.Width = 66;
-            // 
-            // pi_inoutno
-            // 
-            this.pi_inoutno.ID = null;
-            this.pi_inoutno.Location = new System.Drawing.Point(76, 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);
-            this.pi_inoutno.Str = null;
-            this.pi_inoutno.Str1 = null;
-            this.pi_inoutno.Str2 = null;
-            this.pi_inoutno.TabIndex = 2;
-            this.pi_inoutno.KeyDown += new System.Windows.Forms.KeyEventHandler(this.pi_inoutno_KeyDown);
-            // 
-            // SingleLabel
-            // 
-            this.SingleLabel.Controls.Add(this.SingleDocRefresh);
-            this.SingleLabel.Controls.Add(this.label17);
-            this.SingleLabel.Controls.Add(this.groupBoxWithBorder4);
-            this.SingleLabel.Controls.Add(this.label7);
-            this.SingleLabel.Controls.Add(this.label16);
-            this.SingleLabel.Controls.Add(this.SingleLabelPrinter);
-            this.SingleLabel.Controls.Add(this.SingleBoxEnd);
-            this.SingleLabel.Controls.Add(this.SingleBoxBegin);
-            this.SingleLabel.Controls.Add(this.SingleLabelPrint);
-            this.SingleLabel.Controls.Add(this.SingleLabelAutoPrint);
-            this.SingleLabel.Controls.Add(this.SingleLabelCombox);
-            this.SingleLabel.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.SingleLabel.Location = new System.Drawing.Point(638, 6);
-            this.SingleLabel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
-            this.SingleLabel.Name = "SingleLabel";
-            this.SingleLabel.Padding = new System.Windows.Forms.Padding(2);
-            this.SingleLabel.Size = new System.Drawing.Size(180, 269);
-            this.SingleLabel.TabIndex = 77;
-            this.SingleLabel.TabStop = false;
-            this.SingleLabel.Text = "单盘标签";
-            // 
-            // SingleDocRefresh
-            // 
-            this.SingleDocRefresh.AutoSize = true;
-            this.SingleDocRefresh.Font = new System.Drawing.Font("微软雅黑", 10F);
-            this.SingleDocRefresh.Location = new System.Drawing.Point(67, 24);
-            this.SingleDocRefresh.Name = "SingleDocRefresh";
-            this.SingleDocRefresh.Size = new System.Drawing.Size(37, 20);
-            this.SingleDocRefresh.TabIndex = 118;
-            this.SingleDocRefresh.TabStop = true;
-            this.SingleDocRefresh.Text = "刷新";
-            this.SingleDocRefresh.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.DocRefresh_LinkClicked);
-            // 
-            // label17
-            // 
-            this.label17.AutoSize = true;
-            this.label17.Font = new System.Drawing.Font("微软雅黑", 10F);
-            this.label17.Location = new System.Drawing.Point(9, 24);
-            this.label17.Name = "label17";
-            this.label17.Size = new System.Drawing.Size(55, 20);
-            this.label17.TabIndex = 115;
-            this.label17.Text = "格式(T)";
-            // 
-            // groupBoxWithBorder4
-            // 
-            this.groupBoxWithBorder4.Controls.Add(this.label20);
-            this.groupBoxWithBorder4.Controls.Add(this.BackCombo);
-            this.groupBoxWithBorder4.Controls.Add(this.label19);
-            this.groupBoxWithBorder4.Controls.Add(this.FrontCombo);
-            this.groupBoxWithBorder4.Font = new System.Drawing.Font("微软雅黑", 10F);
-            this.groupBoxWithBorder4.Location = new System.Drawing.Point(7, 186);
-            this.groupBoxWithBorder4.Name = "groupBoxWithBorder4";
-            this.groupBoxWithBorder4.Size = new System.Drawing.Size(165, 78);
-            this.groupBoxWithBorder4.TabIndex = 41;
-            this.groupBoxWithBorder4.TabStop = false;
-            this.groupBoxWithBorder4.Text = "扫描区域";
-            // 
-            // label20
-            // 
-            this.label20.AutoSize = true;
-            this.label20.Font = new System.Drawing.Font("微软雅黑", 10F);
-            this.label20.Location = new System.Drawing.Point(8, 49);
-            this.label20.Name = "label20";
-            this.label20.Size = new System.Drawing.Size(37, 20);
-            this.label20.TabIndex = 94;
-            this.label20.Text = "后端";
-            // 
-            // BackCombo
-            // 
-            this.BackCombo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
-            this.BackCombo.Font = new System.Drawing.Font("微软雅黑", 8F);
-            this.BackCombo.FormattingEnabled = true;
-            this.BackCombo.Location = new System.Drawing.Point(52, 48);
-            this.BackCombo.Name = "BackCombo";
-            this.BackCombo.Size = new System.Drawing.Size(105, 24);
-            this.BackCombo.TabIndex = 93;
-            // 
-            // label19
-            // 
-            this.label19.AutoSize = true;
-            this.label19.Font = new System.Drawing.Font("微软雅黑", 10F);
-            this.label19.Location = new System.Drawing.Point(8, 24);
-            this.label19.Name = "label19";
-            this.label19.Size = new System.Drawing.Size(37, 20);
-            this.label19.TabIndex = 92;
-            this.label19.Text = "前端";
-            // 
-            // FrontCombo
-            // 
-            this.FrontCombo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
-            this.FrontCombo.Font = new System.Drawing.Font("微软雅黑", 8F);
-            this.FrontCombo.FormattingEnabled = true;
-            this.FrontCombo.Location = new System.Drawing.Point(52, 22);
-            this.FrontCombo.Name = "FrontCombo";
-            this.FrontCombo.Size = new System.Drawing.Size(105, 24);
-            this.FrontCombo.TabIndex = 0;
-            // 
-            // label7
-            // 
-            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(8, 139);
-            this.label7.Name = "label7";
-            this.label7.Size = new System.Drawing.Size(56, 17);
-            this.label7.TabIndex = 76;
-            this.label7.Text = "单盘范围";
-            // 
-            // label16
-            // 
-            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(68, 165);
-            this.label16.Name = "label16";
-            this.label16.Size = new System.Drawing.Size(13, 17);
-            this.label16.TabIndex = 87;
-            this.label16.Text = "-";
-            // 
-            // SingleLabelPrinter
-            // 
-            this.SingleLabelPrinter.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.SingleLabelPrinter.Location = new System.Drawing.Point(6, 81);
-            this.SingleLabelPrinter.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
-            this.SingleLabelPrinter.Name = "SingleLabelPrinter";
-            this.SingleLabelPrinter.Size = new System.Drawing.Size(169, 25);
-            this.SingleLabelPrinter.TabIndex = 40;
+            this.SingleLabelPrinter.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.SingleLabelPrinter.Location = new System.Drawing.Point(6, 81);
+            this.SingleLabelPrinter.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
+            this.SingleLabelPrinter.Name = "SingleLabelPrinter";
+            this.SingleLabelPrinter.Size = new System.Drawing.Size(169, 25);
+            this.SingleLabelPrinter.TabIndex = 40;
             // 
             // SingleBoxEnd
             // 
@@ -2476,6 +2230,252 @@
             // 
             this.PLC1.Tag = "PLC1";
             // 
+            // pib_outboxcode2
+            // 
+            this.pib_outboxcode2.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.ColumnHeader;
+            this.pib_outboxcode2.DataPropertyName = "pib_outboxcode2";
+            this.pib_outboxcode2.HeaderText = "外箱号";
+            this.pib_outboxcode2.Name = "pib_outboxcode2";
+            this.pib_outboxcode2.Width = 66;
+            // 
+            // pib_outboxcode1
+            // 
+            this.pib_outboxcode1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.ColumnHeader;
+            this.pib_outboxcode1.DataPropertyName = "pib_outboxcode1";
+            this.pib_outboxcode1.HeaderText = "中盒号";
+            this.pib_outboxcode1.Name = "pib_outboxcode1";
+            this.pib_outboxcode1.Width = 66;
+            // 
+            // pr_spec
+            // 
+            this.pr_spec.DataPropertyName = "pr_spec";
+            this.pr_spec.HeaderText = "规格";
+            this.pr_spec.Name = "pr_spec";
+            this.pr_spec.Width = 54;
+            // 
+            // pd_custprodspec
+            // 
+            this.pd_custprodspec.DataPropertyName = "pd_custprodspec";
+            this.pd_custprodspec.HeaderText = "客户型号";
+            this.pd_custprodspec.Name = "pd_custprodspec";
+            this.pd_custprodspec.ReadOnly = true;
+            this.pd_custprodspec.Width = 78;
+            // 
+            // pd_custprodcode
+            // 
+            this.pd_custprodcode.DataPropertyName = "pd_custprodcode";
+            this.pd_custprodcode.HeaderText = "客户料号";
+            this.pd_custprodcode.Name = "pd_custprodcode";
+            this.pd_custprodcode.ReadOnly = true;
+            this.pd_custprodcode.Width = 78;
+            // 
+            // pd_pocode
+            // 
+            this.pd_pocode.DataPropertyName = "pd_pocode";
+            this.pd_pocode.HeaderText = "客户PO";
+            this.pd_pocode.Name = "pd_pocode";
+            this.pd_pocode.ReadOnly = true;
+            this.pd_pocode.Width = 66;
+            // 
+            // pib_custoutboxcode
+            // 
+            this.pib_custoutboxcode.DataPropertyName = "pib_custoutboxcode";
+            this.pib_custoutboxcode.HeaderText = "外箱条码";
+            this.pib_custoutboxcode.Name = "pib_custoutboxcode";
+            this.pib_custoutboxcode.Width = 78;
+            // 
+            // pib_custmidboxcode
+            // 
+            this.pib_custmidboxcode.DataPropertyName = "pib_custmidboxcode";
+            this.pib_custmidboxcode.HeaderText = "中盒条码";
+            this.pib_custmidboxcode.Name = "pib_custmidboxcode";
+            this.pib_custmidboxcode.Width = 78;
+            // 
+            // pib_custbarcode
+            // 
+            this.pib_custbarcode.DataPropertyName = "pib_custbarcode";
+            this.pib_custbarcode.HeaderText = "唯一条码";
+            this.pib_custbarcode.Name = "pib_custbarcode";
+            this.pib_custbarcode.ReadOnly = true;
+            this.pib_custbarcode.Width = 78;
+            // 
+            // pib_barcode
+            // 
+            this.pib_barcode.DataPropertyName = "pib_barcode";
+            this.pib_barcode.HeaderText = "唯一条码";
+            this.pib_barcode.Name = "pib_barcode";
+            this.pib_barcode.ReadOnly = true;
+            this.pib_barcode.Visible = false;
+            this.pib_barcode.Width = 78;
+            // 
+            // pib_qty
+            // 
+            this.pib_qty.DataPropertyName = "pib_qty";
+            this.pib_qty.HeaderText = "数量";
+            this.pib_qty.Name = "pib_qty";
+            this.pib_qty.ReadOnly = true;
+            this.pib_qty.Width = 54;
+            // 
+            // pib_datecode1
+            // 
+            this.pib_datecode1.DataPropertyName = "pib_datecode1";
+            this.pib_datecode1.HeaderText = "DateCode1";
+            this.pib_datecode1.Name = "pib_datecode1";
+            this.pib_datecode1.Visible = false;
+            this.pib_datecode1.Width = 84;
+            // 
+            // pib_ifrecheck
+            // 
+            this.pib_ifrecheck.DataPropertyName = "pib_ifrecheck";
+            this.pib_ifrecheck.HeaderText = "已复核";
+            this.pib_ifrecheck.Name = "pib_ifrecheck";
+            this.pib_ifrecheck.Width = 47;
+            // 
+            // pib_ifprint
+            // 
+            this.pib_ifprint.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
+            this.pib_ifprint.DataPropertyName = "pib_ifprint";
+            this.pib_ifprint.HeaderText = "已打标";
+            this.pib_ifprint.Name = "pib_ifprint";
+            this.pib_ifprint.Width = 60;
+            // 
+            // pib_ifpick
+            // 
+            this.pib_ifpick.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
+            this.pib_ifpick.DataPropertyName = "pib_ifpick";
+            this.pib_ifpick.HeaderText = "已扫描";
+            this.pib_ifpick.Name = "pib_ifpick";
+            this.pib_ifpick.Width = 60;
+            // 
+            // pib_datecode
+            // 
+            this.pib_datecode.DataPropertyName = "pib_datecode";
+            this.pib_datecode.HeaderText = "DateCode";
+            this.pib_datecode.Name = "pib_datecode";
+            this.pib_datecode.Width = 78;
+            // 
+            // pib_lotno
+            // 
+            this.pib_lotno.DataPropertyName = "pib_lotno";
+            this.pib_lotno.HeaderText = "LotNo";
+            this.pib_lotno.Name = "pib_lotno";
+            this.pib_lotno.Width = 60;
+            // 
+            // pr_unit
+            // 
+            this.pr_unit.DataPropertyName = "pr_unit";
+            this.pr_unit.HeaderText = "单位";
+            this.pr_unit.Name = "pr_unit";
+            this.pr_unit.Width = 54;
+            // 
+            // pr_zxbzs
+            // 
+            this.pr_zxbzs.DataPropertyName = "pr_zxbzs";
+            this.pr_zxbzs.HeaderText = "最小包装数";
+            this.pr_zxbzs.Name = "pr_zxbzs";
+            this.pr_zxbzs.Visible = false;
+            this.pr_zxbzs.Width = 90;
+            // 
+            // pr_orispeccode
+            // 
+            this.pr_orispeccode.DataPropertyName = "pr_orispeccode";
+            this.pr_orispeccode.HeaderText = "原厂型号";
+            this.pr_orispeccode.Name = "pr_orispeccode";
+            this.pr_orispeccode.Width = 78;
+            // 
+            // pib_madein
+            // 
+            this.pib_madein.DataPropertyName = "pib_madein";
+            this.pib_madein.HeaderText = "产地";
+            this.pib_madein.Name = "pib_madein";
+            this.pib_madein.Visible = false;
+            this.pib_madein.Width = 54;
+            // 
+            // pib_brand
+            // 
+            this.pib_brand.DataPropertyName = "pib_brand";
+            this.pib_brand.HeaderText = "品牌";
+            this.pib_brand.Name = "pib_brand";
+            this.pib_brand.ReadOnly = true;
+            this.pib_brand.Width = 54;
+            // 
+            // pr_vendprodcode
+            // 
+            this.pr_vendprodcode.DataPropertyName = "pr_vendprodcode";
+            this.pr_vendprodcode.HeaderText = "MPN";
+            this.pr_vendprodcode.Name = "pr_vendprodcode";
+            this.pr_vendprodcode.ReadOnly = true;
+            this.pr_vendprodcode.Visible = false;
+            this.pr_vendprodcode.Width = 48;
+            // 
+            // pib_ifupload
+            // 
+            this.pib_ifupload.DataPropertyName = "pib_ifupload";
+            this.pib_ifupload.HeaderText = "已上传";
+            this.pib_ifupload.Name = "pib_ifupload";
+            this.pib_ifupload.Resizable = System.Windows.Forms.DataGridViewTriState.True;
+            this.pib_ifupload.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
+            this.pib_ifupload.Width = 66;
+            // 
+            // pib_ifmodify
+            // 
+            this.pib_ifmodify.DataPropertyName = "pib_ifmodify";
+            this.pib_ifmodify.HeaderText = "已修改";
+            this.pib_ifmodify.Name = "pib_ifmodify";
+            this.pib_ifmodify.Resizable = System.Windows.Forms.DataGridViewTriState.True;
+            this.pib_ifmodify.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
+            this.pib_ifmodify.Width = 66;
+            // 
+            // pib_prodcode
+            // 
+            this.pib_prodcode.DataPropertyName = "pib_prodcode";
+            this.pib_prodcode.HeaderText = "物料编号";
+            this.pib_prodcode.Name = "pib_prodcode";
+            this.pib_prodcode.ReadOnly = true;
+            this.pib_prodcode.Width = 78;
+            // 
+            // pib_pdno
+            // 
+            this.pib_pdno.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.ColumnHeader;
+            this.pib_pdno.DataPropertyName = "pib_pdno";
+            this.pib_pdno.HeaderText = "明细序号";
+            this.pib_pdno.Name = "pib_pdno";
+            this.pib_pdno.ReadOnly = true;
+            this.pib_pdno.Width = 78;
+            // 
+            // rownum
+            // 
+            this.rownum.DataPropertyName = "rownum";
+            this.rownum.HeaderText = "行号";
+            this.rownum.Name = "rownum";
+            this.rownum.Width = 54;
+            // 
+            // pib_id1
+            // 
+            this.pib_id1.DataPropertyName = "pib_id";
+            this.pib_id1.HeaderText = "pib_id";
+            this.pib_id1.Name = "pib_id1";
+            this.pib_id1.Visible = false;
+            this.pib_id1.Width = 66;
+            // 
+            // pd_id
+            // 
+            this.pd_id.DataPropertyName = "pd_id";
+            this.pd_id.HeaderText = "pd_id";
+            this.pd_id.Name = "pd_id";
+            this.pd_id.Visible = false;
+            this.pd_id.Width = 60;
+            // 
+            // Choose
+            // 
+            this.Choose.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
+            this.Choose.HeaderText = "勾选";
+            this.Choose.Name = "Choose";
+            this.Choose.Resizable = System.Windows.Forms.DataGridViewTriState.True;
+            this.Choose.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
+            this.Choose.Visible = false;
+            this.Choose.Width = 55;
+            // 
             // UAS_出货标签打印
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);

+ 123 - 127
UAS-出货标签管理(吉利通)/UAS_出货标签管理.cs

@@ -294,6 +294,7 @@ namespace UAS_LabelMachine
         private bool RegexMatch(string CheckType, string msg, out string ErrorMsg)
         {
             ErrorMsg = "";
+            bool Matched = false;
             for (int i = 0; i < ScanGroup.Rows.Count; i++)
             {
                 string sg_name = ScanGroup.Rows[i]["sg_name"].ToString();
@@ -305,6 +306,8 @@ namespace UAS_LabelMachine
                 DataTable dt = BaseUtil.filterDataTable(ScanItem, "sg_id=" + sg_id);
                 if (matchs1.Success)
                 {
+                    int rownum = 0;
+                    Matched = true;
                     string ItemStr = "";
                     foreach (var groupName in reg.GetGroupNames())
                     {
@@ -336,7 +339,6 @@ namespace UAS_LabelMachine
                                         PN = matchs1.Groups[reg.GroupNumberFromName(groupName)].Value;
                                         //自动匹配客户PN
                                         DataTable pndt = (DataTable)adh.ExecuteSql("select min(rownum) as rn from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "' and pr_orispeccode='" + PN + "' and pib_ifpick=0", "select");
-                                        int rownum = 0;
                                         if (pndt.Rows[0][0].ToString() != "")
                                         {
                                             if (CheckType == "FrontCheck")
@@ -400,21 +402,17 @@ namespace UAS_LabelMachine
                         ErrorMsg = "订单号不匹配";
                     }
                     //如果品牌不对应的话则不能使用本次的匹配规则
-                    if (LabelInf.Rows[CurrentRowIndex].Cells["pib_brand"].Value.ToString() == sg_brand)
+                    if (LabelInf.Rows[CurrentRowIndex].Cells["pib_brand"].Value.ToString() == sg_brand && rownum != 0)
                     {
                         ErrorMsg = "";
                         break;
                     }
-                    else
-                    {
-                        ErrorMsg = "未匹配到合适的采集策略";
-                    }
-                }
-                else
-                {
-                    ErrorMsg = "未匹配到合适的采集策略";
                 }
             }
+            if (!Matched)
+            {
+                ErrorMsg = "未匹配到合适的采集策略";
+            }
             if (ErrorMsg == "")
             {
                 return true;
@@ -441,9 +439,9 @@ namespace UAS_LabelMachine
                 LabelInf.Rows[CurrentRowIndex].Cells["pib_lotno"].Value = LotNo;
                 LabelInf.Rows[CurrentRowIndex].Cells["pib_ifmodify"].Value = true;
                 string boxcode = adh.getFieldDataByCondition("prodiobarcode", "max(pib_outboxcode1)", "pib_inoutno='" + pi_inoutno.Text + "'").ToString();
-                int outboxcode1 = int.Parse(boxcode == "" ? "1" : boxcode);
+                int outboxcode1 = int.Parse(Process_midboxcode.Text == "" ? "1" : Process_midboxcode.Text);
                 boxcode = adh.getFieldDataByCondition("prodiobarcode", "max(pib_outboxcode2)", "pib_inoutno='" + pi_inoutno.Text + "'").ToString();
-                int outboxcode2 = int.Parse(boxcode == "" ? "1" : boxcode);
+                int outboxcode2 = int.Parse(Process_outboxcode.Text == "" ? "1" : Process_outboxcode.Text);
                 string pd_id = LabelInf.Rows[CurrentRowIndex].Cells["pd_id"].Value.ToString();
                 //如果满容量获取过箱号就不再重复获取了
                 bool GetBarcode = false;
@@ -465,7 +463,8 @@ namespace UAS_LabelMachine
                     //或者不符合合并条件中盒号+1
                     if (cu_print_midlotno.Checked)
                     {
-                        if (LastRowData.Rows[0]["pib_lotno"].ToString() != LabelInf.Rows[CurrentRowIndex].Cells["pib_lotno"].Value.ToString() && !GetBarcode)
+                        string TempData = LastRowData.Rows[0]["pib_lotno"].ToString();
+                        if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pib_lotno"].Value.ToString() && !GetBarcode)
                         {
                             LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
                             LogicHandler.SendDataToPLC(PLC1, PLCInstruct.MaterialTray);
@@ -475,7 +474,8 @@ namespace UAS_LabelMachine
                     }
                     else if (cu_print_midpo.Checked)
                     {
-                        if (LastRowData.Rows[0]["pd_pocode"].ToString() != LabelInf.Rows[CurrentRowIndex].Cells["pd_pocode"].Value.ToString() && !GetBarcode)
+                        string TempData = LastRowData.Rows[0]["pd_pocode"].ToString();
+                        if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pd_pocode"].Value.ToString() && !GetBarcode)
                         {
                             LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
                             LogicHandler.SendDataToPLC(PLC1, PLCInstruct.MaterialTray);
@@ -485,7 +485,8 @@ namespace UAS_LabelMachine
                     }
                     else if (cu_print_midprod.Checked)
                     {
-                        if (LastRowData.Rows[0]["pd_custprodcode"].ToString() != LabelInf.Rows[CurrentRowIndex].Cells["pd_custprodcode"].Value.ToString() && !GetBarcode)
+                        string TempData = LastRowData.Rows[0]["pd_custprodcode"].ToString();
+                        if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pd_custprodcode"].Value.ToString() && !GetBarcode)
                         {
                             LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
                             LogicHandler.SendDataToPLC(PLC1, PLCInstruct.MaterialTray);
@@ -495,7 +496,8 @@ namespace UAS_LabelMachine
                     }
                     else if (cu_print_midspec.Checked)
                     {
-                        if (LastRowData.Rows[0]["pd_custprodspec"].ToString() != LabelInf.Rows[CurrentRowIndex].Cells["pd_custprodspec"].Value.ToString() && !GetBarcode)
+                        string TempData = LastRowData.Rows[0]["pd_custprodspec"].ToString();
+                        if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pd_custprodspec"].Value.ToString() && !GetBarcode)
                         {
                             LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
                             LogicHandler.SendDataToPLC(PLC1, PLCInstruct.MaterialTray);
@@ -505,7 +507,8 @@ namespace UAS_LabelMachine
                     }
                     else if (cu_print_middc.Checked)
                     {
-                        if (LastRowData.Rows[0]["pib_datecode"].ToString() != LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode"].Value.ToString() && !GetBarcode)
+                        string TempData = LastRowData.Rows[0]["pib_datecode"].ToString();
+                        if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode"].Value.ToString() && !GetBarcode)
                         {
                             LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
                             LogicHandler.SendDataToPLC(PLC1, PLCInstruct.MaterialTray);
@@ -536,7 +539,8 @@ namespace UAS_LabelMachine
                     //或者不符合合并条件中盒号+1
                     if (cu_print_outlotno.Checked)
                     {
-                        if (LastRowData.Rows[0]["pib_lotno"].ToString() != LabelInf.Rows[CurrentRowIndex].Cells["pib_lotno"].Value.ToString() && !GetBarcode)
+                        string TempData = LastRowData.Rows[0]["pib_lotno"].ToString();
+                        if (TempData!=""&& TempData != LabelInf.Rows[CurrentRowIndex].Cells["pib_lotno"].Value.ToString() && !GetBarcode)
                         {
                             LogicHandler.GetBarCode(PI_ID, pd_id, 1, out OutBoxBarCode);
                             LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
@@ -544,7 +548,8 @@ namespace UAS_LabelMachine
                     }
                     else if (cu_print_outpo.Checked)
                     {
-                        if (LastRowData.Rows[0]["pd_pocode"].ToString() != LabelInf.Rows[CurrentRowIndex].Cells["pd_pocode"].Value.ToString() && !GetBarcode)
+                        string TempData = LastRowData.Rows[0]["pd_pocode"].ToString();
+                        if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pd_pocode"].Value.ToString() && !GetBarcode)
                         {
                             LogicHandler.GetBarCode(PI_ID, pd_id, 1, out OutBoxBarCode);
                             LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
@@ -552,7 +557,8 @@ namespace UAS_LabelMachine
                     }
                     else if (cu_print_outprod.Checked)
                     {
-                        if (LastRowData.Rows[0]["pd_custprodcode"].ToString() != LabelInf.Rows[CurrentRowIndex].Cells["pd_custprodcode"].Value.ToString() && !GetBarcode)
+                        string TempData = LastRowData.Rows[0]["pd_custprodcode"].ToString();
+                        if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pd_custprodcode"].Value.ToString() && !GetBarcode)
                         {
                             LogicHandler.GetBarCode(PI_ID, pd_id, 1, out OutBoxBarCode);
                             LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
@@ -560,7 +566,8 @@ namespace UAS_LabelMachine
                     }
                     else if (cu_print_outspec.Checked)
                     {
-                        if (LastRowData.Rows[0]["pd_custprodspec"].ToString() != LabelInf.Rows[CurrentRowIndex].Cells["pd_custprodspec"].Value.ToString() && !GetBarcode)
+                        string TempData = LastRowData.Rows[0]["pd_custprodspec"].ToString();
+                        if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pd_custprodspec"].Value.ToString() && !GetBarcode)
                         {
                             LogicHandler.GetBarCode(PI_ID, pd_id, 1, out OutBoxBarCode);
                             LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
@@ -568,7 +575,8 @@ namespace UAS_LabelMachine
                     }
                     else if (cu_print_outdc.Checked)
                     {
-                        if (LastRowData.Rows[0]["pib_datecode"].ToString() != LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode"].Value.ToString() && !GetBarcode)
+                        string TempData = LastRowData.Rows[0]["pib_datecode"].ToString();
+                        if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode"].Value.ToString() && !GetBarcode)
                         {
                             LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
                             LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
@@ -584,6 +592,7 @@ namespace UAS_LabelMachine
                     LogicHandler.GetBarCode(PI_ID, pd_id, 1, out OutBoxBarCode);
                     LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
                 }
+                //设置中盒外箱号
                 LabelInf.Rows[CurrentRowIndex].Cells["pib_outboxcode1"].Value = outboxcode1;
                 LabelInf.Rows[CurrentRowIndex].Cells["pib_outboxcode2"].Value = outboxcode2;
                 string pib_id = LabelInf.Rows[CurrentRowIndex].Cells["pib_id1"].Value.ToString();
@@ -751,29 +760,26 @@ namespace UAS_LabelMachine
                     sql.Append(dr1[0]["lp_sql"].ToString() + ",");
                 }
             }
-            if (sql.Length != 0)
+            sql.Append("1,");
+            DataTable dt = (DataTable)adh.ExecuteSql("select " + sql.ToString().Substring(0, sql.Length - 1) + " from prodiobarcode where pib_id=" + pib_id, "select");
+            for (int i = 0; i < SingleDoc.Variables.FormVariables.Count; i++)
             {
-                DataTable dt = (DataTable)adh.ExecuteSql("select " + sql.ToString().Substring(0, sql.Length - 1) + " from prodiobarcode where pib_id=" + pib_id, "select");
-                for (int i = 0; i < SingleDoc.Variables.FormVariables.Count; i++)
+                DataRow[] dr1 = SingleLabelParam.Select("lp_name='" + SingleDoc.Variables.FormVariables.Item(i + 1).Name.ToLower() + "'");
+                if (dr1.Length > 0)
+                {
+                    SingleDoc.Variables.FormVariables.Item(i + 1).Value = dt.Rows[0][dr1[0]["lp_sql"].ToString()].ToString();
+                }
+                if (SingleDoc.Variables.FormVariables.Item(i + 1).Value == "")
                 {
-                    DataRow[] dr1 = SingleLabelParam.Select("lp_name='" + SingleDoc.Variables.FormVariables.Item(i + 1).Name.ToLower() + "'");
+                    dr1 = Attach.Select("lp_name='" + SingleDoc.Variables.FormVariables.Item(i + 1).Name.ToLower() + "'");
                     if (dr1.Length > 0)
-                    {
-                        SingleDoc.Variables.FormVariables.Item(i + 1).Value = dt.Rows[0][dr1[0]["lp_sql"].ToString()].ToString();
-                    }
-                    if (SingleDoc.Variables.FormVariables.Item(i + 1).Value == "")
-                    {
-                        dr1 = Attach.Select("lp_name='" + SingleDoc.Variables.FormVariables.Item(i + 1).Name.ToLower() + "'");
-                        if (dr1.Length > 0)
-                            SingleDoc.Variables.FormVariables.Item(i + 1).Value = dr1[0]["lp_sql"].ToString();
-                    }
+                        SingleDoc.Variables.FormVariables.Item(i + 1).Value = dr1[0]["lp_sql"].ToString();
                 }
-                SingleDoc.Printer.SwitchTo(SingleLabelPrinter.Text);
-                SingleDoc.PrintDocument();
-                LogicHandler.UpdateRowPrinted(pib_id);
-                LabelInf.Rows[CurrentRowIndex].Cells["pib_ifprint"].Value = true;
             }
-            else MessageLog.AppendText("未能匹配到单盘标签参数,请检查标签模板\n", Color.Red);
+            SingleDoc.Printer.SwitchTo(SingleLabelPrinter.Text);
+            SingleDoc.PrintDocument();
+            LogicHandler.UpdateRowPrinted(pib_id);
+            LabelInf.Rows[CurrentRowIndex].Cells["pib_ifprint"].Value = true;
         }
 
         //关闭窗口前提示用户确认
@@ -1059,28 +1065,25 @@ namespace UAS_LabelMachine
                                     sql.Append(dr1[0]["lp_sql"].ToString() + ",");
                                 }
                             }
-                            if (sql.Length != 0)
+                            sql.Append("1,");
+                            DataTable dt = (DataTable)adh.ExecuteSql("select " + sql.ToString().Substring(0, sql.Length - 1) + " from prodiobarcode where pib_id=" + pib_id, "select");
+                            for (int j = 0; j < SingleDoc.Variables.FormVariables.Count; j++)
                             {
-                                DataTable dt = (DataTable)adh.ExecuteSql("select " + sql.ToString().Substring(0, sql.Length - 1) + " from prodiobarcode where pib_id=" + pib_id, "select");
-                                for (int j = 0; j < SingleDoc.Variables.FormVariables.Count; j++)
+                                DataRow[] dr1 = SingleLabelParam.Select("lp_name='" + SingleDoc.Variables.FormVariables.Item(j + 1).Name.ToLower() + "'");
+                                if (dr1.Length > 0)
                                 {
-                                    DataRow[] dr1 = SingleLabelParam.Select("lp_name='" + SingleDoc.Variables.FormVariables.Item(j + 1).Name.ToLower() + "'");
+                                    SingleDoc.Variables.FormVariables.Item(j + 1).Value = dt.Rows[0][dr1[0]["lp_sql"].ToString()].ToString();
+                                }
+                                if (SingleDoc.Variables.FormVariables.Item(j + 1).Value == "")
+                                {
+                                    dr1 = Attach.Select("lp_name='" + SingleDoc.Variables.FormVariables.Item(j + 1).Name.ToLower() + "'");
                                     if (dr1.Length > 0)
-                                    {
-                                        SingleDoc.Variables.FormVariables.Item(j + 1).Value = dt.Rows[0][dr1[0]["lp_sql"].ToString()].ToString();
-                                    }
-                                    if (SingleDoc.Variables.FormVariables.Item(j + 1).Value == "")
-                                    {
-                                        dr1 = Attach.Select("lp_name='" + SingleDoc.Variables.FormVariables.Item(j + 1).Name.ToLower() + "'");
-                                        if (dr1.Length > 0)
-                                            SingleDoc.Variables.FormVariables.Item(j + 1).Value = dr1[0]["lp_sql"].ToString();
-                                    }
+                                        SingleDoc.Variables.FormVariables.Item(j + 1).Value = dr1[0]["lp_sql"].ToString();
                                 }
-                                SingleDoc.Printer.SwitchTo(SingleLabelPrinter.Text);
-                                SingleDoc.PrintDocument();
-                                LogicHandler.UpdateRowPrinted(pib_id);
                             }
-                            else MessageLog.AppendText("未能匹配到单盘标签参数,请检查标签模板\n", Color.Red);
+                            SingleDoc.Printer.SwitchTo(SingleLabelPrinter.Text);
+                            SingleDoc.PrintDocument();
+                            LogicHandler.UpdateRowPrinted(pib_id);
                             if (MidLabelAutoPrint.Checked)
                             {
                                 //判断当前行的盒号和下一行不相等或者已经是最后一行了
@@ -1345,47 +1348,44 @@ namespace UAS_LabelMachine
                     sql.Append(dr1[0]["lp_sql"].ToString() + ",");
                 }
             }
-            if (sql.Length != 0)
+            sql.Append("1,");
+            DataTable dt = (DataTable)adh.ExecuteSql("select " + sql.ToString().Substring(0, sql.Length - 1) + " from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode1=" + (pib_outboxcode1 == "" ? "0" : pib_outboxcode1), "select");
+            for (int j = 0; j < MidDoc.Variables.FormVariables.Count; j++)
             {
-                DataTable dt = (DataTable)adh.ExecuteSql("select " + sql.ToString().Substring(0, sql.Length - 1) + " from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode1=" + (pib_outboxcode1 == "" ? "0" : pib_outboxcode1), "select");
-                for (int j = 0; j < MidDoc.Variables.FormVariables.Count; j++)
+                DataRow[] dr1 = MidLabelParam.Select("lp_name='" + MidDoc.Variables.FormVariables.Item(j + 1).Name.ToLower() + "'");
+                if (dr1.Length > 0 && dr1[0]["lp_valuetype"].ToString() == "字符串")
                 {
-                    DataRow[] dr1 = MidLabelParam.Select("lp_name='" + MidDoc.Variables.FormVariables.Item(j + 1).Name.ToLower() + "'");
-                    if (dr1.Length > 0 && dr1[0]["lp_valuetype"].ToString() == "字符串")
-                    {
-                        MidDoc.Variables.FormVariables.Item(j + 1).Value = dt.Rows[0][dr1[0]["lp_sql"].ToString()].ToString();
-                    }
-                    //SQL判断多个值的时候
-                    if (dr1.Length > 0 && dr1[0]["lp_valuetype"].ToString() == "SQL值")
+                    MidDoc.Variables.FormVariables.Item(j + 1).Value = dt.Rows[0][dr1[0]["lp_sql"].ToString()].ToString();
+                }
+                //SQL判断多个值的时候
+                if (dr1.Length > 0 && dr1[0]["lp_valuetype"].ToString() == "SQL值")
+                {
+                    DataTable dt1 = (DataTable)adh.ExecuteSql(dr1[0]["lp_sql"].ToString().Replace("{1}", "'" + pi_inoutno.Text + "'").Replace("{2}", pib_outboxcode1), "select");
+                    for (int i = 0; i < dt1.Rows.Count; i++)
                     {
-                        DataTable dt1 = (DataTable)adh.ExecuteSql(dr1[0]["lp_sql"].ToString().Replace("{1}", "'" + pi_inoutno.Text + "'").Replace("{2}", pib_outboxcode1), "select");
-                        for (int i = 0; i < dt1.Rows.Count; i++)
+                        for (int k = 0; k < MidDoc.Variables.FormVariables.Count; k++)
                         {
-                            for (int k = 0; k < MidDoc.Variables.FormVariables.Count; k++)
+                            if (i == 0 & MidDoc.Variables.FormVariables.Item(k + 1).Name.ToUpper() == dr1[0]["lp_name"].ToString().ToUpper())
                             {
-                                if (i == 0 & MidDoc.Variables.FormVariables.Item(k + 1).Name.ToUpper() == dr1[0]["lp_name"].ToString().ToUpper())
-                                {
-                                    MidDoc.Variables.FormVariables.Item(k + 1).Value = dt1.Rows[0][0].ToString();
-                                }
-                                //使用SN开头的参数赋值SN1,SN2,SN3等参数
-                                if (MidDoc.Variables.FormVariables.Item(k + 1).Name.ToUpper() == (dr1[0]["lp_name"].ToString() + (i + 1)).ToUpper())
-                                {
-                                    MidDoc.Variables.FormVariables.Item(k + 1).Value = dt1.Rows[i][0].ToString();
-                                }
+                                MidDoc.Variables.FormVariables.Item(k + 1).Value = dt1.Rows[0][0].ToString();
+                            }
+                            //使用SN开头的参数赋值SN1,SN2,SN3等参数
+                            if (MidDoc.Variables.FormVariables.Item(k + 1).Name.ToUpper() == (dr1[0]["lp_name"].ToString() + (i + 1)).ToUpper())
+                            {
+                                MidDoc.Variables.FormVariables.Item(k + 1).Value = dt1.Rows[i][0].ToString();
                             }
                         }
                     }
-                    if (MidDoc.Variables.FormVariables.Item(j + 1).Value == "")
-                    {
-                        dr1 = Attach.Select("lp_name='" + MidDoc.Variables.FormVariables.Item(j + 1).Name.ToLower() + "'");
-                        if (dr1.Length > 0)
-                            MidDoc.Variables.FormVariables.Item(j + 1).Value = dr1[0]["lp_sql"].ToString();
-                    }
                 }
-                MidDoc.Printer.SwitchTo(MidLabelPrinter.Text);
-                MidDoc.PrintDocument();
+                if (MidDoc.Variables.FormVariables.Item(j + 1).Value == "")
+                {
+                    dr1 = Attach.Select("lp_name='" + MidDoc.Variables.FormVariables.Item(j + 1).Name.ToLower() + "'");
+                    if (dr1.Length > 0)
+                        MidDoc.Variables.FormVariables.Item(j + 1).Value = dr1[0]["lp_sql"].ToString();
+                }
             }
-            else MessageLog.AppendText("未能匹配到中盒标签参数,请检查标签模板\n", Color.Red);
+            MidDoc.Printer.SwitchTo(MidLabelPrinter.Text);
+            MidDoc.PrintDocument();
         }
 
         /// <summary>
@@ -1406,50 +1406,47 @@ namespace UAS_LabelMachine
                     sql.Append(dr1[0]["lp_sql"].ToString() + ",");
                 }
             }
-            if (sql.Length != 0)
+            sql.Append("1,");
+            DataTable dt = (DataTable)adh.ExecuteSql("select " + sql.ToString().Substring(0, sql.Length - 1) + " from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode2=" + (pib_outboxcode2 == "" ? "0" : pib_outboxcode2), "select");
+            if (dt.Rows.Count > 0)
             {
-                DataTable dt = (DataTable)adh.ExecuteSql("select " + sql.ToString().Substring(0, sql.Length - 1) + " from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode2=" + (pib_outboxcode2 == "" ? "0" : pib_outboxcode2), "select");
-                if (dt.Rows.Count > 0)
+                for (int j = 0; j < OutBoxDoc.Variables.FormVariables.Count; j++)
                 {
-                    for (int j = 0; j < OutBoxDoc.Variables.FormVariables.Count; j++)
+                    DataRow[] dr1 = OutLabelParam.Select("lp_name='" + OutBoxDoc.Variables.FormVariables.Item(j + 1).Name.ToLower() + "'");
+                    if (dr1.Length > 0 && dr1[0]["lp_valuetype"].ToString() == "字符串")
                     {
-                        DataRow[] dr1 = OutLabelParam.Select("lp_name='" + OutBoxDoc.Variables.FormVariables.Item(j + 1).Name.ToLower() + "'");
-                        if (dr1.Length > 0 && dr1[0]["lp_valuetype"].ToString() == "字符串")
-                        {
-                            OutBoxDoc.Variables.FormVariables.Item(j + 1).Value = dt.Rows[0][dr1[0]["lp_sql"].ToString()].ToString();
-                        }
-                        //SQL判断多个值的时候
-                        if (dr1.Length > 0 && dr1[0]["lp_valuetype"].ToString() == "SQL值")
+                        OutBoxDoc.Variables.FormVariables.Item(j + 1).Value = dt.Rows[0][dr1[0]["lp_sql"].ToString()].ToString();
+                    }
+                    //SQL判断多个值的时候
+                    if (dr1.Length > 0 && dr1[0]["lp_valuetype"].ToString() == "SQL值")
+                    {
+                        DataTable dt1 = (DataTable)adh.ExecuteSql(dr1[0]["lp_sql"].ToString().Replace("{1}", "'" + pi_inoutno.Text + "'").Replace("{2}", pib_outboxcode2), "select");
+                        for (int i = 0; i < dt1.Rows.Count; i++)
                         {
-                            DataTable dt1 = (DataTable)adh.ExecuteSql(dr1[0]["lp_sql"].ToString().Replace("{1}", "'" + pi_inoutno.Text + "'").Replace("{2}", pib_outboxcode2), "select");
-                            for (int i = 0; i < dt1.Rows.Count; i++)
+                            for (int k = 0; k < OutBoxDoc.Variables.FormVariables.Count; k++)
                             {
-                                for (int k = 0; k < OutBoxDoc.Variables.FormVariables.Count; k++)
+                                if (i == 0 & OutBoxDoc.Variables.FormVariables.Item(k + 1).Name.ToUpper() == dr1[0]["lp_name"].ToString().ToUpper())
                                 {
-                                    if (i == 0 & OutBoxDoc.Variables.FormVariables.Item(k + 1).Name.ToUpper() == dr1[0]["lp_name"].ToString().ToUpper())
-                                    {
-                                        OutBoxDoc.Variables.FormVariables.Item(k + 1).Value = dt1.Rows[0][0].ToString();
-                                    }
-                                    //使用SN开头的参数赋值SN1,SN2,SN3等参数
-                                    if (OutBoxDoc.Variables.FormVariables.Item(k + 1).Name.ToUpper() == (dr1[0]["lp_name"].ToString() + (i + 1)).ToUpper())
-                                    {
-                                        OutBoxDoc.Variables.FormVariables.Item(k + 1).Value = dt1.Rows[i][0].ToString();
-                                    }
+                                    OutBoxDoc.Variables.FormVariables.Item(k + 1).Value = dt1.Rows[0][0].ToString();
+                                }
+                                //使用SN开头的参数赋值SN1,SN2,SN3等参数
+                                if (OutBoxDoc.Variables.FormVariables.Item(k + 1).Name.ToUpper() == (dr1[0]["lp_name"].ToString() + (i + 1)).ToUpper())
+                                {
+                                    OutBoxDoc.Variables.FormVariables.Item(k + 1).Value = dt1.Rows[i][0].ToString();
                                 }
                             }
                         }
-                        if (OutBoxDoc.Variables.FormVariables.Item(j + 1).Value == "")
-                        {
-                            dr1 = Attach.Select("lp_name='" + OutBoxDoc.Variables.FormVariables.Item(j + 1).Name.ToLower() + "'");
-                            if (dr1.Length > 0)
-                                OutBoxDoc.Variables.FormVariables.Item(j + 1).Value = dr1[0]["lp_sql"].ToString();
-                        }
                     }
-                    OutBoxDoc.Printer.SwitchTo(OutBoxPrinter.Text);
-                    OutBoxDoc.PrintDocument();
+                    if (OutBoxDoc.Variables.FormVariables.Item(j + 1).Value == "")
+                    {
+                        dr1 = Attach.Select("lp_name='" + OutBoxDoc.Variables.FormVariables.Item(j + 1).Name.ToLower() + "'");
+                        if (dr1.Length > 0)
+                            OutBoxDoc.Variables.FormVariables.Item(j + 1).Value = dr1[0]["lp_sql"].ToString();
+                    }
                 }
+                OutBoxDoc.Printer.SwitchTo(OutBoxPrinter.Text);
+                OutBoxDoc.PrintDocument();
             }
-            else MessageLog.AppendText("未能匹配到外箱标签参数,请检查标签模板\n", Color.Red);
         }
 
         private void OutBoxLabelPrint_Click(object sender, EventArgs e)
@@ -1478,17 +1475,17 @@ namespace UAS_LabelMachine
                 string outboxcode = "";
                 if (CurrentRowIndex - 1 >= 0)
                 {
-                    outboxcode = LabelInf.Rows[CurrentRowIndex - 1].Cells["pib_outboxcode2"].Value.ToString();
-                    midboxcode = LabelInf.Rows[CurrentRowIndex - 1].Cells["pib_outboxcode1"].Value.ToString();
+                    midboxcode = adh.getFieldDataByCondition("prodiobarcode", "max(pib_outboxcode1)", "pib_inoutno='" + pi_inoutno.Text + "'").ToString();
+                    outboxcode = adh.getFieldDataByCondition("prodiobarcode", "max(pib_outboxcode2)", "pib_inoutno='" + pi_inoutno.Text + "'").ToString();
                 }
                 //未超出当前范围的时候
-                int midboxcount = adh.getRowCount("prodiobarcode", "pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode1=" + (midboxcode == "" ? "0" : midboxcode));
-                int outboxcount = adh.getRowCount("prodiobarcode", "pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode2=" + (outboxcode == "" ? "0" : outboxcode));
+                int midboxcount = adh.getRowCount("prodiobarcode", "pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode1=" + (midboxcode == "" ? "1" : midboxcode));
+                int outboxcount = adh.getRowCount("prodiobarcode", "pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode2=" + (outboxcode == "" ? "1" : outboxcode));
                 midboxProcess.Text = midboxcount + "/" + MidBoxCapacity.Value;
                 outboxProcess.Text = outboxcount + "/" + OutBoxCapacity.Value;
                 //设置当前的箱号和盒号
-                Process_midboxcode.Text = midboxcode;
-                Process_outboxcode.Text = outboxcode;
+                Process_midboxcode.Text = midboxcode == "" ? "1" : midboxcode;
+                Process_outboxcode.Text = outboxcode == "" ? "1" : outboxcode;
                 //设置当前总数和已采集数量
                 CollectedCount.Text = Count + "/" + PageNum.Text.Replace("总数", "");
             }
@@ -1984,7 +1981,6 @@ namespace UAS_LabelMachine
 
         private void ButtonCollectPass_Click(object sender, EventArgs e)
         {
-            string pib_id = LabelInf.Rows[CurrentRowIndex].Cells["pib_id1"].Value.ToString();
             int pib_pdno = int.Parse(LabelInf.Rows[CurrentRowIndex].Cells["pib_pdno"].Value.ToString());
             string ErrorMsg = "";
             FrontCheckFunction("", out ErrorMsg);