Prechádzať zdrojové kódy

添加修改支持Bartender2016版本打印

callm 5 dní pred
rodič
commit
819b935991

+ 1 - 1
UAS_MES_ZDXW/FunctionCode/Make/Make_ColorBoxLabelPrint.cs

@@ -95,7 +95,7 @@ namespace UAS_MES_NEW.Make
             }
             catch (Exception)
             {
-                OperateResult.AppendText("未正确安装CodeSoft软件\n", Color.Red);
+                OperateResult.AppendText("未正确安装Bartender软件\n", Color.Red);
             }
         }
 

+ 1 - 1
UAS_MES_ZDXW/FunctionCode/Make/Make_ColorBoxLoadPrint.cs

@@ -79,7 +79,7 @@ namespace UAS_MES_NEW.Make
             }
             catch (Exception)
             {
-                OperateResult.AppendText("未正确安装CodeSoft软件\n", Color.Red);
+                OperateResult.AppendText("未正确安装Bartender软件\n", Color.Red);
             }
         }
 

+ 2 - 2
UAS_MES_ZDXW/FunctionCode/Make/Make_ColorBoxLoadPrintBZ.cs

@@ -78,7 +78,7 @@ namespace UAS_MES_NEW.Make
             }
             catch (Exception)
             {
-                OperateResult.AppendText("未正确安装CodeSoft软件\n", Color.Red);
+                OperateResult.AppendText("未正确安装Bartender软件\n", Color.Red);
             }
         }
 
@@ -507,7 +507,7 @@ namespace UAS_MES_NEW.Make
                     //刷新数据
                     EventArgs e = new EventArgs();
                     object sender = null;
-                    if (!Print.CodeSoft(Tag.ToString(), ref lbl, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), Printer.Text, ms_sncode, int.Parse(PrintNum.Text), ma_code, ma_prodcode.Text, "彩盒标", "0", out ErrorMessage))
+                    if (!Print.Bartender(Tag.ToString(), ref lbl, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), Printer.Text, ms_sncode, int.Parse(PrintNum.Text), ma_code, ma_prodcode.Text, "彩盒标", "0", out ErrorMessage))
                     {
                         OperateResult.AppendText(ErrorMessage + "\n", Color.Red);
                     }

+ 2 - 2
UAS_MES_ZDXW/FunctionCode/Make/Make_ColorBoxWeigh.cs

@@ -108,7 +108,7 @@ namespace UAS_MES_NEW.Make
             }
             catch (Exception)
             {
-                OperateResult.AppendText("未正确安装CodeSoft软件\n", Color.Red);
+                OperateResult.AppendText("未正确安装Bartender软件\n", Color.Red);
             }
         }
 
@@ -299,7 +299,7 @@ namespace UAS_MES_NEW.Make
             if (PrintLabel.Items.Count != 0)
             {
                 string oErrorMessage;
-                if (!Print.CodeSoft(Tag.ToString(), ref lbl, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), PrinterList.Text, sncode.Text, int.Parse(PrintNum.Text), ma_code.Text, pr_code.Text, "彩盒标", "0", out oErrorMessage))
+                if (!Print.Bartender(Tag.ToString(), ref lbl, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), PrinterList.Text, sncode.Text, int.Parse(PrintNum.Text), ma_code.Text, pr_code.Text, "彩盒标", "0", out oErrorMessage))
                 {
                     OperateResult.AppendText(oErrorMessage + "\n", Color.Red);
                 }

+ 5 - 7
UAS_MES_ZDXW/FunctionCode/Make/Make_FuselageLabelPrint.cs

@@ -10,6 +10,7 @@ using LabelManager2;
 using System.IO;
 using System.Threading;
 using UAS_MES_NEW.PublicForm;
+using Seagull.BarTender.Print;
 
 namespace UAS_MES_NEW.Make
 {
@@ -28,8 +29,6 @@ namespace UAS_MES_NEW.Make
 
         string ma_unlimitin = "";
 
-        ApplicationClass lbl;
-
         string oMakeCode = "";
         string oMsId = "";
 
@@ -89,17 +88,17 @@ namespace UAS_MES_NEW.Make
             //    BaseUtil.SetFormValue(this.Controls, dt);
             //}
         }
+        public BarTender.Application engine;
 
         private void InPrint()
         {
             try
             {
-                lbl = new ApplicationClass();
-                BaseUtil.WriteLbl();
+                engine = new BarTender.Application();
             }
             catch (Exception ex)
             {
-                OperateResult.AppendText("未正确安装CodeSoft软件\n", Color.Red);
+                OperateResult.AppendText("未正确安装Bartender软件\n", Color.Red);
             }
         }
 
@@ -179,7 +178,7 @@ namespace UAS_MES_NEW.Make
                             OperateResult.AppendText("<<序列号:" + sncode.Text + "\n", Color.Black);
                             //按照打印张数打印
                             //doc = lbl.Documents.Open(PrintLabel.Text);
-                            if (Print.CodeSoft(Tag.ToString(), ref lbl, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), Printer.Text, sncode.Text, int.Parse(PrintNum.Text), oMakeCode, ma_prodcode.Text, "机身标", "0", out oErrorMessage))
+                            if (Print.Bartender(Tag.ToString(), ref engine, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), Printer.Text, sncode.Text, int.Parse(PrintNum.Text), oMakeCode, ma_prodcode.Text, "机身标", "0", out oErrorMessage))
                             {
                                 //提示用户打印成功
                                 OperateResult.AppendText(">>序列号:" + sncode.Text + "打印成功\n", Color.Green);
@@ -263,7 +262,6 @@ namespace UAS_MES_NEW.Make
 
         private void Make_FuselageLabelPrint_FormClosing(object sender, FormClosingEventArgs e)
         {
-            BaseUtil.ClosePrint(lbl);
         }
 
         private void Make_FuselageLabelPrint_SizeChanged(object sender, EventArgs e)

+ 2 - 2
UAS_MES_ZDXW/FunctionCode/Make/Make_GetReMakeSN.cs

@@ -50,7 +50,7 @@ namespace UAS_MES_NEW.Make
             }
             catch (Exception ex)
             {
-                OperateResult.AppendText("未正确安装CodeSoft软件\n", Color.Red);
+                OperateResult.AppendText("未正确安装Bartender软件\n", Color.Red);
             }
         }
 
@@ -330,7 +330,7 @@ namespace UAS_MES_NEW.Make
                                     {
                                         OperateResult.AppendText(">>打印序列号" + sn_code.Text + "\n", Color.Black);
                                         //doc = lbl.Documents.Open(PrintLabel.Text);
-                                        if (!Print.CodeSoft(Tag.ToString(), ref lbl, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), PrinterList.Text, sn_code.Text, int.Parse(PrintNum.Text), ma_code.Text, pr_code.Text, "SN标签", "0", out ErrMessage))
+                                        if (!Print.Bartender(Tag.ToString(), ref lbl, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), PrinterList.Text, sn_code.Text, int.Parse(PrintNum.Text), ma_code.Text, pr_code.Text, "SN标签", "0", out ErrMessage))
                                         {
                                             OperateResult.AppendText(ErrMessage + "\n", Color.Red);
                                             return;

+ 2 - 2
UAS_MES_ZDXW/FunctionCode/Make/Make_SpecialCartonPack.cs

@@ -64,7 +64,7 @@ namespace UAS_MES_NEW.Make
             }
             catch (Exception)
             {
-                OperateResult.AppendText("未正确安装CodeSoft软件\n", Color.Red);
+                OperateResult.AppendText("未正确安装Bartender软件\n", Color.Red);
             }
         }
 
@@ -191,7 +191,7 @@ namespace UAS_MES_NEW.Make
                     dh.ExecuteSql("update package set pa_printcount=pa_printcount+1 where pa_outboxcode='" + pa_outboxcode.Text + "'", "update");
                     OperateResult.AppendText(">>开始打印箱号" + pa_outboxcode.Text + "\n", Color.Black);
                     //doc = lbl.Documents.Open(PrintLabel.Text);
-                    if (!Print.CodeSoft(Tag.ToString(), ref lbl, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), PrintList.Text, pa_outboxcode.Text, int.Parse(PrintNum.Text), ms_makecode.Text, pr_code.Text, "卡通箱标", "0", out ErrorMessage))
+                    if (!Print.Bartender(Tag.ToString(), ref lbl, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), PrintList.Text, pa_outboxcode.Text, int.Parse(PrintNum.Text), ms_makecode.Text, pr_code.Text, "卡通箱标", "0", out ErrorMessage))
                     {
                         OperateResult.AppendText(ErrorMessage + "\n", Color.Red);
                     }

+ 2 - 2
UAS_MES_ZDXW/FunctionCode/Packing/Packing_BigBoxCollection.cs

@@ -51,7 +51,7 @@ namespace UAS_MES_NEW.Packing
             }
             catch
             {
-                OperateResult.AppendText("未正确安装CodeSoft软件\n", Color.Red);
+                OperateResult.AppendText("未正确安装Bartender软件\n", Color.Red);
             }
         }
 
@@ -432,7 +432,7 @@ namespace UAS_MES_NEW.Packing
             {
                 if (dh.getFieldDataByCondition("package", "pa_status", "pa_outboxcode='" + pa_outboxcode.Text + "'").ToString() == "1")
                 {
-                    if (Print.CodeSoft(Tag.ToString(), ref lbl, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), PrinterList.Text, pa_outboxcode.Text, int.Parse(PrintNum.Text), pa_makecode.Text, pa_prodcode.Text, "大箱标", "0", out ErrorMessage))
+                    if (Print.Bartender(Tag.ToString(), ref lbl, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), PrinterList.Text, pa_outboxcode.Text, int.Parse(PrintNum.Text), pa_makecode.Text, pa_prodcode.Text, "大箱标", "0", out ErrorMessage))
                     {
                         OperateResult.AppendText(">>打印箱号" + pa_outboxcode.Text + "\n", Color.Black);
                     }

+ 2 - 2
UAS_MES_ZDXW/FunctionCode/Packing/Packing_BigBoxWeight.cs

@@ -90,7 +90,7 @@ namespace UAS_MES_NEW.Packing
             }
             catch
             {
-                OperateResult.AppendText("未正确安装CodeSoft软件\n", Color.Red);
+                OperateResult.AppendText("未正确安装Bartender软件\n", Color.Red);
             }
         }
 
@@ -140,7 +140,7 @@ namespace UAS_MES_NEW.Packing
                         {
                             //doc = lbl.Documents.Open(ftpOperater.DownLoadTo + PrintLabel.Text);
                             string ErrorMessage = "";
-                            if (!Print.CodeSoft(Tag.ToString(), ref lbl, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), Printer.Text, pa_outboxcode.Text, int.Parse(PrintNum.Text), pa_makecode.Text, pa_prodcode.Text, "大箱标", "0", out ErrorMessage))
+                            if (!Print.Bartender(Tag.ToString(), ref lbl, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), Printer.Text, pa_outboxcode.Text, int.Parse(PrintNum.Text), pa_makecode.Text, pa_prodcode.Text, "大箱标", "0", out ErrorMessage))
                             {
                                 OperateResult.AppendText(ErrorMessage + "\n", Color.Red);
                             }

+ 2 - 2
UAS_MES_ZDXW/FunctionCode/Packing/Packing_CartonBoxSNWeigh.cs

@@ -106,7 +106,7 @@ namespace UAS_MES_NEW.Packing
             }
             catch (Exception)
             {
-                OperateResult.AppendText("未正确安装CodeSoft软件\n", Color.Red);
+                OperateResult.AppendText("未正确安装Bartender软件\n", Color.Red);
             }
         }
 
@@ -255,7 +255,7 @@ namespace UAS_MES_NEW.Packing
         {
             //doc = lbl.Documents.Open(PrintLabel.Text);
             string ErrorMessage = "";
-            if (!Print.CodeSoft(Tag.ToString(), ref lbl, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), PrinterList.Text, outboxcode, int.Parse(PrintNum.Text), ma_code.Text, pr_code.Text, "卡通箱标", "0", out ErrorMessage))
+            if (!Print.Bartender(Tag.ToString(), ref lbl, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), PrinterList.Text, outboxcode, int.Parse(PrintNum.Text), ma_code.Text, pr_code.Text, "卡通箱标", "0", out ErrorMessage))
             {
                 OperateResult.AppendText(ErrorMessage + "\n", Color.Red);
             }

+ 2 - 2
UAS_MES_ZDXW/FunctionCode/Packing/Packing_CartonBoxWeigh.cs

@@ -94,7 +94,7 @@ namespace UAS_MES_NEW.Packing
             }
             catch (Exception)
             {
-                OperateResult.AppendText("未正确安装CodeSoft软件\n", Color.Red);
+                OperateResult.AppendText("未正确安装Bartender软件\n", Color.Red);
             }
         }
 
@@ -232,7 +232,7 @@ namespace UAS_MES_NEW.Packing
         {
             //doc = lbl.Documents.Open(PrintLabel.Text);
             string ErrorMessage = "";
-            if (!Print.CodeSoft(Tag.ToString(), ref lbl, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), PrinterList.Text, outboxcode.Text, int.Parse(PrintNum.Text), ma_code.Text, pr_code.Text, "卡通箱标", "0", out ErrorMessage))
+            if (!Print.Bartender(Tag.ToString(), ref lbl, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), PrinterList.Text, outboxcode.Text, int.Parse(PrintNum.Text), ma_code.Text, pr_code.Text, "卡通箱标", "0", out ErrorMessage))
             {
                 OperateResult.AppendText(ErrorMessage + "\n", Color.Red);
             }

+ 1 - 1
UAS_MES_ZDXW/FunctionCode/Packing/Packing_PackageCollection.cs

@@ -52,7 +52,7 @@ namespace UAS_MES_NEW.Packing
             }
             catch (Exception ex)
             {
-                OperateResult.AppendText("未正确安装CodeSoft软件\n" + ex.Message, Color.Red);
+                OperateResult.AppendText("未正确安装Bartender软件\n" + ex.Message, Color.Red);
             }
         }
 

+ 2 - 2
UAS_MES_ZDXW/FunctionCode/Packing/Packing_PalletCollection.cs

@@ -56,7 +56,7 @@ namespace UAS_MES_NEW.Packing
             }
             catch
             {
-                OperateResult.AppendText("未正确安装CodeSoft软件\n", Color.Red);
+                OperateResult.AppendText("未正确安装Bartender软件\n", Color.Red);
             }
         }
 
@@ -423,7 +423,7 @@ namespace UAS_MES_NEW.Packing
                         outboxcode.SelectAll();
                     }
                     //doc = lbl.Documents.Open(PrintLabel.Text);
-                    if (Print.CodeSoft(Tag.ToString(), ref lbl, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), PrinterList.Text, pa_outboxcode.Text, int.Parse(PrintNum.Text), pa_makecode.Text, pa_prodcode.Text, "栈板标", "0", out ErrorMessage))
+                    if (Print.Bartender(Tag.ToString(), ref lbl, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), PrinterList.Text, pa_outboxcode.Text, int.Parse(PrintNum.Text), pa_makecode.Text, pa_prodcode.Text, "栈板标", "0", out ErrorMessage))
                     {
                         OperateResult.AppendText(">>打印栈板" + pa_outboxcode.Text + "\n", Color.Black);
                     }

+ 2 - 2
UAS_MES_ZDXW/FunctionCode/Packing/Packing_PalletWeigh.cs

@@ -79,7 +79,7 @@ namespace UAS_MES_NEW.Packing
             }
             catch (Exception ex)
             {
-                OperateResult.AppendText("未正确安装CodeSoft软件\n", Color.Red);
+                OperateResult.AppendText("未正确安装Bartender软件\n", Color.Red);
             }
         }
 
@@ -167,7 +167,7 @@ namespace UAS_MES_NEW.Packing
                                 }
                                 //doc = lbl.Documents.Open(PrintLabel.Text);
                                 string ErrorMessage = "";
-                                if (Print.CodeSoft(Tag.ToString(), ref lbl, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), Printer.Text, palletcode.Text, int.Parse(PrintNum.Text), pa_makecode.Text, pa_prodcode.Text, "栈板标", "0", out ErrorMessage))
+                                if (Print.Bartender(Tag.ToString(), ref lbl, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), Printer.Text, palletcode.Text, int.Parse(PrintNum.Text), pa_makecode.Text, pa_prodcode.Text, "栈板标", "0", out ErrorMessage))
                                 {
                                     //打印成功,请输入栈板号
                                     OperateResult.AppendText("<<打印成功\n", Color.Green);

+ 1 - 1
UAS_MES_ZDXW/FunctionCode/Packing/Packing_PalletWightCollection.cs

@@ -75,7 +75,7 @@ namespace UAS_MES_NEW.Packing
             }
             catch
             {
-                OperateResult.AppendText("未正确安装CodeSoft软件\n", Color.Red);
+                OperateResult.AppendText("未正确安装Bartender软件\n", Color.Red);
             }
         }
 

+ 1 - 1
UAS_MES_ZDXW/FunctionCode/Query/Query_SpecialReport.cs

@@ -100,7 +100,7 @@ namespace UAS_MES_NEW.Query
             }
             catch (Exception)
             {
-                MessageBox.Show("未正确安装CodeSoft软件");
+                MessageBox.Show("未正确安装Bartender软件");
             }
         }
 

+ 14 - 14
UAS_MES_ZDXW/FunctionCode/SystemSetting/SystemSetting_LabelMaintain.Designer.cs

@@ -34,7 +34,7 @@
             this.pr_spec_label = new System.Windows.Forms.Label();
             this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
             this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog();
-            this.CodeSoft = new System.Windows.Forms.RadioButton();
+            this.Bartender = new System.Windows.Forms.RadioButton();
             this.labelSoft_label = new System.Windows.Forms.Label();
             this.label1 = new System.Windows.Forms.Label();
             this.la_name = new System.Windows.Forms.TextBox();
@@ -115,18 +115,18 @@
             // 
             this.openFileDialog1.FileName = "openFileDialog1";
             // 
-            // CodeSoft
+            // Bartender
             // 
-            this.CodeSoft.AutoSize = true;
-            this.CodeSoft.Checked = true;
-            this.CodeSoft.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.CodeSoft.Location = new System.Drawing.Point(968, 12);
-            this.CodeSoft.Name = "CodeSoft";
-            this.CodeSoft.Size = new System.Drawing.Size(99, 25);
-            this.CodeSoft.TabIndex = 161;
-            this.CodeSoft.TabStop = true;
-            this.CodeSoft.Text = "CodeSoft";
-            this.CodeSoft.UseVisualStyleBackColor = true;
+            this.Bartender.AutoSize = true;
+            this.Bartender.Checked = true;
+            this.Bartender.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.Bartender.Location = new System.Drawing.Point(968, 12);
+            this.Bartender.Name = "Bartender";
+            this.Bartender.Size = new System.Drawing.Size(99, 25);
+            this.Bartender.TabIndex = 161;
+            this.Bartender.TabStop = true;
+            this.Bartender.Text = "Bartender";
+            this.Bartender.UseVisualStyleBackColor = true;
             // 
             // labelSoft_label
             // 
@@ -642,7 +642,7 @@
             this.Controls.Add(this.LabelDataGridView);
             this.Controls.Add(this.label1);
             this.Controls.Add(this.labelSoft_label);
-            this.Controls.Add(this.CodeSoft);
+            this.Controls.Add(this.Bartender);
             this.Controls.Add(this.pr_code);
             this.Controls.Add(this.UpdateGrid);
             this.Controls.Add(this.Screen);
@@ -677,7 +677,7 @@
         private System.Windows.Forms.OpenFileDialog openFileDialog1;
         private System.Windows.Forms.FolderBrowserDialog folderBrowserDialog1;
         private CustomControl.TextBoxWithIcon.SearchTextBox pr_code;
-        private System.Windows.Forms.RadioButton CodeSoft;
+        private System.Windows.Forms.RadioButton Bartender;
         private System.Windows.Forms.Label labelSoft_label;
         private System.Windows.Forms.Label label1;
         private CustomControl.DataGrid_View.DataGridViewWithSerialNum LabelDataGridView;

+ 7 - 7
UAS_MES_ZDXW/FunctionCode/SystemSetting/SystemSetting_LabelMaintain.cs

@@ -26,7 +26,7 @@ namespace UAS_MES_NEW.SystemSetting
         //用于拼接条件查询
         StringBuilder condition = new StringBuilder();
         LogStringBuilder sql = new LogStringBuilder();
-        /*CodeSoft新建打印机引擎*/
+        /*Bartender新建打印机引擎*/
         ApplicationClass lbl;
         Document doc;
         /*BarTender新建打印机引擎*/
@@ -136,7 +136,7 @@ namespace UAS_MES_NEW.SystemSetting
             }
             catch (Exception ex)
             {
-                MessageBox.Show("未正确安装codesoft");
+                MessageBox.Show("未正确安装Bartender");
             }
         }
         private void La_code_DbChange(object sender, EventArgs e)
@@ -162,7 +162,7 @@ namespace UAS_MES_NEW.SystemSetting
                     LabelCode = LabelDataGridView.Rows[e.RowIndex].Cells["pl_labelcode"].Value.ToString();
                     pl_id1 = LabelDataGridView.Rows[e.RowIndex].Cells["pl_id"].Value.ToString();
                     La_id1 = LabelDataGridView.Rows[e.RowIndex].Cells["la_id"].Value.ToString();
-                    if (CodeSoft.Checked)
+                    if (Bartender.Checked)
                     {
                         string LabelName = LabelDataGridView.Rows[e.RowIndex].Cells["pl_labelname"].Value.ToString();
                         doc = lbl.Documents.Open(BaseUtil.GetLabelUrl(LabelPath, LabelName));
@@ -256,9 +256,9 @@ namespace UAS_MES_NEW.SystemSetting
         {
             string LabelSoft = "";
             //需要处理新增的行和原有数据然后更新的行
-            if (CodeSoft.Checked)
+            if (Bartender.Checked)
             {
-                LabelSoft = "CodeSoft";
+                LabelSoft = "Bartender";
             }
             DataTable dt = (DataTable)LabelDataGridView.DataSource;
             //如果有改变的行才传递到后台
@@ -323,7 +323,7 @@ namespace UAS_MES_NEW.SystemSetting
         private void OpenFolder_Click(object sender, EventArgs e)
         {
             //根据勾选的不同设置不同的文件后缀过滤
-            if (CodeSoft.Checked)
+            if (Bartender.Checked)
             {
                 openFileDialog1.Filter = "(*.lab)|*.lab";
             }
@@ -453,7 +453,7 @@ namespace UAS_MES_NEW.SystemSetting
             {
                 if (FTPShare.Checked)
                 {
-                    string SoftWare = "CodeSoft";
+                    string SoftWare = "Bartender";
                   
                     ftp.UpLoadFile(FolderPath.Text, la_name.Text,SavePath.Text);
                     if (pl_id2 != "")

+ 33 - 18
UAS_MES_ZDXW/PublicMethod/Print.cs

@@ -7,15 +7,16 @@ using UAS_MES_NEW.Entity;
 using System.Text.RegularExpressions;
 using System.Windows.Forms;
 using Seagull.BarTender.Print;
+using System;
 
 namespace UAS_MES_NEW.PublicMethod
 {
     class Print
     {
         static DataHelper dh = SystemInf.dh;
-        //CodeSoft打印的驱动和文件
+        //Bartender打印的驱动和文件
         static Document doc;
-        ////CodeSoft的打印机
+        ////Bartender的打印机
         //string CodeSpft_Printer;
 
         static LabelFormatDocument format;
@@ -134,7 +135,8 @@ namespace UAS_MES_NEW.PublicMethod
             lbl.Quit(BarTender.BtSaveOptions.btDoNotSaveChanges);
             return true;
         }
-        public static bool CodeSoft(string iCaller, Document doc, string LabelName, string LaID, string PrinterName, string SnCode, int PrintNum, string MakeCode, string ProdCode, string LabelType, string IfRePrint, out string ErrorMessage)
+
+        public static bool Bartender(string iCaller, ref BarTender.Application doc, string LabelName, string LaID, string PrinterName, string SnCode, int PrintNum, string MakeCode, string ProdCode, string LabelType, string IfRePrint, out string ErrorMessage)
         {
             ErrorMessage = "";
             DataTable dt = new DataTable();
@@ -159,6 +161,16 @@ namespace UAS_MES_NEW.PublicMethod
             //查询模板对应的取值SQL和参数名称
             dt = (DataTable)dh.ExecuteSql("select lp_name,lp_sql from label left join LABELPARAMETER on la_id=lp_laid where la_id='" + LaID + "'", "select");
             StringBuilder sb = new StringBuilder();
+
+            try
+            {
+                doc2 = doc.Formats.Open(LabelName);
+            }
+            catch (System.Exception)
+            {
+                doc2 = doc.Formats.Open(LabelName);
+            }
+
             if (doc == null)
             {
                 MessageBox.Show("打印文件不存在");
@@ -182,44 +194,47 @@ namespace UAS_MES_NEW.PublicMethod
                     //查询的结果的参数个数大于1需要给标签的多个参数赋值
                     if (Param.Rows.Count > 0)
                     {
-                        int LoopTime = Param.Rows.Count > 100 ? 100 : Param.Rows.Count;
+                        int LoopTime = Param.Rows.Count > 200 ? 200 : Param.Rows.Count;
                         for (int j = 0; j < LoopTime; j++)
                         {
-                            for (int k = 0; k < doc.Variables.FormVariables.Count; k++)
+                            for (int k = 0; k < doc2.NamedSubStrings.Count; k++)
                             {
-                                if (j == 0 & doc.Variables.FormVariables.Item(k + 1).Name.ToUpper() == dt.Rows[i]["lp_name"].ToString().ToUpper())
+                                if (j == 0 & doc2.NamedSubStrings.Item(k + 1).Name.ToUpper() == dt.Rows[i]["lp_name"].ToString().ToUpper())
                                 {
-                                    doc.Variables.FormVariables.Item(k + 1).Value = Param.Rows[0][0].ToString();
+                                    doc2.SetNamedSubStringValue(doc2.NamedSubStrings.Item(k + 1).Name, Param.Rows[0][0].ToString());
                                 }
                                 //使用SN开头的参数赋值SN1,SN2,SN3等参数
-                                if (doc.Variables.FormVariables.Item(k + 1).Name.ToUpper() == dt.Rows[i]["lp_name"].ToString().ToUpper() + (j + 1))
+                                //if (j != 0 & doc2.NamedSubStrings.Item(k + 1).Name.ToUpper() == dt.Rows[i]["lp_name"].ToString().ToUpper() + (j))
+                                //{
+                                //    doc2.SetNamedSubStringValue(doc2.NamedSubStrings.Item(k + 1).Name, Param.Rows[j][0].ToString());
+                                //}
+                                if (doc2.NamedSubStrings.Item(k + 1).Name.ToUpper() == dt.Rows[i]["lp_name"].ToString().ToUpper() + (j + 1))
                                 {
-                                    doc.Variables.FormVariables.Item(k + 1).Value = Param.Rows[j][0].ToString();
+                                    doc2.SetNamedSubStringValue(doc2.NamedSubStrings.Item(k + 1).Name, Param.Rows[j][0].ToString());
                                 }
                             }
                         }
                     }
                 }
-                catch (System.Exception)
+                catch (Exception)
                 {
                     MessageBox.Show("SQL维护不正确");
                 }
             }
             LogManager.DoLog(sb.ToString());
-            //保存本次赋值进行打印
-            doc.Printer.SwitchTo(PrinterName);
-            doc.PrintDocument(PrintNum);
+            //保存本次赋值进行打印a
+            doc2.PrintSetup.IdenticalCopiesOfLabel = PrintNum;
+            // 序列标签数 
+            doc2.PrintSetup.NumberSerializedLabels = 1;
+            doc2.PrintSetup.Printer = PrinterName;
+            doc2.PrintOut(false, false);
             LogicHandler.DoCommandLog(iCaller, User.UserCode, "", User.UserLineCode, User.UserSourceCode, "打印", "成功打印", SnCode, "");
-            for (int k = 0; k < doc.Variables.FormVariables.Count; k++)
-            {
-                doc.Variables.FormVariables.Item(k + 1).Value = null;
-            }
             LogicHandler.doLabelPrintLog(SnCode, LabelType, MakeCode, ProdCode, User.UserSourceCode, User.CurrentStepCode, IfRePrint, User.UserCode);
             return true;
         }
 
 
-        public static bool CodeSoft(string iCaller, ref ApplicationClass lbl, string LabelName, string LaID, string PrinterName, string SnCode, int PrintNum, string MakeCode, string ProdCode, string LabelType, string IfRePrint, out string ErrorMessage)
+        public static bool Bartender(string iCaller, ref ApplicationClass lbl, string LabelName, string LaID, string PrinterName, string SnCode, int PrintNum, string MakeCode, string ProdCode, string LabelType, string IfRePrint, out string ErrorMessage)
         {
             ErrorMessage = "";
             DataTable dt = new DataTable();