Browse Source

正大信维标签打印方法调用逻辑修改提交

caosy 1 year ago
parent
commit
e9c2c1703a

+ 1 - 1
UAS_MES_ZDXW/App.config

@@ -72,7 +72,7 @@
   <applicationSettings>
     <UAS_MES_NEW.Properties.Settings>
       <setting name="MES" serializeAs="String">
-        <value>Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=N_MES;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.101.253)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));</value>
+        <value>Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=N_MES;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.1.81.208)(PORT=11665)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));</value>
       </setting>
     </UAS_MES_NEW.Properties.Settings>
   </applicationSettings>

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

@@ -231,7 +231,7 @@ namespace UAS_MES_NEW.Make
 
                                     for (int i = 0; i < _dt.Rows.Count; i++)
                                     {
-                                        if (Print.BarTender(Tag.ToString(), ref engine, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), Printer.Text, sncode.Text, int.Parse(PrintNum.Text), oMakeCode, pr_code.Text, "彩盒标", "0", out ErrorMessage))
+                                        if (Print.BarTender1(Tag.ToString(), ref engine, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), Printer.Text, sncode.Text, int.Parse(PrintNum.Text), oMakeCode, pr_code.Text, "彩盒标", "0", out ErrorMessage))
                                         {
                                             //提示用户打印成功
                                             OperateResult.AppendText(">>序列号:" + sncode.Text + "打印结束\n", Color.Green);

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

@@ -508,7 +508,7 @@ namespace UAS_MES_NEW.Make
                     //刷新数据
                     EventArgs e = new EventArgs();
                     object sender = null;
-                    if (!Print.BarTender(Tag.ToString(), ref engine, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), Printer.Text, ms_sncode, int.Parse(PrintNum.Text), ma_code, ma_prodcode.Text, "SN标签", "0", out ErrorMessage))
+                    if (!Print.BarTender1(Tag.ToString(), ref engine, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), Printer.Text, ms_sncode, int.Parse(PrintNum.Text), ma_code, ma_prodcode.Text, "SN标签", "0", out ErrorMessage))
                     {
                         OperateResult.AppendText(ErrorMessage + "\n", Color.Red);
                     }

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

@@ -214,7 +214,7 @@ namespace UAS_MES_NEW.Make
                 }
                 //判定通过进行打印 
                 //doc = lbl.Documents.Open(PrintLabel.Text);
-                if (Print.BarTender(Tag.ToString(), ref engine, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), Printer.Text, inputValue.Text, int.Parse(printNum.Text), ms_makecode.Text, pr_code.Text, giftBox.Checked ? "彩盒标" : "机身标", "-1", out errorMessage))
+                if (Print.BarTender1(Tag.ToString(), ref engine, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), Printer.Text, inputValue.Text, int.Parse(printNum.Text), ms_makecode.Text, pr_code.Text, giftBox.Checked ? "彩盒标" : "机身标", "-1", out errorMessage))
                 {
                     //按照打印张数打印
                     OperateResult.AppendText("<<打印成功\n", Color.Green);
@@ -245,7 +245,7 @@ namespace UAS_MES_NEW.Make
                     return;
                 }
                 //doc = lbl.Documents.Open(PrintLabel.Text);
-                if (Print.BarTender(Tag.ToString(), ref engine, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), Printer.Text, inputValue.Text, int.Parse(printNum.Text), ms_makecode.Text, pr_code.Text, "卡通箱标", "-1", out errorMessage))
+                if (Print.BarTender1(Tag.ToString(), ref engine, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), Printer.Text, inputValue.Text, int.Parse(printNum.Text), ms_makecode.Text, pr_code.Text, "卡通箱标", "-1", out errorMessage))
                 {
                     //判断通过,打印
                     OperateResult.AppendText("<<打印成功\n", Color.Green);

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

@@ -338,7 +338,7 @@ namespace UAS_MES_NEW.Make
                                 }
                                 for (int i = 0; i < _dt.Rows.Count; i++)
                                 {
-                                    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 errorMessage))
+                                    if (Print.BarTender1(Tag.ToString(), ref engine, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), Printer.Text, sncode.Text, int.Parse(PrintNum.Text), oMakeCode, ma_prodcode.Text, "机身标", "0", out errorMessage))
                                     {
                                         //提示用户打印成功
                                         OperateResult.AppendText(">>序列号:" + sncode.Text + "打印结束\n", Color.Green);

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

@@ -159,7 +159,7 @@ namespace UAS_MES_NEW.Packing
                     dh.ExecuteSql("update package set pa_printcount=pa_printcount+1 where pa_outboxcode='" + pa_outboxcode.Text + "'", "update");
                     for (int i = 0; i < _dt.Rows.Count; i++)
                     {
-                        if (Print.BarTender(Tag.ToString(), ref engine, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), PrintList.Text, pa_outboxcode.Text, int.Parse(PrintNum.Text), oMakeCode == "" ? pa_makecode.Text : oMakeCode, pr_code.Text, "卡通箱标", "0", out ErrorMessage))
+                        if (Print.BarTender1(Tag.ToString(), ref engine, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), PrintList.Text, pa_outboxcode.Text, int.Parse(PrintNum.Text), oMakeCode == "" ? pa_makecode.Text : oMakeCode, pr_code.Text, "卡通箱标", "0", out ErrorMessage))
                         {
                             OperateResult.AppendText(">>开始打印箱号" + pa_outboxcode.Text + "\n", Color.Black);
                         }

+ 25 - 7
UAS_MES_ZDXW/FunctionCode/Packing/Packing_PackageCollectionWeigh.cs

@@ -14,6 +14,9 @@ using System.IO.Ports;
 using System.IO;
 using System.Text.RegularExpressions;
 using System.Collections.Generic;
+using System.Diagnostics;
+using Seagull.BarTender.Print;
+using HslCommunication;
 
 namespace UAS_MES_NEW.Packing
 {
@@ -23,8 +26,7 @@ namespace UAS_MES_NEW.Packing
         DataTable dt;
         LogStringBuilder sql = new LogStringBuilder();
         AutoSizeFormClass asc = new AutoSizeFormClass();
-        Document doc;
-        ApplicationClass lbl;
+        BarTender.Application engine;
         Thread thread;
         DataTable Dbfind;
         string ErrorMessage = "";
@@ -65,17 +67,27 @@ namespace UAS_MES_NEW.Packing
         {
             try
             {
-                lbl = new ApplicationClass();
-                BaseUtil.WriteLbl();
+                engine = new BarTender.Application();
             }
             catch (Exception ex)
             {
-                OperateResult.AppendText("未正确安装CodeSoft软件\n", Color.Red);
+                OperateResult.AppendText("未正确安装打印软件\n" + ex.Message, Color.Red);
             }
         }
 
         private void Make_PackageCollectionWeigh_Load(object sender, EventArgs e)
         {
+            // 杀死之前全部未关闭的进程
+            Process[] processes = System.Diagnostics.Process.GetProcessesByName("lppa");
+            Process[] processes1 = System.Diagnostics.Process.GetProcessesByName("bartend");
+            for (int i = 0; i < processes1.Length; i++)
+            {
+                processes1[i].Kill();
+            }
+            for (int i = 0; i < processes.Length; i++)
+            {
+                processes[i].Kill();
+            }
             ComList.Text = BaseUtil.GetCacheData("PortName").ToString();
             Baurate.Text = BaseUtil.GetCacheData("BaudRate").ToString();
             //设置DbFind的必须的数据
@@ -235,7 +247,7 @@ namespace UAS_MES_NEW.Packing
                 {
                     dh.ExecuteSql("update package set pa_printcount=pa_printcount+1 where pa_outboxcode='" + pa_outboxcode.Text + "'", "update");
                     //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), oMakeCode == "" ? pa_makecode.Text : oMakeCode, pr_code.Text, "卡通箱标", "0", out ErrorMessage))
+                    if (Print.SinglePrint(Tag.ToString(), engine, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), PrintList.Text, pa_outboxcode.Text, int.Parse(PrintNum.Text), oMakeCode == "" ? pa_makecode.Text : oMakeCode, pr_code.Text, "卡通箱标", "0", out ErrorMessage))
                     {
                         OperateResult.AppendText(">>开始打印箱号" + pa_outboxcode.Text + "\n", Color.Black);
                     }
@@ -494,6 +506,8 @@ namespace UAS_MES_NEW.Packing
                                         OperateResult.AppendText(">>箱号" + pa_outboxcode.Text + "满箱封箱成功\n", Color.Green);
                                         LogicHandler.RecordProdWeight(pa_outboxcode.Text, "CARTON", float.Parse(ActWeigh.ToString()), "kg", User.UserLineCode, pr_code.Text, User.UserSourceCode, User.UserName);
                                         LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, pa_makecode.Text, User.UserLineCode, User.UserSourceCode, "卡通箱称重", "称量完成:" + weight.Text.Trim(), pa_outboxcode.Text, "");
+                                        if (AutoPrint.Checked)
+                                            Print_Click(new object(), new EventArgs());
                                         if (LogicHandler.OutBoxStepPass(pa_outboxcode.Text, ms_makecode, User.UserSourceCode, User.UserCode, "卡通箱:" + pa_outboxcode.Text + "整箱过站", "卡通箱整箱过站", out ErrorMessage))
                                         {
                                             dh.UpdateByCondition("package", "pa_nextstep='" + dh.getFieldDataByCondition("packagedetail left join makeserial on ms_sncode=pd_barcode and ms_makecode=pd_makecode", "max(ms_nextstepcode)", "pd_outboxcode='" + pa_outboxcode.Text + "'").ToString() + "', PA_CURRENTSTEP = '' ", "pa_outboxcode='" + pa_outboxcode.Text + "'");
@@ -591,7 +605,9 @@ namespace UAS_MES_NEW.Packing
 
         private void Make_PackageCollectionWeigh_FormClosing(object sender, FormClosingEventArgs e)
         {
-            BaseUtil.ClosePrint(lbl);
+            if (engine != null)
+                engine.Quit(BarTender.BtSaveOptions.btDoNotSaveChanges);
+            dh.Dispose();
             if (serialPort1.IsOpen)
             {
                 GetData = false;
@@ -629,6 +645,8 @@ namespace UAS_MES_NEW.Packing
                     LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, pa_makecode.Text, User.UserLineCode, User.UserSourceCode, "卡通箱称重", "称量完成:" + weight.Text.Trim(), pa_outboxcode.Text, "");
                     LogicHandler.RecordProdWeight(pa_outboxcode.Text, "CARTON", float.Parse(ActWeigh.ToString()), "kg", User.UserLineCode, pr_code.Text, User.UserSourceCode, User.UserName);
                     string ms_makecode = dh.getFieldDataByCondition("packagedetail", "pd_makecode", "pd_outboxcode = '" + pa_outboxcode.Text + "'").ToString();
+                    if (AutoPrint.Checked)
+                        Print_Click(new object(), new EventArgs());
                     if (LogicHandler.OutBoxStepPass(pa_outboxcode.Text, ms_makecode, User.UserSourceCode, User.UserCode, "卡通箱:" + pa_outboxcode.Text + "整箱过站", "卡通箱整箱过站", out ErrorMessage))
                     {
                         dh.UpdateByCondition("package", "pa_nextstep='" + dh.getFieldDataByCondition("packagedetail left join makeserial on ms_sncode=pd_barcode and ms_makecode=pd_makecode", "max(ms_nextstepcode)", "pd_outboxcode='" + pa_outboxcode.Text + "'").ToString() + "', PA_CURRENTSTEP = '' ", "pa_outboxcode='" + pa_outboxcode.Text + "'");

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

@@ -498,7 +498,7 @@ namespace UAS_MES_NEW.Packing
                         pa_outboxcode.SelectAll();
                     }
                     //doc = lbl.Documents.Open(PrintLabel.Text);
-                    if (Print.BarTender(Tag.ToString(), ref engine, 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.BarTender1(Tag.ToString(), ref engine, 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 - 1
UAS_MES_ZDXW/Login.cs

@@ -93,7 +93,8 @@ namespace UAS_MES_NEW
             //设置选中数据库的链接
             string DBUser = DB.SelectedValue.ToString().Split('#')[0];
             string Address = DB.SelectedValue.ToString().Split('#')[1];
-            DataHelper.DBConnectionString = "Password=select!#%*(;User ID=" + DBUser + ";Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=" + Address + ")(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
+            //DataHelper.DBConnectionString = "Password=select!#%*(;User ID=" + DBUser + ";Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=" + Address + ")(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
+            DataHelper.DBConnectionString = "Password=select!#%*(;User ID=" + DBUser + ";Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.1.81.208)(PORT=11665)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
             SystemInf.CurrentDB = DBUser;
             //设置屏幕的宽高信息
             SystemInf.ScreenWidth = Screen.PrimaryScreen.WorkingArea.Width;

+ 3 - 3
UAS_MES_ZDXW/Properties/Resources.Designer.cs

@@ -19,7 +19,7 @@ namespace UAS_MES_NEW.Properties {
     // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
     // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
     // (以 /str 作为命令选项),或重新生成 VS 项目。
-    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
     [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
     internal class Resources {
@@ -47,8 +47,8 @@ namespace UAS_MES_NEW.Properties {
         }
         
         /// <summary>
-        ///   使用此强类型资源类,为所有资源查找
-        ///   重写当前线程的 CurrentUICulture 属性
+        ///   重写当前线程的 CurrentUICulture 属性,对
+        ///   使用此强类型资源类的所有资源查找执行重写。
         /// </summary>
         [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
         internal static global::System.Globalization.CultureInfo Culture {

+ 3 - 3
UAS_MES_ZDXW/Properties/Settings.Designer.cs

@@ -12,7 +12,7 @@ namespace UAS_MES_NEW.Properties {
     
     
     [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
-    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.6.0.0")]
     internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
         
         private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
@@ -122,8 +122,8 @@ namespace UAS_MES_NEW.Properties {
         [global::System.Configuration.ApplicationScopedSettingAttribute()]
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
         [global::System.Configuration.DefaultSettingValueAttribute("Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=N_MES;Pooling=fal" +
-            "se;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1" +
-            "01.253)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));")]
+            "se;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.1.81.2" +
+            "08)(PORT=11665)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));")]
         public string MES {
             get {
                 return ((string)(this["MES"]));

+ 1 - 1
UAS_MES_ZDXW/Properties/Settings.settings

@@ -27,7 +27,7 @@
       <Value Profile="(Default)">ftp://10.8.0.82|vsftpd|vsftpd</Value>
     </Setting>
     <Setting Name="MES" Type="System.String" Scope="Application">
-      <Value Profile="(Default)">Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=N_MES;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.101.253)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));</Value>
+      <Value Profile="(Default)">Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=N_MES;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.1.81.208)(PORT=11665)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));</Value>
     </Setting>
   </Settings>
 </SettingsFile>

+ 1 - 1
UAS_MES_ZDXW/PublicMethod/LogicHandler.cs

@@ -185,7 +185,7 @@ namespace UAS_MES_NEW.PublicMethod
             }
             else
             {
-                if (User.CurrentStepCode != "B_WEIGH") {
+                if (User.CurrentStepCode != "PACKING") {
                     SetCheck set = new SetCheck("NG", Color.Red);
                     BaseUtil.SetFormCenter(set);
                     set.ShowDialog();

+ 112 - 1
UAS_MES_ZDXW/PublicMethod/Print.cs

@@ -20,9 +20,120 @@ namespace UAS_MES_NEW.PublicMethod
 
         static LabelFormatDocument format;
 
+        static BarTender.Format doc2;
+
         public Print() { }
 
+        public static bool SinglePrint(string iCaller, BarTender.Application 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();
+            if (IfRePrint != "-1")
+            {
+                if (LabelType == "卡通箱标" || LabelType == "彩盒标" || LabelType == "栈板标" || LabelType == "机身标")
+                {
+                    dt = (DataTable)dh.ExecuteSql("select lpl_id from labelprintlog where lpl_value='" + SnCode + "' and lpl_type='" + LabelType + "' and lpl_stepcode='" + User.CurrentStepCode + "'", "select");
+                }
+                else
+                {
+                    dt = (DataTable)dh.ExecuteSql("select lpl_id from labelprintlog where lpl_value='" + SnCode + "' and lpl_makecode='" + MakeCode + "' and lpl_type='" + LabelType + "' and lpl_stepcode='" + User.CurrentStepCode + "'", "select");
+                }
+                //////如果已经打印过了,则不允许再打印
+                //if (dt.Rows.Count > 0)
+                //{
+                //    ErrorMessage = SnCode + LabelType + "已打印";
+                //    return false;
+                //}
+            }
+            //  string filelastwritetime = dh.getFieldDataByCondition("label", "la_lastwritetime", "la_id = '" + LaID + "'").ToString();
+            // FileInfo PrintFile = new FileInfo(LabelName);
+            //打开模板路径
+            //查询模板对应的取值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();
+            //if (!PrintFile.Exists)
+            //{
+            //    MessageBox.Show("打印文件不存在");
+            //    return false;
+            //}
+            //string filechangetime = PrintFile.LastWriteTime.ToString();
+            //if (filechangetime != filelastwritetime)
+            //{
+            //    lbl.Dispose();
+            //    lbl = new Engine();
+            //  //  BaseUtil.WriteLbl();
+            //    filechangetime = PrintFile.LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss");
+            //    string update = "la_lastwritetime = to_date((regexp_substr('" + filechangetime + "','\\d+.+\\d+')),'yyyy-mm-dd hh24:mi:ss')";
+            //    dh.UpdateByCondition("label", update, "la_id = '" + LaID + "'");
+            //}
+            doc2 = lbl.Formats.Open(LabelName);
+            if (doc2 == null)
+            {
+                MessageBox.Show("标签文件打开失败");
+                return false;
+            }
+            //执行全部的SQL
+            for (int i = 0; i < dt.Rows.Count; i++)
+            {
+                string sql = dt.Rows[i]["lp_sql"].ToString();
+                try
+                {
+                    Regex ConnoteA = new Regex("{\\w+}");
+                    foreach (Match mch in ConnoteA.Matches(sql))
+                    {
+                        string x = mch.Value.Trim();
+                        sql = sql.Replace(x, "'" + SnCode + "'");
+                    }
+                    DataTable Param = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
+                    if (Param.Rows.Count == 0)
+                        continue;
+                    //查询的结果的参数个数大于1需要给标签的多个参数赋值
+                    if (Param.Rows.Count > 0)
+                    {
+                        int LoopTime = Param.Rows.Count > 200 ? 200 : Param.Rows.Count;
+                        for (int j = 0; j < LoopTime; j++)
+                        {
+                            for (int k = 0; k < doc2.NamedSubStrings.Count; k++)
+                            {
+                                if (j == 0 & doc2.NamedSubStrings.Item(k + 1).Name.ToUpper() == dt.Rows[i]["lp_name"].ToString().ToUpper())
+                                {
+                                    doc2.SetNamedSubStringValue(doc2.NamedSubStrings.Item(k + 1).Name, Param.Rows[0][0].ToString());
+                                }
+                                //使用SN开头的参数赋值SN1,SN2,SN3等参数
+                                //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))
+                                {
+                                    doc2.SetNamedSubStringValue(doc2.NamedSubStrings.Item(k + 1).Name, Param.Rows[j][0].ToString());
+                                }
+                            }
+                        }
+                    }
+                }
+                catch (System.Exception ex)
+                {
+                    MessageBox.Show("SQL维护不正确" + ex.Message);
+                }
+            }
+            //  LogManager.DoLog(sb.ToString());
+            //保存本次赋值进行打印
+            // doc2.Printer.SwitchTo(PrinterName);
 
+            // 同样标签的份数 
+            doc2.PrintSetup.IdenticalCopiesOfLabel = PrintNum;
+            // 序列标签数 
+            doc2.PrintSetup.NumberSerializedLabels = 1;
+            doc2.PrintSetup.Printer = PrinterName;
+            doc2.PrintOut(false, false);
+            doc2.Close(BarTender.BtSaveOptions.btDoNotSaveChanges);
+            LogicHandler.DoCommandLog(iCaller, User.UserCode, "", User.UserLineCode, User.UserSourceCode, "打印", "成功打印", SnCode, "");
+            LogicHandler.doLabelPrintLog(SnCode, LabelType, MakeCode, ProdCode, User.UserSourceCode, User.CurrentStepCode, IfRePrint, User.UserCode);
+            //打印完毕 
+            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)
         {
             ErrorMessage = "";
@@ -210,7 +321,7 @@ namespace UAS_MES_NEW.PublicMethod
             return true;
         }
 
-        public static bool BarTender(string iCaller, ref Engine 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 BarTender1(string iCaller, ref Engine 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();

+ 15 - 2
UAS_MES_ZDXW/UAS_MES_ZDXW.csproj

@@ -12,6 +12,7 @@
     <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
     <FileAlignment>512</FileAlignment>
     <IsWebBootstrapper>true</IsWebBootstrapper>
+    <TargetFrameworkProfile />
     <PublishUrl>ftp://yitoadt.wicp.io:21/</PublishUrl>
     <Install>true</Install>
     <InstallFrom>Web</InstallFrom>
@@ -41,15 +42,17 @@
     <DefineConstants>DEBUG;TRACE</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
+    <Prefer32Bit>false</Prefer32Bit>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
-    <PlatformTarget>AnyCPU</PlatformTarget>
+    <PlatformTarget>x86</PlatformTarget>
     <DebugType>pdbonly</DebugType>
     <Optimize>true</Optimize>
     <OutputPath>bin\Release\</OutputPath>
     <DefineConstants>TRACE</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
+    <Prefer32Bit>false</Prefer32Bit>
   </PropertyGroup>
   <PropertyGroup>
     <ApplicationIcon>Resources\U_Icon.ico</ApplicationIcon>
@@ -146,7 +149,7 @@
       <SpecificVersion>False</SpecificVersion>
       <HintPath>Tool\Oracle.ManagedDataAccess.dll</HintPath>
     </Reference>
-    <Reference Include="Seagull.BarTender.Print, Version=10.1.4.1, Culture=neutral, PublicKeyToken=109ff779a1b4cbc7, processorArchitecture=x86">
+    <Reference Include="Seagull.BarTender.Print, Version=10.1.3.1, Culture=neutral, PublicKeyToken=109ff779a1b4cbc7, processorArchitecture=x86">
       <SpecificVersion>False</SpecificVersion>
       <HintPath>Tool\Seagull.BarTender.Print.dll</HintPath>
     </Reference>
@@ -1720,6 +1723,7 @@
     <Content Include="Tool\NPOI.dll" />
     <Content Include="Tool\Oracle.DataAccess%2811g%29.dll" />
     <Content Include="Tool\Oracle.ManagedDataAccess.dll" />
+    <Content Include="Tool\Seagull.BarTender.Print.dll" />
     <Content Include="Tool\System.Data.OracleClient.dll" />
     <None Include="Resources\close.png" />
     <Content Include="Resources\close_16px_558195_easyicon.net.png" />
@@ -1793,6 +1797,15 @@
     <Content Include="Resources\zxing_android_code_48px_1107946_easyicon.net.png" />
   </ItemGroup>
   <ItemGroup>
+    <COMReference Include="BarTender">
+      <Guid>{D58562C1-E51B-11CF-8941-00A024A9083F}</Guid>
+      <VersionMajor>11</VersionMajor>
+      <VersionMinor>0</VersionMinor>
+      <Lcid>0</Lcid>
+      <WrapperTool>tlbimp</WrapperTool>
+      <Isolated>False</Isolated>
+      <EmbedInteropTypes>True</EmbedInteropTypes>
+    </COMReference>
     <COMReference Include="LabelManager2">
       <Guid>{3624B9C2-9E5D-11D3-A896-00C04F324E22}</Guid>
       <VersionMajor>6</VersionMajor>