Browse Source

提交修改代码

章政 7 years ago
parent
commit
407d9c704b

+ 11 - 1
UAS-出货标签管理(泽天)/Properties/Resources.Designer.cs

@@ -191,7 +191,7 @@ namespace UAS_LabelMachine.Properties {
         }
         
         /// <summary>
-        ///   查找类似于 (Icon) 的 System.Drawing.Icon 类型的本地化资源。
+        ///   查找类似于 (图标) 的 System.Drawing.Icon 类型的本地化资源。
         /// </summary>
         internal static System.Drawing.Icon matte_white_square_icon_business_tool_hammer_96px_571061_easyicon_net {
             get {
@@ -220,6 +220,16 @@ namespace UAS_LabelMachine.Properties {
             }
         }
         
+        /// <summary>
+        ///   查找 System.Drawing.Bitmap 类型的本地化资源。
+        /// </summary>
+        internal static System.Drawing.Bitmap Status {
+            get {
+                object obj = ResourceManager.GetObject("Status", resourceCulture);
+                return ((System.Drawing.Bitmap)(obj));
+            }
+        }
+        
         /// <summary>
         ///   查找 System.Drawing.Bitmap 类型的本地化资源。
         /// </summary>

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

@@ -181,4 +181,7 @@
   <data name="write_15_893687707641px_1181413_easyicon_net" type="System.Resources.ResXFileRef, System.Windows.Forms">
     <value>..\Resources\write_15.893687707641px_1181413_easyicon.net.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
   </data>
+  <data name="Status" type="System.Resources.ResXFileRef, System.Windows.Forms">
+    <value>..\Resources\Status.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
+  </data>
 </root>

BIN
UAS-出货标签管理(泽天)/Resources/Status.png


+ 1 - 0
UAS-出货标签管理(泽天)/UAS-出货标签管理(泽天).csproj

@@ -745,6 +745,7 @@
       <Generator>WCF Proxy Generator</Generator>
       <LastGenOutput>Reference.cs</LastGenOutput>
     </None>
+    <None Include="Resources\Status.png" />
     <Content Include="tool\Analysis.dll" />
     <Content Include="tool\DataHelper.dll" />
     <Content Include="tool\NPOI.dll" />

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

@@ -31,7 +31,6 @@
             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.label22 = new System.Windows.Forms.Label();
             this.label24 = new System.Windows.Forms.Label();
             this.LabelMainTain = new System.Windows.Forms.Button();
             this.CleanDetail = new System.Windows.Forms.Button();
@@ -73,7 +72,6 @@
             this.AttachInfo = new System.Windows.Forms.Button();
             this.pi_date = new System.Windows.Forms.Label();
             this.label19 = new System.Windows.Forms.Label();
-            this.SetPrintStatus = new System.Windows.Forms.Button();
             this.ExportData = new System.Windows.Forms.Button();
             this.PrintFooter = new System.Windows.Forms.Button();
             this.SetPrintStatus_label = new System.Windows.Forms.Label();
@@ -108,7 +106,6 @@
             this.Installed = new System.Windows.Forms.Label();
             this.Process = new System.Windows.Forms.Label();
             this.Input = new UAS_LabelMachine.CustomControl.EnterTextBox();
-            this.griddetno = new UAS_LabelMachine.CustomControl.EnterTextBox();
             this.LabelInf = new UAS_LabelMachine.CustomControl.DataGridViewWithSerialNum();
             this.Choose = new System.Windows.Forms.DataGridViewCheckBoxColumn();
             this.pib_ifprint = new System.Windows.Forms.DataGridViewCheckBoxColumn();
@@ -153,6 +150,7 @@
             this.OutBoxLabelPrint = new System.Windows.Forms.Button();
             this.OutBoxLabelAutoPrint = new System.Windows.Forms.CheckBox();
             this.OutBoxCombox = new System.Windows.Forms.ComboBox();
+            this.pictureBox1 = new System.Windows.Forms.PictureBox();
             ((System.ComponentModel.ISupportInitialize)(this.MidSource)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.GridPrcode)).BeginInit();
             this.groupBoxWithBorder1.SuspendLayout();
@@ -162,6 +160,7 @@
             this.MidLabel.SuspendLayout();
             this.OutBoxLabel.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.OutboxCapacity)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
             this.SuspendLayout();
             // 
             // pi_inoutno_label
@@ -174,21 +173,11 @@
             this.pi_inoutno_label.TabIndex = 3;
             this.pi_inoutno_label.Text = "出货单号";
             // 
-            // label22
-            // 
-            this.label22.AutoSize = true;
-            this.label22.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label22.Location = new System.Drawing.Point(5, 68);
-            this.label22.Name = "label22";
-            this.label22.Size = new System.Drawing.Size(65, 20);
-            this.label22.TabIndex = 34;
-            this.label22.Text = "明细序号";
-            // 
             // label24
             // 
             this.label24.AutoSize = true;
             this.label24.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label24.Location = new System.Drawing.Point(9, 105);
+            this.label24.Location = new System.Drawing.Point(9, 69);
             this.label24.Name = "label24";
             this.label24.Size = new System.Drawing.Size(51, 20);
             this.label24.TabIndex = 55;
@@ -519,18 +508,6 @@
             this.label19.TabIndex = 87;
             this.label19.Text = "物料资料";
             // 
-            // SetPrintStatus
-            // 
-            this.SetPrintStatus.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.SetPrintStatus.Location = new System.Drawing.Point(320, 80);
-            this.SetPrintStatus.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
-            this.SetPrintStatus.Name = "SetPrintStatus";
-            this.SetPrintStatus.Size = new System.Drawing.Size(68, 26);
-            this.SetPrintStatus.TabIndex = 92;
-            this.SetPrintStatus.Text = "打印状态";
-            this.SetPrintStatus.UseVisualStyleBackColor = true;
-            this.SetPrintStatus.Click += new System.EventHandler(this.SetPrintStatus_Click);
-            // 
             // ExportData
             // 
             this.ExportData.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
@@ -559,7 +536,7 @@
             this.SetPrintStatus_label.AutoSize = true;
             this.SetPrintStatus_label.Font = new System.Drawing.Font("微软雅黑", 12F);
             this.SetPrintStatus_label.ForeColor = System.Drawing.Color.Green;
-            this.SetPrintStatus_label.Location = new System.Drawing.Point(256, 82);
+            this.SetPrintStatus_label.Location = new System.Drawing.Point(242, 165);
             this.SetPrintStatus_label.Name = "SetPrintStatus_label";
             this.SetPrintStatus_label.Size = new System.Drawing.Size(58, 21);
             this.SetPrintStatus_label.TabIndex = 76;
@@ -893,30 +870,17 @@
             // Input
             // 
             this.Input.ID = null;
-            this.Input.Location = new System.Drawing.Point(76, 105);
+            this.Input.Location = new System.Drawing.Point(76, 72);
             this.Input.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.Input.Multiline = true;
             this.Input.Name = "Input";
-            this.Input.Size = new System.Drawing.Size(150, 61);
+            this.Input.Size = new System.Drawing.Size(150, 68);
             this.Input.Str = null;
             this.Input.Str1 = null;
             this.Input.Str2 = null;
             this.Input.TabIndex = 54;
             this.Input.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Input_KeyDown);
             // 
-            // griddetno
-            // 
-            this.griddetno.ID = null;
-            this.griddetno.Location = new System.Drawing.Point(76, 68);
-            this.griddetno.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
-            this.griddetno.Name = "griddetno";
-            this.griddetno.Size = new System.Drawing.Size(102, 21);
-            this.griddetno.Str = null;
-            this.griddetno.Str1 = null;
-            this.griddetno.Str2 = null;
-            this.griddetno.TabIndex = 50;
-            this.griddetno.KeyDown += new System.Windows.Forms.KeyEventHandler(this.griddetno_KeyDown);
-            // 
             // LabelInf
             // 
             this.LabelInf.AllowUserToAddRows = false;
@@ -1164,10 +1128,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(5, 95);
+            this.SingleLabelAutoPrint.Location = new System.Drawing.Point(8, 95);
             this.SingleLabelAutoPrint.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.SingleLabelAutoPrint.Name = "SingleLabelAutoPrint";
             this.SingleLabelAutoPrint.Size = new System.Drawing.Size(75, 21);
@@ -1398,15 +1360,24 @@
             this.OutBoxCombox.TabIndex = 78;
             this.OutBoxCombox.SelectedIndexChanged += new System.EventHandler(this.OutBoxCombox_SelectedIndexChanged);
             // 
+            // pictureBox1
+            // 
+            this.pictureBox1.Image = global::UAS_LabelMachine.Properties.Resources.Status;
+            this.pictureBox1.Location = new System.Drawing.Point(320, 114);
+            this.pictureBox1.Name = "pictureBox1";
+            this.pictureBox1.Size = new System.Drawing.Size(136, 74);
+            this.pictureBox1.TabIndex = 93;
+            this.pictureBox1.TabStop = false;
+            // 
             // UAS_出货标签打印
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(229)))), ((int)(((byte)(233)))), ((int)(((byte)(206)))));
             this.ClientSize = new System.Drawing.Size(1257, 711);
+            this.Controls.Add(this.pictureBox1);
             this.Controls.Add(this.SetPrintStatus_label);
             this.Controls.Add(this.PrintFooter);
-            this.Controls.Add(this.SetPrintStatus);
             this.Controls.Add(this.GridPrcode);
             this.Controls.Add(this.ExportData);
             this.Controls.Add(this.label19);
@@ -1424,8 +1395,6 @@
             this.Controls.Add(this.LabelMainTain);
             this.Controls.Add(this.label24);
             this.Controls.Add(this.Input);
-            this.Controls.Add(this.griddetno);
-            this.Controls.Add(this.label22);
             this.Controls.Add(this.LabelInf);
             this.Controls.Add(this.pi_inoutno_label);
             this.Controls.Add(this.pi_inoutno);
@@ -1455,6 +1424,7 @@
             this.OutBoxLabel.ResumeLayout(false);
             this.OutBoxLabel.PerformLayout();
             ((System.ComponentModel.ISupportInitialize)(this.OutboxCapacity)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
             this.ResumeLayout(false);
             this.PerformLayout();
 
@@ -1503,8 +1473,6 @@
         private CustomControl.EnterTextBox pi_inoutno;
         private System.Windows.Forms.Label pi_inoutno_label;
         private CustomControl.DataGridViewWithSerialNum LabelInf;
-        private System.Windows.Forms.Label label22;
-        private CustomControl.EnterTextBox griddetno;
         private CustomControl.EnterTextBox Input;
         private System.Windows.Forms.Label label24;
         private System.Windows.Forms.Button LabelMainTain;
@@ -1553,7 +1521,6 @@
         private System.Windows.Forms.Label pi_date;
         private System.Windows.Forms.Label label19;
         private CustomControl.DataGridViewWithSerialNum GridPrcode;
-        private System.Windows.Forms.Button SetPrintStatus;
         private System.Windows.Forms.Label SetPrintStatus_label;
         private System.Windows.Forms.Button PrintFooter;
         private System.Windows.Forms.DataGridViewCheckBoxColumn Choose;
@@ -1584,5 +1551,6 @@
         private System.Windows.Forms.DataGridViewTextBoxColumn pr_unit;
         private System.Windows.Forms.DataGridViewTextBoxColumn pd_brand;
         private System.Windows.Forms.DataGridViewTextBoxColumn pjd_zxbzs_user;
+        private System.Windows.Forms.PictureBox pictureBox1;
     }
 }

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

@@ -57,10 +57,6 @@ namespace UAS_LabelMachine
         /// 当前品牌
         /// </summary>
         string PI_ID;
-        /// <summary>
-        /// 当前扫描的所在行
-        /// </summary>
-        int CurrentRowIndex = 0;
 
         bool logout = false;
 
@@ -133,6 +129,16 @@ namespace UAS_LabelMachine
         int OutNumLength = 0;
         int OutRadix = 0;
 
+        string SingleSQL = "";
+
+        string MidSQL = "";
+
+        string OutSQL = "";
+
+        DataTable Attach;
+
+        private bool EnablePrint = true;
+
         public UAS_出货标签打印(string Master)
         {
             InitializeComponent();
@@ -252,6 +258,21 @@ namespace UAS_LabelMachine
         /// </summary>
         private void CollectInputData()
         {
+            if (Input.Text == "SC")
+            {
+                EnablePrint = !EnablePrint;
+                if (EnablePrint)
+                {
+                    SetPrintStatus_label.ForeColor = Color.Green;
+                    SetPrintStatus_label.Text = "可打印";
+                }
+                else
+                {
+                    SetPrintStatus_label.ForeColor = Color.Red;
+                    SetPrintStatus_label.Text = "暂停打印";
+                }
+                return;
+            }
             Dictionary<string, string> Data = new Dictionary<string, string>();
             string[] SplitData = Input.Text.Split('*');
             if (SplitData.Length < 6)
@@ -380,8 +401,8 @@ namespace UAS_LabelMachine
             sql.Append("insert into prodiobarcode(PIB_ID,PIB_PRODCODE,PIB_INDATE,PIB_INOUTNO,PIB_PIID,PIB_PDNO, PIB_PDID,PIB_PICLASS,");
             sql.Append("PIB_BARCODE,PIB_CUSTBARCODE,PIB_QTY,PIB_OUTBOXCODE1,pib_datecode,pib_lotno,PIB_OUTBOXCODE2,pib_custoutboxcode,PIB_IFPRINT,PIB_ORDERCODE,PIB_CUSTPO) ");
             sql.Append("select :PIB_ID,pd_prodcode,sysdate,pi_inoutno,pi_id,pd_pdno,pd_id,pi_class,");
-            sql.Append("'" + pib_barcode + "',:PIB_CUSTBARCODE,'" + CurrentZXBZ + "','','" + Data["LOTNO"] + "','" + Data["DATECODE"] + "','" + pib_outboxcode2 + "',:pib_custoutboxcode,0,pd_ordercode,pd_pocode ");
-            sql.Append("from prodinout left join prodiodetail on pi_id=pd_piid where pi_id='" + PI_ID + "' and pd_prodcode='" + CurrentPrCode + "'");
+            sql.Append("'" + pib_barcode + "',:PIB_CUSTBARCODE,'" + CurrentZXBZ + "','','" + Data["DATECODE"] + "','" + Data["LOTNO"] + "','" + pib_outboxcode2 + "',:pib_custoutboxcode,0,pd_ordercode,pd_pocode ");
+            sql.Append("from prodinout left join prodiodetail on pi_id=pd_piid where pi_id='" + PI_ID + "' and pd_prodcode='" + CurrentPrCode + "' and pd_pdno='" + CurrentPDNO + "'");
             dh.BatchInsert(sql.ToString(), new string[] { "PIB_ID", "PIB_CUSTBARCODE", "pib_custoutboxcode" }, PIBID, CustBarCode.ToArray(), CustOutBarCode.ToArray());
             //更新流水号
             dh.UpdateByCondition("RULEMAXNUM", "rmn_maxnumber='" + (SingleMaxNum + CodeCount) + "'", "rmn_nrcode='" + pi_cardcode.Text + "' and rmn_type='Single' and rmn_prefix='" + SinglePrefix + "'");
@@ -394,7 +415,6 @@ namespace UAS_LabelMachine
             }
             if (SingleLabelAutoPrint.Checked)
             {
-                GetSingleBoxData();
                 AutoPrintSingleLabel(PIBID);
             }
             //采集后重新计数,自动跳到下一行
@@ -402,12 +422,24 @@ namespace UAS_LabelMachine
             CollectQty = (collectqty == "" ? 0 : int.Parse(collectqty));
             if (CollectQty == int.Parse(CurrentPrCount))
             {
+                for (int i = 0; i < GridPrcode.Rows.Count; i++)
+                {
+                    if (GridPrcode.Rows[i].Cells["pd_prodcode"].Value.ToString() == CurrentPrCode)
+                    {
+                        if (int.Parse(GridPrcode.Rows[i].Cells["pd_pdno"].Value.ToString()) > int.Parse(CurrentPDNO))
+                        {
+                            GridPrcode.Rows[i].Selected = true;
+                            return;
+                        }
+                    }
+                }
                 DataGridViewSelectedRowCollection dsc = GridPrcode.SelectedRows;
                 if (dsc[0].Index + 1 < GridPrcode.Rows.Count)
                 {
                     GridPrcode.Rows[dsc[0].Index + 1].Selected = true;
                 }
             }
+            OutBoxNum_Click(new object(), new EventArgs());
         }
 
         private void AutoPrintSingleLabel(string[] pib_id)
@@ -418,19 +450,19 @@ namespace UAS_LabelMachine
             for (int i = 0; i < pib_id.Length; i++)
             {
                 //将维护的模板参数和模板本身的参数名称进行比对
+                DataTable dt = (DataTable)dh.ExecuteSql(SingleSQL.Replace("{pib_id}", "'" + pib_id[i] + "'"), "select");
                 for (int k = 0; k < SingleLabelParam.Rows.Count; k++)
                 {
-                    DataRow[] dr = SingleBoxCacheData.Select("pib_id=" + pib_id[i]);
                     string ParamName = SingleLabelParam.Rows[k]["lp_name"].ToString();
-                    if (arg.Contains(SingleDoc.Variables.FreeVariables.Item(ParamName).Name))
-                        SingleDoc.Variables.FreeVariables.Item(ParamName).Value = dr[0][SingleDoc.Variables.FreeVariables.Item(ParamName).Name].ToString();
+
+                    SingleDoc.Variables.FreeVariables.Item(ParamName).Value = dt.Rows[0][k].ToString();
                     if (SingleDoc.Variables.FreeVariables.Item(ParamName).Value == "")
                     {
-                        DataRow[] drow = SingleLabelParam.Select("lp_name='" + SingleDoc.Variables.FreeVariables.Item(ParamName).Name + "'");
+                        DataRow[] drow = Attach.Select("lp_name='" + SingleDoc.Variables.FreeVariables.Item(ParamName).Name + "'");
                         if (drow.Length > 0)
                             SingleDoc.Variables.FreeVariables.Item(ParamName).Value = drow[0]["lp_sql"].ToString();
                     }
-                    ParamLog.AppendLine("pib_id:" + LabelInf.Rows[CurrentRowIndex].Cells["pib_id1"].Value.ToString() + ",SingleDoc打印参数【" + SingleDoc.Variables.FreeVariables.Item(ParamName).Name + "】赋值," + "取到值" + SingleDoc.Variables.FreeVariables.Item(ParamName).Value);
+                    ParamLog.AppendLine("pib_id:" + pib_id[i] + ",SingleDoc打印参数【" + SingleDoc.Variables.FreeVariables.Item(ParamName).Name + "】赋值," + "取到值" + SingleDoc.Variables.FreeVariables.Item(ParamName).Value);
                 }
                 LogManager.DoLog(ParamLog.ToString());
                 //保存参数打印
@@ -465,7 +497,6 @@ namespace UAS_LabelMachine
         private void GetInOutInfAndLabelFile()
         {
             ComBoxClickChangeLabelDoc = false;
-            DataTable Attach = (DataTable)dh.ExecuteSql("select lap_param lp_name,lap_value lp_sql  from LabelAttachPARAMETER where lap_custcode='" + pi_cardcode.Text + "'", "select");
             sql.Clear();
             sql.Append("select to_char(nvl(cl_date,sysdate),'YYYY-MM-DD HH24:Mi:SS') cl_date,cl_labelname,cl_isdefault,la_id||'#'||cl_labelurl||'#'||to_char(cl_date,'YYYY-MM-DD HH24:Mi:SS')  la_id,cl_custcode from customerlabel left join prodinout on pi_cardcode=cl_custcode ");
             sql.Append("left join customer on cu_code=cl_custcode left join label on la_code=CL_LABELCODE where ((pi_cardcode='" + pi_cardcode.Text + "' ");
@@ -501,8 +532,16 @@ namespace UAS_LabelMachine
                         ParamCondition += "'" + SingleDoc.Variables.FreeVariables.Item(i + 1).Name + "'";
                     }
                 }
-                SingleLabelParam = (DataTable)dh.ExecuteSql("select lp_name,lp_sql from label left join LABELPARAMETER on la_id= lp_laid where la_id=" + SingleLabelCombox.SelectedValue.ToString().Split('#')[0] + " and lp_name in(" + ParamCondition + ")", "select");
-                SingleLabelParam.Merge(Attach);
+                SingleLabelParam = (DataTable)dh.ExecuteSql("select lp_name,lp_sql from label left join LABELPARAMETER on la_id= lp_laid where la_id=" + SingleLabelCombox.SelectedValue.ToString().Split('#')[0] + " and lp_name in(" + ParamCondition + ") order by lp_detno", "select");
+                //SingleLabelParam.Merge(Attach);
+                SingleSQL = "select * from ";
+                for (int i = 0; i < SingleLabelParam.Rows.Count; i++)
+                {
+                    if (i != SingleLabelParam.Rows.Count - 1)
+                        SingleSQL += "(" + SingleLabelParam.Rows[i]["lp_sql"].ToString() + "),";
+                    else
+                        SingleSQL += "(" + SingleLabelParam.Rows[i]["lp_sql"].ToString() + ")";
+                }
             }
             sql.Clear();
             sql.Append("select to_char(nvl(cl_date,sysdate),'YYYY-MM-DD HH24:Mi:SS') cl_date,cl_labelname,cl_isdefault,la_id||'#'||cl_labelurl||'#'||to_char(cl_date,'YYYY-MM-DD HH24:Mi:SS')  la_id,cl_custcode from customerlabel left join prodinout on pi_cardcode=cl_custcode ");
@@ -539,7 +578,16 @@ namespace UAS_LabelMachine
                         ParamCondition += "'" + MidDoc.Variables.FreeVariables.Item(i + 1).Name + "'";
                     }
                 }
-                MidLabelParam = (DataTable)dh.ExecuteSql("select lp_name,lp_sql from label left join LABELPARAMETER on la_id= lp_laid where la_id=" + MidLabelCombox.SelectedValue.ToString().Split('#')[0] + " and lp_name in(" + ParamCondition + ")", "select");
+                MidLabelParam = (DataTable)dh.ExecuteSql("select lp_name,lp_sql from label left join LABELPARAMETER on la_id= lp_laid where la_id=" + MidLabelCombox.SelectedValue.ToString().Split('#')[0] + " and lp_name in(" + ParamCondition + ")  order by lp_detno", "select");
+                MidSQL = "select * from ";
+                for (int i = 0; i < MidLabelParam.Rows.Count; i++)
+                {
+                    if (i != MidLabelParam.Rows.Count - 1)
+                        MidSQL += "(" + MidLabelParam.Rows[i]["lp_sql"].ToString() + "),";
+                    else
+                        MidSQL += "(" + MidLabelParam.Rows[i]["lp_sql"].ToString() + ")";
+                }
+
                 MidLabelParam.Merge(Attach);
             }
             //缓存中盒参数
@@ -578,8 +626,15 @@ namespace UAS_LabelMachine
                         ParamCondition += "'" + OutBoxDoc.Variables.FreeVariables.Item(i + 1).Name + "'";
                     }
                 }
-                OutLabelParam = (DataTable)dh.ExecuteSql("select lp_name,lp_sql from label left join LABELPARAMETER on la_id= lp_laid where la_id=" + OutBoxCombox.SelectedValue.ToString().Split('#')[0] + " and lp_name in(" + ParamCondition + ")", "select");
-                OutLabelParam.Merge(Attach);
+                OutLabelParam = (DataTable)dh.ExecuteSql("select lp_name,lp_sql from label left join LABELPARAMETER on la_id= lp_laid where la_id=" + OutBoxCombox.SelectedValue.ToString().Split('#')[0] + " and lp_name in(" + ParamCondition + ")  order by lp_detno", "select");
+                OutSQL = "select * from ";
+                for (int i = 0; i < OutLabelParam.Rows.Count; i++)
+                {
+                    if (i != OutLabelParam.Rows.Count - 1)
+                        OutSQL += "(" + OutLabelParam.Rows[i]["lp_sql"].ToString() + "),";
+                    else
+                        OutSQL += "(" + OutLabelParam.Rows[i]["lp_sql"].ToString() + ")";
+                }
             }
             //缓存外箱参数
             ComBoxClickChangeLabelDoc = true;
@@ -618,7 +673,7 @@ namespace UAS_LabelMachine
                     SingleID.Clear();
                     Input.Focus();
                     //获取外箱数据
-                    OutBoxNum_Click(sender, new EventArgs());
+                    Attach = (DataTable)dh.ExecuteSql("select lap_param lp_name,lap_value lp_sql  from LabelAttachPARAMETER where lap_custcode='" + pi_cardcode.Text + "'", "select");
                     thread = new Thread(GetInOutInfAndLabelFile);
                     stw = new SetLoadingWindow(thread, "正在获取打印标签");
                     BaseUtil.SetFormCenter(stw);
@@ -651,11 +706,6 @@ namespace UAS_LabelMachine
                     MessageBox.Show("中盘标签未维护参数", "提示");
                 }
             }
-            string la_id = SingleLabelCombox.SelectedValue.ToString().Split('#')[0];
-            string cl_labelname = SingleLabelCombox.Text;
-            string LabelUrl = dh.getFieldDataByCondition("label left join customerlabel on la_code=cl_labelcode", "cl_labelurl", "la_id='" + la_id + "' and cl_labelname='" + cl_labelname + "'").ToString();
-            //查询该模板维护的所有参数
-            dt = (DataTable)dh.ExecuteSql("select lp_name,lp_sql from label left join LABELPARAMETER on la_id= lp_laid where la_id=" + la_id, "select");
             if (SingleLabelParam.Rows.Count > 0 && LabelInf.Rows.Count > 0)
             {
                 //每次打印清除之前缓存的行号和ID,后面会判断需要打印的数据重新加载
@@ -709,52 +759,51 @@ namespace UAS_LabelMachine
                     if (LabelInf.Rows[i].Cells["Choose"].FormattedValue.ToString() == "True" && LabelInf.Rows[i].Cells["pib_ifprint"].FormattedValue.ToString() != "True")
                     {
                         CheckedRowCount = CheckedRowCount + 1;
-                        CurrentRowIndex = i;
                         //以标签模板的参数为基准,循环取数
-                        //try
-                        //{
-                        string pib_id = LabelInf.Rows[i].Cells["pib_id1"].Value.ToString();
-                        DataRow[] dr = SingleBoxCacheData.Select("pib_id=" + pib_id);
-                        StringBuilder ParamLog = new StringBuilder();
-                        for (int k = 0; k < SingleLabelParam.Rows.Count; k++)
+                        try
                         {
-                            string ParamName = SingleLabelParam.Rows[k]["lp_name"].ToString();
-                            if (arg.Contains(SingleDoc.Variables.FreeVariables.Item(ParamName).Name))
-                                SingleDoc.Variables.FreeVariables.Item(ParamName).Value = dr[0][SingleDoc.Variables.FreeVariables.Item(ParamName).Name].ToString();
-                            if (SingleDoc.Variables.FreeVariables.Item(ParamName).Value == "")
+                            string pib_id = LabelInf.Rows[i].Cells["pib_id1"].Value.ToString();
+                            DataTable dt = (DataTable)dh.ExecuteSql(SingleSQL.Replace("{pib_id}", "'" + pib_id + "'"), "select");
+                            StringBuilder ParamLog = new StringBuilder();
+                            for (int k = 0; k < SingleLabelParam.Rows.Count; k++)
                             {
-                                DataRow[] drow = SingleLabelParam.Select("lp_name='" + SingleDoc.Variables.FreeVariables.Item(ParamName).Name + "'");
-                                if (drow.Length > 0)
-                                    SingleDoc.Variables.FreeVariables.Item(ParamName).Value = drow[0]["lp_sql"].ToString();
+                                string ParamName = SingleLabelParam.Rows[k]["lp_name"].ToString();
+
+                                SingleDoc.Variables.FreeVariables.Item(ParamName).Value = dt.Rows[0][k].ToString();
+                                if (SingleDoc.Variables.FreeVariables.Item(ParamName).Value == "")
+                                {
+                                    DataRow[] drow = Attach.Select("lp_name='" + SingleDoc.Variables.FreeVariables.Item(ParamName).Name + "'");
+                                    if (drow.Length > 0)
+                                        SingleDoc.Variables.FreeVariables.Item(ParamName).Value = drow[0]["lp_sql"].ToString();
+                                }
+                                ParamLog.AppendLine("pib_id:" + pib_id + ",SingleDoc打印参数【" + SingleDoc.Variables.FreeVariables.Item(ParamName).Name + "】赋值," + "取到值" + SingleDoc.Variables.FreeVariables.Item(ParamName).Value);
                             }
-                            ParamLog.AppendLine("pib_id:" + LabelInf.Rows[CurrentRowIndex].Cells["pib_id1"].Value.ToString() + ",SingleDoc打印参数【" + SingleDoc.Variables.FreeVariables.Item(ParamName).Name + "】赋值," + "取到值" + SingleDoc.Variables.FreeVariables.Item(ParamName).Value);
-                        }
-                        LogManager.DoLog(ParamLog.ToString());
-                        //保存参数打印
-                        if (EnablePrint)
-                        {
-                            SingleDoc.Printer.SwitchTo(SingleLabelPrinter.Text);
-                            SingleDoc.PrintDocument();
-                        }
-                        if (MidLabelAutoPrint.Checked)
-                        {
-                            //判断当前行的盒号和下一行不相等或者已经是最后一行了
-                            if (i + 1 == LabelInf.RowCount || LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString() != LabelInf.Rows[i + 1 == LabelInf.RowCount ? i : i + 1].Cells["pib_outboxcode1"].Value.ToString())
+                            LogManager.DoLog(ParamLog.ToString());
+                            //保存参数打印
+                            if (EnablePrint)
+                            {
+                                SingleDoc.Printer.SwitchTo(SingleLabelPrinter.Text);
+                                SingleDoc.PrintDocument();
+                            }
+                            if (MidLabelAutoPrint.Checked)
                             {
-                                if (outboxcode1[LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString()])
+                                //判断当前行的盒号和下一行不相等或者已经是最后一行了
+                                if (i + 1 == LabelInf.RowCount || LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString() != LabelInf.Rows[i + 1 == LabelInf.RowCount ? i : i + 1].Cells["pib_outboxcode1"].Value.ToString())
                                 {
-                                    if (MidLabelCombox.SelectedValue != null)
+                                    if (outboxcode1[LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString()])
                                     {
-                                        string la_id_mid = MidLabelCombox.SelectedValue.ToString().Split('#')[0];
-                                        MidBoxCodePrint(la_id_mid, CurrentRowIndex);
+                                        if (MidLabelCombox.SelectedValue != null)
+                                        {
+                                            string la_id_mid = MidLabelCombox.SelectedValue.ToString().Split('#')[0];
+                                            MidBoxCodePrint(la_id_mid, i);
+                                        }
                                     }
                                 }
                             }
+                            //勾选为已打印
+                            LabelInf.Rows[i].Cells["pib_ifprint"].Value = true;
                         }
-                        //勾选为已打印
-                        LabelInf.Rows[i].Cells["pib_ifprint"].Value = true;
-                        //}
-                        //catch (Exception ex) { LogManager.DoLog(ex.StackTrace); }
+                        catch (Exception ex) { LogManager.DoLog(ex.StackTrace); }
                     }
                 }
                 dh.BatchInsert("update prodiobarcode set pib_printdate=sysdate where pib_id=:pib_id", new string[] { "pib_id" }, SingleID.ToArray());
@@ -762,8 +811,6 @@ namespace UAS_LabelMachine
                 BaseUtil.CleanDataTable(MidBoxCacheData);
                 if (CheckedRowCount == 0)
                     MessageBox.Show("未勾选打印明细!", "提示");
-                else if (CurrentRowIndex + 1 < LabelInf.Rows.Count)
-                    CurrentRowIndex = CurrentRowIndex + 1;
                 outboxcode1.Clear();
             }
             else
@@ -1154,60 +1201,49 @@ namespace UAS_LabelMachine
 
         private void MidBoxCodePrint(string la_id, int rowindex)
         {
-            if (MidBoxCacheData.Rows.Count == 0)
-            {
-                MidIDAndOutboxcode.Add(LabelInf.Rows[rowindex].Cells["pib_id1"].Value.ToString(), LabelInf.Rows[rowindex].Cells["pib_outboxcode1"].Value.ToString());
-                GetMidBoxData();
-            }
-            DataTable dt = (DataTable)dh.ExecuteSql("select lp_name,lp_sql from label left join LABELPARAMETER on la_id= lp_laid where la_id=" + la_id, "select");
-            DataTable Attach = (DataTable)dh.ExecuteSql("select lap_param lp_name,lap_value lp_sql from LabelAttachPARAMETER where lap_custcode='" + pi_cardcode.Text + "'", "select");
-            //用标签本身的变量作为最外层的循环条件去匹配;
-            dt.Merge(Attach);
             string[] arg = MidBoxArgument.ToArray();
             //将维护的模板参数和模板本身的参数名称进行比对
             for (int k = 0; k < MidLabelParam.Rows.Count; k++)
             {
                 //名称相等的时候,取SQL进行值的查询
                 string ParamName = MidLabelParam.Rows[k]["lp_name"].ToString();
-                if (MidDoc.Variables.FreeVariables.Item(ParamName).Name == MidLabelParam.Rows[k]["lp_name"].ToString())
+                string pib_id = LabelInf.Rows[rowindex].Cells["pib_id1"].Value.ToString();
+                string pib_outboxcode1 = LabelInf.Rows[rowindex].Cells["pib_outboxcode1"].Value.ToString();
+                DataTable dt = (DataTable)dh.ExecuteSql(MidSQL.Replace("{pib_id}", pib_id).Replace("{pib_outboxcode1}", pib_outboxcode1), "select");
+
+                //获取打印执行的SQL
+                string sql = MidLabelParam.Rows[k]["lp_sql"].ToString();
+                try
                 {
-                    //获取对应行的pib_id
-                    string pib_id = LabelInf.Rows[rowindex].Cells["pib_id1"].Value.ToString();
-                    string pib_outboxcode1 = LabelInf.Rows[rowindex].Cells["pib_outboxcode1"].Value.ToString();
                     //获取打印执行的SQL
-                    string sql = MidLabelParam.Rows[k]["lp_sql"].ToString();
-                    try
+                    if (sql.IndexOf("{") == 0)
                     {
-                        //获取打印执行的SQL
-                        if (sql.IndexOf("{") == 0)
-                        {
-                            MidDoc.Variables.FreeVariables.Item(ParamName).Value = dh.GetLabelParam(sql).ToString();
-                            LogManager.DoLog("打印参数【" + MidDoc.Variables.FreeVariables.Item(ParamName).Name + "】赋值," + "取值SQL:" + dt.Rows[k]["lp_sql"].ToString() + ",取到值" + MidDoc.Variables.FreeVariables.Item(ParamName).Value);
-                        }
-                        else
+                        MidDoc.Variables.FreeVariables.Item(ParamName).Value = dh.GetLabelParam(sql).ToString();
+                        LogManager.DoLog("打印参数【" + MidDoc.Variables.FreeVariables.Item(ParamName).Name + "】赋值," + "取值SQL:" + dt.Rows[k]["lp_sql"].ToString() + ",取到值" + MidDoc.Variables.FreeVariables.Item(ParamName).Value);
+                    }
+                    else
+                    {
+                        DataRow[] dr = MidBoxCacheData.Select("pib_outboxcode1='" + pib_outboxcode1 + "'");
+                        if (arg.Contains(MidDoc.Variables.FreeVariables.Item(ParamName).Name))
                         {
-                            DataRow[] dr = MidBoxCacheData.Select("pib_outboxcode1='" + pib_outboxcode1 + "'");
-                            if (arg.Contains(MidDoc.Variables.FreeVariables.Item(ParamName).Name))
-                            {
-                                if (dr.Length > 0)
-                                {
-                                    MidDoc.Variables.FreeVariables.Item(ParamName).Value = dr[0][MidDoc.Variables.FreeVariables.Item(ParamName).Name].ToString();
-                                }
-                            }
-                            if (MidDoc.Variables.FreeVariables.Item(ParamName).Value == "")
+                            if (dr.Length > 0)
                             {
-                                DataRow[] drow = MidLabelParam.Select("lp_name='" + MidDoc.Variables.FreeVariables.Item(ParamName).Name + "'");
-                                if (drow.Length > 0)
-                                    MidDoc.Variables.FreeVariables.Item(ParamName).Value = drow[0]["lp_sql"].ToString();
+                                MidDoc.Variables.FreeVariables.Item(ParamName).Value = dr[0][MidDoc.Variables.FreeVariables.Item(ParamName).Name].ToString();
                             }
-                            LogManager.DoLog("打印参数【" + MidDoc.Variables.FreeVariables.Item(ParamName).Name + "】赋值," + "取值SQL:" + sql + ",取到值" + MidDoc.Variables.FreeVariables.Item(ParamName).Value);
                         }
+                        if (MidDoc.Variables.FreeVariables.Item(ParamName).Value == "")
+                        {
+                            DataRow[] drow = Attach.Select("lp_name='" + MidDoc.Variables.FreeVariables.Item(ParamName).Name + "'");
+                            if (drow.Length > 0)
+                                MidDoc.Variables.FreeVariables.Item(ParamName).Value = drow[0]["lp_sql"].ToString();
+                        }
+                        LogManager.DoLog("打印参数【" + MidDoc.Variables.FreeVariables.Item(ParamName).Name + "】赋值," + "取值SQL:" + sql + ",取到值" + MidDoc.Variables.FreeVariables.Item(ParamName).Value);
                     }
-                    catch (Exception)
-                    {
-                        LogManager.DoLog("SQL维护不正确,请检查SQL语句\n" + sql);
-                        return;
-                    }
+                }
+                catch (Exception)
+                {
+                    LogManager.DoLog("SQL维护不正确,请检查SQL语句\n" + sql);
+                    return;
                 }
             }
             //保存参数打印
@@ -1220,7 +1256,6 @@ namespace UAS_LabelMachine
 
         private void MidBoxCodePrint(string la_id, int rowindex, int[] midindex)
         {
-
             //将维护的模板参数和模板本身的参数名称进行比对
             for (int k = 0; k < MidLabelParam.Rows.Count; k++)
             {
@@ -1272,7 +1307,7 @@ namespace UAS_LabelMachine
                         }
                         if (MidDoc.Variables.FreeVariables.Item(ParamName).Value == "")
                         {
-                            DataRow[] drow = MidLabelParam.Select("lp_name='" + MidDoc.Variables.FreeVariables.Item(ParamName).Name + "'");
+                            DataRow[] drow = Attach.Select("lp_name='" + MidDoc.Variables.FreeVariables.Item(ParamName).Name + "'");
                             if (drow.Length > 0)
                                 MidDoc.Variables.FreeVariables.Item(ParamName).Value = drow[0]["lp_sql"].ToString();
                         }
@@ -1301,34 +1336,21 @@ namespace UAS_LabelMachine
             try
             {
                 //将维护的模板参数和模板本身的参数名称进行比对
+                string pib_id = LabelInf.Rows[rowindex].Cells["pib_id1"].Value.ToString();
+                string pib_outboxcode2 = LabelInf.Rows[rowindex].Cells["pib_outboxcode2"].Value.ToString();
+                DataTable dt = (DataTable)dh.ExecuteSql(OutSQL.Replace("{pib_id}", "'" + pib_id + "'").Replace("{pib_outboxcode2}", "'" + pib_outboxcode2 + "'"), "select");
                 for (int k = 0; k < OutLabelParam.Rows.Count; k++)
                 {
                     //获取对应行的pib_id
                     string ParamName = OutLabelParam.Rows[k]["lp_name"].ToString();
-                    string pib_id = LabelInf.Rows[rowindex].Cells["pib_id1"].Value.ToString();
-                    string pib_outboxcode2 = LabelInf.Rows[rowindex].Cells["pib_outboxcode2"].Value.ToString();
-                    //获取打印执行的SQL
-                    string sql = OutLabelParam.Rows[k]["lp_sql"].ToString();
-                    try
-                    {
-                        string ExeSQL = "";
-                        ExeSQL = sql.ToLower().Replace("{pib_id}", "'" + pib_id + "'");
-                        ExeSQL = ExeSQL.Replace("{pib_outboxcode2}", "'" + pib_outboxcode2 + "'");
-                        OutBoxDoc.Variables.FreeVariables.Item(ParamName).Value = dh.GetLabelParam(ExeSQL).ToString();
-                        if (OutBoxDoc.Variables.FreeVariables.Item(ParamName).Value == "")
-                        {
-                            DataRow[] drow = OutLabelParam.Select("lp_name='" + OutBoxDoc.Variables.FreeVariables.Item(ParamName).Name + "'");
-                            if (drow.Length > 0)
-                                OutBoxDoc.Variables.FreeVariables.Item(ParamName).Value = drow[0]["lp_sql"].ToString();
-                        }
-                        LogManager.DoLog("打印参数【" + OutBoxDoc.Variables.FreeVariables.Item(ParamName).Name + "】赋值," + "取值SQL:" + ExeSQL + ",取到值" + OutBoxDoc.Variables.FreeVariables.Item(ParamName).Value);
-                    }
-                    catch (Exception)
+                    OutBoxDoc.Variables.FreeVariables.Item(ParamName).Value = dt.Rows[0][k].ToString();
+                    if (OutBoxDoc.Variables.FreeVariables.Item(ParamName).Value == "")
                     {
-                        LogManager.DoLog("SQL维护不正确,请检查SQL语句" + sql);
-                        MessageBox.Show("SQL维护不正确,请检查SQL语句\n" + sql, "提示");
-                        return;
+                        DataRow[] drow = Attach.Select("lp_name='" + OutBoxDoc.Variables.FreeVariables.Item(ParamName).Name + "'");
+                        if (drow.Length > 0)
+                            OutBoxDoc.Variables.FreeVariables.Item(ParamName).Value = drow[0]["lp_sql"].ToString();
                     }
+                    LogManager.DoLog("打印参数【" + OutBoxDoc.Variables.FreeVariables.Item(ParamName).Name + "】赋值," + ",取到值" + OutBoxDoc.Variables.FreeVariables.Item(ParamName).Value);
                 }
                 //保存参数打印
                 if (EnablePrint)
@@ -1417,33 +1439,6 @@ namespace UAS_LabelMachine
             pi_inoutno_KeyDown(sender, e2);
         }
 
-        /// <summary>
-        /// 采集明细切换
-        /// </summary>
-        /// <param name="sender"></param>
-        /// <param name="e"></param>
-        private void griddetno_KeyDown(object sender, KeyEventArgs e)
-        {
-            if (Keys.Enter == e.KeyData)
-            {
-                bool FindDetno = false;
-                for (int i = 0; i < LabelInf.RowCount; i++)
-                {
-                    if (LabelInf.Rows[i].Cells["pib_pdno"].Value.ToString() == griddetno.Text)
-                    {
-                        FindDetno = true;
-                        CurrentRowIndex = i;
-                        break;
-                    }
-                }
-                if (!FindDetno)
-                {
-                    MessageBox.Show("不存在未采集的明细序号" + griddetno.Text, "提示");
-                    return;
-                }
-            }
-        }
-
         private void AutoPrintMidLabel()
         {
             bool FullBox = true;
@@ -1462,7 +1457,7 @@ namespace UAS_LabelMachine
                 if (MidLabelCombox.SelectedValue != null)
                 {
                     string la_id = MidLabelCombox.SelectedValue.ToString().Split('#')[0];
-                    MidBoxCodePrint(la_id, CurrentRowIndex);
+                    MidBoxCodePrint(la_id, 0);
                 }
                 else
                     MessageBox.Show("未维护中盒模板", "提示");
@@ -1690,22 +1685,7 @@ 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 = "暂停打印";
-            }
-        }
 
         private void OutBoxNum_Click(object sender, EventArgs e)
         {