Procházet zdrojové kódy

分离打印方式

章政 před 5 roky
rodič
revize
23d2353d6e

+ 148 - 6
UAS-出货标签管理(贸易版)/PublicMethod/Print.cs

@@ -1,4 +1,5 @@
 using LabelManager2;
+using Seagull.BarTender.Print;
 using System;
 using System.Collections.Generic;
 using System.Data;
@@ -169,17 +170,158 @@ namespace UAS_LabelMachine.PublicMethod
 
         public class BarTender
         {
-            public static void SinglePrint()
+            public static void SinglePrint(LabelFormatDocument SingleFormat, DataTable SingleLabelParam, string pib_id)
             {
-
+                StringBuilder sql = new StringBuilder();
+                sql.Clear();
+                for (int j = 0; j < SingleFormat.SubStrings.Count; j++)
+                {
+                    DataRow[] dr1 = SingleLabelParam.Select("lp_name='" + SingleFormat.SubStrings[j].Name + "'");
+                    if (dr1.Length > 0)
+                    {
+                        if (dr1[0]["lp_valuetype"].ToString() == "字符串")
+                            sql.Append(dr1[0]["lp_sql"].ToString() + ",");
+                    }
+                }
+                sql.Append("1,");
+                DataTable dt = (DataTable)SystemInf.sdh.ExecuteSql("select " + sql.ToString().Substring(0, sql.Length - 1) + " from prodiobarcode where pib_id=" + pib_id, "select");
+                for (int j = 0; j < SingleFormat.SubStrings.Count; j++)
+                {
+                    DataRow[] dr1 = SingleLabelParam.Select("lp_name='" + SingleFormat.SubStrings[j].Name + "'");
+                    if (dr1.Length > 0 && dr1[0]["lp_valuetype"].ToString() == "SQL值")
+                    {
+                        DataTable dt1 = (DataTable)SystemInf.sdh.ExecuteSql(dr1[0]["lp_sql"].ToString().Replace("{1}", pib_id), "select");
+                        if (dt1.Rows.Count > 0)
+                        {
+                            SingleFormat.SubStrings[j].Value = dt1.Rows[0][0].ToString();
+                        }
+                    }
+                    else if (dr1.Length > 0)
+                    {
+                        SingleFormat.SubStrings[j].Value = dt.Rows[0][dr1[0]["lp_sql"].ToString()].ToString();
+                    }
+                    if (SingleFormat.SubStrings[j].Value == "")
+                    {
+                        dr1 = UAS_出货标签打印.Attach.Select("lp_name='" + SingleFormat.SubStrings[j].Name + "'");
+                        if (dr1.Length > 0)
+                            SingleFormat.SubStrings[j].Value = dr1[0]["lp_sql"].ToString();
+                    }
+                }
+                SingleFormat.Print();
             }
-            public static void MidPrint()
-            {
 
-            }
-            public static void OutPrint()
+            public static void MidPrint(LabelFormatDocument MidFormat, DataTable MidLabelParam, string pi_inoutno, string pib_id, string pib_outboxcode1)
             {
+                StringBuilder sql = new StringBuilder();
+                //查询参数名称相同的获取到取值字段
+                for (int j = 0; j < MidFormat.SubStrings.Count; j++)
+                {
+                    DataRow[] dr1 = MidLabelParam.Select("lp_name='" + MidFormat.SubStrings[j].Name + "'");
+                    if (dr1.Length > 0 && dr1[0]["lp_valuetype"].ToString() == "字符串")
+                    {
+                        sql.Append(dr1[0]["lp_sql"].ToString() + ",");
+                    }
+                }
+                sql.Append("1,");
+                DataTable dt = (DataTable)SystemInf.sdh.ExecuteSql("select " + sql.ToString().Substring(0, sql.Length - 1) + " from prodiobarcode where pib_inoutno='" + pi_inoutno + "' and pib_outboxcode1=" + (pib_outboxcode1 == "" ? "0" : pib_outboxcode1), "select");
+                for (int j = 0; j < MidFormat.SubStrings.Count; j++)
+                {
+                    DataRow[] dr1 = MidLabelParam.Select("lp_name='" + MidFormat.SubStrings[j].Name + "'");
+                    if (dr1.Length == 0)
+                        dr1 = MidLabelParam.Select("lp_name='" + MidFormat.SubStrings[j].Name.Replace("_1", "") + "'");
+                    if (dr1.Length > 0 && dr1[0]["lp_valuetype"].ToString() == "字符串")
+                    {
+                        MidFormat.SubStrings[j].Value = dt.Rows[0][dr1[0]["lp_sql"].ToString()].ToString();
+                    }
+                    //SQL判断多个值的时候
+                    if (dr1.Length > 0 && dr1[0]["lp_valuetype"].ToString() == "SQL值")
+                    {
+                        DataTable dt1 = (DataTable)SystemInf.sdh.ExecuteSql(dr1[0]["lp_sql"].ToString().Replace("{1}", "'" + pi_inoutno + "'").Replace("{2}", pib_outboxcode1), "select");
+                        for (int i = 0; i < dt1.Rows.Count; i++)
+                        {
+                            for (int k = 0; k < MidFormat.SubStrings.Count; k++)
+                            {
+                                if (i == 0 & MidFormat.SubStrings[k].Name == dr1[0]["lp_name"].ToString())
+                                {
+                                    MidFormat.SubStrings[k].Value = dt1.Rows[0][0].ToString();
+                                }
+                                //使用SN开头的参数赋值SN1,SN2,SN3等参数
+                                if (MidFormat.SubStrings[k].Name == (dr1[0]["lp_name"].ToString() + "_" + (i + 1)))
+                                {
+                                    MidFormat.SubStrings[k].Value = dt1.Rows[i][0].ToString();
+                                }
+                            }
+                        }
+                    }
+                    if (MidFormat.SubStrings[j].Value == "")
+                    {
+                        dr1 = UAS_出货标签打印.Attach.Select("lp_name='" + MidFormat.SubStrings[j].Name + "'");
+                        if (dr1.Length > 0)
+                            MidFormat.SubStrings[j].Value = dr1[0]["lp_sql"].ToString();
+                    }
+                }
+                MidFormat.Print();
+            }
 
+            public static void OutPrint(LabelFormatDocument OutFormat, DataTable OutLabelParam, string pi_inoutno, string pib_id, string pib_outboxcode2)
+            {
+                StringBuilder sql = new StringBuilder();
+                sql.Clear();
+                for (int j = 0; j < OutFormat.SubStrings.Count; j++)
+                {
+                    DataRow[] dr1 = OutLabelParam.Select("lp_name='" + OutFormat.SubStrings[j].Name + "'");
+                    if (dr1.Length > 0 && dr1[0]["lp_valuetype"].ToString() == "字符串")
+                    {
+                        sql.Append(dr1[0]["lp_sql"].ToString() + ",");
+                    }
+                }
+                sql.Append("1,");
+                DataTable dt = (DataTable)SystemInf.sdh.ExecuteSql("select " + sql.ToString().Substring(0, sql.Length - 1) + " from prodiobarcode where pib_inoutno='" + pi_inoutno + "' and pib_outboxcode2=" + (pib_outboxcode2 == "" ? "0" : pib_outboxcode2), "select");
+                if (dt.Rows.Count > 0)
+                {
+                    for (int j = 0; j < OutFormat.SubStrings.Count; j++)
+                    {
+                        DataRow[] dr1 = OutLabelParam.Select("lp_name='" + OutFormat.SubStrings[j].Name + "'");
+                        //多参数命名
+                        if (dr1.Length == 0)
+                            dr1 = OutLabelParam.Select("lp_name='" + OutFormat.SubStrings[j].Name.Replace("_1", "") + "'");
+                        if (dr1.Length > 0 && dr1[0]["lp_valuetype"].ToString() == "字符串")
+                        {
+                            OutFormat.SubStrings[j].Value = dt.Rows[0][dr1[0]["lp_sql"].ToString()].ToString();
+                        }
+                        //SQL判断多个值的时候
+                        if (dr1.Length > 0 && dr1[0]["lp_valuetype"].ToString() == "SQL值")
+                        {
+                            DataTable dt1 = (DataTable)SystemInf.sdh.ExecuteSql(dr1[0]["lp_sql"].ToString().Replace("{1}", "'" + pi_inoutno + "'").Replace("{2}", pib_outboxcode2), "select");
+                            for (int i = 0; i < dt1.Rows.Count; i++)
+                            {
+                                for (int k = 0; k < OutFormat.SubStrings.Count; k++)
+                                {
+                                    if (i == 0 & OutFormat.SubStrings[k].Name == dr1[0]["lp_name"].ToString())
+                                    {
+                                        OutFormat.SubStrings[k].Value = dt1.Rows[0][0].ToString();
+                                    }
+                                    //使用SN开头的参数赋值SN1,SN2,SN3等参数
+                                    if (OutFormat.SubStrings[k].Name == (dr1[0]["lp_name"].ToString() + "_" + (i + 1)))
+                                    {
+                                        OutFormat.SubStrings[k].Value = dt1.Rows[i][0].ToString();
+                                    }
+                                    if (dr1[0]["lp_sql"].ToString().Contains("pib_year"))
+                                    {
+                                        string date = dt1.Rows[0][0].ToString();
+                                    }
+                                }
+                            }
+                        }
+                        if (OutFormat.SubStrings[j].Value == "")
+                        {
+                            dr1 = UAS_出货标签打印.Attach.Select("lp_name='" + OutFormat.SubStrings[j].Name + "'");
+                            if (dr1.Length > 0)
+                                OutFormat.SubStrings[j].Value = dr1[0]["lp_sql"].ToString();
+                        }
+                    }
+                    OutFormat.Print();
+                }
             }
         }
     }

+ 4 - 0
UAS-出货标签管理(贸易版)/UAS-出货标签管理(贸易版).csproj

@@ -110,6 +110,10 @@
     <Reference Include="Oracle.ManagedDataAccess">
       <HintPath>tool\Oracle.ManagedDataAccess.dll</HintPath>
     </Reference>
+    <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>
     <Reference Include="System" />
     <Reference Include="System.configuration" />
     <Reference Include="System.Core" />

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

@@ -61,7 +61,6 @@
             this.label3 = new System.Windows.Forms.Label();
             this.CleanInputAfterCollect = new System.Windows.Forms.CheckBox();
             this.AllCollected = new System.Windows.Forms.Button();
-            this.RefreshDBConnect = new System.Windows.Forms.Timer(this.components);
             this.GetGridOnly = new System.Windows.Forms.CheckBox();
             this.dataGridViewCheckBoxColumn1 = new System.Windows.Forms.DataGridViewCheckBoxColumn();
             this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
@@ -513,10 +512,6 @@
             this.AllCollected.UseVisualStyleBackColor = true;
             this.AllCollected.Click += new System.EventHandler(this.AllCollected_Click);
             // 
-            // RefreshDBConnect
-            // 
-            this.RefreshDBConnect.Tick += new System.EventHandler(this.RefreshDBConnect_Tick);
-            // 
             // GetGridOnly
             // 
             this.GetGridOnly.AutoSize = true;
@@ -1876,7 +1871,6 @@
         private System.Windows.Forms.Button PowerSetting;
         private System.Windows.Forms.Button GetOutBoxCode;
         private System.Windows.Forms.LinkLabel LogingOut;
-        private System.Windows.Forms.Timer RefreshDBConnect;
         private System.Windows.Forms.CheckBox GetGridOnly;
         private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn16;
         private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn17;

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

@@ -15,6 +15,7 @@ using System.Threading;
 using System.IO;
 using System.Globalization;
 using System.Reflection;
+using Seagull.BarTender.Print;
 
 namespace UAS_LabelMachine
 {
@@ -38,15 +39,15 @@ namespace UAS_LabelMachine
         /// </summary>
         ApplicationClass lbl;
         /// <summary>
-        /// 单盘打印文件
+        /// CodeSoft单盘打印文件
         /// </summary>
         Document SingleDoc;
         /// <summary>
-        /// 中盒打印文件
+        /// CodeSoft中盒打印文件
         /// </summary>
         Document MidDoc;
         /// <summary>
-        /// 外箱打印文件
+        /// CodeSoft外箱打印文件
         /// </summary>
         Document OutBoxDoc;
         /// <summary>
@@ -91,6 +92,22 @@ namespace UAS_LabelMachine
         DataTable SingleLabelParam;
         DataTable MidLabelParam;
         DataTable OutLabelParam;
+        /// <summary>
+        /// BarTender引擎
+        /// </summary>
+        Engine engine;
+        /// <summary>
+        /// BarTender单盘
+        /// </summary>
+        LabelFormatDocument SingleFormat;
+        /// <summary>
+        /// BarTender中盒
+        /// </summary>
+        LabelFormatDocument MidFormat;
+        /// <summary>
+        /// BarTender外箱
+        /// </summary>
+        LabelFormatDocument OutFormat;
 
         Dictionary<string, string> CollectData;
         //缓存单盘数据数据的DataTable
@@ -136,14 +153,14 @@ namespace UAS_LabelMachine
         /// </summary>
         bool ComBoxClickChangeLabelDoc = false;
 
-        List<string> SingleParam = new List<string>();
-
         List<string> MidParam = new List<string>();
 
         List<string> OutParam = new List<string>();
 
         public static DataTable Attach;
 
+        public string PrintMethod = "CodeSoft";
+
         public UAS_出货标签打印(string Master)
         {
             //设置窗体的双缓冲
@@ -157,7 +174,7 @@ namespace UAS_LabelMachine
             Text = Text + "-" + Master;
         }
 
-        protected override void WndProc(ref Message m)
+        protected override void WndProc(ref System.Windows.Forms.Message m)
         {
             //拦截双击标题栏、移动窗体的系统消息
             if (m.Msg != 0xA3)
@@ -170,6 +187,11 @@ namespace UAS_LabelMachine
         {
             //杀死之前全部未关闭的进程
             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();
@@ -211,17 +233,23 @@ namespace UAS_LabelMachine
 
             asc.controllInitializeSize(this);
             asc.controlAutoSize(this);
-            //实例化打印进程
-            try
+            string Code = dh.GetConfig("PrintMethod", "CodeOrBar").ToString();
+            if (Code == "")
             {
-                lbl = new ApplicationClass();
+                try
+                {
+                    lbl = new ApplicationClass();
+                }
+                catch (Exception)
+                {
+                    MessageBox.Show("未安装CodeSoft软件或者版本不正确");
+                }
             }
-            catch (Exception)
+            else
             {
-                MessageBox.Show("未安装CodeSoft软件或者版本不正确");
+                engine = new Engine(true);
+                PrintMethod = "BarTender";
             }
-            RefreshDBConnect.Interval = 60000;
-            RefreshDBConnect.Start();
         }
 
         private void Sg_code_DbChange(object sender, EventArgs e)
@@ -643,7 +671,10 @@ namespace UAS_LabelMachine
 
         private void AutoPrintSingleLabel(string pib_id)
         {
-            Print.CodeSoft.SinglePrint(SingleDoc, SingleLabelParam, pib_id);
+            if (PrintMethod == "CodeSoft")
+                Print.CodeSoft.SinglePrint(SingleDoc, SingleLabelParam, pib_id);
+            else
+                Print.BarTender.SinglePrint(SingleFormat, SingleLabelParam, pib_id);
             LabelInf.Rows[CurrentRowIndex].Cells["pib_ifprint"].Value = true;
         }
 
@@ -955,6 +986,8 @@ namespace UAS_LabelMachine
             SingleLabelCombox.DataSource = dt;
             if (SingleDoc != null)
                 SingleDoc.Close();
+            if (SingleFormat != null)
+                SingleFormat.Close(SaveOptions.DoNotSaveChanges);
             if (!GetGridOnly.Checked)
                 for (int i = 0; i < dt.Rows.Count; i++)
                 {
@@ -967,12 +1000,17 @@ namespace UAS_LabelMachine
                 }
             if (SingleLabelCombox.Text != "")
             {
-                SingleDoc = lbl.Documents.Open(ftpOperater.DownLoadTo + SingleLabelCombox.Text);
-                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++)
+                if (PrintMethod == "CodeSoft")
                 {
-                    SingleParam.Add(SingleDoc.Variables.FreeVariables.Item(i + 1).Name);
+                    SingleDoc = lbl.Documents.Open(ftpOperater.DownLoadTo + SingleLabelCombox.Text);
+                    SingleDoc.Printer.SwitchTo(SingleLabelPrinter.Text);
                 }
+                else
+                {
+                    SingleFormat = engine.Documents.Open(ftpOperater.DownLoadTo + SingleLabelCombox.Text);
+                    SingleFormat.PrintSetup.PrinterName = SingleLabelPrinter.Text;
+                }
+                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");
             }
             sql.Clear();
             sql.Append("select to_char(nvl(cl_date,sysdate),'YYYY-MM-DD HH24:Mi:SS') cl_date,cl_labelname,cl_isdefault,la_id||'#'||cl_labelurl||'#'||to_char(cl_date,'YYYY-MM-DD HH24:Mi:SS')  la_id,cl_custcode from customerlabel left join prodinout on pi_cardcode=cl_custcode ");
@@ -994,9 +1032,19 @@ namespace UAS_LabelMachine
                     if (time.ToString() != file.LastWriteTime.ToString())
                         BaseUtil.GetLabelUrl(LabelUrl, LabelName, time);
                 }
+
             if (MidLabelCombox.Text != "")
             {
-                MidDoc = lbl.Documents.Open(ftpOperater.DownLoadTo + MidLabelCombox.Text);
+                if (PrintMethod == "CodeSoft")
+                {
+                    MidDoc = lbl.Documents.Open(ftpOperater.DownLoadTo + MidLabelCombox.Text);
+                    MidDoc.Printer.SwitchTo(MidLabelPrinter.Text);
+                }
+                else
+                {
+                    MidFormat = engine.Documents.Open(ftpOperater.DownLoadTo + MidLabelCombox.Text);
+                    MidFormat.PrintSetup.PrinterName = MidLabelPrinter.Text;
+                }
                 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");
             }
             //缓存中盒参数
@@ -1022,7 +1070,16 @@ namespace UAS_LabelMachine
                 }
             if (OutBoxCombox.Text != "")
             {
-                OutBoxDoc = lbl.Documents.Open(ftpOperater.DownLoadTo + OutBoxCombox.Text);
+                if (PrintMethod == "CodeSoft")
+                {
+                    OutBoxDoc = lbl.Documents.Open(ftpOperater.DownLoadTo + OutBoxCombox.Text);
+                    OutBoxDoc.Printer.SwitchTo(OutBoxPrinter.Text);
+                }
+                else
+                {
+                    OutFormat = engine.Documents.Open(ftpOperater.DownLoadTo + OutBoxCombox.Text);
+                    OutFormat.PrintSetup.PrinterName = OutBoxPrinter.Text;
+                }
                 OutLabelParam = (DataTable)dh.ExecuteSql("select lp_name,lp_sql,lp_valuetype from label left join LABELPARAMETER on la_id= lp_laid where la_id=" + OutBoxCombox.SelectedValue.ToString().Split('#')[0], "select");
             }
             //缓存外箱参数
@@ -1086,25 +1143,6 @@ namespace UAS_LabelMachine
 
         private void SingleBoxPrint()
         {
-            try
-            {
-                if (SingleDoc.Variables.FreeVariables.Count == 0) { }
-            }
-            catch (Exception)
-            {
-                MessageBox.Show("单盘标签未维护参数");
-            }
-            if (MidLabelAutoPrint.Checked)
-            {
-                try
-                {
-                    if (MidDoc.Variables.FreeVariables.Count == 0) { }
-                }
-                catch (Exception)
-                {
-                    MessageBox.Show("中盘标签未维护参数");
-                }
-            }
             if (SingleLabelParam.Rows.Count > 0 && LabelInf.Rows.Count > 0)
             {
                 //每次打印清除之前缓存的行号和ID,后面会判断需要打印的数据重新加载
@@ -1418,8 +1456,10 @@ namespace UAS_LabelMachine
             //获取对应行的pib_id
             string pib_id = LabelInf.Rows[rowindex].Cells["pib_id1"].Value.ToString();
             string pib_outboxcode1 = LabelInf.Rows[rowindex].Cells["pib_outboxcode1"].Value.ToString();
-            Print.CodeSoft.MidPrint(MidDoc, MidLabelParam, pi_inoutno.Text, pib_id, pib_outboxcode1);
-
+            if (PrintMethod == "CodeSoft")
+                Print.CodeSoft.MidPrint(MidDoc, MidLabelParam, pi_inoutno.Text, pib_id, pib_outboxcode1);
+            else
+                Print.BarTender.MidPrint(MidDoc, MidLabelParam, pi_inoutno.Text, pib_id, pib_outboxcode1);
         }
 
         private void OutBoxCodePrint(int rowindex)
@@ -1427,7 +1467,10 @@ namespace UAS_LabelMachine
             //获取对应行的pib_id
             string pib_id = LabelInf.Rows[rowindex].Cells["pib_id1"].Value.ToString();
             string pib_outboxcode2 = LabelInf.Rows[rowindex].Cells["pib_outboxcode2"].Value.ToString();
-            Print.CodeSoft.OutPrint(OutBoxDoc, OutLabelParam, pi_inoutno.Text, pib_id, pib_outboxcode2);
+            if (PrintMethod == "CodeSoft")
+                Print.CodeSoft.OutPrint(OutBoxDoc, OutLabelParam, pi_inoutno.Text, pib_id, pib_outboxcode2);
+            else
+                Print.BarTender.OutPrint(OutBoxDoc, OutLabelParam, pi_inoutno.Text, pib_id, pib_outboxcode2);
         }
 
         private void CleanDetail_Click(object sender, EventArgs e)
@@ -2000,11 +2043,6 @@ namespace UAS_LabelMachine
             }
         }
 
-        private void RefreshDBConnect_Tick(object sender, EventArgs e)
-        {
-            dh.ExecuteSql("select sysdate from dual", "select");
-        }
-
         private void CleanBarCode_Click(object sender, EventArgs e)
         {
             string close = MessageBox.Show(this.ParentForm, "是否清除该出货单条码", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
@@ -2020,16 +2058,40 @@ namespace UAS_LabelMachine
             switch ((sender as Control).Parent.Name)
             {
                 case "SingleLabelPrinter":
-                    if (SingleDoc != null)
-                        SingleDoc.Printer.SwitchTo(SingleLabelPrinter.Text);
+                    if (PrintMethod == "CodeSoft")
+                    {
+                        if (SingleDoc != null)
+                            SingleDoc.Printer.SwitchTo(SingleLabelPrinter.Text);
+                    }
+                    else
+                    {
+                        if (SingleFormat != null)
+                            SingleFormat.PrintSetup.PrinterName = SingleLabelPrinter.Text;
+                    }
                     break;
                 case "MidLabelPrinter":
-                    if (MidDoc != null)
-                        MidDoc.Printer.SwitchTo(MidLabelPrinter.Text);
+                    if (PrintMethod == "CodeSoft")
+                    {
+                        if (MidDoc != null)
+                            MidDoc.Printer.SwitchTo(MidLabelPrinter.Text);
+                    }
+                    else
+                    {
+                        if (MidFormat != null)
+                            MidFormat.PrintSetup.PrinterName = MidLabelPrinter.Text;
+                    }
                     break;
                 case "OutBoxPrinter":
-                    if (OutBoxDoc != null)
-                        OutBoxDoc.Printer.SwitchTo(OutBoxLabelPrint.Text);
+                    if (PrintMethod == "CodeSoft")
+                    {
+                        if (OutBoxDoc != null)
+                            OutBoxDoc.Printer.SwitchTo(OutBoxLabelPrint.Text);
+                    }
+                    else
+                    {
+                        if (OutFormat != null)
+                            OutFormat.PrintSetup.PrinterName = OutBoxLabelPrint.Text;
+                    }
                     break;
                 default:
                     break;

+ 0 - 3
UAS-出货标签管理(贸易版)/UAS_出货标签管理.resx

@@ -141,9 +141,6 @@
   <metadata name="si_expressionitem.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>
-  <metadata name="RefreshDBConnect.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
-    <value>17, 17</value>
-  </metadata>
   <metadata name="MidSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
     <value>179, 17</value>
   </metadata>

+ 160 - 35
UAS-出货标签管理(贸易版)/客户标签维护.Designer.cs

@@ -33,8 +33,8 @@ namespace UAS_LabelMachine
         private void InitializeComponent()
         {
             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(客户标签维护));
-            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
-            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
+            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
+            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
             this.cl_code_label = new System.Windows.Forms.Label();
             this.cu_name_label = new System.Windows.Forms.Label();
             this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
@@ -47,7 +47,6 @@ namespace UAS_LabelMachine
             this.FolderPath_Label = new System.Windows.Forms.Label();
             this.la_type1 = new System.Windows.Forms.ComboBox();
             this.cl_custcode_label = new System.Windows.Forms.Label();
-            this.dataGridViewCheckBoxColumn1 = new System.Windows.Forms.DataGridViewCheckBoxColumn();
             this.la_code_label = new System.Windows.Forms.Label();
             this.NetURL_label = new System.Windows.Forms.Label();
             this.cl_labeltype_label = new System.Windows.Forms.Label();
@@ -57,6 +56,22 @@ namespace UAS_LabelMachine
             this.FTPShare = new System.Windows.Forms.CheckBox();
             this.CodeSoft = new System.Windows.Forms.RadioButton();
             this.pictureBox1 = new System.Windows.Forms.PictureBox();
+            this.PortModel = new System.Windows.Forms.CheckBox();
+            this.BarTender = new System.Windows.Forms.RadioButton();
+            this.dataGridViewCheckBoxColumn1 = new System.Windows.Forms.DataGridViewCheckBoxColumn();
+            this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.dataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.dataGridViewTextBoxColumn3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.dataGridViewTextBoxColumn4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.dataGridViewTextBoxColumn5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.dataGridViewTextBoxColumn6 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.dataGridViewTextBoxColumn7 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.dataGridViewTextBoxColumn8 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.dataGridViewTextBoxColumn9 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.dataGridViewTextBoxColumn10 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.dataGridViewTextBoxColumn11 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.dataGridViewTextBoxColumn12 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.dataGridViewTextBoxColumn13 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.pagination1 = new UAS_LabelMachine.CustomControl.Pagination();
             this.NewLabel = new UAS_LabelMachine.CustomControl.NormalButton();
             this.NetURL = new UAS_LabelMachine.CustomControl.EnterTextBox();
@@ -85,7 +100,6 @@ namespace UAS_LabelMachine
             this.UpdateGrid = new UAS_LabelMachine.CustomControl.NormalButton();
             this.Screen = new UAS_LabelMachine.CustomControl.NormalButton();
             this.cu_name = new UAS_LabelMachine.CustomControl.EnterTextBox();
-            this.PortModel = new System.Windows.Forms.CheckBox();
             ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.LabelDataGridView)).BeginInit();
             this.SuspendLayout();
@@ -196,12 +210,6 @@ namespace UAS_LabelMachine
             this.cl_custcode_label.TabIndex = 167;
             this.cl_custcode_label.Text = "客户编号";
             // 
-            // dataGridViewCheckBoxColumn1
-            // 
-            this.dataGridViewCheckBoxColumn1.HeaderText = "";
-            this.dataGridViewCheckBoxColumn1.Name = "dataGridViewCheckBoxColumn1";
-            this.dataGridViewCheckBoxColumn1.Width = 30;
-            // 
             // la_code_label
             // 
             this.la_code_label.AutoSize = true;
@@ -277,16 +285,14 @@ namespace UAS_LabelMachine
             // CodeSoft
             // 
             this.CodeSoft.AutoSize = true;
-            this.CodeSoft.Checked = true;
+            this.CodeSoft.Enabled = false;
             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(1058, 86);
+            this.CodeSoft.Location = new System.Drawing.Point(1058, 78);
             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.CodeSoft.Visible = false;
             // 
             // pictureBox1
             // 
@@ -297,6 +303,121 @@ namespace UAS_LabelMachine
             this.pictureBox1.TabIndex = 191;
             this.pictureBox1.TabStop = false;
             // 
+            // PortModel
+            // 
+            this.PortModel.AutoSize = true;
+            this.PortModel.Location = new System.Drawing.Point(923, 116);
+            this.PortModel.Name = "PortModel";
+            this.PortModel.Size = new System.Drawing.Size(96, 16);
+            this.PortModel.TabIndex = 193;
+            this.PortModel.Text = "启用被动模式";
+            this.PortModel.UseVisualStyleBackColor = true;
+            this.PortModel.CheckedChanged += new System.EventHandler(this.PortModel_CheckedChanged);
+            // 
+            // BarTender
+            // 
+            this.BarTender.AutoSize = true;
+            this.BarTender.Enabled = false;
+            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(1058, 110);
+            this.BarTender.Name = "BarTender";
+            this.BarTender.Size = new System.Drawing.Size(106, 25);
+            this.BarTender.TabIndex = 194;
+            this.BarTender.Text = "BarTender";
+            this.BarTender.UseVisualStyleBackColor = true;
+            // 
+            // dataGridViewCheckBoxColumn1
+            // 
+            this.dataGridViewCheckBoxColumn1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
+            this.dataGridViewCheckBoxColumn1.HeaderText = "";
+            this.dataGridViewCheckBoxColumn1.Name = "dataGridViewCheckBoxColumn1";
+            this.dataGridViewCheckBoxColumn1.Resizable = System.Windows.Forms.DataGridViewTriState.False;
+            this.dataGridViewCheckBoxColumn1.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
+            this.dataGridViewCheckBoxColumn1.Width = 30;
+            // 
+            // dataGridViewTextBoxColumn1
+            // 
+            this.dataGridViewTextBoxColumn1.DataPropertyName = "la_id";
+            this.dataGridViewTextBoxColumn1.HeaderText = "la_id";
+            this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1";
+            this.dataGridViewTextBoxColumn1.Visible = false;
+            // 
+            // dataGridViewTextBoxColumn2
+            // 
+            this.dataGridViewTextBoxColumn2.DataPropertyName = "cu_name";
+            this.dataGridViewTextBoxColumn2.HeaderText = "客户名称";
+            this.dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2";
+            this.dataGridViewTextBoxColumn2.ReadOnly = true;
+            // 
+            // dataGridViewTextBoxColumn3
+            // 
+            this.dataGridViewTextBoxColumn3.DataPropertyName = "cl_id";
+            this.dataGridViewTextBoxColumn3.HeaderText = "cl_id";
+            this.dataGridViewTextBoxColumn3.Name = "dataGridViewTextBoxColumn3";
+            this.dataGridViewTextBoxColumn3.Visible = false;
+            // 
+            // dataGridViewTextBoxColumn4
+            // 
+            this.dataGridViewTextBoxColumn4.DataPropertyName = "cl_custcode";
+            this.dataGridViewTextBoxColumn4.HeaderText = "客户编号";
+            this.dataGridViewTextBoxColumn4.Name = "dataGridViewTextBoxColumn4";
+            this.dataGridViewTextBoxColumn4.ReadOnly = true;
+            // 
+            // dataGridViewTextBoxColumn5
+            // 
+            this.dataGridViewTextBoxColumn5.DataPropertyName = "cl_labeltype";
+            this.dataGridViewTextBoxColumn5.HeaderText = "标签类型";
+            this.dataGridViewTextBoxColumn5.Name = "dataGridViewTextBoxColumn5";
+            // 
+            // dataGridViewTextBoxColumn6
+            // 
+            this.dataGridViewTextBoxColumn6.DataPropertyName = "cl_labelcode";
+            this.dataGridViewTextBoxColumn6.HeaderText = "模板编号";
+            this.dataGridViewTextBoxColumn6.Name = "dataGridViewTextBoxColumn6";
+            // 
+            // dataGridViewTextBoxColumn7
+            // 
+            this.dataGridViewTextBoxColumn7.DataPropertyName = "cl_labelurl";
+            this.dataGridViewTextBoxColumn7.HeaderText = "模板路径";
+            this.dataGridViewTextBoxColumn7.Name = "dataGridViewTextBoxColumn7";
+            // 
+            // dataGridViewTextBoxColumn8
+            // 
+            this.dataGridViewTextBoxColumn8.DataPropertyName = "cl_labelname";
+            this.dataGridViewTextBoxColumn8.HeaderText = "模板名称";
+            this.dataGridViewTextBoxColumn8.Name = "dataGridViewTextBoxColumn8";
+            // 
+            // dataGridViewTextBoxColumn9
+            // 
+            this.dataGridViewTextBoxColumn9.DataPropertyName = "cl_date";
+            this.dataGridViewTextBoxColumn9.HeaderText = "最后修改时间";
+            this.dataGridViewTextBoxColumn9.Name = "dataGridViewTextBoxColumn9";
+            // 
+            // dataGridViewTextBoxColumn10
+            // 
+            this.dataGridViewTextBoxColumn10.DataPropertyName = "cl_isdefault";
+            this.dataGridViewTextBoxColumn10.HeaderText = "是否默认";
+            this.dataGridViewTextBoxColumn10.Name = "dataGridViewTextBoxColumn10";
+            // 
+            // dataGridViewTextBoxColumn11
+            // 
+            this.dataGridViewTextBoxColumn11.DataPropertyName = "cl_detno";
+            this.dataGridViewTextBoxColumn11.HeaderText = "序号";
+            this.dataGridViewTextBoxColumn11.Name = "dataGridViewTextBoxColumn11";
+            // 
+            // dataGridViewTextBoxColumn12
+            // 
+            this.dataGridViewTextBoxColumn12.DataPropertyName = "cl_labelsoft";
+            this.dataGridViewTextBoxColumn12.HeaderText = "标签软件";
+            this.dataGridViewTextBoxColumn12.Name = "dataGridViewTextBoxColumn12";
+            // 
+            // dataGridViewTextBoxColumn13
+            // 
+            this.dataGridViewTextBoxColumn13.DataPropertyName = "cl_status";
+            this.dataGridViewTextBoxColumn13.HeaderText = "状态";
+            this.dataGridViewTextBoxColumn13.Name = "dataGridViewTextBoxColumn13";
+            this.dataGridViewTextBoxColumn13.ReadOnly = true;
+            // 
             // pagination1
             // 
             this.pagination1.Cursor = System.Windows.Forms.Cursors.Hand;
@@ -401,16 +522,16 @@ namespace UAS_LabelMachine
             this.cl_status});
             this.LabelDataGridView.Location = new System.Drawing.Point(17, 90);
             this.LabelDataGridView.Name = "LabelDataGridView";
-            dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
-            dataGridViewCellStyle3.BackColor = System.Drawing.Color.Blue;
-            dataGridViewCellStyle3.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            dataGridViewCellStyle3.ForeColor = System.Drawing.SystemColors.WindowText;
-            dataGridViewCellStyle3.SelectionBackColor = System.Drawing.SystemColors.Highlight;
-            dataGridViewCellStyle3.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(128)))));
-            dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
-            this.LabelDataGridView.RowHeadersDefaultCellStyle = dataGridViewCellStyle3;
-            dataGridViewCellStyle4.BackColor = System.Drawing.Color.White;
-            this.LabelDataGridView.RowsDefaultCellStyle = dataGridViewCellStyle4;
+            dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
+            dataGridViewCellStyle1.BackColor = System.Drawing.Color.Blue;
+            dataGridViewCellStyle1.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText;
+            dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight;
+            dataGridViewCellStyle1.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(128)))));
+            dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
+            this.LabelDataGridView.RowHeadersDefaultCellStyle = dataGridViewCellStyle1;
+            dataGridViewCellStyle2.BackColor = System.Drawing.Color.White;
+            this.LabelDataGridView.RowsDefaultCellStyle = dataGridViewCellStyle2;
             this.LabelDataGridView.RowTemplate.Height = 23;
             this.LabelDataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
             this.LabelDataGridView.Size = new System.Drawing.Size(890, 348);
@@ -597,22 +718,12 @@ namespace UAS_LabelMachine
             this.cu_name.TabIndex = 147;
             this.cu_name.Tag = "cu_name";
             // 
-            // PortModel
-            // 
-            this.PortModel.AutoSize = true;
-            this.PortModel.Location = new System.Drawing.Point(923, 116);
-            this.PortModel.Name = "PortModel";
-            this.PortModel.Size = new System.Drawing.Size(96, 16);
-            this.PortModel.TabIndex = 193;
-            this.PortModel.Text = "启用被动模式";
-            this.PortModel.UseVisualStyleBackColor = true;
-            this.PortModel.CheckedChanged += new System.EventHandler(this.PortModel_CheckedChanged);
-            // 
             // 客户标签维护
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(1179, 581);
+            this.Controls.Add(this.BarTender);
             this.Controls.Add(this.PortModel);
             this.Controls.Add(this.pictureBox1);
             this.Controls.Add(this.pagination1);
@@ -716,5 +827,19 @@ namespace UAS_LabelMachine
         private DataGridViewTextBoxColumn cl_status;
         private PictureBox pictureBox1;
         private CheckBox PortModel;
+        private RadioButton BarTender;
+        private DataGridViewTextBoxColumn dataGridViewTextBoxColumn1;
+        private DataGridViewTextBoxColumn dataGridViewTextBoxColumn2;
+        private DataGridViewTextBoxColumn dataGridViewTextBoxColumn3;
+        private DataGridViewTextBoxColumn dataGridViewTextBoxColumn4;
+        private DataGridViewTextBoxColumn dataGridViewTextBoxColumn5;
+        private DataGridViewTextBoxColumn dataGridViewTextBoxColumn6;
+        private DataGridViewTextBoxColumn dataGridViewTextBoxColumn7;
+        private DataGridViewTextBoxColumn dataGridViewTextBoxColumn8;
+        private DataGridViewTextBoxColumn dataGridViewTextBoxColumn9;
+        private DataGridViewTextBoxColumn dataGridViewTextBoxColumn10;
+        private DataGridViewTextBoxColumn dataGridViewTextBoxColumn11;
+        private DataGridViewTextBoxColumn dataGridViewTextBoxColumn12;
+        private DataGridViewTextBoxColumn dataGridViewTextBoxColumn13;
     }
 }

+ 18 - 2
UAS-出货标签管理(贸易版)/客户标签维护.cs

@@ -85,11 +85,19 @@ namespace UAS_LabelMachine
         
         private void 条码维护_Load(object sender, EventArgs e)
         {
+            dh = SystemInf.dh;
             if (Settings.Default.FTPAddress == "")
             {
                 FTPShare.Visible = false;
             }
-            dh = SystemInf.dh;
+            if (dh.GetConfig("PrintMethod", "CodeOrBar").ToString() == "")
+            {
+                CodeSoft.Checked = true;
+            }
+            else
+            {
+                BarTender.Checked = true;
+            }
             condition.Append("");
             ChooseAll.ChooseAll(LabelDataGridView);
             PortModel.Checked = Settings.Default.FTPModel;
@@ -192,6 +200,10 @@ namespace UAS_LabelMachine
             {
                 LabelSoft = "CodeSoft";
             }
+            if (BarTender.Checked)
+            {
+                LabelSoft = "BarTender";
+            }
             DataTable dt = (DataTable)LabelDataGridView.DataSource;
             //如果有改变的行才传递到后台
             if (dt.GetChanges() != null)
@@ -228,6 +240,10 @@ namespace UAS_LabelMachine
             {
                 openFileDialog1.Filter = "(*.lab)|*.lab";
             }
+            if (BarTender.Checked)
+            {
+                openFileDialog1.Filter = "(*.btw)|*.btw";
+            }
             DialogResult result = openFileDialog1.ShowDialog();
             if (result == DialogResult.OK)
             {
@@ -338,7 +354,7 @@ namespace UAS_LabelMachine
                 {
                     ftpOperater ftp = new ftpOperater(PortModel.Checked);
                     ftp.UpLoadFile(sourcePath, fileName);
-                    string SoftWare = "CodeSoft";
+                    string SoftWare = CodeSoft.Checked ? "CodeSoft" : "BarTender";
                     if (CL_ID2 != null)
                     {
                         sql.Clear();