Kaynağa Gözat

添加状态打印

章政 7 yıl önce
ebeveyn
işleme
164ffa3887

+ 53 - 18
UAS-出货标签管理/UAS_出货标签管理.Designer.cs

@@ -28,6 +28,7 @@
         /// </summary>
         private void InitializeComponent()
         {
+            this.components = new System.ComponentModel.Container();
             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(UAS_出货标签打印));
             this.pi_inoutno_label = new System.Windows.Forms.Label();
             this.label1 = new System.Windows.Forms.Label();
@@ -61,7 +62,7 @@
             this.CleanInputAfterCollect = new System.Windows.Forms.CheckBox();
             this.AllCollected = new System.Windows.Forms.Button();
             this.PowerSetting = new System.Windows.Forms.Button();
-            this.RefreshDBConnect = new System.Windows.Forms.Timer();
+            this.RefreshDBConnect = new System.Windows.Forms.Timer(this.components);
             this.GetGridOnly = new System.Windows.Forms.CheckBox();
             this.dataGridViewCheckBoxColumn1 = new System.Windows.Forms.DataGridViewCheckBoxColumn();
             this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
@@ -89,7 +90,7 @@
             this.dataGridViewTextBoxColumn21 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.dataGridViewTextBoxColumn22 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.dataGridViewTextBoxColumn23 = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.MidSource = new System.Windows.Forms.BindingSource();
+            this.MidSource = new System.Windows.Forms.BindingSource(this.components);
             this.ChooseAll = new System.Windows.Forms.Button();
             this.ExportFileDialog = new System.Windows.Forms.FolderBrowserDialog();
             this.AttachInfo = new System.Windows.Forms.Button();
@@ -98,6 +99,8 @@
             this.GridPrcode = new UAS_LabelMachine.CustomControl.DataGridViewWithSerialNum();
             this.pd_prodcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.groupBoxWithBorder1 = new UAS_LabelMachine.CustomControl.GroupBoxWithBorder.GroupBoxWithBorder();
+            this.SetPrintStatus_label = new System.Windows.Forms.Label();
+            this.SetPrintStatus = new System.Windows.Forms.Button();
             this.ExportData = new System.Windows.Forms.Button();
             this.label18 = new System.Windows.Forms.Label();
             this.MidBoxEnd = new UAS_LabelMachine.CustomControl.EnterTextBox();
@@ -821,6 +824,8 @@
             // 
             // groupBoxWithBorder1
             // 
+            this.groupBoxWithBorder1.Controls.Add(this.SetPrintStatus_label);
+            this.groupBoxWithBorder1.Controls.Add(this.SetPrintStatus);
             this.groupBoxWithBorder1.Controls.Add(this.ExportData);
             this.groupBoxWithBorder1.Controls.Add(this.label18);
             this.groupBoxWithBorder1.Controls.Add(this.MidBoxEnd);
@@ -839,11 +844,35 @@
             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(11, 202);
+            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 = "可打印";
+            // 
+            // SetPrintStatus
+            // 
+            this.SetPrintStatus.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+            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(78, 200);
+            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);
+            this.SetPrintStatus.TabIndex = 92;
+            this.SetPrintStatus.Text = "打印状态";
+            this.SetPrintStatus.UseVisualStyleBackColor = true;
+            this.SetPrintStatus.Click += new System.EventHandler(this.SetPrintStatus_Click);
+            // 
             // ExportData
             // 
             this.ExportData.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
             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(76, 200);
+            this.ExportData.Location = new System.Drawing.Point(78, 165);
             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);
@@ -856,7 +885,7 @@
             // 
             this.label18.AutoSize = true;
             this.label18.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label18.Location = new System.Drawing.Point(68, 147);
+            this.label18.Location = new System.Drawing.Point(69, 128);
             this.label18.Name = "label18";
             this.label18.Size = new System.Drawing.Size(13, 17);
             this.label18.TabIndex = 90;
@@ -865,7 +894,7 @@
             // MidBoxEnd
             // 
             this.MidBoxEnd.ID = null;
-            this.MidBoxEnd.Location = new System.Drawing.Point(88, 148);
+            this.MidBoxEnd.Location = new System.Drawing.Point(88, 127);
             this.MidBoxEnd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.MidBoxEnd.Name = "MidBoxEnd";
             this.MidBoxEnd.Size = new System.Drawing.Size(50, 21);
@@ -877,7 +906,7 @@
             // MidBoxBegin
             // 
             this.MidBoxBegin.ID = null;
-            this.MidBoxBegin.Location = new System.Drawing.Point(13, 148);
+            this.MidBoxBegin.Location = new System.Drawing.Point(13, 127);
             this.MidBoxBegin.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.MidBoxBegin.Name = "MidBoxBegin";
             this.MidBoxBegin.Size = new System.Drawing.Size(50, 21);
@@ -890,7 +919,7 @@
             // 
             this.label16.AutoSize = true;
             this.label16.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label16.Location = new System.Drawing.Point(67, 74);
+            this.label16.Location = new System.Drawing.Point(68, 55);
             this.label16.Name = "label16";
             this.label16.Size = new System.Drawing.Size(13, 17);
             this.label16.TabIndex = 87;
@@ -899,7 +928,7 @@
             // SingleBoxEnd
             // 
             this.SingleBoxEnd.ID = null;
-            this.SingleBoxEnd.Location = new System.Drawing.Point(87, 75);
+            this.SingleBoxEnd.Location = new System.Drawing.Point(87, 54);
             this.SingleBoxEnd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.SingleBoxEnd.Name = "SingleBoxEnd";
             this.SingleBoxEnd.Size = new System.Drawing.Size(50, 21);
@@ -911,7 +940,7 @@
             // SingleBoxBegin
             // 
             this.SingleBoxBegin.ID = null;
-            this.SingleBoxBegin.Location = new System.Drawing.Point(12, 75);
+            this.SingleBoxBegin.Location = new System.Drawing.Point(12, 54);
             this.SingleBoxBegin.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.SingleBoxBegin.Name = "SingleBoxBegin";
             this.SingleBoxBegin.Size = new System.Drawing.Size(50, 21);
@@ -924,7 +953,7 @@
             // 
             this.label12.AutoSize = true;
             this.label12.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label12.Location = new System.Drawing.Point(12, 111);
+            this.label12.Location = new System.Drawing.Point(12, 94);
             this.label12.Name = "label12";
             this.label12.Size = new System.Drawing.Size(56, 17);
             this.label12.TabIndex = 77;
@@ -934,7 +963,7 @@
             // 
             this.label7.AutoSize = true;
             this.label7.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label7.Location = new System.Drawing.Point(12, 38);
+            this.label7.Location = new System.Drawing.Point(12, 21);
             this.label7.Name = "label7";
             this.label7.Size = new System.Drawing.Size(56, 17);
             this.label7.TabIndex = 76;
@@ -1477,6 +1506,8 @@
             // SingleLabelAutoPrint
             // 
             this.SingleLabelAutoPrint.AutoSize = true;
+            this.SingleLabelAutoPrint.Checked = true;
+            this.SingleLabelAutoPrint.CheckState = System.Windows.Forms.CheckState.Checked;
             this.SingleLabelAutoPrint.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.SingleLabelAutoPrint.Location = new System.Drawing.Point(8, 107);
             this.SingleLabelAutoPrint.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
@@ -1596,6 +1627,8 @@
             // 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(9, 106);
             this.MidLabelAutoPrint.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
@@ -1879,26 +1912,26 @@
             ((System.ComponentModel.ISupportInitialize)(this.Si_ItemDGV)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.MidSource)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.GridPrcode)).EndInit();
-            this.groupBoxWithBorder1.ResumeLayout(false);
+            this.groupBoxWithBorder1.ResumeLayout(true);
             this.groupBoxWithBorder1.PerformLayout();
-            this.CollectionProcess.ResumeLayout(false);
+            this.CollectionProcess.ResumeLayout(true);
             this.CollectionProcess.PerformLayout();
             ((System.ComponentModel.ISupportInitialize)(this.LabelInf)).EndInit();
-            this.SingleLabel.ResumeLayout(false);
+            this.SingleLabel.ResumeLayout(true);
             this.SingleLabel.PerformLayout();
-            this.MidLabel.ResumeLayout(false);
+            this.MidLabel.ResumeLayout(true);
             this.MidLabel.PerformLayout();
             ((System.ComponentModel.ISupportInitialize)(this.MidBoxCapacity)).EndInit();
-            this.OutBoxLabel.ResumeLayout(false);
+            this.OutBoxLabel.ResumeLayout(true);
             this.OutBoxLabel.PerformLayout();
             ((System.ComponentModel.ISupportInitialize)(this.OutboxCapacity)).EndInit();
-            this.ResumeLayout(false);
+            this.ResumeLayout(true);
             this.PerformLayout();
 
         }
 
         #endregion
-        private UAS_LabelMachine.CustomControl.GroupBoxWithBorder.GroupBoxWithBorder OutBoxLabel;
+        private CustomControl.GroupBoxWithBorder.GroupBoxWithBorder OutBoxLabel;
         private CustomControl.EnterTextBox OutBoxNum;
         private System.Windows.Forms.Label label10;
         private CustomControl.EnterTextBox WeightNet;
@@ -2054,5 +2087,7 @@
         private System.Windows.Forms.Label label19;
         private CustomControl.DataGridViewWithSerialNum GridPrcode;
         private System.Windows.Forms.DataGridViewTextBoxColumn pd_prodcode;
+        private System.Windows.Forms.Button SetPrintStatus;
+        private System.Windows.Forms.Label SetPrintStatus_label;
     }
 }

+ 79 - 198
UAS-出货标签管理/UAS_出货标签管理.cs

@@ -311,17 +311,6 @@ namespace UAS_LabelMachine
             }
         }
 
-        private void SaveGridData()
-        {
-            DataTable savedt = (LabelInf.DataSource as DataTable);
-            if (LabelInf.DataSource != null && savedt.GetChanges() != null)
-            {
-                dh.UpDateTableByCondition(savedt, "ProdioBarCode", "pib_id");
-                LoadGridData(new object(), new EventArgs());
-                MessageBox.Show("保存成功!");
-            }
-        }
-
         //放大镜选择后出发的事件
         private void sg_code_UserControlTextChanged(object sender, EventArgs e)
         {
@@ -670,209 +659,75 @@ namespace UAS_LabelMachine
             }
         }
 
-        private void Run1()
-        {
-            string[] arg = SingleBoxArgument.ToArray();
-            for (int j = 0; j < 3; j++)
-            {
-                //将维护的模板参数和模板本身的参数名称进行比对
-                StringBuilder ParamLog = new StringBuilder();
-                for (int k = 0; k < SingleLabelParam.Rows.Count; k++)
-                {
-                    //名称相等的时候,取SQL进行值的查询
-                    if (SingleParam[j] == SingleLabelParam.Rows[k]["lp_name"].ToString().ToLower())
-                    {
-                        string pib_id = LabelInf.Rows[CurrentRowIndex].Cells["pib_id1"].Value.ToString();
-                        DataRow[] dr = SingleBoxCacheData.Select("pib_id=" + pib_id);
-                        if (arg.Contains(SingleParam[j]))
-                            SingleDoc.Variables.FreeVariables.Item(SingleParam[j]).Value = dr[0][SingleDoc.Variables.FreeVariables.Item(j + 1).Name].ToString();
-                        if (SingleParam[j].Contains("datecode1"))
-                        {
-                            if (LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode1"].Value != null)
-                                SingleDoc.Variables.FreeVariables.Item(SingleParam[j]).Value = LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode1"].Value.ToString();
-                        }
-                        else if (SingleParam[j].Contains("lotno"))
-                        {
-                            if (LabelInf.Rows[CurrentRowIndex].Cells["pib_lotno"].Value != null)
-                                SingleDoc.Variables.FreeVariables.Item(SingleParam[j]).Value = LabelInf.Rows[CurrentRowIndex].Cells["pib_lotno"].Value.ToString();
-                        }
-                        else if (SingleParam[j].Contains("datecode"))
-                        {
-                            if (LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode"].Value != null)
-                                SingleDoc.Variables.FreeVariables.Item(SingleParam[j]).Value = LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode"].Value.ToString();
-                        }
-                        else if (SingleParam[j].Contains("产地"))
-                        {
-                            if (LabelInf.Rows[CurrentRowIndex].Cells["pib_madein"].Value != null)
-                                SingleDoc.Variables.FreeVariables.Item(SingleParam[j]).Value = LabelInf.Rows[CurrentRowIndex].Cells["pib_madein"].Value.ToString();
-                        }
-                        else if (SingleParam[j].Contains("pib_cusbarcode"))
-                        {
-                            if (LabelInf.Rows[CurrentRowIndex].Cells["pib_cusbarcode"].Value != null)
-                                SingleDoc.Variables.FreeVariables.Item(SingleParam[j]).Value = LabelInf.Rows[CurrentRowIndex].Cells["pib_cusbarcode"].Value.ToString();
-                        }
-                        if (SingleDoc.Variables.FreeVariables.Item(SingleParam[j]).Value == "")
-                        {
-                            try
-                            {
-                                SingleDoc.Variables.FreeVariables.Item(SingleParam[j]).Value = SingleLabelParam.Select("lp_name='" + SingleDoc.Variables.FreeVariables.Item(j + 1).Name + "'")[0]["lp_sql"].ToString();
-                            }
-                            catch (Exception)
-                            {
-
-                            }
-                        }
-                        ParamLog.AppendLine("pib_id:" + LabelInf.Rows[CurrentRowIndex].Cells["pib_id1"].Value.ToString() + ",SingleDoc打印参数【" + SingleParam[j] + "】赋值," + "取到值" + SingleDoc.Variables.FreeVariables.Item(SingleParam[j]).Value);
-                    }
-                    else if (SingleDoc.Variables.FreeVariables.Item(j + 1).Name == "DateCode1")
-                    {
-                        if (LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode1"].Value != null)
-                            SingleDoc.Variables.FreeVariables.Item(SingleParam[j]).Value = LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode1"].Value.ToString();
-                    }
-                }
-                LogManager.DoLog(ParamLog.ToString());
-            }
-        }
-
-        private void Run2()
+        private void AutoPrintSingleLabel(string la_id, string LabelUrl)
         {
+            //用标签本身的变量作为最外层的循环条件去匹配;
             string[] arg = SingleBoxArgument.ToArray();
-            for (int j = 0; j <6; j++)
+            StringBuilder ParamLog = new StringBuilder();
+            for (int j = 0; j < SingleDoc.Variables.FreeVariables.Count; j++)
             {
                 //将维护的模板参数和模板本身的参数名称进行比对
-                StringBuilder ParamLog = new StringBuilder();
                 for (int k = 0; k < SingleLabelParam.Rows.Count; k++)
                 {
                     //名称相等的时候,取SQL进行值的查询
-                    if (SingleParam[j] == SingleLabelParam.Rows[k]["lp_name"].ToString().ToLower())
+                    if (SingleDoc.Variables.FreeVariables.Item(j + 1).Name == SingleLabelParam.Rows[k]["lp_name"].ToString().ToLower())
                     {
                         string pib_id = LabelInf.Rows[CurrentRowIndex].Cells["pib_id1"].Value.ToString();
                         DataRow[] dr = SingleBoxCacheData.Select("pib_id=" + pib_id);
-                        if (arg.Contains(SingleParam[j]))
-                            SingleDoc.Variables.FreeVariables.Item(SingleParam[j]).Value = dr[0][SingleDoc.Variables.FreeVariables.Item(j + 1).Name].ToString();
-                        if (SingleParam[j].Contains("datecode1"))
+                        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(SingleParam[j]).Value = LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode1"].Value.ToString();
+                                SingleDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode1"].Value.ToString();
                         }
-                        else if (SingleParam[j].Contains("lotno"))
+                        else if (SingleDoc.Variables.FreeVariables.Item(j + 1).Name.Contains("lotno"))
                         {
                             if (LabelInf.Rows[CurrentRowIndex].Cells["pib_lotno"].Value != null)
-                                SingleDoc.Variables.FreeVariables.Item(SingleParam[j]).Value = LabelInf.Rows[CurrentRowIndex].Cells["pib_lotno"].Value.ToString();
+                                SingleDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[CurrentRowIndex].Cells["pib_lotno"].Value.ToString();
                         }
-                        else if (SingleParam[j].Contains("datecode"))
+                        else if (SingleDoc.Variables.FreeVariables.Item(j + 1).Name.Contains("datecode"))
                         {
                             if (LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode"].Value != null)
-                                SingleDoc.Variables.FreeVariables.Item(SingleParam[j]).Value = LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode"].Value.ToString();
+                                SingleDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode"].Value.ToString();
                         }
-                        else if (SingleParam[j].Contains("产地"))
+                        else if (SingleDoc.Variables.FreeVariables.Item(j + 1).Name.Contains("产地"))
                         {
                             if (LabelInf.Rows[CurrentRowIndex].Cells["pib_madein"].Value != null)
-                                SingleDoc.Variables.FreeVariables.Item(SingleParam[j]).Value = LabelInf.Rows[CurrentRowIndex].Cells["pib_madein"].Value.ToString();
+                                SingleDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[CurrentRowIndex].Cells["pib_madein"].Value.ToString();
                         }
-                        else if (SingleParam[j].Contains("pib_cusbarcode"))
+                        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(SingleParam[j]).Value = LabelInf.Rows[CurrentRowIndex].Cells["pib_cusbarcode"].Value.ToString();
+                                SingleDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[CurrentRowIndex].Cells["pib_cusbarcode"].Value.ToString();
                         }
-                        if (SingleDoc.Variables.FreeVariables.Item(SingleParam[j]).Value == "")
+                        if (SingleDoc.Variables.FreeVariables.Item(j + 1).Value == "")
                         {
                             try
                             {
-                                SingleDoc.Variables.FreeVariables.Item(SingleParam[j]).Value = SingleLabelParam.Select("lp_name='" + SingleDoc.Variables.FreeVariables.Item(j + 1).Name + "'")[0]["lp_sql"].ToString();
+                                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[CurrentRowIndex].Cells["pib_id1"].Value.ToString() + ",SingleDoc打印参数【" + SingleParam[j] + "】赋值," + "取到值" + SingleDoc.Variables.FreeVariables.Item(SingleParam[j]).Value);
+                        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(SingleParam[j]).Value = LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode1"].Value.ToString();
+                            SingleDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode1"].Value.ToString();
                     }
                 }
-                LogManager.DoLog(ParamLog.ToString());
             }
-        }
-
-        private void Run3()
-        {
-            string[] arg = SingleBoxArgument.ToArray();
-            for (int j = 0; j < 10; j++)
+            LogManager.DoLog(ParamLog.ToString());
+            //保存参数打印
+            if (EnablePrint)
             {
-                //将维护的模板参数和模板本身的参数名称进行比对
-                StringBuilder ParamLog = new StringBuilder();
-                for (int k = 0; k < SingleLabelParam.Rows.Count; k++)
-                {
-                    //名称相等的时候,取SQL进行值的查询
-                    if (SingleParam[j] == SingleLabelParam.Rows[k]["lp_name"].ToString().ToLower())
-                    {
-                        string pib_id = LabelInf.Rows[CurrentRowIndex].Cells["pib_id1"].Value.ToString();
-                        DataRow[] dr = SingleBoxCacheData.Select("pib_id=" + pib_id);
-                        if (arg.Contains(SingleParam[j]))
-                            SingleDoc.Variables.FreeVariables.Item(SingleParam[j]).Value = dr[0][SingleDoc.Variables.FreeVariables.Item(j + 1).Name].ToString();
-                        if (SingleParam[j].Contains("datecode1"))
-                        {
-                            if (LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode1"].Value != null)
-                                SingleDoc.Variables.FreeVariables.Item(SingleParam[j]).Value = LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode1"].Value.ToString();
-                        }
-                        else if (SingleParam[j].Contains("lotno"))
-                        {
-                            if (LabelInf.Rows[CurrentRowIndex].Cells["pib_lotno"].Value != null)
-                                SingleDoc.Variables.FreeVariables.Item(SingleParam[j]).Value = LabelInf.Rows[CurrentRowIndex].Cells["pib_lotno"].Value.ToString();
-                        }
-                        else if (SingleParam[j].Contains("datecode"))
-                        {
-                            if (LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode"].Value != null)
-                                SingleDoc.Variables.FreeVariables.Item(SingleParam[j]).Value = LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode"].Value.ToString();
-                        }
-                        else if (SingleParam[j].Contains("产地"))
-                        {
-                            if (LabelInf.Rows[CurrentRowIndex].Cells["pib_madein"].Value != null)
-                                SingleDoc.Variables.FreeVariables.Item(SingleParam[j]).Value = LabelInf.Rows[CurrentRowIndex].Cells["pib_madein"].Value.ToString();
-                        }
-                        else if (SingleParam[j].Contains("pib_cusbarcode"))
-                        {
-                            if (LabelInf.Rows[CurrentRowIndex].Cells["pib_cusbarcode"].Value != null)
-                                SingleDoc.Variables.FreeVariables.Item(SingleParam[j]).Value = LabelInf.Rows[CurrentRowIndex].Cells["pib_cusbarcode"].Value.ToString();
-                        }
-                        if (SingleDoc.Variables.FreeVariables.Item(SingleParam[j]).Value == "")
-                        {
-                            try
-                            {
-                                SingleDoc.Variables.FreeVariables.Item(SingleParam[j]).Value = SingleLabelParam.Select("lp_name='" + SingleDoc.Variables.FreeVariables.Item(j + 1).Name + "'")[0]["lp_sql"].ToString();
-                            }
-                            catch (Exception)
-                            {
-
-                            }
-                        }
-                        ParamLog.AppendLine("pib_id:" + LabelInf.Rows[CurrentRowIndex].Cells["pib_id1"].Value.ToString() + ",SingleDoc打印参数【" + SingleParam[j] + "】赋值," + "取到值" + SingleDoc.Variables.FreeVariables.Item(SingleParam[j]).Value);
-                    }
-                    else if (SingleDoc.Variables.FreeVariables.Item(j + 1).Name == "DateCode1")
-                    {
-                        if (LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode1"].Value != null)
-                            SingleDoc.Variables.FreeVariables.Item(SingleParam[j]).Value = LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode1"].Value.ToString();
-                    }
-                }
-                LogManager.DoLog(ParamLog.ToString());
+                SingleDoc.Printer.SwitchTo(SingleLabelPrinter.Text);
+                SingleDoc.PrintDocument();
             }
-        }
-
-        private void AutoPrintSingleLabel(string la_id, string LabelUrl)
-        {
-            //用标签本身的变量作为最外层的循环条件去匹配;
-            Console.WriteLine(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"));
-            Parallel.Invoke(Run1, Run2);
-            Console.WriteLine(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"));
-            //保存参数打印
-            SingleDoc.Printer.SwitchTo(SingleLabelPrinter.Text);
-            SingleDoc.PrintDocument();
-            Console.WriteLine(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"));
-            LogManager.DoLog("执行打印单盘,pib_id:" + LabelInf.Rows[CurrentRowIndex].Cells["pib_id1"].Value.ToString() + ",标签地址" + LabelUrl);
             LabelInf.Rows[CurrentRowIndex].Cells["pib_ifprint"].Value = true;
         }
 
@@ -1129,7 +984,7 @@ namespace UAS_LabelMachine
                             else
                                 str = str.Substring(int.Parse(SiItem[item]["si_index"]));
                         }
-                        catch (Exception e) { LogManager.DoLog(e.Message); }
+                        catch (Exception e) { LogManager.DoLog(e.StackTrace); }
                     }
                     break;
                 case "索引字符":
@@ -1145,7 +1000,7 @@ namespace UAS_LabelMachine
                                 str = str.Substring(str.IndexOf(SiItem[item]["si_indexstring"]) + 1);
                         }
                     }
-                    catch (Exception e) { LogManager.DoLog(e.Message); }
+                    catch (Exception e) { LogManager.DoLog(e.StackTrace); }
                     break;
                 case "二次解析":
                     if (SiItem[item]["si_indexstring"] != "")
@@ -1291,8 +1146,7 @@ namespace UAS_LabelMachine
             }
             //缓存外箱参数
             ComBoxClickChangeLabelDoc = true;
-            GetSingleBoxData();
-            GetMidBoxData();
+            Parallel.Invoke(GetSingleBoxData, GetMidBoxData);
         }
 
         /// <summary>
@@ -1325,6 +1179,8 @@ namespace UAS_LabelMachine
                     SingleBoxArgument.Clear();
                     SingleBoxCacheData.Clear();
                     BaseUtil.CleanDataTable(SingleBoxCacheData);
+                    MidIDAndOutboxcode.Clear();
+                    SingleID.Clear();
                     //刷新采集进度
                     RefreshProcessData();
                     //设置当前的最大箱号
@@ -1388,18 +1244,19 @@ namespace UAS_LabelMachine
                 Dictionary<string, bool> outboxcode1 = new Dictionary<string, bool>();
                 //判断所有盒号为该盒的是否勾选已采集
                 outboxcode1.Add(LabelInf.Rows[0].Cells["pib_outboxcode1"].Value.ToString(), true);
-                //for (int i = 0; i < LabelInf.Rows.Count; i++)
-                //{
-                //    SingleID.Add(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString());
-                //    if (LabelInf.Rows[i].Cells["Choose"].FormattedValue.ToString() == "True" && LabelInf.Rows[i].Cells["pib_ifpick"].FormattedValue.ToString() == "True" && LabelInf.Rows[i].Cells["pib_ifprint"].FormattedValue.ToString() != "True")
-                //    {
-                //        //如果不存在中盒号则进行添加
-                //        if (!MidIDAndOutboxcode.ContainsValue(LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString()))
-                //        {
-                //            MidIDAndOutboxcode.Add(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString(), LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString());
-                //        }
-                //    }
-                //}
+                for (int i = 0; i < LabelInf.Rows.Count; i++)
+                {
+                    if (!SingleID.Contains(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString()))
+                        SingleID.Add(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString());
+                    if (LabelInf.Rows[i].Cells["Choose"].FormattedValue.ToString() == "True" && LabelInf.Rows[i].Cells["pib_ifpick"].FormattedValue.ToString() == "True" && LabelInf.Rows[i].Cells["pib_ifprint"].FormattedValue.ToString() != "True")
+                    {
+                        //如果不存在中盒号则进行添加
+                        if (!MidIDAndOutboxcode.ContainsValue(LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString()))
+                        {
+                            MidIDAndOutboxcode.Add(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString(), LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString());
+                        }
+                    }
+                }
                 if (SingleID.ToArray().Length == 0)
                 {
                     MessageBox.Show("选择的行未勾选采集或者已打印");
@@ -1488,8 +1345,10 @@ namespace UAS_LabelMachine
                             }
                             LogManager.DoLog(ParamLog.ToString());
                             //保存参数打印
-                            SingleDoc.Printer.SwitchTo(SingleLabelPrinter.Text);
-                            SingleDoc.PrintDocument();
+                            if (EnablePrint) {
+                                SingleDoc.Printer.SwitchTo(SingleLabelPrinter.Text);
+                                SingleDoc.PrintDocument();
+                            }
                             if (MidLabelAutoPrint.Checked)
                             {
                                 //判断当前行的盒号和下一行不相等或者已经是最后一行了
@@ -1536,12 +1395,11 @@ namespace UAS_LabelMachine
                 return;
             for (int i = 0; i < LabelInf.Rows.Count; i++)
             {
-                SingleID.Add(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString());
+                if (!SingleID.Contains(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString()))
+                    SingleID.Add(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString());
                 //如果不存在中盒号则进行添加
                 if (!MidIDAndOutboxcode.ContainsValue(LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString()))
-                {
                     MidIDAndOutboxcode.Add(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString(), LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString());
-                }
             }
             //id数组
             string[] pib_id_arr = SingleID.ToArray();
@@ -1986,8 +1844,10 @@ namespace UAS_LabelMachine
                 }
             }
             //保存参数打印
-            MidDoc.Printer.SwitchTo(MidLabelPrinter.Text);
-            MidDoc.PrintDocument();
+            if (EnablePrint) {
+                MidDoc.Printer.SwitchTo(MidLabelPrinter.Text);
+                MidDoc.PrintDocument();
+            }
         }
 
         private void MidBoxCodePrint(string la_id, int rowindex, int[] midindex)
@@ -2068,8 +1928,10 @@ namespace UAS_LabelMachine
                 }
             }
             //保存参数打印
-            MidDoc.Printer.SwitchTo(MidLabelPrinter.Text);
-            MidDoc.PrintDocument();
+            if (EnablePrint) {
+                MidDoc.Printer.SwitchTo(MidLabelPrinter.Text);
+                MidDoc.PrintDocument();
+            }
         }
 
         /// <summary>
@@ -2160,8 +2022,10 @@ namespace UAS_LabelMachine
                     }
                 }
                 //保存参数打印
-                OutBoxDoc.Printer.SwitchTo(OutBoxPrinter.Text);
-                OutBoxDoc.PrintDocument();
+                if (EnablePrint) {
+                    OutBoxDoc.Printer.SwitchTo(OutBoxPrinter.Text);
+                    OutBoxDoc.PrintDocument();
+                }
                 LogManager.DoLog("执行打印外箱,pib_id:" + LabelInf.Rows[rowindex].Cells["pib_id1"].Value.ToString());
             }
             catch (Exception ex) { MessageBox.Show(ex.Message); }
@@ -2872,5 +2736,22 @@ namespace UAS_LabelMachine
                 }
             }
         }
+
+        private bool EnablePrint = true;
+
+        private void SetPrintStatus_Click(object sender, EventArgs e)
+        {
+            EnablePrint = !EnablePrint;
+            if (EnablePrint)
+            {
+                SetPrintStatus_label.ForeColor = Color.Green;
+                SetPrintStatus_label.Text = "可打印";
+            }
+            else
+            {
+                SetPrintStatus_label.ForeColor = Color.Red;
+                SetPrintStatus_label.Text = "暂停打印";
+            }
+        }
     }
 }