Browse Source

Merge branch 'master' of ssh://10.10.100.21/source/mes-client

caosy 6 years ago
parent
commit
9d3f874e19

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

@@ -235,6 +235,7 @@
             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.sd_brand = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.pib_madein = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.pr_orispeccode = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.pr_barcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
@@ -1528,6 +1529,7 @@
             this.pib_ifupload,
             this.pr_vendprodcode,
             this.pib_brand,
+            this.sd_brand,
             this.pib_madein,
             this.pr_orispeccode,
             this.pr_barcode,
@@ -2540,6 +2542,13 @@
             this.pib_brand.ReadOnly = true;
             this.pib_brand.Width = 54;
             // 
+            // sd_brand
+            // 
+            this.sd_brand.DataPropertyName = "sd_brand";
+            this.sd_brand.HeaderText = "出货品牌";
+            this.sd_brand.Name = "sd_brand";
+            this.sd_brand.Width = 78;
+            // 
             // pib_madein
             // 
             this.pib_madein.DataPropertyName = "pib_madein";
@@ -3035,6 +3044,7 @@
         private System.Windows.Forms.DataGridViewCheckBoxColumn pib_ifupload;
         private System.Windows.Forms.DataGridViewTextBoxColumn pr_vendprodcode;
         private System.Windows.Forms.DataGridViewTextBoxColumn pib_brand;
+        private System.Windows.Forms.DataGridViewTextBoxColumn sd_brand;
         private System.Windows.Forms.DataGridViewTextBoxColumn pib_madein;
         private System.Windows.Forms.DataGridViewTextBoxColumn pr_orispeccode;
         private System.Windows.Forms.DataGridViewTextBoxColumn pr_barcode;

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

@@ -1605,9 +1605,9 @@ namespace UAS_LabelMachine
                 sql.Clear();
                 sql.Append("select t.*,rownum from (select pib_autoset,pd_ordercode,pib_year,pib_month,pib_day,pr_barcode,pr_detail,pib_custoutboxcode,pib_custmidboxcode,pr_orispeccode,pd_id,pd_custprodcode,pib_indate,pi_date,pib_inoutno,pd_custprodspec,");
                 sql.Append("nvl(pib_ifrecheck,0)pib_ifrecheck,nvl(pib_ifupload,0)pib_ifupload,nvl(pib_ifmodify,0)pib_ifmodify,pd_pocode,pib_madein,pib_custbarcode,pib_id,pib_pdid,pib_piid,");
-                sql.Append("pib_pdno,pib_prodcode,nvl(nvl(pd_brand,pib_brand),pr_brand)pib_brand, pr_vendprodcode,pib_lotno,pib_datecode,pib_qty,pr_spec,pi_title,pr_zxbzs,pr_unit,pib_barcode,pib_outboxcode1,");
+                sql.Append("pib_pdno,pib_prodcode,nvl(nvl(pd_brand,pib_brand),pr_brand)pib_brand,(select pr_brand from saledetail left join product on pr_code=sd_prodcode where sd_code=pd_ordercode and sd_detno=pd_orderdetno ) sd_brand, pr_vendprodcode,pib_lotno,pib_datecode,pib_qty,pr_spec,pi_title,pr_zxbzs,pr_unit,pib_barcode,pib_outboxcode1,");
                 sql.Append("pib_outboxcode2,nvl(pib_ifpick,0)pib_ifpick,nvl(pib_ifprint,0)pib_ifprint from prodiobarcode left join prodinout on pib_piid=pi_id left join prodiodetail on pib_piid=pd_piid and  ");
-                sql.Append("pd_pdno=pib_pdno and pd_prodcode=pib_prodcode left join product on pr_code=pib_prodcode left join sale on sa_code=pib_ordercode where pib_piid='" + PI_ID + "' order by to_number(pib_id))t");
+                sql.Append("pd_pdno=pib_pdno and pd_prodcode=pib_prodcode left join product on pr_code=pib_prodcode  where pib_piid='" + PI_ID + "' order by to_number(pib_id))t");
                 LabelInfDataTable = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
                 //检验查询的字段和本地数据库字段是否匹配
                 adh.AddColumFromDataTable(LabelInfDataTable, "prodiobarcode");

+ 3 - 0
UAS-出货标签管理(吉利通)/UAS_出货标签管理.resx

@@ -141,6 +141,9 @@
   <metadata name="pib_ifupload.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>
+  <metadata name="sd_brand.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
   <metadata name="pib_madein.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>

+ 4 - 5
UAS-出货标签管理(贸易版)/CustomControl/PrinterCombox.Designer.cs

@@ -37,19 +37,18 @@
             this.PrinterList.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
             this.PrinterList.FormattingEnabled = true;
             this.PrinterList.Location = new System.Drawing.Point(0, 0);
-            this.PrinterList.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.PrinterList.Name = "PrinterList";
-            this.PrinterList.Size = new System.Drawing.Size(284, 26);
+            this.PrinterList.Size = new System.Drawing.Size(189, 20);
             this.PrinterList.TabIndex = 0;
+            this.PrinterList.SelectedIndexChanged += new System.EventHandler(this.PrinterList_SelectedIndexChanged);
             // 
             // PrinterCombox
             // 
-            this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F);
+            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.Controls.Add(this.PrinterList);
-            this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
             this.Name = "PrinterCombox";
-            this.Size = new System.Drawing.Size(284, 28);
+            this.Size = new System.Drawing.Size(189, 19);
             this.Load += new System.EventHandler(this.PrinterCombox_Load);
             this.ResumeLayout(false);
 

+ 13 - 2
UAS-出货标签管理(贸易版)/CustomControl/PrinterCombox.cs

@@ -16,12 +16,15 @@ namespace UAS_LabelMachine.CustomControl
         {
             InitializeComponent();
         }
+        public delegate void OnSelectIndexChange(object sender, EventArgs e);
+
+        public event OnSelectIndexChange UserOnSelectIndexChange;
 
         public override string Text
         {
             get
             {
-                return PrinterList.Text; 
+                return PrinterList.Text;
             }
 
             set
@@ -30,17 +33,25 @@ namespace UAS_LabelMachine.CustomControl
             }
         }
 
+        bool Loading = true;
+
         private void PrinterCombox_Load(object sender, EventArgs e)
         {
             PrintDocument print = new PrintDocument();
             string sDefault = print.PrinterSettings.PrinterName;//默认打印机名
-
             foreach (string sPrint in PrinterSettings.InstalledPrinters)//获取所有打印机名称
             {
                 PrinterList.Items.Add(sPrint);
                 if (sPrint == sDefault)
                     PrinterList.SelectedIndex = PrinterList.Items.IndexOf(sPrint);
             }
+            Loading = false;
+        }
+
+        private void PrinterList_SelectedIndexChanged(object sender, EventArgs e)
+        {
+            if(!Loading)
+            UserOnSelectIndexChange.Invoke(sender, e);
         }
     }
 }

+ 2 - 3
UAS-出货标签管理(贸易版)/Login.cs

@@ -30,9 +30,8 @@ namespace UAS_LabelMachine
 
         private void Login_Load(object sender, EventArgs e)
         {
-            dh = new DataHelper();
-            sdh = new SqliteDBHelper("LabelPrint.db3");
-            SystemInf.dh = dh;
+            SystemInf.dh = dh = new DataHelper();
+            SystemInf.sdh = sdh = new SqliteDBHelper("LabelPrint.db3");
             //获取账套信息
             dt = (DataTable)dh.ExecuteSql("select ma_function,ms_pwd,ma_user from master ", "select");
             DataTable MasterDB = dt.Clone();

+ 20 - 0
UAS-出货标签管理(贸易版)/PublicMethod/BaseUtil.cs

@@ -29,6 +29,26 @@ namespace UAS_LabelMachine
             }
         }
 
+        /// <summary>
+        /// 筛选DataTable
+        /// </summary>
+        /// <param name="dt"></param>
+        /// <param name="condition"></param>
+        /// <returns></returns>
+        public static DataTable filterDataTable(DataTable dt, String condition)
+        {
+            if (dt == null)
+                return new DataTable();
+            //获取筛选条件中的列名,值
+            DataRow[] dataRows = dt.Select(condition);
+            DataTable ndt = dt.Clone();
+            for (int i = 0; i < dataRows.Length; i++)
+            {
+                ndt.Rows.Add(dataRows[i].ItemArray);
+            }
+            return ndt;
+        }
+
         public static string DToAny(double DB, int Type)
         {
             string H = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";

+ 22 - 1
UAS-出货标签管理(贸易版)/PublicMethod/DataHelper.cs

@@ -940,9 +940,30 @@ namespace UAS_LabelMachine
             command.ArrayBindCount = names[1].Length;
             //因为第一个数组保存的是参数的名称,所以循环从1而不是0开始
             //将第一个数组的下标固定为0作为循环添加的参数的名称
+            //因为第一个数组保存的是参数的名称,所以循环从1而不是0开始
+            //将第一个数组的下标固定为0作为循环添加的参数的名称
             for (int i = 1; i <= names[0].Length; i++)
             {
-                command.Parameters.Add(new OracleParameter(names[0][i - 1].ToString(), OracleDbType.Varchar2, names[i], ParameterDirection.Input));
+                if (names[0][i - 1].ToString().ToUpper().Contains("DATE") && !names[0][i - 1].ToString().ToUpper().Contains("DATECODE"))
+                {
+                    DateTime[] time = new DateTime[names[i].Length];
+                    try
+                    {
+                        for (int j = 0; j < names[i].Length; j++)
+                        {
+                            time[j] = Convert.ToDateTime(names[i][j]);
+                        }
+                        command.Parameters.Add(new OracleParameter(names[0][i - 1].ToString(), OracleDbType.Date, time, ParameterDirection.Input));
+                    }
+                    catch (Exception)
+                    {
+                        command.Parameters.Add(new OracleParameter(names[0][i - 1].ToString(), OracleDbType.Varchar2, names[i], ParameterDirection.Input));
+                    }
+                }
+                else
+                {
+                    command.Parameters.Add(new OracleParameter(names[0][i - 1].ToString(), OracleDbType.Varchar2, names[i], ParameterDirection.Input));
+                }
             }
             command.ExecuteNonQuery();
             command.Dispose();

+ 1 - 0
UAS-出货标签管理(贸易版)/PublicMethod/SqliteDBHelper.cs

@@ -502,6 +502,7 @@ namespace UAS_LabelMachine
         {
             object result = null;
             command = new SQLiteCommand(SQL, this._odcConnection);
+            Console.WriteLine(SQL);
             Reconnect(command);
             switch (Type.ToUpper())
             {

+ 17 - 45
UAS-出货标签管理(贸易版)/UAS_出货标签管理.Designer.cs

@@ -152,7 +152,6 @@
             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.ViVoPlate = new System.Windows.Forms.Button();
             this.SingleLabelPrinter = new UAS_LabelMachine.CustomControl.PrinterCombox();
             this.SingleLabelPrint = new System.Windows.Forms.Button();
             this.SingleLabelAutoPrint = new System.Windows.Forms.CheckBox();
@@ -175,7 +174,6 @@
             this.label6 = new System.Windows.Forms.Label();
             this.OutBoxPrinter = new UAS_LabelMachine.CustomControl.PrinterCombox();
             this.OutboxCapacity = new System.Windows.Forms.NumericUpDown();
-            this.OutBoxLabelPackage = new System.Windows.Forms.Button();
             this.OutBoxLabelPrint = new System.Windows.Forms.Button();
             this.OutBoxLabelAutoPrint = new System.Windows.Forms.CheckBox();
             this.OutBoxCombox = new System.Windows.Forms.ComboBox();
@@ -320,7 +318,7 @@
             this.SaveGrid.Name = "SaveGrid";
             this.SaveGrid.Size = new System.Drawing.Size(68, 26);
             this.SaveGrid.TabIndex = 59;
-            this.SaveGrid.Text = "保存明细";
+            this.SaveGrid.Text = "上传条码";
             this.SaveGrid.UseVisualStyleBackColor = true;
             this.SaveGrid.Click += new System.EventHandler(this.SaveGrid_Click);
             // 
@@ -360,11 +358,11 @@
             this.si_expression,
             this.si_item,
             this.si_expressionitem});
-            this.Si_ItemDGV.Location = new System.Drawing.Point(324, 16);
+            this.Si_ItemDGV.Location = new System.Drawing.Point(324, 11);
             this.Si_ItemDGV.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.Si_ItemDGV.Name = "Si_ItemDGV";
             this.Si_ItemDGV.RowTemplate.Height = 23;
-            this.Si_ItemDGV.Size = new System.Drawing.Size(134, 144);
+            this.Si_ItemDGV.Size = new System.Drawing.Size(134, 149);
             this.Si_ItemDGV.TabIndex = 65;
             // 
             // si_detno
@@ -950,11 +948,11 @@
             this.CollectionProcess.Controls.Add(this.label13);
             this.CollectionProcess.Controls.Add(this.Installed);
             this.CollectionProcess.Controls.Add(this.Process);
-            this.CollectionProcess.Location = new System.Drawing.Point(464, 10);
+            this.CollectionProcess.Location = new System.Drawing.Point(464, 6);
             this.CollectionProcess.Margin = new System.Windows.Forms.Padding(2);
             this.CollectionProcess.Name = "CollectionProcess";
             this.CollectionProcess.Padding = new System.Windows.Forms.Padding(2);
-            this.CollectionProcess.Size = new System.Drawing.Size(130, 152);
+            this.CollectionProcess.Size = new System.Drawing.Size(130, 155);
             this.CollectionProcess.TabIndex = 80;
             this.CollectionProcess.TabStop = false;
             this.CollectionProcess.Text = " ";
@@ -1393,7 +1391,6 @@
             // 
             // SingleLabel
             // 
-            this.SingleLabel.Controls.Add(this.ViVoPlate);
             this.SingleLabel.Controls.Add(this.SingleLabelPrinter);
             this.SingleLabel.Controls.Add(this.SingleLabelPrint);
             this.SingleLabel.Controls.Add(this.SingleLabelAutoPrint);
@@ -1408,27 +1405,15 @@
             this.SingleLabel.TabStop = false;
             this.SingleLabel.Text = "单盘标签";
             // 
-            // ViVoPlate
-            // 
-            this.ViVoPlate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
-            this.ViVoPlate.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.ViVoPlate.Location = new System.Drawing.Point(80, 169);
-            this.ViVoPlate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
-            this.ViVoPlate.Name = "ViVoPlate";
-            this.ViVoPlate.Size = new System.Drawing.Size(68, 26);
-            this.ViVoPlate.TabIndex = 41;
-            this.ViVoPlate.Text = "ViVo料盘";
-            this.ViVoPlate.UseVisualStyleBackColor = true;
-            this.ViVoPlate.Click += new System.EventHandler(this.ViVoPlate_Click);
-            // 
             // 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, 78);
             this.SingleLabelPrinter.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
             this.SingleLabelPrinter.Name = "SingleLabelPrinter";
-            this.SingleLabelPrinter.Size = new System.Drawing.Size(142, 30);
+            this.SingleLabelPrinter.Size = new System.Drawing.Size(142, 25);
             this.SingleLabelPrinter.TabIndex = 40;
+            this.SingleLabelPrinter.UserOnSelectIndexChange += new UAS_LabelMachine.CustomControl.PrinterCombox.OnSelectIndexChange(this.LabelPrinter_UserOnSelectIndexChange);
             // 
             // SingleLabelPrint
             // 
@@ -1527,8 +1512,9 @@
             this.MidLabelPrinter.Location = new System.Drawing.Point(6, 78);
             this.MidLabelPrinter.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
             this.MidLabelPrinter.Name = "MidLabelPrinter";
-            this.MidLabelPrinter.Size = new System.Drawing.Size(142, 30);
+            this.MidLabelPrinter.Size = new System.Drawing.Size(142, 25);
             this.MidLabelPrinter.TabIndex = 41;
+            this.MidLabelPrinter.UserOnSelectIndexChange += new UAS_LabelMachine.CustomControl.PrinterCombox.OnSelectIndexChange(this.LabelPrinter_UserOnSelectIndexChange);
             // 
             // label15
             // 
@@ -1595,7 +1581,6 @@
             this.OutBoxLabel.Controls.Add(this.label6);
             this.OutBoxLabel.Controls.Add(this.OutBoxPrinter);
             this.OutBoxLabel.Controls.Add(this.OutboxCapacity);
-            this.OutBoxLabel.Controls.Add(this.OutBoxLabelPackage);
             this.OutBoxLabel.Controls.Add(this.OutBoxLabelPrint);
             this.OutBoxLabel.Controls.Add(this.OutBoxLabelAutoPrint);
             this.OutBoxLabel.Controls.Add(this.OutBoxCombox);
@@ -1623,10 +1608,10 @@
             // GetOutBoxCode
             // 
             this.GetOutBoxCode.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.GetOutBoxCode.Location = new System.Drawing.Point(89, 167);
+            this.GetOutBoxCode.Location = new System.Drawing.Point(91, 167);
             this.GetOutBoxCode.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.GetOutBoxCode.Name = "GetOutBoxCode";
-            this.GetOutBoxCode.Size = new System.Drawing.Size(76, 26);
+            this.GetOutBoxCode.Size = new System.Drawing.Size(68, 26);
             this.GetOutBoxCode.TabIndex = 93;
             this.GetOutBoxCode.Text = "获取箱号";
             this.GetOutBoxCode.UseVisualStyleBackColor = true;
@@ -1636,7 +1621,7 @@
             // 
             this.OutBoxNum.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.OutBoxNum.ID = null;
-            this.OutBoxNum.Location = new System.Drawing.Point(46, 201);
+            this.OutBoxNum.Location = new System.Drawing.Point(47, 205);
             this.OutBoxNum.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.OutBoxNum.Name = "OutBoxNum";
             this.OutBoxNum.Size = new System.Drawing.Size(37, 23);
@@ -1649,7 +1634,7 @@
             // 
             this.label10.AutoSize = true;
             this.label10.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label10.Location = new System.Drawing.Point(6, 204);
+            this.label10.Location = new System.Drawing.Point(6, 208);
             this.label10.Name = "label10";
             this.label10.Size = new System.Drawing.Size(32, 17);
             this.label10.TabIndex = 90;
@@ -1671,8 +1656,9 @@
             this.OutBoxPrinter.Location = new System.Drawing.Point(8, 78);
             this.OutBoxPrinter.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
             this.OutBoxPrinter.Name = "OutBoxPrinter";
-            this.OutBoxPrinter.Size = new System.Drawing.Size(158, 30);
+            this.OutBoxPrinter.Size = new System.Drawing.Size(158, 25);
             this.OutBoxPrinter.TabIndex = 82;
+            this.OutBoxPrinter.UserOnSelectIndexChange += new UAS_LabelMachine.CustomControl.PrinterCombox.OnSelectIndexChange(this.LabelPrinter_UserOnSelectIndexChange);
             // 
             // OutboxCapacity
             // 
@@ -1689,25 +1675,13 @@
             0});
             this.OutboxCapacity.Leave += new System.EventHandler(this.MidBoxCapacity_Leave);
             // 
-            // OutBoxLabelPackage
-            // 
-            this.OutBoxLabelPackage.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.OutBoxLabelPackage.Location = new System.Drawing.Point(89, 113);
-            this.OutBoxLabelPackage.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
-            this.OutBoxLabelPackage.Name = "OutBoxLabelPackage";
-            this.OutBoxLabelPackage.Size = new System.Drawing.Size(75, 26);
-            this.OutBoxLabelPackage.TabIndex = 81;
-            this.OutBoxLabelPackage.Text = "Vivo打印";
-            this.OutBoxLabelPackage.UseVisualStyleBackColor = true;
-            this.OutBoxLabelPackage.Click += new System.EventHandler(this.OutBoxLabelPackage_Click);
-            // 
             // OutBoxLabelPrint
             // 
             this.OutBoxLabelPrint.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.OutBoxLabelPrint.Location = new System.Drawing.Point(90, 199);
+            this.OutBoxLabelPrint.Location = new System.Drawing.Point(91, 202);
             this.OutBoxLabelPrint.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.OutBoxLabelPrint.Name = "OutBoxLabelPrint";
-            this.OutBoxLabelPrint.Size = new System.Drawing.Size(76, 26);
+            this.OutBoxLabelPrint.Size = new System.Drawing.Size(68, 26);
             this.OutBoxLabelPrint.TabIndex = 80;
             this.OutBoxLabelPrint.Text = "打印箱标";
             this.OutBoxLabelPrint.UseVisualStyleBackColor = true;
@@ -1840,7 +1814,6 @@
         private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn15;
         private System.Windows.Forms.Label label6;
         private System.Windows.Forms.NumericUpDown OutboxCapacity;
-        private System.Windows.Forms.Button OutBoxLabelPackage;
         private System.Windows.Forms.CheckBox OutBoxLabelAutoPrint;
         private System.Windows.Forms.ComboBox MidLabelCombox;
         private System.Windows.Forms.CheckBox MidLabelAutoPrint;
@@ -1905,7 +1878,6 @@
         private System.Windows.Forms.LinkLabel LogingOut;
         private System.Windows.Forms.Timer RefreshDBConnect;
         private System.Windows.Forms.CheckBox GetGridOnly;
-        private System.Windows.Forms.Button ViVoPlate;
         private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn16;
         private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn17;
         private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn18;

+ 189 - 395
UAS-出货标签管理(贸易版)/UAS_出货标签管理.cs

@@ -10,12 +10,10 @@ using System.Diagnostics;
 using LabelManager2;
 using UAS_LabelMachine.PublicMethod;
 using UAS_LabelMachine.Entity;
-using UAS_特殊解析规则;
 using UAS_LabelMachine.PublicForm;
 using System.Threading;
 using System.IO;
 using System.Globalization;
-using System.Threading.Tasks;
 using System.Reflection;
 
 namespace UAS_LabelMachine
@@ -96,7 +94,6 @@ namespace UAS_LabelMachine
 
         Dictionary<string, string> CollectData;
         //缓存单盘数据数据的DataTable
-        DataTable SingleBoxCacheData;
         /// <summary>
         /// 存放单盘的ID
         /// </summary>
@@ -108,7 +105,6 @@ namespace UAS_LabelMachine
         /// <summary>
         /// 中盒缓存数据
         /// </summary>
-        DataTable MidBoxCacheData;
         /// <summary>
         /// 存放中盒的ID和盒号
         /// </summary>
@@ -186,8 +182,6 @@ namespace UAS_LabelMachine
             CloumnCount = LabelInf.Columns.Count;
             pi_inoutno.Focus();
             //将本地读取的打印机设置进Combox,并选中默认打印机
-            MidBoxCacheData = new DataTable();
-            SingleBoxCacheData = new DataTable();
             sg_code.FormName = Name;
             sg_code.SetValueField = new string[] { "sg_code" };
             sg_code.SelectField = "sg_code # 策略编号 ,sg_name # 策略名称,sg_brand # 品牌,sg_separator # 分隔符";
@@ -214,22 +208,7 @@ namespace UAS_LabelMachine
             Height = ScreenArea.Height;
             MidBoxCapacity.Value = Properties.Settings.Default.MidBoxCapacity;
             OutboxCapacity.Value = Properties.Settings.Default.OutboxCapacity;
-            //怡海能达添加的特殊字段
-            if (DataHelper.DBConnectionString.Contains("sz.hi-mantech.com") || DataHelper.DBConnectionString.Contains("192.168.1.200"))
-            {
-                pib_datecode1.Visible = true;
-                SingleLabelAutoPrint.Checked = true;
-                MidLabelAutoPrint.Checked = true;
-                pib_madein.Visible = true;
-            }
-            if (!(DataHelper.DBConnectionString.Contains("richwell") || DataHelper.DBConnectionString.Contains("192.168.0.88")))
-            {
-                pib_cusbarcode.Visible = false;
-                pib_cusoutboxcode.Visible = false;
-                ViVoPlate.Visible = false;
-                OutBoxLabelPackage.Visible = false;
-                //GetOutBoxCode.Visible = false;
-            }
+
             asc.controllInitializeSize(this);
             asc.controlAutoSize(this);
             //实例化打印进程
@@ -314,7 +293,6 @@ namespace UAS_LabelMachine
             DataTable savedt = (LabelInf.DataSource as DataTable);
             if (savedt != null && savedt.GetChanges() != null)
             {
-                MidSource.EndEdit();
                 dh.SaveDataTable(savedt.GetChanges(), "ProdioBarCode", "pib_id");
                 MessageBox.Show("保存成功!");
             }
@@ -387,12 +365,6 @@ namespace UAS_LabelMachine
                     return;
                 }
                 CollectInputData();
-                DataTable savedt = (LabelInf.DataSource as DataTable);
-                if (savedt != null && savedt.GetChanges() != null)
-                {
-                    MidSource.EndEdit();
-                    dh.SaveDataTable(savedt.GetChanges(), "ProdioBarCode", "pib_id");
-                }
             }
         }
 
@@ -528,71 +500,75 @@ namespace UAS_LabelMachine
                 if (CollectVeProdCodePass && CollectQTYPass)
                 {
                     //如果按盒号采集,所有的此盒的均更新为
-                    DataTable dt = (DataTable)MidSource.DataSource;
+                    DataTable dt = (DataTable)LabelInf.DataSource;
+                    StringBuilder pibid1 = new StringBuilder();
                     if (CollectionUnit.Text == "盒")
                     {
-                        string la_id = "";
-                        if (SingleLabelCombox.SelectedValue != null)
-                        {
-                            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();
+                        string lotno = "";
+                        string datecode = "";
                         for (int i = 0; i < LabelInf.RowCount; i++)
                         {
                             if (LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString() == LabelInf.Rows[CurrentRowIndex].Cells["pib_outboxcode1"].Value.ToString())
                             {
-                                dt.Rows[i]["pib_lotno"] = LabelInf.Rows[CurrentRowIndex].Cells["pib_lotno"].Value;
-                                dt.Rows[i]["pib_datecode"] = LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode"].Value;
+                                lotno = LabelInf.Rows[CurrentRowIndex].Cells["pib_lotno"].Value.ToString();
+                                datecode = LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode"].Value.ToString();
+                                string pibid = LabelInf.Rows[i].Cells["pib_id1"].Value.ToString();
+                                dt.Rows[i]["pib_lotno"] = lotno;
+                                dt.Rows[i]["pib_datecode"] = datecode;
                                 LabelInf.Rows[i].Cells["pib_ifpick"].Value = true;
                                 LabelInf.Rows[i].Cells["Choose"].Value = true;
+                                pibid1.Append(pibid + ",");
                                 LabelInf.Invalidate();
                                 //当前行的索引随循环增长
                                 CurrentRowIndex = i;
                                 if (SingleLabelAutoPrint.Checked)
                                 {
-                                    if (la_id != "")
-                                        AutoPrintSingleLabel(la_id);
-                                    else
-                                    {
-                                        MessageBox.Show("未维护单盘标签");
-                                        return;
-                                    }
+                                    AutoPrintSingleLabel(pibid);
                                 }
                                 if (MidLabelAutoPrint.Checked)
                                     AutoPrintMidLabel();
                                 SetOutBoxCode2(true);
                             }
                         }
+                        pibid1.Append("1");
+                        sdh.ExecuteSql("update prodiobarcode set pib_ifpick=-1,pib_lotno='" + lotno + "',pib_datecode='" + pib_datecode + "' where pib_id in (" + pibid1 + ")", "update");
                     }
                     else if (CollectionUnit.Text == "全部")
                     {
+                        string lotno = "";
+                        string datecode = "";
                         for (int i = 0; i < LabelInf.RowCount; i++)
                         {
-                            dt.Rows[i]["pib_lotno"] = LabelInf.Rows[CurrentRowIndex].Cells["pib_lotno"].Value;
-                            dt.Rows[i]["pib_datecode"] = LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode"].Value;
+                            lotno = LabelInf.Rows[CurrentRowIndex].Cells["pib_lotno"].Value.ToString();
+                            datecode = LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode"].Value.ToString();
+                            string pibid = LabelInf.Rows[i].Cells["pib_id1"].Value.ToString();
+                            dt.Rows[i]["pib_lotno"] = lotno;
+                            dt.Rows[i]["pib_datecode"] = datecode;
                             CurrentRowIndex = i;
                             LabelInf.Refresh();
                             LabelInf.Rows[i].Cells["pib_ifpick"].Value = true;
                             LabelInf.Rows[i].Cells["Choose"].Value = true;
+                            pibid1.Append(pibid + ",");
                             LabelInf.Invalidate();
                             SetOutBoxCode2(true);
                         }
+                        pibid1.Append("1");
+                        sdh.ExecuteSql("update prodiobarcode set pib_ifpick=-1,pib_lotno='" + lotno + "',pib_datecode='" + pib_datecode + "' where pib_id in (" + pibid1 + ")", "update");
                     }
                     else
                     {
+                        string lotno = LabelInf.Rows[CurrentRowIndex].Cells["pib_lotno"].Value.ToString();
+                        string datecode = LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode"].Value.ToString();
                         LabelInf.Rows[CurrentRowIndex].Cells["pib_ifpick"].Value = true;
                         LabelInf.Rows[CurrentRowIndex].Cells["Choose"].Value = true;
+                        sdh.ExecuteSql("update prodiobarcode set pib_ifpick=-1,pib_lotno='" + lotno + "',pib_datecode='" + pib_datecode + "' where pib_id in (" + pibid1 + ")", "update");
                         LabelInf.Invalidate();
                         //勾选了单盘自动打印
                         if (SingleLabelAutoPrint.Checked)
                         {
                             if (SingleLabelCombox.SelectedValue != null)
                             {
-                                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();
-                                AutoPrintSingleLabel(la_id);
+                                AutoPrintSingleLabel(LabelInf.Rows[CurrentRowIndex].Cells["pib_id1"].Value.ToString());
                             }
                             else
                             {
@@ -703,8 +679,6 @@ namespace UAS_LabelMachine
                 }
             }
             SingleDoc.PrintDocument();
-            SingleDoc.Printer.SwitchTo(SingleLabelPrinter.Text);
-            SingleDoc.PrintDocument();
             LabelInf.Rows[CurrentRowIndex].Cells["pib_ifprint"].Value = true;
         }
 
@@ -824,7 +798,7 @@ namespace UAS_LabelMachine
                         string MatchResult = "";
                         if (kind != "MPN" && kind != "QTY" && kind != "品牌")
                         {
-                            DataTable dt = (DataTable)MidSource.DataSource;
+                            DataTable dt = (DataTable)LabelInf.DataSource;
                             cell.Value = Matchstr;
                             MatchResult = "成功";
                         }
@@ -959,18 +933,6 @@ namespace UAS_LabelMachine
                     }
                     catch (Exception e) { LogManager.DoLog(e.StackTrace); }
                     break;
-                case "二次解析":
-                    if (SiItem[item]["si_indexstring"] != "")
-                    {
-                        //长度不为空的时候按照指定的长度去取数据
-                        if (SiItem[item]["si_length"] != "")
-                            str = str.Substring(str.IndexOf(SiItem[item]["si_indexstring"]) + 1, int.Parse(SiItem[item]["si_length"]));
-                        //长度为空的时候取index之后的全部数据
-                        else
-                            str = str.Substring(str.IndexOf(SiItem[item]["si_indexstring"]) + 1);
-                    }
-                    str = Analysis.AnalysisData(Brand, item, str);
-                    break;
                 case "全部":
                     break;
                 default:
@@ -1041,7 +1003,7 @@ namespace UAS_LabelMachine
             if (SingleLabelCombox.Text != "")
             {
                 SingleDoc = lbl.Documents.Open(ftpOperater.DownLoadTo + SingleLabelCombox.Text);
-                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], "select");
+                SingleLabelParam = (DataTable)dh.ExecuteSql("select lp_name,lp_sql,lp_valuetype from label left join LABELPARAMETER on la_id= lp_laid where la_id=" + SingleLabelCombox.SelectedValue.ToString().Split('#')[0], "select");
                 for (int i = 0; i < SingleDoc.Variables.FreeVariables.Count; i++)
                 {
                     SingleParam.Add(SingleDoc.Variables.FreeVariables.Item(i + 1).Name);
@@ -1070,7 +1032,7 @@ namespace UAS_LabelMachine
             if (MidLabelCombox.Text != "")
             {
                 MidDoc = lbl.Documents.Open(ftpOperater.DownLoadTo + MidLabelCombox.Text);
-                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], "select");
+                MidLabelParam = (DataTable)dh.ExecuteSql("select lp_name,lp_sql,lp_valuetype from label left join LABELPARAMETER on la_id= lp_laid where la_id=" + MidLabelCombox.SelectedValue.ToString().Split('#')[0], "select");
             }
             //缓存中盒参数
             sql.Clear();
@@ -1127,11 +1089,7 @@ namespace UAS_LabelMachine
                     LoadGridData(sender, e);
                     //重新输入单号后清除缓存
                     MidBoxArgument.Clear();
-                    MidBoxCacheData.Clear();
-                    BaseUtil.CleanDataTable(MidBoxCacheData);
                     SingleBoxArgument.Clear();
-                    SingleBoxCacheData.Clear();
-                    BaseUtil.CleanDataTable(SingleBoxCacheData);
                     MidIDAndOutboxcode.Clear();
                     SingleID.Clear();
                     //刷新采集进度
@@ -1182,11 +1140,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,后面会判断需要打印的数据重新加载
@@ -1246,25 +1199,7 @@ namespace UAS_LabelMachine
                         try
                         {
                             string pib_id = LabelInf.Rows[i].Cells["pib_id1"].Value.ToString();
-                            DataRow[] dr = SingleBoxCacheData.Select("pib_id=" + pib_id);
-                            StringBuilder ParamLog = new StringBuilder();
-                            for (int j = 0; j < SingleDoc.Variables.FreeVariables.Count; j++)
-                            {
-                                if (arg.Contains(SingleDoc.Variables.FreeVariables.Item(j + 1).Name))
-                                    SingleDoc.Variables.FreeVariables.Item(j + 1).Value = dr[0][SingleDoc.Variables.FreeVariables.Item(j + 1).Name].ToString();
-                                if (SingleDoc.Variables.FreeVariables.Item(j + 1).Value == "")
-                                {
-                                    DataRow[] dr1 = Attach.Select("lp_name='" + SingleDoc.Variables.FreeVariables.Item(j + 1).Name + "'");
-                                    if (dr1.Length > 0)
-                                    {
-                                        SingleDoc.Variables.FreeVariables.Item(j + 1).Value = dr1[0]["lp_sql"].ToString();
-                                    }
-                                }
-                                ParamLog.AppendLine("pib_id:" + LabelInf.Rows[i].Cells["pib_id1"].Value.ToString() + ",SingleDoc打印参数【" + SingleDoc.Variables.FreeVariables.Item(j + 1).Name + "】赋值," + "取到值" + SingleDoc.Variables.FreeVariables.Item(j + 1).Value);
-                            }
-                            LogManager.DoLog(ParamLog.ToString());
-                            SingleDoc.Printer.SwitchTo(SingleLabelPrinter.Text);
-                            SingleDoc.PrintDocument();
+                            AutoPrintSingleLabel(pib_id);
                             if (MidLabelAutoPrint.Checked)
                             {
                                 //判断当前行的盒号和下一行不相等或者已经是最后一行了
@@ -1274,8 +1209,7 @@ namespace UAS_LabelMachine
                                     {
                                         if (MidLabelCombox.SelectedValue != null)
                                         {
-                                            string la_id_mid = MidLabelCombox.SelectedValue.ToString().Split('#')[0];
-                                            MidBoxCodePrint(la_id_mid, CurrentRowIndex);
+                                            MidBoxCodePrint(CurrentRowIndex);
                                         }
                                     }
                                 }
@@ -1287,8 +1221,6 @@ namespace UAS_LabelMachine
                     }
                 }
                 dh.BatchInsert("update prodiobarcode set pib_printdate=sysdate where pib_id=:pib_id", new string[] { "pib_id" }, SingleID.ToArray());
-                MidBoxCacheData.Clear();
-                BaseUtil.CleanDataTable(MidBoxCacheData);
                 if (CheckedRowCount == 0)
                     MessageBox.Show("未勾选打印明细!");
                 else if (CurrentRowIndex + 1 < LabelInf.Rows.Count)
@@ -1386,11 +1318,8 @@ namespace UAS_LabelMachine
                     }
                 }
                 MidBoxArgument.Clear();
-                MidBoxCacheData.Clear();
-                BaseUtil.CleanDataTable(MidBoxCacheData);
                 List<int> MidOutBoxCode = new List<int>();
                 List<int> MidOutBoxCodeIndex = new List<int>();
-                string la_id = MidLabelCombox.SelectedValue.ToString().Split('#')[0];
                 for (int i = (begin == 0 ? 0 : begin); i <= (end == 0 ? LabelInf.Rows.Count - 1 : end); i++)
                 {
                     if (!MidIDAndOutboxcode.ContainsValue(LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString()))
@@ -1403,19 +1332,14 @@ namespace UAS_LabelMachine
                 }
                 for (int i = 0; i < MidOutBoxCodeIndex.Count; i++)
                 {
-                    MidBoxCodePrint(la_id, MidOutBoxCodeIndex[i]);
+                    MidBoxCodePrint(MidOutBoxCodeIndex[i]);
                 }
                 MidBoxArgument.Clear();
-                MidBoxCacheData.Clear();
-                BaseUtil.CleanDataTable(MidBoxCacheData);
                 return;
             }
             bool FindMidLabel = false;
             if (MidLabelCombox.SelectedValue != null)
             {
-                string la_id = MidLabelCombox.SelectedValue.ToString().Split('#')[0];
-                string cl_labelname = MidLabelCombox.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();
                 //中盒号所在的行
                 int MidLabelRowIndex = 0;
                 //查找是否存在该中盒号
@@ -1433,7 +1357,7 @@ namespace UAS_LabelMachine
                 }
                 //找到了指定的盒号
                 if (FindMidLabel)
-                    MidBoxCodePrint(la_id, MidLabelRowIndex, MidRowIndex.ToArray());
+                    MidBoxCodePrint(MidLabelRowIndex);
                 else
                     MessageBox.Show("该出入库单未找到该中盒号!");
             }
@@ -1458,9 +1382,6 @@ namespace UAS_LabelMachine
         {
             List<string> Outboxcode = new List<string>();
             //如果未勾选箱号则对勾选的数据的箱号进行整合
-            string la_id = OutBoxCombox.SelectedValue.ToString().Split('#')[0];
-            string cl_labelname = OutBoxCombox.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();
             if (OutBoxNum.Text == "")
             {
                 for (int i = 0; i < LabelInf.RowCount; i++)
@@ -1486,7 +1407,7 @@ namespace UAS_LabelMachine
                             {
                                 if (LabelInf.Rows[h].Cells["pib_outboxcode2"].Value.ToString() == Outboxcode.ToArray()[i])
                                 {
-                                    OutBoxCodePrint(la_id, h);
+                                    OutBoxCodePrint(h);
                                     break;
                                 }
                             }
@@ -1518,7 +1439,7 @@ namespace UAS_LabelMachine
                     }
                     //找到了指定的盒号
                     if (FindMidLabel)
-                        OutBoxCodePrint(la_id, OutBoxLabelRowIndex);
+                        OutBoxCodePrint(OutBoxLabelRowIndex);
                     else
                         MessageBox.Show("该出入库单未找到该外箱号!");
                 }
@@ -1527,189 +1448,137 @@ namespace UAS_LabelMachine
             Outboxcode.Clear();
         }
 
-        private void MidBoxCodePrint(string la_id, int rowindex)
+        private void MidBoxCodePrint(int rowindex)
         {
-            if (MidBoxCacheData.Rows.Count == 0)
+            //获取对应行的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.Clear();
+
+            //查询参数名称相同的获取到取值字段
+            for (int j = 0; j < MidDoc.Variables.FormVariables.Count; j++)
             {
-                MidIDAndOutboxcode.Add(LabelInf.Rows[rowindex].Cells["pib_id1"].Value.ToString(), LabelInf.Rows[rowindex].Cells["pib_outboxcode1"].Value.ToString());
+                DataRow[] dr1 = MidLabelParam.Select("lp_name='" + MidDoc.Variables.FormVariables.Item(j + 1).Name + "'");
+                if (dr1.Length > 0 && dr1[0]["lp_valuetype"].ToString() == "字符串")
+                {
+                    sql.Append(dr1[0]["lp_sql"].ToString() + ",");
+                }
             }
-            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");
-            string[] arg = MidBoxArgument.ToArray();
-            for (int j = 0; j < MidDoc.Variables.FreeVariables.Count; j++)
+            sql.Append("1,");
+            DataTable dt = (DataTable)sdh.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++)
             {
-                //将维护的模板参数和模板本身的参数名称进行比对
-                for (int k = 0; k < MidLabelParam.Rows.Count; k++)
+                DataRow[] dr1 = MidLabelParam.Select("lp_name='" + MidDoc.Variables.FormVariables.Item(j + 1).Name + "'");
+                if (dr1.Length == 0)
+                    dr1 = MidLabelParam.Select("lp_name='" + MidDoc.Variables.FormVariables.Item(j + 1).Name.Replace("_1", "") + "'");
+                if (dr1.Length > 0 && dr1[0]["lp_valuetype"].ToString() == "字符串")
                 {
-                    //名称相等的时候,取SQL进行值的查询
-                    if (MidDoc.Variables.FreeVariables.Item(j + 1).Name == MidLabelParam.Rows[k]["lp_name"].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值")
+                {
+                    DataTable dt1 = (DataTable)sdh.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++)
                     {
-                        //获取对应行的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
+                        for (int k = 0; k < MidDoc.Variables.FormVariables.Count; k++)
                         {
-                            //获取打印执行的SQL
-                            if (sql.IndexOf("{") == 0)
+                            if (i == 0 & MidDoc.Variables.FormVariables.Item(k + 1).Name == dr1[0]["lp_name"].ToString())
                             {
-                                MidDoc.Variables.FreeVariables.Item(j + 1).Value = dh.GetLabelParam(sql).ToString();
-                                LogManager.DoLog("打印参数【" + MidDoc.Variables.FreeVariables.Item(j + 1).Name + "】赋值," + "取值SQL:" + dt.Rows[k]["lp_sql"].ToString() + ",取到值" + MidDoc.Variables.FreeVariables.Item(j + 1).Value);
+                                MidDoc.Variables.FormVariables.Item(k + 1).Value = dt1.Rows[0][0].ToString();
                             }
-                            else
+                            //使用SN开头的参数赋值SN1,SN2,SN3等参数
+                            if (MidDoc.Variables.FormVariables.Item(k + 1).Name == (dr1[0]["lp_name"].ToString() + "_" + (i + 1)))
                             {
-                                DataRow[] dr = MidBoxCacheData.Select("pib_outboxcode1='" + pib_outboxcode1 + "'");
-                                if (arg.Contains(MidDoc.Variables.FreeVariables.Item(j + 1).Name))
-                                {
-                                    if (dr.Length > 0)
-                                    {
-                                        MidDoc.Variables.FreeVariables.Item(j + 1).Value = dr[0][MidDoc.Variables.FreeVariables.Item(j + 1).Name].ToString();
-                                    }
-                                }
-                                if (MidDoc.Variables.FreeVariables.Item(j + 1).Value == "")
-                                {
-                                    DataRow[] dr1 = Attach.Select("lp_name='" + MidDoc.Variables.FreeVariables.Item(j + 1).Name + "'");
-                                    if (dr1.Length > 0)
-                                    {
-                                        MidDoc.Variables.FreeVariables.Item(j + 1).Value = dr1[0]["lp_sql"].ToString();
-                                    }
-                                }
-                                LogManager.DoLog("打印参数【" + MidDoc.Variables.FreeVariables.Item(j + 1).Name + "】赋值," + "取值SQL:" + sql + ",取到值" + MidDoc.Variables.FreeVariables.Item(j + 1).Value);
+                                MidDoc.Variables.FormVariables.Item(k + 1).Value = dt1.Rows[i][0].ToString();
                             }
                         }
-                        catch (Exception)
-                        {
-                            LogManager.DoLog("SQL维护不正确,请检查SQL语句\n" + sql);
-                            return;
-                        }
                     }
                 }
+                if (MidDoc.Variables.FormVariables.Item(j + 1).Value == "")
+                {
+                    dr1 = Attach.Select("lp_name='" + MidDoc.Variables.FormVariables.Item(j + 1).Name + "'");
+                    if (dr1.Length > 0)
+                        MidDoc.Variables.FormVariables.Item(j + 1).Value = dr1[0]["lp_sql"].ToString();
+                }
             }
-            MidDoc.Printer.SwitchTo(MidLabelPrinter.Text);
             MidDoc.PrintDocument();
         }
 
-        private void MidBoxCodePrint(string la_id, int rowindex, int[] midindex)
+        private void OutBoxCodePrint(int rowindex)
         {
-            for (int j = 0; j < MidDoc.Variables.FreeVariables.Count; j++)
+            //获取对应行的pib_id
+            string pib_id = LabelInf.Rows[rowindex].Cells["pib_id1"].Value.ToString();
+            string pib_outboxcode2 = LabelInf.Rows[rowindex].Cells["pib_outboxcode2"].Value.ToString();
+            sql.Clear();
+            for (int j = 0; j < OutBoxDoc.Variables.FormVariables.Count; j++)
             {
-                //将维护的模板参数和模板本身的参数名称进行比对
-                for (int k = 0; k < MidLabelParam.Rows.Count; k++)
+                DataRow[] dr1 = OutLabelParam.Select("lp_name='" + OutBoxDoc.Variables.FormVariables.Item(j + 1).Name + "'");
+                if (dr1.Length > 0 && dr1[0]["lp_valuetype"].ToString() == "字符串")
                 {
-                    //名称相等的时候,取SQL进行值的查询
-                    if (MidDoc.Variables.FreeVariables.Item(j + 1).Name == MidLabelParam.Rows[k]["lp_name"].ToString())
+                    sql.Append(dr1[0]["lp_sql"].ToString() + ",");
+                }
+            }
+            sql.Append("1,");
+            DataTable dt = (DataTable)sdh.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++)
+                {
+                    DataRow[] dr1 = OutLabelParam.Select("lp_name='" + OutBoxDoc.Variables.FormVariables.Item(j + 1).Name + "'");
+                    //多参数命名
+                    if (dr1.Length == 0)
+                        dr1 = OutLabelParam.Select("lp_name='" + OutBoxDoc.Variables.FormVariables.Item(j + 1).Name.Replace("_1", "") + "'");
+                    if (dr1.Length > 0 && dr1[0]["lp_valuetype"].ToString() == "字符串")
                     {
-                        //获取对应行的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
+                        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)sdh.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++)
                         {
-                            //获取打印执行的SQL
-                            if (sql.IndexOf("{") == 0)
-                            {
-                                MidDoc.Variables.FreeVariables.Item(j + 1).Value = dh.GetLabelParam(sql).ToString();
-                                LogManager.DoLog("打印参数【" + MidDoc.Variables.FreeVariables.Item(j + 1).Name + "】赋值," + "取值SQL:" + dt.Rows[k]["lp_sql"].ToString() + ",取到值" + MidDoc.Variables.FreeVariables.Item(j + 1).Value);
-                            }
-                            else
+                            for (int k = 0; k < OutBoxDoc.Variables.FormVariables.Count; k++)
                             {
-                                if (sql.ToLower().Contains("pib_qty"))
+                                if (i == 0 & OutBoxDoc.Variables.FormVariables.Item(k + 1).Name == dr1[0]["lp_name"].ToString())
                                 {
-                                    sql = sql.Substring(0, sql.IndexOf("{")) + pib_id + sql.Substring(sql.IndexOf("}") + 1);
-                                    sql = sql.Substring(0, sql.LastIndexOf("=")) + "='" + pib_outboxcode1 + "' group by pib_outboxcode1";
+                                    OutBoxDoc.Variables.FormVariables.Item(k + 1).Value = dt1.Rows[0][0].ToString();
                                 }
-                                else
+                                //使用SN开头的参数赋值SN1,SN2,SN3等参数
+                                if (OutBoxDoc.Variables.FormVariables.Item(k + 1).Name == (dr1[0]["lp_name"].ToString() + "_" + (i + 1)))
                                 {
-                                    sql = sql.Substring(0, sql.IndexOf("{"));
-                                    sql = sql.Substring(0, sql.LastIndexOf("="));
-                                    sql = sql + " in (select distinct pib_outboxcode1 from PRODIOBARCODE where pib_inoutno='" + pi_inoutno.Text + "')" + " and pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode1='" + pib_outboxcode1 + "'";
+                                    OutBoxDoc.Variables.FormVariables.Item(k + 1).Value = dt1.Rows[i][0].ToString();
                                 }
-                                MidDoc.Variables.FreeVariables.Item(j + 1).Value = dh.GetLabelParam(sql).ToString();
-                                if (MidDoc.Variables.FreeVariables.Item(j + 1).Value == "")
+                                if (dr1[0]["lp_sql"].ToString().Contains("pib_year"))
                                 {
-                                    DataRow[] dr1 = Attach.Select("lp_name='" + MidDoc.Variables.FreeVariables.Item(j + 1).Name + "'");
-                                    if (dr1.Length > 0)
-                                    {
-                                        MidDoc.Variables.FreeVariables.Item(j + 1).Value = dr1[0]["lp_sql"].ToString();
-                                    }
+                                    string date = dt1.Rows[0][0].ToString();
                                 }
-                                LogManager.DoLog("打印参数【" + MidDoc.Variables.FreeVariables.Item(j + 1).Name + "】赋值," + "取值SQL:" + sql + ",取到值" + MidDoc.Variables.FreeVariables.Item(j + 1).Value);
                             }
                         }
-                        catch (Exception)
-                        {
-                            LogManager.DoLog("SQL维护不正确,请检查SQL语句\n" + sql);
-                            return;
-                        }
                     }
-                }
-            }
-            MidDoc.Printer.SwitchTo(MidLabelPrinter.Text);
-            MidDoc.PrintDocument();
-        }
-
-        /// <summary>
-        /// 执行打印外箱号
-        /// </summary>
-        private void OutBoxCodePrint(string la_id, int rowindex)
-        {
-            DataTable dt = (DataTable)dh.ExecuteSql("select lp_name,lp_sql,lp_valuetype from label left join LABELPARAMETER on la_id= lp_laid where la_id=" + la_id, "select");
-            try
-            {
-                for (int j = 0; j < OutBoxDoc.Variables.FreeVariables.Count; j++)
-                {
-                    //将维护的模板参数和模板本身的参数名称进行比对
-                    for (int k = 0; k < OutLabelParam.Rows.Count; k++)
+                    if (OutBoxDoc.Variables.FormVariables.Item(j + 1).Value == "")
                     {
-                        //名称相等的时候,取SQL进行值的查询
-                        if (OutBoxDoc.Variables.FreeVariables.Item(j + 1).Name == OutLabelParam.Rows[k]["lp_name"].ToString())
-                        {
-                            //获取对应行的pib_id
-                            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();
-                            //select * from productiobarcode where pib_id={pib_id} and pib_outboxcode1={pib_outboxcode1}
-                            try
-                            {
-                                string ExeSQL = "";
-                                ExeSQL = sql.ToLower().Replace("{pib_id}", "'" + pib_id + "'");
-                                ExeSQL = ExeSQL.Replace("{pib_outboxcode2}", "'" + pib_outboxcode2 + "'");
-                                OutBoxDoc.Variables.FreeVariables.Item(j + 1).Value = dh.GetLabelParam(ExeSQL).ToString();
-                                if (OutBoxDoc.Variables.FreeVariables.Item(j + 1).Value == "")
-                                {
-                                    DataRow[] dr1 = Attach.Select("lp_name='" + OutBoxDoc.Variables.FreeVariables.Item(j + 1).Name + "'");
-                                    if (dr1.Length > 0)
-                                    {
-                                        OutBoxDoc.Variables.FreeVariables.Item(j + 1).Value = dr1[0]["lp_sql"].ToString();
-                                    }
-                                }
-                                LogManager.DoLog("打印参数【" + OutBoxDoc.Variables.FreeVariables.Item(j + 1).Name + "】赋值," + "取值SQL:" + ExeSQL + ",取到值" + OutBoxDoc.Variables.FreeVariables.Item(j + 1).Value);
-                            }
-                            catch (Exception)
-                            {
-                                LogManager.DoLog("SQL维护不正确,请检查SQL语句" + sql);
-                                MessageBox.Show("SQL维护不正确,请检查SQL语句\n" + sql);
-                                return;
-                            }
-                        }
+                        dr1 = Attach.Select("lp_name='" + OutBoxDoc.Variables.FormVariables.Item(j + 1).Name + "'");
+                        if (dr1.Length > 0)
+                            OutBoxDoc.Variables.FormVariables.Item(j + 1).Value = dr1[0]["lp_sql"].ToString();
                     }
                 }
-                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); }
         }
 
         private void CleanDetail_Click(object sender, EventArgs e)
         {
             ArrayList<string> DeleteID = new ArrayList<string>();
+            StringBuilder pibid = new StringBuilder();
             for (int i = 0; i < LabelInf.RowCount; i++)
             {
                 if (LabelInf.Rows[i].Cells["Choose"].FormattedValue.ToString() == "True")
+                {
                     DeleteID.Add(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString());
+                    pibid.Append(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString() + ",");
+                }
             }
             //勾选了删除的明细之后
             if (DeleteID.ToArray().Length > 0)
@@ -1717,6 +1586,8 @@ namespace UAS_LabelMachine
                 string close = MessageBox.Show(this.ParentForm, "删除后不可恢复,是否确认删除", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
                 if (close.ToString() == "Yes")
                 {
+                    pibid.Append("1");
+                    sdh.ExecuteSql("delete from prodiobarcode where pib_id in(" + pibid + ")", "delete");
                     dh.BatchInsert("delete from prodiobarcode where pib_id=:pib_id", new string[] { "pib_id" }, DeleteID.ToArray());
                     MessageBox.Show("删除成功");
                     LoadGridData(sender, e);
@@ -1779,7 +1650,7 @@ namespace UAS_LabelMachine
         {
             LoadGridData(new object(), new EventArgs());
         }
-
+        DataTable LabelInfDataTable;
         /// <summary>
         /// 自定义函数  加载明细行的数据,多处使用添加进函数
         /// </summary>
@@ -1788,32 +1659,26 @@ namespace UAS_LabelMachine
         private void LoadGridData(object sender, EventArgs e)
         {
             AllCollect = false;
-            PrintedVivoOutboxCode.Clear();
-            //如果是富为则使用特殊的查询语句                                
-            if (DataHelper.DBConnectionString.Contains("richwell") || DataHelper.DBConnectionString.Contains("192.168.0.88"))
-            {
-                sql.Clear();
-                sql.Append("select pd_custprodcode,pd_pocode,pd_inoutno,pib_custbarcode,pib_brand,pib_cusbarcode,pib_cusoutboxcode,pib_id,pib_pdid,pib_piid,pib_pdno,pib_prodcode,");
-                sql.Append("pr_brand,pr_vendprodcode,pib_lotno,pib_datecode,pib_qty,pib_barcode,pib_outboxcode1,pib_outboxcode2,pib_ifpick,pib_ifprint,");
-                sql.Append("pr_spec,pd_prodcode,pd_pocode,pr_code from prodiobarcode  left join prodiodetail on pib_piid=pd_piid and pd_pdno=pib_pdno ");
-                sql.Append("and pd_prodcode=pib_prodcode left join product on pr_code=pib_prodcode left join (select pd_prodcode ");
-                sql.Append("prcode,pd_pocode pocode,max(pd_detno) pd_detno from  prodinout left join packing on packing.pi_code=prodinout.pi_packingcode ");
-                sql.Append("left join packingdetail on packing.pi_id=pd_piid where prodinout.pi_id='" + PI_ID + "' group by pd_prodcode,pd_pocode");
-                sql.Append(")A on pd_pocode=A.pocode and pd_prodcode=A.PRCODE where pd_piid='" + PI_ID + "' order by pr_code,a.pd_detno,pib_id");
-                GetOutBoxCode.Visible = true;
-            }
-            else
+            sql.Clear();
+            sql.Append("select * from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "' order by rownum ");
+            LabelInfDataTable = (DataTable)sdh.ExecuteSql(sql.ToString(), "select");
+            if (LabelInfDataTable.Rows.Count == 0)
             {
+                //嵌套查询重置RowNum
                 sql.Clear();
-                sql.Append("select pd_custprodcode,pd_custprodspec,pd_pocode,pib_madein,pib_custbarcode,pib_custoutboxcode,pib_id,pib_datecode1,pib_pdid,pib_piid,pib_pdno,pib_prodcode,nvl(nvl(pd_brand,pib_brand),pr_brand)pib_brand, pr_vendprodcode,");
-                sql.Append("pib_lotno,pib_datecode,pib_qty,pr_spec,pr_zxbzs,pr_unit,pib_barcode,pib_outboxcode1,pib_outboxcode2,nvl(pib_ifpick,0)pib_ifpick,nvl(pib_ifprint,0)pib_ifprint");
-                sql.Append(" from prodiobarcode left join prodiodetail on pib_piid=pd_piid and pd_pdno=pib_pdno and ");
-                sql.Append(" pd_prodcode=pib_prodcode left join product on pr_code=pib_prodcode left join sale on sa_code=pib_ordercode ");
-                sql.Append("where pib_piid='" + PI_ID + "' order by to_number(pib_outboxcode1),pib_id,pd_prodcode");
-            }
-            dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
-            MidSource.DataSource = dt;
-            BaseUtil.FillDgvWithDataTable(LabelInf, (DataTable)MidSource.DataSource);
+                sql.Append("select t.*,rownum from (select pd_ordercode,pib_year,pib_month,pib_day,pr_barcode,pr_detail,pib_custoutboxcode,pib_custmidboxcode,pr_orispeccode,pd_id,pd_custprodcode,pib_indate,pi_date,pib_inoutno,pd_custprodspec,");
+                sql.Append("nvl(pib_ifrecheck,0)pib_ifrecheck,nvl(pib_ifupload,0)pib_ifupload,nvl(pib_ifmodify,0)pib_ifmodify,pd_pocode,pib_madein,pib_custbarcode,pib_id,pib_pdid,pib_piid,");
+                sql.Append("pib_pdno,pib_prodcode,nvl(nvl(pd_brand,pib_brand),pr_brand)pib_brand, pr_vendprodcode,pib_lotno,pib_datecode,pib_qty,pr_spec,pi_title,pr_zxbzs,pr_unit,pib_barcode,pib_outboxcode1,");
+                sql.Append("pib_outboxcode2,nvl(pib_ifpick,0)pib_ifpick,nvl(pib_ifprint,0)pib_ifprint from prodiobarcode left join prodinout on pib_piid=pi_id left join prodiodetail on pib_piid=pd_piid and  ");
+                sql.Append("pd_pdno=pib_pdno and pd_prodcode=pib_prodcode left join product on pr_code=pib_prodcode left join sale on sa_code=pib_ordercode where pib_piid='" + PI_ID + "' order by to_number(pib_id))t");
+                LabelInfDataTable = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
+                //检验查询的字段和本地数据库字段是否匹配
+                sdh.AddColumFromDataTable(LabelInfDataTable, "prodiobarcode");
+                //将数据保存在本地数据库
+                sdh.SaveDataTable(LabelInfDataTable, "prodiobarcode");
+            }
+            bindingsource(LabelInf, LabelInfDataTable);
+            BaseUtil.FillDgvWithDataTable(LabelInf, LabelInfDataTable);
             //有数据的话默认取第一条的品牌去取采集策略
             TotalCount.Text = LabelInf.RowCount.ToString();
             if (LabelInf.RowCount > 0)
@@ -1837,6 +1702,21 @@ namespace UAS_LabelMachine
             }
         }
 
+        delegate void BindDataSource(DataGridView dgv, DataTable dt);//定义委托
+
+        void bindingsource(DataGridView dgv, DataTable dt)
+        {
+            if (dgv.InvokeRequired)
+            {
+                dgv.Invoke(new BindDataSource(bindingsource), new object[] { dgv, dt });
+            }
+            else
+            {
+                dgv.AutoGenerateColumns = false;
+                dgv.DataSource = dt;
+            }
+        }
+
         /// <summary>
         /// 重绘Cell的颜色
         /// </summary>
@@ -1881,43 +1761,6 @@ namespace UAS_LabelMachine
             pr_code.Condition = "  pd_inoutno='" + pi_inoutno.Text + "'";
         }
 
-        private void OutBoxLabelPackage_Click(object sender, EventArgs e)
-        {
-            thread = new Thread(CusLabelPrint);
-            stw = new SetLoadingWindow(thread, "正在打印客户外箱号");
-            BaseUtil.SetFormCenter(stw);
-            stw.ShowDialog();
-        }
-
-        private void CusLabelPrint()
-        {
-            //MaxOutBoxCode = MaxOutBoxCode + 1;
-            List<int> CusOutBoxCode = new List<int>();
-            //统计客户外箱号
-            if (LabelInf.Rows.Count > 0)
-                CusOutBoxCode.Add(0);
-            for (int i = 0; i < LabelInf.Rows.Count; i++)
-            {
-                if (i - 1 > 0 && LabelInf.Rows[i].Cells["pib_ifprint"].FormattedValue.ToString() == "True")
-                {
-                    string cutboxcode = LabelInf.Rows[i].Cells["pib_cusoutboxcode"].Value.ToString();
-                    string nextcutboxcode = LabelInf.Rows[i - 1].Cells["pib_cusoutboxcode"].Value.ToString();
-                    if (cutboxcode != nextcutboxcode)
-                        CusOutBoxCode.Add(i);
-                }
-            }
-            //打印外箱号
-            string la_id = OutBoxCombox.SelectedValue.ToString().Split('#')[0];
-            for (int i = 0; i < CusOutBoxCode.Count; i++)
-            {
-                if (!PrintedVivoOutboxCode.Contains(CusOutBoxCode[i].ToString()))
-                {
-                    OutBoxCodePrint(la_id, CusOutBoxCode[i]);
-                    PrintedVivoOutboxCode.Add(CusOutBoxCode[i].ToString());
-                }
-            }
-        }
-
         private void pr_code_UserControlTextChanged(object sender, EventArgs e)
         {
             //用户在重新勾选后重置采集项目的索引
@@ -1984,8 +1827,7 @@ namespace UAS_LabelMachine
             {
                 if (MidLabelCombox.SelectedValue != null)
                 {
-                    string la_id = MidLabelCombox.SelectedValue.ToString().Split('#')[0];
-                    MidBoxCodePrint(la_id, CurrentRowIndex);
+                    MidBoxCodePrint(CurrentRowIndex);
                 }
                 else
                     MessageBox.Show("未维护中盒模板");
@@ -2177,82 +2019,6 @@ namespace UAS_LabelMachine
             catch (Exception) { }
         }
 
-        /// <summary>
-        /// 获取ViVo的料盘信息
-        /// </summary>
-        /// <param name="sender"></param>
-        /// <param name="e"></param>
-        private void ViVoPlate_Click(object sender, EventArgs e)
-        {
-            thread = new Thread(GetVivoInf);
-            stw = new SetLoadingWindow(thread, "正在获取Vivo箱号");
-            BaseUtil.SetFormCenter(stw);
-            stw.ShowDialog();
-        }
-
-        private void GetVivoInf()
-        {
-            if (LabelInf.Rows.Count > 0)
-            {
-                if (LabelInf.Rows[0].Cells["pib_outboxcode2"].Value != null)
-                {
-                    Vivo_GetPlateID.Service1SoapClient getPlateID = new Vivo_GetPlateID.Service1SoapClient();
-                    Vivo_BoxReelRelation.Service1SoapClient getOutBox = new Vivo_BoxReelRelation.Service1SoapClient();
-                    string VenderCode = dh.GetConfig("VivoCode", "ProdInOut!Sale").ToString();
-                    string CurrentTime = System.DateTime.Now.ToString("yyyyMM");
-                    string Createcode = VenderCode + CurrentTime;
-                    string outboxcode = "";
-                    //装入箱内的数量统计,用于判断是否达到容量
-                    decimal InBoxCount = OutboxCapacity.Value;
-                    for (int i = 0; i < LabelInf.Rows.Count; i++)
-                    {
-                        //勾选了的内容才进行料盘的获取和箱号的维护
-                        if (LabelInf.Rows[i].Cells["Choose"].FormattedValue.ToString() == "True")
-                        {
-                            int amount = int.Parse(LabelInf.Rows[i].Cells["pib_qty"].Value.ToString());
-                            string DateCode = LabelInf.Rows[i].Cells["pib_datecode"].Value.ToString();
-                            string LotNo = LabelInf.Rows[i].Cells["pib_lotno"].Value.ToString();
-                            string OrderCode = LabelInf.Rows[i].Cells["pr_vendprodcode"].Value.ToString();
-                            string custprodcode = LabelInf.Rows[i].Cells["pd_custprodcode"].Value.ToString();
-                            //通过接口获取Vivo料盘号
-                            string custbarcode = getPlateID.getCompID(Createcode, "", custprodcode, VenderCode, LotNo, DateCode, amount, OrderCode, "", "").Replace("T-", "");
-                            LabelInf.Rows[i].Cells["pib_cusbarcode"].Value = custbarcode;
-                            //如果下一行的外箱号和当前行不一致
-                            bool NextBoxDiff = false;
-                            //通过接口维护料盘和外箱关系,需要根据箱内容量计算
-                            //判断下一行箱号不一样重新取一个客户外箱号
-                            if (i - 1 > 0)
-                            {
-                                string CurrentOutBoxCode = LabelInf.Rows[i].Cells["pib_outboxcode2"].Value.ToString();
-                                string NextOutBoxCode = LabelInf.Rows[i - 1].Cells["pib_outboxcode2"].Value.ToString();
-                                if (CurrentOutBoxCode != NextOutBoxCode)
-                                {
-                                    NextBoxDiff = true;
-                                    InBoxCount = OutboxCapacity.Value - 1;
-                                }
-                            }
-                            if (InBoxCount == OutboxCapacity.Value || NextBoxDiff)
-                            {
-                                outboxcode = VenderCode + "-" + CurrentTime + "-" + LabelInf.Rows[i].Cells["pib_id1"].Value.ToString();
-                                InBoxCount = 1;
-                                NextBoxDiff = false;
-                            }
-                            else
-                                InBoxCount = InBoxCount + 1;
-                            //获取信息为T-表示成功获取了信息
-                            string Message = getOutBox.insertBoxReelRelation(Createcode, VenderCode, outboxcode, custbarcode, "", "");
-                            if (Message.Substring(0, 1) == "T")
-                                LabelInf.Rows[i].Cells["pib_cusoutboxcode"].Value = outboxcode;
-                            else
-                                LabelInf.Rows[i].Cells["pib_cusoutboxcode"].Value = Message;
-                        }
-                    }
-                }
-                else
-                    MessageBox.Show("请先维护外箱号");
-            }
-        }
-
         private void ChooseAll_Click(object sender, EventArgs e)
         {
             if (AllChecked)
@@ -2271,24 +2037,31 @@ namespace UAS_LabelMachine
 
         private void LabelInf_CellEndEdit(object sender, DataGridViewCellEventArgs e)
         {
+            StringBuilder pibid = new StringBuilder();
+            string madein = LabelInf.Rows[e.RowIndex].Cells["pib_madein"].Value.ToString();
             if (LabelInf.Columns[e.ColumnIndex].Name == "pib_madein" && CollectionUnit.Text == "盒")
             {
-                string madein = LabelInf.Rows[e.RowIndex].Cells["pib_madein"].Value.ToString();
+
                 string midbox = LabelInf.Rows[e.RowIndex].Cells["pib_outboxcode1"].Value.ToString();
                 for (int i = 0; i < LabelInf.Rows.Count; i++)
                 {
                     if (midbox == LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString())
+                    {
                         LabelInf.Rows[i].Cells["pib_madein"].Value = madein;
+                        pibid.Append(LabelInf.Rows[i].Cells["pib_id1"].Value + ",");
+                    }
                 }
             }
             if (LabelInf.Columns[e.ColumnIndex].Name == "pib_madein" && CollectionUnit.Text == "全部")
             {
-                string madein = LabelInf.Rows[e.RowIndex].Cells["pib_madein"].Value.ToString();
                 for (int i = 0; i < LabelInf.Rows.Count; i++)
                 {
                     LabelInf.Rows[i].Cells["pib_madein"].Value = madein;
+                    pibid.Append(LabelInf.Rows[i].Cells["pib_id1"].Value + ",");
                 }
             }
+            pibid.Append("1");
+            sdh.ExecuteSql("update prodiobarcode set pib_madein='" + madein + "' where pib_id in (" + pibid + ")", "update");
         }
 
         private void ExportData_Click(object sender, EventArgs e)
@@ -2298,7 +2071,7 @@ namespace UAS_LabelMachine
             if (result == DialogResult.OK)
             {
                 ExcelHandler eh = new ExcelHandler();
-                DataTable dt = ((DataTable)MidSource.DataSource).Copy();
+                DataTable dt = ((DataTable)LabelInf.DataSource).Copy();
                 for (int i = dt.Columns.Count - 1; i >= 0; i--)
                 {
                     for (int j = 0; j < LabelInf.Columns.Count; j++)
@@ -2379,5 +2152,26 @@ namespace UAS_LabelMachine
                 LoadGridData(sender, e);
             }
         }
+
+        private void LabelPrinter_UserOnSelectIndexChange(object sender, EventArgs e)
+        {
+            switch ((sender as Control).Parent.Name)
+            {
+                case "SingleLabelPrinter":
+                    if (SingleDoc != null)
+                        SingleDoc.Printer.SwitchTo(SingleLabelPrinter.Text);
+                    break;
+                case "MidLabelPrinter":
+                    if (MidDoc != null)
+                        MidDoc.Printer.SwitchTo(MidLabelPrinter.Text);
+                    break;
+                case "OutBoxPrinter":
+                    if (OutBoxDoc != null)
+                        OutBoxDoc.Printer.SwitchTo(OutBoxLabelPrint.Text);
+                    break;
+                default:
+                    break;
+            }
+        }
     }
 }