章政 vor 6 Jahren
Ursprung
Commit
9a535db433

+ 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";

+ 16 - 44
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();
@@ -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;

+ 57 - 197
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
@@ -214,22 +212,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);
             //实例化打印进程
@@ -703,8 +686,6 @@ namespace UAS_LabelMachine
                 }
             }
             SingleDoc.PrintDocument();
-            SingleDoc.Printer.SwitchTo(SingleLabelPrinter.Text);
-            SingleDoc.PrintDocument();
             LabelInf.Rows[CurrentRowIndex].Cells["pib_ifprint"].Value = true;
         }
 
@@ -959,18 +940,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:
@@ -1182,11 +1151,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 +1210,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)
                             {
                                 //判断当前行的盒号和下一行不相等或者已经是最后一行了
@@ -1585,7 +1531,6 @@ namespace UAS_LabelMachine
                     }
                 }
             }
-            MidDoc.Printer.SwitchTo(MidLabelPrinter.Text);
             MidDoc.PrintDocument();
         }
 
@@ -1645,7 +1590,6 @@ namespace UAS_LabelMachine
                     }
                 }
             }
-            MidDoc.Printer.SwitchTo(MidLabelPrinter.Text);
             MidDoc.PrintDocument();
         }
 
@@ -1696,7 +1640,6 @@ namespace UAS_LabelMachine
                         }
                     }
                 }
-                OutBoxDoc.Printer.SwitchTo(OutBoxPrinter.Text);
                 OutBoxDoc.PrintDocument();
                 LogManager.DoLog("执行打印外箱,pib_id:" + LabelInf.Rows[rowindex].Cells["pib_id1"].Value.ToString());
             }
@@ -1779,7 +1722,7 @@ namespace UAS_LabelMachine
         {
             LoadGridData(new object(), new EventArgs());
         }
-
+        DataTable LabelInfDataTable;
         /// <summary>
         /// 自定义函数  加载明细行的数据,多处使用添加进函数
         /// </summary>
@@ -1788,32 +1731,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 +1774,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 +1833,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)
         {
             //用户在重新勾选后重置采集项目的索引
@@ -2177,82 +2092,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)
@@ -2379,5 +2218,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;
+            }
+        }
     }
 }