Explorar o código

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

caosy %!s(int64=6) %!d(string=hai) anos
pai
achega
52bd0c3d1b

+ 4 - 1
UAS-MES/FunctionCode/Make/Make_FeedingCollection.cs

@@ -212,6 +212,9 @@ namespace UAS_MES.Make
                                 string cm_status = dt.Rows[0]["cm_status"].ToString();
                                 string cm_makecode = dt.Rows[0]["cm_makecode"].ToString();
                                 string cm_craftcode = dt.Rows[0]["cm_craftcode"].ToString();
+                                sql.Clear();
+                                sql.Append("update makeserial set ms_nextstepcode=ms_stepcode where ms_id=" + oMsid);
+                                dh.ExecuteSql(sql.GetString(), "update");
                                 //清除已被使用的序列号
                                 sql.Clear();
                                 sql.Append("update makeserial set ms_nextmacode='' where ms_sncode in(select cm_barcode from craftmaterial where ");
@@ -369,7 +372,7 @@ namespace UAS_MES.Make
             sql.Append("sp_regex,max(pr_detail)pr_detail from stepproduct left join product on pr_code=sp_fsoncode where ");
             sql.Append("sp_bomversion='" + ms_bomversion.Text + "' and sp_craftcode='" + ms_craftcode.Text + "' and sp_stepcode='" + User.CurrentStepCode + "' ");
             sql.Append("And sp_mothercode ='" + ma_prodcode.Text + "' and sp_tracekind=1 and not exists(select 1 from craftmaterial where ");
-            sql.Append("cm_sncode in (select '" + ms_firstsn + "' from dual union select sn from makesnrelation where firstsn='" + ms_firstsn + "') and cm_makecode='" + ma_code.Text + "' and cm_fsoncode=");
+            sql.Append("cm_sncode in (select '" + ms_firstsn + "' from dual union select sn from makesnrelation where firstsn='" + ms_firstsn + "') and cm_fsoncode=");
             sql.Append("sp_fsoncode and cm_status=0) group by sp_fsoncode order by SP_DETNO asc");
             dt1 = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
             code.Clear();

+ 0 - 1
UAS-MES/FunctionCode/Make/Make_SMTStencil.cs

@@ -198,7 +198,6 @@ namespace UAS_MES.Make
                 {
                     MessageBox.Show("人员编号" + em_code1.Text + "不存在");
                 }
-
             }
             else
             {

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

@@ -338,7 +338,6 @@ namespace UAS_LabelMachine.CustomControl
             }
             try
             {
-                Console.WriteLine(sql);
                 dt = (DataTable)dh.ExecuteSql(sql, "select");
                 if (dt.Rows.Count > 0)
                     ReturnDataToForm();

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

@@ -11,27 +11,28 @@ namespace UAS_LabelMachine
     public class DataHelper
     {
 
-        //海创外网地址
-        private readonly string ConnectionStrings = "Data Source=cmityj.gicp.net/orcl;User ID=HC_TEST;PassWord=select!#%*(";
-        //海创ERP地址
-        public static readonly string ERPAddesss = "http://cmityj.gicp.net:8099/ERP/";
-        //海创FTP
-        public static readonly string FTPAdress = "ftp://cmityj.gicp.net|HCFTP|Admin1@#";
-        //Oracle端口
-        public static readonly string OraclePort = "1521";
-        //需要显示的账套
-        public static readonly string Masters = "HC_TEST";
-
-        ////富为外网地址
-        //private readonly string ConnectionStrings = "Data Source=richwellgroup.com.cn/orcl;User ID=DATACENTER;PassWord=select!#%*(";
-        ////富为ERP地址
-        //public static readonly string ERPAddesss = "http://richwellgroup.com.cn:8099/ERP/";
-        ////富为FTP
-        //public static readonly string FTPAdress = "ftp://richwellgroup.com.cn|printuser|printuser";
+        ////海创外网地址
+        //private readonly string ConnectionStrings = "Data Source=cmityj.gicp.net/orcl;User ID=HC_TEST;PassWord=select!#%*(";
+        ////海创ERP地址
+        //public static readonly string ERPAddesss = "http://cmityj.gicp.net:8099/ERP/";
+        ////海创FTP
+        //public static readonly string FTPAdress = "ftp://cmityj.gicp.net|HCFTP|Admin1@#";
         ////Oracle端口
         //public static readonly string OraclePort = "1521";
         ////需要显示的账套
-        //public static readonly string Masters = "JDTSY,FW_JDT,N_DATACENTER,FY_TEST,JD_TEST,XY_TEST,FW_TEST,DATACENTER,FW,XY,FY";
+        //public static readonly string Masters = "HC_TEST";
+
+        //高登地址
+        private readonly string ConnectionStrings = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=DATACENTER;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=183.238.39.179)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
+        //高登ERP地址
+        public static readonly string ERPAddesss = "http://183.238.39.179:8099/ERP/";
+        //高登TP
+        //public static readonly string FTPAdress = "ftp://192.168.0.158:21|GOLDENFTP|Admin1@#";
+        public static readonly string FTPAdress = "ftp://183.238.39.179:21|GOLDENFTP|Admin1@#";
+        //Oracle端口
+        public static readonly string OraclePort = "1521";
+        //需要显示的账套
+        public static readonly string Masters = "GOLDEN";
 
         ////怡海能达外网地址
         //private readonly string ConnectionStrings = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=DATACENTER;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=sz.hi-mantech.com)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
@@ -843,11 +844,23 @@ namespace UAS_LabelMachine
             switch (Type.ToUpper())
             {
                 case "SELECT":
-                    result = new DataTable();
-                    OracleDataAdapter ad = new OracleDataAdapter(command);
-                    ad.Fill((DataTable)result);
-                    ad.Dispose();
-                    //成功执行后将重复连接数置为0
+                    try
+                    {
+                        result = new DataTable();
+                        OracleDataAdapter ad = new OracleDataAdapter(command);
+                        ad.Fill((DataTable)result);
+                        ad.Dispose();
+                    }
+                    catch (Exception)
+                    {
+                        connection = new OracleConnection(DBConnectionString);
+                        connection.Open();
+                        command.Connection = connection;
+                        result = new DataTable();
+                        OracleDataAdapter ad = new OracleDataAdapter(command);
+                        ad.Fill((DataTable)result);
+                        ad.Dispose();
+                    }
                     break;
                 case "DELETE":
                     result = command.ExecuteNonQuery();

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

@@ -1,4 +1,5 @@
 using LabelManager2;
+using Seagull.BarTender.Print;
 using System;
 using System.Collections.Generic;
 using System.Data;
@@ -69,8 +70,6 @@ namespace UAS_LabelMachine.PublicMethod
                 for (int j = 0; j < MidDoc.Variables.FormVariables.Count; j++)
                 {
                     DataRow[] dr1 = MidLabelParam.Select("lp_name='" + MidDoc.Variables.FormVariables.Item(j + 1).Name + "'");
-                    if (dr1.Length == 0)
-                        dr1 = MidLabelParam.Select("lp_name='" + MidDoc.Variables.FormVariables.Item(j + 1).Name.Replace("_1", "") + "'");
                     if (dr1.Length > 0 && dr1[0]["lp_valuetype"].ToString() == "字符串")
                     {
                         MidDoc.Variables.FormVariables.Item(j + 1).Value = dt.Rows[0][dr1[0]["lp_sql"].ToString()].ToString();
@@ -124,9 +123,6 @@ namespace UAS_LabelMachine.PublicMethod
                     for (int j = 0; j < OutBoxDoc.Variables.FormVariables.Count; j++)
                     {
                         DataRow[] dr1 = OutLabelParam.Select("lp_name='" + OutBoxDoc.Variables.FormVariables.Item(j + 1).Name + "'");
-                        //多参数命名
-                        if (dr1.Length == 0)
-                            dr1 = OutLabelParam.Select("lp_name='" + OutBoxDoc.Variables.FormVariables.Item(j + 1).Name.Replace("_1", "") + "'");
                         if (dr1.Length > 0 && dr1[0]["lp_valuetype"].ToString() == "字符串")
                         {
                             OutBoxDoc.Variables.FormVariables.Item(j + 1).Value = dt.Rows[0][dr1[0]["lp_sql"].ToString()].ToString();
@@ -169,17 +165,153 @@ 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) + " limit 0,1", "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[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) + " limit 0,1", "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[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();
+                }
             }
         }
     }

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

@@ -172,21 +172,6 @@ namespace UAS_LabelMachine
         public void SaveDataTable(DataTable dt, string TableName)
         {
             StringBuilder sb = new StringBuilder();
-            //预防插入的DataTable中存在不属于该表的列,在进行下一步操作之前全部剔除
-            //DataTable data = (DataTable)ExecuteSql("select top 1 * from " + TableName, "select");
-            ////将所有的字段拼接起来
-            //for (int i = 0; i < data.Columns.Count; i++)
-            //{
-            //    sb.Append("#" + data.Columns[i].ColumnName.ToString().ToUpper());
-            //}
-            ////移除掉所有不属于该表的列
-            //for (int i = dt.Columns.Count - 1; i >= 0; i--)
-            //{
-            //    if (!sb.ToString().Contains(dt.Columns[i].ColumnName.ToUpper()))
-            //    {
-            //        dt.Columns.RemoveAt(i);
-            //    }
-            //}
             sb.Clear();
             sb.Append("insert into " + TableName + " (");
             string field = "";
@@ -240,21 +225,58 @@ namespace UAS_LabelMachine
 
         public void BatchInsert(string tableName, DataTable dt)
         {
-            List<string> columnList = new List<string>();
-            foreach (DataColumn one in dt.Columns)
+            StringBuilder sb = new StringBuilder();
+            sb.Clear();
+            sb.Append("update  " + tableName + " set  ");
+            for (int i = 0; i < dt.Columns.Count; i++)
             {
-                columnList.Add(one.ColumnName);
+                if (dt.Columns[i].ColumnName.ToUpper() != "PIB_ID")
+                {
+                    if (i != dt.Columns.Count - 1)
+                    {
+                        sb.Append(dt.Columns[i].ColumnName + "=?,");
+                    }
+                    else
+                    {
+                        sb.Append(dt.Columns[i].ColumnName + "=?");
+                    }
+                }              
             }
-            SQLiteDataAdapter adapter = new SQLiteDataAdapter();
-            adapter.SelectCommand = new SQLiteCommand("select pib_id from " + tableName, this._odcConnection);
-            using (SQLiteCommandBuilder builder = new SQLiteCommandBuilder(adapter))
+            sb.Append("where pib_id=?");
+            SQLiteTransaction tx = this._odcConnection.BeginTransaction();
+            command = new SQLiteCommand();
+            command.Connection = this._odcConnection;
+            command.Transaction = tx;
+            string sql = sb.ToString();
+            try
             {
-                adapter.InsertCommand = builder.GetInsertCommand();
-                foreach (string one in columnList)
+                for (int i = 0; i < dt.Rows.Count; i++)
                 {
-                    adapter.InsertCommand.Parameters.Add(new SQLiteParameter(one.ToLower(), "Test"));
+                    command.CommandText = sql;
+                    for (int j = 0; j < dt.Columns.Count; j++)
+                    {
+                        if (dt.Columns[j].ColumnName.ToUpper() != "PIB_ID")
+                            command.Parameters.AddWithValue(dt.Columns[j].ColumnName, dt.Rows[i][j]);
+                    }
+                    command.Parameters.AddWithValue("pib_id", dt.Rows[i]["pib_id"]);
+                    try
+                    {
+                        command.ExecuteNonQuery();
+                        command.Parameters.Clear();
+                    }
+                    catch (Exception e)
+                    {
+                        MessageBox.Show(e.Message.ToString());
+                    }
                 }
+                tx.Commit();
             }
+            catch (Exception E)
+            {
+                tx.Rollback();
+                throw new Exception(E.Message);
+            }
+
         }
 
         /// <summary>
@@ -502,7 +524,6 @@ namespace UAS_LabelMachine
         {
             object result = null;
             command = new SQLiteCommand(SQL, this._odcConnection);
-            Console.WriteLine(SQL);
             Reconnect(command);
             switch (Type.ToUpper())
             {

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

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

@@ -55,13 +55,11 @@
             this.si_expressionitem = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.CleanDetail = new System.Windows.Forms.Button();
             this.pib_id = new System.Windows.Forms.Label();
-            this.pi_cardcode = new System.Windows.Forms.Label();
             this.pi_cardcode_label = new System.Windows.Forms.Label();
             this.Fresh = new System.Windows.Forms.LinkLabel();
             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();
@@ -125,38 +123,17 @@
             this.sg_code = new UAS_LabelMachine.CustomControl.SearchTextBox();
             this.MessageLog = new UAS_LabelMachine.CustomControl.RichText.RichTextAutoBottom();
             this.LabelInf = new UAS_LabelMachine.CustomControl.DataGridViewWithSerialNum();
-            this.Choose = new System.Windows.Forms.DataGridViewCheckBoxColumn();
-            this.pib_ifpick = new System.Windows.Forms.DataGridViewCheckBoxColumn();
-            this.pib_ifprint = new System.Windows.Forms.DataGridViewCheckBoxColumn();
-            this.pib_id1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pib_pdno = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pib_prodcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pr_vendprodcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pib_brand = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pib_madein = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pr_zxbzs = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pr_unit = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pib_lotno = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pib_datecode = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pib_cusbarcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pib_cusoutboxcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pib_datecode1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pib_qty = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pib_barcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pib_custbarcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pd_pocode = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pd_custprodcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pd_custprodspec = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pr_spec = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pib_outboxcode1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pib_outboxcode2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.pi_inoutno = new UAS_LabelMachine.CustomControl.EnterTextBox();
             this.SingleLabel = new UAS_LabelMachine.CustomControl.GroupBoxWithBorder.GroupBoxWithBorder();
+            this.label8 = new System.Windows.Forms.Label();
+            this.SingleDocRefresh = new System.Windows.Forms.LinkLabel();
             this.SingleLabelPrinter = new UAS_LabelMachine.CustomControl.PrinterCombox();
             this.SingleLabelPrint = new System.Windows.Forms.Button();
             this.SingleLabelAutoPrint = new System.Windows.Forms.CheckBox();
             this.SingleLabelCombox = new System.Windows.Forms.ComboBox();
             this.MidLabel = new UAS_LabelMachine.CustomControl.GroupBoxWithBorder.GroupBoxWithBorder();
+            this.label9 = new System.Windows.Forms.Label();
+            this.MidDocRefresh = new System.Windows.Forms.LinkLabel();
             this.MidLabelNum = new UAS_LabelMachine.CustomControl.EnterTextBox();
             this.label5 = new System.Windows.Forms.Label();
             this.label4 = new System.Windows.Forms.Label();
@@ -167,6 +144,8 @@
             this.MidLabelAutoPrint = new System.Windows.Forms.CheckBox();
             this.MidLabelCombox = new System.Windows.Forms.ComboBox();
             this.OutBoxLabel = new UAS_LabelMachine.CustomControl.GroupBoxWithBorder.GroupBoxWithBorder();
+            this.label19 = new System.Windows.Forms.Label();
+            this.OutDocRefresh = new System.Windows.Forms.LinkLabel();
             this.LogingOut = new System.Windows.Forms.LinkLabel();
             this.GetOutBoxCode = new System.Windows.Forms.Button();
             this.OutBoxNum = new UAS_LabelMachine.CustomControl.EnterTextBox();
@@ -177,6 +156,30 @@
             this.OutBoxLabelPrint = new System.Windows.Forms.Button();
             this.OutBoxLabelAutoPrint = new System.Windows.Forms.CheckBox();
             this.OutBoxCombox = new System.Windows.Forms.ComboBox();
+            this.cu_code = new UAS_LabelMachine.CustomControl.SearchTextBox();
+            this.Choose = new System.Windows.Forms.DataGridViewCheckBoxColumn();
+            this.pib_ifpick = new System.Windows.Forms.DataGridViewCheckBoxColumn();
+            this.pib_ifprint = new System.Windows.Forms.DataGridViewCheckBoxColumn();
+            this.pib_id1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pib_pdno = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pib_prodcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pr_vendprodcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pib_brand = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pib_madein = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pr_zxbzs = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pr_unit = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pib_lotno = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pib_datecode = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pib_datecode1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pib_qty = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pib_barcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pib_custbarcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pd_pocode = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pd_custprodcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pd_custprodspec = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pr_spec = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pib_outboxcode1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pib_outboxcode2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             ((System.ComponentModel.ISupportInitialize)(this.Si_ItemDGV)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.MidSource)).BeginInit();
             this.groupBoxWithBorder1.SuspendLayout();
@@ -449,15 +452,6 @@
             this.pib_id.TabIndex = 69;
             this.pib_id.Visible = false;
             // 
-            // pi_cardcode
-            // 
-            this.pi_cardcode.AutoSize = true;
-            this.pi_cardcode.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.pi_cardcode.Location = new System.Drawing.Point(77, 38);
-            this.pi_cardcode.Name = "pi_cardcode";
-            this.pi_cardcode.Size = new System.Drawing.Size(0, 20);
-            this.pi_cardcode.TabIndex = 71;
-            // 
             // pi_cardcode_label
             // 
             this.pi_cardcode_label.AutoSize = true;
@@ -513,10 +507,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;
@@ -756,6 +746,7 @@
             this.AttachInfo.TabIndex = 85;
             this.AttachInfo.Text = "附加信息设置";
             this.AttachInfo.UseVisualStyleBackColor = true;
+            this.AttachInfo.Visible = false;
             this.AttachInfo.Click += new System.EventHandler(this.AttachInfo_Click);
             // 
             // pi_date
@@ -1139,8 +1130,8 @@
             // LabelInf
             // 
             this.LabelInf.AllowUserToAddRows = false;
-            this.LabelInf.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.AllCells;
-            this.LabelInf.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells;
+            this.LabelInf.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.DisplayedCells;
+            this.LabelInf.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.DisplayedCells;
             this.LabelInf.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
             this.LabelInf.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
             this.Choose,
@@ -1156,8 +1147,6 @@
             this.pr_unit,
             this.pib_lotno,
             this.pib_datecode,
-            this.pib_cusbarcode,
-            this.pib_cusoutboxcode,
             this.pib_datecode1,
             this.pib_qty,
             this.pib_barcode,
@@ -1179,203 +1168,6 @@
             this.LabelInf.CellValueChanged += new System.Windows.Forms.DataGridViewCellEventHandler(this.LabelInf_CellValueChanged);
             this.LabelInf.DataError += new System.Windows.Forms.DataGridViewDataErrorEventHandler(this.LabelInf_DataError);
             // 
-            // Choose
-            // 
-            this.Choose.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
-            this.Choose.HeaderText = "勾选";
-            this.Choose.Name = "Choose";
-            this.Choose.Resizable = System.Windows.Forms.DataGridViewTriState.True;
-            this.Choose.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
-            this.Choose.Width = 55;
-            // 
-            // pib_ifpick
-            // 
-            this.pib_ifpick.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
-            this.pib_ifpick.DataPropertyName = "pib_ifpick";
-            this.pib_ifpick.HeaderText = "已采集";
-            this.pib_ifpick.Name = "pib_ifpick";
-            this.pib_ifpick.Width = 60;
-            // 
-            // pib_ifprint
-            // 
-            this.pib_ifprint.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
-            this.pib_ifprint.DataPropertyName = "pib_ifprint";
-            this.pib_ifprint.HeaderText = "已打印";
-            this.pib_ifprint.Name = "pib_ifprint";
-            this.pib_ifprint.Width = 60;
-            // 
-            // pib_id1
-            // 
-            this.pib_id1.DataPropertyName = "pib_id";
-            this.pib_id1.HeaderText = "pib_id";
-            this.pib_id1.Name = "pib_id1";
-            this.pib_id1.Visible = false;
-            this.pib_id1.Width = 66;
-            // 
-            // pib_pdno
-            // 
-            this.pib_pdno.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
-            this.pib_pdno.DataPropertyName = "pib_pdno";
-            this.pib_pdno.HeaderText = "明细序号";
-            this.pib_pdno.Name = "pib_pdno";
-            this.pib_pdno.ReadOnly = true;
-            this.pib_pdno.Width = 96;
-            // 
-            // pib_prodcode
-            // 
-            this.pib_prodcode.DataPropertyName = "pib_prodcode";
-            this.pib_prodcode.HeaderText = "物料编号";
-            this.pib_prodcode.Name = "pib_prodcode";
-            this.pib_prodcode.ReadOnly = true;
-            this.pib_prodcode.Width = 78;
-            // 
-            // pr_vendprodcode
-            // 
-            this.pr_vendprodcode.DataPropertyName = "pr_vendprodcode";
-            this.pr_vendprodcode.HeaderText = "MPN";
-            this.pr_vendprodcode.Name = "pr_vendprodcode";
-            this.pr_vendprodcode.ReadOnly = true;
-            this.pr_vendprodcode.Width = 48;
-            // 
-            // pib_brand
-            // 
-            this.pib_brand.DataPropertyName = "pib_brand";
-            this.pib_brand.HeaderText = "品牌";
-            this.pib_brand.Name = "pib_brand";
-            this.pib_brand.ReadOnly = true;
-            this.pib_brand.Width = 54;
-            // 
-            // pib_madein
-            // 
-            this.pib_madein.DataPropertyName = "pib_madein";
-            this.pib_madein.HeaderText = "产地";
-            this.pib_madein.Name = "pib_madein";
-            this.pib_madein.Width = 54;
-            // 
-            // pr_zxbzs
-            // 
-            this.pr_zxbzs.DataPropertyName = "pr_zxbzs";
-            this.pr_zxbzs.HeaderText = "最小包装数";
-            this.pr_zxbzs.Name = "pr_zxbzs";
-            this.pr_zxbzs.Visible = false;
-            this.pr_zxbzs.Width = 90;
-            // 
-            // pr_unit
-            // 
-            this.pr_unit.DataPropertyName = "pr_unit";
-            this.pr_unit.HeaderText = "单位";
-            this.pr_unit.Name = "pr_unit";
-            this.pr_unit.Visible = false;
-            this.pr_unit.Width = 54;
-            // 
-            // pib_lotno
-            // 
-            this.pib_lotno.DataPropertyName = "pib_lotno";
-            this.pib_lotno.HeaderText = "LotNo";
-            this.pib_lotno.Name = "pib_lotno";
-            this.pib_lotno.Width = 60;
-            // 
-            // pib_datecode
-            // 
-            this.pib_datecode.DataPropertyName = "pib_datecode";
-            this.pib_datecode.HeaderText = "DateCode";
-            this.pib_datecode.Name = "pib_datecode";
-            this.pib_datecode.Width = 78;
-            // 
-            // pib_cusbarcode
-            // 
-            this.pib_cusbarcode.DataPropertyName = "pib_cusbarcode";
-            this.pib_cusbarcode.HeaderText = "ViVo条码号";
-            this.pib_cusbarcode.Name = "pib_cusbarcode";
-            this.pib_cusbarcode.Width = 90;
-            // 
-            // pib_cusoutboxcode
-            // 
-            this.pib_cusoutboxcode.DataPropertyName = "pib_cusoutboxcode";
-            this.pib_cusoutboxcode.HeaderText = "ViVo外箱";
-            this.pib_cusoutboxcode.Name = "pib_cusoutboxcode";
-            this.pib_cusoutboxcode.Width = 78;
-            // 
-            // pib_datecode1
-            // 
-            this.pib_datecode1.DataPropertyName = "pib_datecode1";
-            this.pib_datecode1.HeaderText = "DateCode1";
-            this.pib_datecode1.Name = "pib_datecode1";
-            this.pib_datecode1.Visible = false;
-            this.pib_datecode1.Width = 84;
-            // 
-            // pib_qty
-            // 
-            this.pib_qty.DataPropertyName = "pib_qty";
-            this.pib_qty.HeaderText = "数量";
-            this.pib_qty.Name = "pib_qty";
-            this.pib_qty.ReadOnly = true;
-            this.pib_qty.Width = 54;
-            // 
-            // pib_barcode
-            // 
-            this.pib_barcode.DataPropertyName = "pib_barcode";
-            this.pib_barcode.HeaderText = "唯一条码";
-            this.pib_barcode.Name = "pib_barcode";
-            this.pib_barcode.ReadOnly = true;
-            this.pib_barcode.Width = 78;
-            // 
-            // pib_custbarcode
-            // 
-            this.pib_custbarcode.DataPropertyName = "pib_custbarcode";
-            this.pib_custbarcode.HeaderText = "客户条码";
-            this.pib_custbarcode.Name = "pib_custbarcode";
-            this.pib_custbarcode.ReadOnly = true;
-            this.pib_custbarcode.Width = 78;
-            // 
-            // pd_pocode
-            // 
-            this.pd_pocode.DataPropertyName = "pd_pocode";
-            this.pd_pocode.HeaderText = "客户PO";
-            this.pd_pocode.Name = "pd_pocode";
-            this.pd_pocode.ReadOnly = true;
-            this.pd_pocode.Width = 66;
-            // 
-            // pd_custprodcode
-            // 
-            this.pd_custprodcode.DataPropertyName = "pd_custprodcode";
-            this.pd_custprodcode.HeaderText = "客户料号";
-            this.pd_custprodcode.Name = "pd_custprodcode";
-            this.pd_custprodcode.ReadOnly = true;
-            this.pd_custprodcode.Width = 78;
-            // 
-            // pd_custprodspec
-            // 
-            this.pd_custprodspec.DataPropertyName = "pd_custprodspec";
-            this.pd_custprodspec.HeaderText = "客户型号";
-            this.pd_custprodspec.Name = "pd_custprodspec";
-            this.pd_custprodspec.ReadOnly = true;
-            this.pd_custprodspec.Width = 78;
-            // 
-            // pr_spec
-            // 
-            this.pr_spec.DataPropertyName = "pr_spec";
-            this.pr_spec.HeaderText = "规格";
-            this.pr_spec.Name = "pr_spec";
-            this.pr_spec.Visible = false;
-            this.pr_spec.Width = 54;
-            // 
-            // pib_outboxcode1
-            // 
-            this.pib_outboxcode1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
-            this.pib_outboxcode1.DataPropertyName = "pib_outboxcode1";
-            this.pib_outboxcode1.HeaderText = "中盒号";
-            this.pib_outboxcode1.Name = "pib_outboxcode1";
-            this.pib_outboxcode1.Width = 90;
-            // 
-            // pib_outboxcode2
-            // 
-            this.pib_outboxcode2.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
-            this.pib_outboxcode2.DataPropertyName = "pib_outboxcode2";
-            this.pib_outboxcode2.HeaderText = "外箱号";
-            this.pib_outboxcode2.Name = "pib_outboxcode2";
-            this.pib_outboxcode2.Width = 90;
-            // 
             // pi_inoutno
             // 
             this.pi_inoutno.ID = null;
@@ -1391,6 +1183,8 @@
             // 
             // SingleLabel
             // 
+            this.SingleLabel.Controls.Add(this.label8);
+            this.SingleLabel.Controls.Add(this.SingleDocRefresh);
             this.SingleLabel.Controls.Add(this.SingleLabelPrinter);
             this.SingleLabel.Controls.Add(this.SingleLabelPrint);
             this.SingleLabel.Controls.Add(this.SingleLabelAutoPrint);
@@ -1405,6 +1199,27 @@
             this.SingleLabel.TabStop = false;
             this.SingleLabel.Text = "单盘标签";
             // 
+            // label8
+            // 
+            this.label8.AutoSize = true;
+            this.label8.Font = new System.Drawing.Font("微软雅黑", 10F);
+            this.label8.Location = new System.Drawing.Point(5, 24);
+            this.label8.Name = "label8";
+            this.label8.Size = new System.Drawing.Size(55, 20);
+            this.label8.TabIndex = 116;
+            this.label8.Text = "格式(T)";
+            // 
+            // SingleDocRefresh
+            // 
+            this.SingleDocRefresh.AutoSize = true;
+            this.SingleDocRefresh.Location = new System.Drawing.Point(58, 24);
+            this.SingleDocRefresh.Name = "SingleDocRefresh";
+            this.SingleDocRefresh.Size = new System.Drawing.Size(42, 21);
+            this.SingleDocRefresh.TabIndex = 89;
+            this.SingleDocRefresh.TabStop = true;
+            this.SingleDocRefresh.Text = "刷新";
+            this.SingleDocRefresh.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.DocRefresh_LinkClicked);
+            // 
             // SingleLabelPrinter
             // 
             this.SingleLabelPrinter.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
@@ -1454,6 +1269,8 @@
             // 
             // MidLabel
             // 
+            this.MidLabel.Controls.Add(this.label9);
+            this.MidLabel.Controls.Add(this.MidDocRefresh);
             this.MidLabel.Controls.Add(this.MidLabelNum);
             this.MidLabel.Controls.Add(this.label5);
             this.MidLabel.Controls.Add(this.label4);
@@ -1471,7 +1288,28 @@
             this.MidLabel.Size = new System.Drawing.Size(158, 238);
             this.MidLabel.TabIndex = 78;
             this.MidLabel.TabStop = false;
-            this.MidLabel.Text = "中盒标签";
+            this.MidLabel.Text = "内盒标签";
+            // 
+            // label9
+            // 
+            this.label9.AutoSize = true;
+            this.label9.Font = new System.Drawing.Font("微软雅黑", 10F);
+            this.label9.Location = new System.Drawing.Point(5, 24);
+            this.label9.Name = "label9";
+            this.label9.Size = new System.Drawing.Size(55, 20);
+            this.label9.TabIndex = 117;
+            this.label9.Text = "格式(T)";
+            // 
+            // MidDocRefresh
+            // 
+            this.MidDocRefresh.AutoSize = true;
+            this.MidDocRefresh.Location = new System.Drawing.Point(60, 24);
+            this.MidDocRefresh.Name = "MidDocRefresh";
+            this.MidDocRefresh.Size = new System.Drawing.Size(42, 21);
+            this.MidDocRefresh.TabIndex = 90;
+            this.MidDocRefresh.TabStop = true;
+            this.MidDocRefresh.Text = "刷新";
+            this.MidDocRefresh.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.DocRefresh_LinkClicked);
             // 
             // MidLabelNum
             // 
@@ -1574,6 +1412,8 @@
             // 
             // OutBoxLabel
             // 
+            this.OutBoxLabel.Controls.Add(this.label19);
+            this.OutBoxLabel.Controls.Add(this.OutDocRefresh);
             this.OutBoxLabel.Controls.Add(this.LogingOut);
             this.OutBoxLabel.Controls.Add(this.GetOutBoxCode);
             this.OutBoxLabel.Controls.Add(this.OutBoxNum);
@@ -1594,6 +1434,27 @@
             this.OutBoxLabel.TabStop = false;
             this.OutBoxLabel.Text = "外箱标签";
             // 
+            // label19
+            // 
+            this.label19.AutoSize = true;
+            this.label19.Font = new System.Drawing.Font("微软雅黑", 10F);
+            this.label19.Location = new System.Drawing.Point(4, 24);
+            this.label19.Name = "label19";
+            this.label19.Size = new System.Drawing.Size(55, 20);
+            this.label19.TabIndex = 118;
+            this.label19.Text = "格式(T)";
+            // 
+            // OutDocRefresh
+            // 
+            this.OutDocRefresh.AutoSize = true;
+            this.OutDocRefresh.Location = new System.Drawing.Point(58, 23);
+            this.OutDocRefresh.Name = "OutDocRefresh";
+            this.OutDocRefresh.Size = new System.Drawing.Size(42, 21);
+            this.OutDocRefresh.TabIndex = 91;
+            this.OutDocRefresh.TabStop = true;
+            this.OutDocRefresh.Text = "刷新";
+            this.OutDocRefresh.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.DocRefresh_LinkClicked);
+            // 
             // LogingOut
             // 
             this.LogingOut.AutoSize = true;
@@ -1704,19 +1565,223 @@
             this.OutBoxCombox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
             this.OutBoxCombox.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.OutBoxCombox.FormattingEnabled = true;
-            this.OutBoxCombox.Location = new System.Drawing.Point(8, 44);
+            this.OutBoxCombox.Location = new System.Drawing.Point(7, 46);
             this.OutBoxCombox.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.OutBoxCombox.Name = "OutBoxCombox";
             this.OutBoxCombox.Size = new System.Drawing.Size(158, 25);
             this.OutBoxCombox.TabIndex = 78;
             this.OutBoxCombox.SelectedIndexChanged += new System.EventHandler(this.OutBoxCombox_SelectedIndexChanged);
             // 
+            // cu_code
+            // 
+            this.cu_code.AllPower = null;
+            this.cu_code.Caller = null;
+            this.cu_code.Condition = null;
+            this.cu_code.DBTitle = null;
+            this.cu_code.FormName = null;
+            this.cu_code.Location = new System.Drawing.Point(76, 38);
+            this.cu_code.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+            this.cu_code.Name = "cu_code";
+            this.cu_code.Power = null;
+            this.cu_code.ReturnData = null;
+            this.cu_code.SelectField = null;
+            this.cu_code.SetValueField = null;
+            this.cu_code.Size = new System.Drawing.Size(149, 21);
+            this.cu_code.TabIndex = 88;
+            this.cu_code.TableName = null;
+            this.cu_code.TextBoxEnable = false;
+            this.cu_code.UserControlTextChanged += new UAS_LabelMachine.CustomControl.SearchTextBox.OnTextChange(this.cu_code_UserControlTextChanged);
+            // 
+            // Choose
+            // 
+            this.Choose.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
+            this.Choose.HeaderText = "勾选";
+            this.Choose.Name = "Choose";
+            this.Choose.Resizable = System.Windows.Forms.DataGridViewTriState.True;
+            this.Choose.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
+            this.Choose.Width = 55;
+            // 
+            // pib_ifpick
+            // 
+            this.pib_ifpick.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
+            this.pib_ifpick.DataPropertyName = "pib_ifpick";
+            this.pib_ifpick.HeaderText = "已采集";
+            this.pib_ifpick.Name = "pib_ifpick";
+            this.pib_ifpick.Width = 60;
+            // 
+            // pib_ifprint
+            // 
+            this.pib_ifprint.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
+            this.pib_ifprint.DataPropertyName = "pib_ifprint";
+            this.pib_ifprint.HeaderText = "已打印";
+            this.pib_ifprint.Name = "pib_ifprint";
+            this.pib_ifprint.Width = 60;
+            // 
+            // pib_id1
+            // 
+            this.pib_id1.DataPropertyName = "pib_id";
+            this.pib_id1.HeaderText = "pib_id";
+            this.pib_id1.Name = "pib_id1";
+            this.pib_id1.Visible = false;
+            this.pib_id1.Width = 66;
+            // 
+            // pib_pdno
+            // 
+            this.pib_pdno.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
+            this.pib_pdno.DataPropertyName = "pib_pdno";
+            this.pib_pdno.HeaderText = "明细序号";
+            this.pib_pdno.Name = "pib_pdno";
+            this.pib_pdno.ReadOnly = true;
+            this.pib_pdno.Width = 96;
+            // 
+            // pib_prodcode
+            // 
+            this.pib_prodcode.DataPropertyName = "pib_prodcode";
+            this.pib_prodcode.HeaderText = "物料编号";
+            this.pib_prodcode.Name = "pib_prodcode";
+            this.pib_prodcode.ReadOnly = true;
+            this.pib_prodcode.Width = 78;
+            // 
+            // pr_vendprodcode
+            // 
+            this.pr_vendprodcode.DataPropertyName = "pr_vendprodcode";
+            this.pr_vendprodcode.HeaderText = "MPN";
+            this.pr_vendprodcode.Name = "pr_vendprodcode";
+            this.pr_vendprodcode.ReadOnly = true;
+            this.pr_vendprodcode.Width = 48;
+            // 
+            // pib_brand
+            // 
+            this.pib_brand.DataPropertyName = "pib_brand";
+            this.pib_brand.HeaderText = "品牌";
+            this.pib_brand.Name = "pib_brand";
+            this.pib_brand.ReadOnly = true;
+            this.pib_brand.Width = 54;
+            // 
+            // pib_madein
+            // 
+            this.pib_madein.DataPropertyName = "pib_madein";
+            this.pib_madein.HeaderText = "产地";
+            this.pib_madein.Name = "pib_madein";
+            this.pib_madein.Width = 54;
+            // 
+            // pr_zxbzs
+            // 
+            this.pr_zxbzs.DataPropertyName = "pr_zxbzs";
+            this.pr_zxbzs.HeaderText = "最小包装数";
+            this.pr_zxbzs.Name = "pr_zxbzs";
+            this.pr_zxbzs.Visible = false;
+            this.pr_zxbzs.Width = 90;
+            // 
+            // pr_unit
+            // 
+            this.pr_unit.DataPropertyName = "pr_unit";
+            this.pr_unit.HeaderText = "单位";
+            this.pr_unit.Name = "pr_unit";
+            this.pr_unit.Visible = false;
+            this.pr_unit.Width = 54;
+            // 
+            // pib_lotno
+            // 
+            this.pib_lotno.DataPropertyName = "pib_lotno";
+            this.pib_lotno.HeaderText = "LotNo";
+            this.pib_lotno.Name = "pib_lotno";
+            this.pib_lotno.Width = 60;
+            // 
+            // pib_datecode
+            // 
+            this.pib_datecode.DataPropertyName = "pib_datecode";
+            this.pib_datecode.HeaderText = "DateCode";
+            this.pib_datecode.Name = "pib_datecode";
+            this.pib_datecode.Width = 78;
+            // 
+            // pib_datecode1
+            // 
+            this.pib_datecode1.DataPropertyName = "pib_datecode1";
+            this.pib_datecode1.HeaderText = "DateCode1";
+            this.pib_datecode1.Name = "pib_datecode1";
+            this.pib_datecode1.Visible = false;
+            this.pib_datecode1.Width = 84;
+            // 
+            // pib_qty
+            // 
+            this.pib_qty.DataPropertyName = "pib_qty";
+            this.pib_qty.HeaderText = "数量";
+            this.pib_qty.Name = "pib_qty";
+            this.pib_qty.ReadOnly = true;
+            this.pib_qty.Width = 54;
+            // 
+            // pib_barcode
+            // 
+            this.pib_barcode.DataPropertyName = "pib_barcode";
+            this.pib_barcode.HeaderText = "唯一条码";
+            this.pib_barcode.Name = "pib_barcode";
+            this.pib_barcode.ReadOnly = true;
+            this.pib_barcode.Width = 78;
+            // 
+            // pib_custbarcode
+            // 
+            this.pib_custbarcode.DataPropertyName = "pib_custbarcode";
+            this.pib_custbarcode.HeaderText = "客户条码";
+            this.pib_custbarcode.Name = "pib_custbarcode";
+            this.pib_custbarcode.ReadOnly = true;
+            this.pib_custbarcode.Width = 78;
+            // 
+            // pd_pocode
+            // 
+            this.pd_pocode.DataPropertyName = "pd_pocode";
+            this.pd_pocode.HeaderText = "客户PO";
+            this.pd_pocode.Name = "pd_pocode";
+            this.pd_pocode.ReadOnly = true;
+            this.pd_pocode.Width = 66;
+            // 
+            // pd_custprodcode
+            // 
+            this.pd_custprodcode.DataPropertyName = "pd_custprodcode";
+            this.pd_custprodcode.HeaderText = "客户料号";
+            this.pd_custprodcode.Name = "pd_custprodcode";
+            this.pd_custprodcode.ReadOnly = true;
+            this.pd_custprodcode.Width = 78;
+            // 
+            // pd_custprodspec
+            // 
+            this.pd_custprodspec.DataPropertyName = "pd_custprodspec";
+            this.pd_custprodspec.HeaderText = "客户型号";
+            this.pd_custprodspec.Name = "pd_custprodspec";
+            this.pd_custprodspec.ReadOnly = true;
+            this.pd_custprodspec.Width = 78;
+            // 
+            // pr_spec
+            // 
+            this.pr_spec.DataPropertyName = "pr_spec";
+            this.pr_spec.HeaderText = "规格";
+            this.pr_spec.Name = "pr_spec";
+            this.pr_spec.Visible = false;
+            this.pr_spec.Width = 54;
+            // 
+            // pib_outboxcode1
+            // 
+            this.pib_outboxcode1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
+            this.pib_outboxcode1.DataPropertyName = "pib_outboxcode1";
+            this.pib_outboxcode1.HeaderText = "中盒号";
+            this.pib_outboxcode1.Name = "pib_outboxcode1";
+            this.pib_outboxcode1.Width = 90;
+            // 
+            // pib_outboxcode2
+            // 
+            this.pib_outboxcode2.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
+            this.pib_outboxcode2.DataPropertyName = "pib_outboxcode2";
+            this.pib_outboxcode2.HeaderText = "外箱号";
+            this.pib_outboxcode2.Name = "pib_outboxcode2";
+            this.pib_outboxcode2.Width = 90;
+            // 
             // UAS_出货标签打印
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(229)))), ((int)(((byte)(233)))), ((int)(((byte)(206)))));
             this.ClientSize = new System.Drawing.Size(1257, 711);
+            this.Controls.Add(this.cu_code);
             this.Controls.Add(this.CleanBarCode);
             this.Controls.Add(this.pi_date);
             this.Controls.Add(this.AttachInfo);
@@ -1727,7 +1792,6 @@
             this.Controls.Add(this.CleanInputAfterCollect);
             this.Controls.Add(this.Fresh);
             this.Controls.Add(this.pi_cardcode_label);
-            this.Controls.Add(this.pi_cardcode);
             this.Controls.Add(this.pib_id);
             this.Controls.Add(this.pr_code);
             this.Controls.Add(this.CleanDetail);
@@ -1867,7 +1931,6 @@
         private System.Windows.Forms.Label Process_midboxcode;
         private System.Windows.Forms.Label Process_outboxcode;
         private System.Windows.Forms.Label Capacity;
-        private System.Windows.Forms.Label pi_cardcode;
         private System.Windows.Forms.Label pi_cardcode_label;
         private System.Windows.Forms.LinkLabel Fresh;
         private System.Windows.Forms.Label label3;
@@ -1876,7 +1939,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;
@@ -1909,6 +1971,14 @@
         private System.Windows.Forms.DataGridViewTextBoxColumn si_expressionitem;
         private System.Windows.Forms.Button AttachInfo;
         private System.Windows.Forms.Label pi_date;
+        private System.Windows.Forms.Button CleanBarCode;
+        private CustomControl.SearchTextBox cu_code;
+        private System.Windows.Forms.LinkLabel SingleDocRefresh;
+        private System.Windows.Forms.LinkLabel MidDocRefresh;
+        private System.Windows.Forms.LinkLabel OutDocRefresh;
+        private System.Windows.Forms.Label label8;
+        private System.Windows.Forms.Label label9;
+        private System.Windows.Forms.Label label19;
         private System.Windows.Forms.DataGridViewCheckBoxColumn Choose;
         private System.Windows.Forms.DataGridViewCheckBoxColumn pib_ifpick;
         private System.Windows.Forms.DataGridViewCheckBoxColumn pib_ifprint;
@@ -1922,8 +1992,6 @@
         private System.Windows.Forms.DataGridViewTextBoxColumn pr_unit;
         private System.Windows.Forms.DataGridViewTextBoxColumn pib_lotno;
         private System.Windows.Forms.DataGridViewTextBoxColumn pib_datecode;
-        private System.Windows.Forms.DataGridViewTextBoxColumn pib_cusbarcode;
-        private System.Windows.Forms.DataGridViewTextBoxColumn pib_cusoutboxcode;
         private System.Windows.Forms.DataGridViewTextBoxColumn pib_datecode1;
         private System.Windows.Forms.DataGridViewTextBoxColumn pib_qty;
         private System.Windows.Forms.DataGridViewTextBoxColumn pib_barcode;
@@ -1934,6 +2002,5 @@
         private System.Windows.Forms.DataGridViewTextBoxColumn pr_spec;
         private System.Windows.Forms.DataGridViewTextBoxColumn pib_outboxcode1;
         private System.Windows.Forms.DataGridViewTextBoxColumn pib_outboxcode2;
-        private System.Windows.Forms.Button CleanBarCode;
     }
 }

+ 227 - 78
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();
@@ -178,6 +200,7 @@ namespace UAS_LabelMachine
             LogManager.DoLog("程序启动,登陆人员【" + User.UserName + "】");
             dh = SystemInf.dh;
             sdh = SystemInf.sdh;
+            sdh.ExecuteZip();
             CheckForIllegalCrossThreadCalls = false;
             CloumnCount = LabelInf.Columns.Count;
             pi_inoutno.Focus();
@@ -192,6 +215,11 @@ namespace UAS_LabelMachine
             pr_code.TableName = "prodiodetail left join product on pd_prodcode=pr_code";
             pr_code.SelectField = "pd_pdno # 行号,pr_code # 物料编号";
 
+            cu_code.FormName = Name;
+            cu_code.SetValueField = new string[] { "cu_code" };
+            cu_code.TableName = "customer";
+            cu_code.SelectField = "cu_code # 客户编号,cu_name # 客户名称";
+
             CollectionUnit.Text = "盘";
             Point pt = new Point();
             //禁止所有列的排序
@@ -211,17 +239,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 +677,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;
         }
 
@@ -932,7 +969,10 @@ namespace UAS_LabelMachine
                     e.Cancel = true;
                 else
                 {
-                    lbl.Quit();
+                    if (lbl != null)
+                        lbl.Quit();
+                    if (engine != null)
+                        engine.Dispose();
                     LogManager.DoLog("关闭程序");
                 }
             }
@@ -944,10 +984,10 @@ namespace UAS_LabelMachine
         private void GetInOutInfAndLabelFile()
         {
             ComBoxClickChangeLabelDoc = false;
-            Attach = (DataTable)dh.ExecuteSql("select lap_param lp_name,lap_value lp_sql  from LabelAttachPARAMETER where lap_custcode='" + pi_cardcode.Text + "'", "select");
+            Attach = (DataTable)dh.ExecuteSql("select lap_param lp_name,lap_value lp_sql  from LabelAttachPARAMETER where lap_custcode='" + cu_code.Text + "'", "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 ");
-            sql.Append("left join customer on cu_code=cl_custcode left join label on la_code=CL_LABELCODE where ((pi_cardcode='" + pi_cardcode.Text + "' ");
+            sql.Append("left join customer on cu_code=cl_custcode left join label on la_code=CL_LABELCODE where ((pi_cardcode='" + cu_code.Text + "' ");
             sql.Append("and  pi_inoutno='" + pi_inoutno.Text + "') or( cl_custcode is null)) and cl_labeltype='单盘' order by cl_custcode");
             dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
             SingleLabelCombox.DisplayMember = "cl_labelname";
@@ -955,6 +995,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,16 +1009,21 @@ 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 ");
-            sql.Append("left join customer on cu_code=cl_custcode left join label on la_code=CL_LABELCODE where ((pi_cardcode='" + pi_cardcode.Text + "' ");
+            sql.Append("left join customer on cu_code=cl_custcode left join label on la_code=CL_LABELCODE where ((pi_cardcode='" + cu_code.Text + "' ");
             sql.Append("and  pi_inoutno='" + pi_inoutno.Text + "') or( cl_custcode is null)) and cl_labeltype='中盒' order by cl_custcode");
             dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
             MidLabelCombox.DisplayMember = "cl_labelname";
@@ -984,6 +1031,8 @@ namespace UAS_LabelMachine
             MidLabelCombox.DataSource = dt;
             if (MidDoc != null)
                 MidDoc.Close();
+            if (MidFormat != null)
+                MidFormat.Close(SaveOptions.DoNotSaveChanges);
             if (!GetGridOnly.Checked)
                 for (int i = 0; i < dt.Rows.Count; i++)
                 {
@@ -994,15 +1043,25 @@ 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");
             }
             //缓存中盒参数
             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 ");
-            sql.Append("left join customer on cu_code=cl_custcode left join label on la_code=CL_LABELCODE where ((pi_cardcode='" + pi_cardcode.Text + "' ");
+            sql.Append("left join customer on cu_code=cl_custcode left join label on la_code=CL_LABELCODE where ((pi_cardcode='" + cu_code.Text + "' ");
             sql.Append("and  pi_inoutno='" + pi_inoutno.Text + "') or( cl_custcode is null)) and cl_labeltype='外箱' order by cl_custcode");
             dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
             OutBoxCombox.DisplayMember = "cl_labelname";
@@ -1010,6 +1069,8 @@ namespace UAS_LabelMachine
             OutBoxCombox.DataSource = dt;
             if (OutBoxDoc != null)
                 OutBoxDoc.Close();
+            if (OutFormat != null)
+                OutFormat.Close(SaveOptions.DoNotSaveChanges);
             if (!GetGridOnly.Checked)
                 for (int i = 0; i < dt.Rows.Count; i++)
                 {
@@ -1022,13 +1083,22 @@ 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");
             }
             //缓存外箱参数
             ComBoxClickChangeLabelDoc = true;
         }
-
+        bool InitGetLabel = true;
         /// <summary>
         /// 出入库单录入框的回车事件
         /// </summary>
@@ -1043,7 +1113,9 @@ namespace UAS_LabelMachine
                 dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
                 if (dt.Rows.Count > 0)
                 {
-                    pi_cardcode.Text = dt.Rows[0]["pi_cardcode"].ToString();
+                    InitGetLabel = true;
+                    cu_code.Text = dt.Rows[0]["pi_cardcode"].ToString();
+                    InitGetLabel = false;
                     pi_date.Text = dt.Rows[0]["pi_date"].ToString();
                     PI_ID = dt.Rows[0]["pi_id"].ToString();
                     if (dh.GetConfig("AutoBarcode", "ProdInOut!Sale").ToString() != "")
@@ -1086,25 +1158,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 +1471,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(MidFormat, MidLabelParam, pi_inoutno.Text, pib_id, pib_outboxcode1);
         }
 
         private void OutBoxCodePrint(int rowindex)
@@ -1427,7 +1482,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(OutFormat, OutLabelParam, pi_inoutno.Text, pib_id, pib_outboxcode2);
         }
 
         private void CleanDetail_Click(object sender, EventArgs e)
@@ -1521,24 +1579,31 @@ namespace UAS_LabelMachine
         private void LoadGridData(object sender, EventArgs e)
         {
             AllCollect = false;
+            //查询Oracle数据库
             sql.Clear();
-            sql.Append("select * from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "' order by rownum ");
-            LabelInfDataTable = (DataTable)sdh.ExecuteSql(sql.ToString(), "select");
-            if (LabelInfDataTable.Rows.Count == 0)
+            sql.Append("select t.*,rownum from prodiobarcode_view t where pib_inoutno='" + pi_inoutno.Text + "'");
+            LabelInfDataTable = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
+            //查询本地数据库
+            sql.Clear();
+            sql.Append("select * from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "' limit 0,1 ");
+            DataTable dt = (DataTable)sdh.ExecuteSql(sql.ToString(), "select");
+            //如果本地没有缓存过
+            if (dt.Rows.Count == 0)
             {
-                //嵌套查询重置RowNum
-                sql.Clear();
-                sql.Append("select t.*,rownum from (select pd_ordercode,pib_year,pib_month,pib_day,pr_barcode,pr_detail,pib_custoutboxcode,pib_custmidboxcode,pr_orispeccode,pd_id,pd_custprodcode,pib_indate,pi_date,pib_inoutno,pd_custprodspec,");
-                sql.Append("nvl(pib_ifrecheck,0)pib_ifrecheck,nvl(pib_ifupload,0)pib_ifupload,nvl(pib_ifmodify,0)pib_ifmodify,pd_pocode,pib_madein,pib_custbarcode,pib_id,pib_pdid,pib_piid,");
-                sql.Append("pib_pdno,pib_prodcode,nvl(nvl(pd_brand,pib_brand),pr_brand)pib_brand, pr_vendprodcode,pib_lotno,pib_datecode,pib_qty,pr_spec,pi_title,pr_zxbzs,pr_unit,pib_barcode,pib_outboxcode1,");
-                sql.Append("pib_outboxcode2,nvl(pib_ifpick,0)pib_ifpick,nvl(pib_ifprint,0)pib_ifprint from prodiobarcode left join prodinout on pib_piid=pi_id left join prodiodetail on pib_piid=pd_piid and  ");
-                sql.Append("pd_pdno=pib_pdno and pd_prodcode=pib_prodcode left join product on pr_code=pib_prodcode left join sale on sa_code=pib_ordercode where pib_piid='" + PI_ID + "' order by to_number(pib_id))t");
-                LabelInfDataTable = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
                 //检验查询的字段和本地数据库字段是否匹配
                 sdh.AddColumFromDataTable(LabelInfDataTable, "prodiobarcode");
                 //将数据保存在本地数据库
                 sdh.SaveDataTable(LabelInfDataTable, "prodiobarcode");
             }
+            else if (LabelInfDataTable.Columns.Count != dt.Columns.Count)
+            {
+                //检验查询的字段和本地数据库字段是否匹配
+                sdh.AddColumFromDataTable(LabelInfDataTable, "prodiobarcode");
+                sdh.BatchInsert("prodiobarcode", LabelInfDataTable);
+            }
+            sql.Clear();
+            sql.Append("select * from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "' order by rownum ");
+            LabelInfDataTable = (DataTable)sdh.ExecuteSql(sql.ToString(), "select");
             bindingsource(LabelInf, LabelInfDataTable);
             BaseUtil.FillDgvWithDataTable(LabelInf, LabelInfDataTable);
             //有数据的话默认取第一条的品牌去取采集策略
@@ -1788,8 +1853,13 @@ namespace UAS_LabelMachine
                         {
                             BoxCode = BoxCode + 1;
                         }
+                        else if (LabelInf.Rows[i].Cells["pib_prodcode"].Value.ToString() != LabelInf.Rows[i + 1].Cells["pib_prodcode"].Value.ToString())
+                        {
+                            BoxCode = BoxCode + 1;
+                        }
                     }
                 }
+                sdh.BatchInsert("prodiobarcode", LabelInf.DataSource as DataTable);
             }
             SaveGrid_Click(sender, e);
         }
@@ -1803,7 +1873,10 @@ namespace UAS_LabelMachine
                 //注销的时候需要将拼接的连接字符串置空
                 DataHelper.DBConnectionString = null;
                 logout = true;
-                lbl.Quit();
+                if (lbl != null)
+                    lbl.Quit();
+                if (engine != null)
+                    engine.Dispose();
                 this.Hide();
                 login.ShowDialog();
                 this.Close();
@@ -1825,10 +1898,15 @@ namespace UAS_LabelMachine
                 {
                     if (SingleDoc != null)
                         SingleDoc.Close();
+                    if (SingleFormat != null)
+                        SingleFormat.Close(SaveOptions.DoNotSaveChanges);
+                    System.DateTime time = Convert.ToDateTime(SingleLabelCombox.SelectedValue.ToString().Split('#')[2]);
                     if (SingleLabelCombox.Text != "" && SingleLabelCombox.SelectedValue != null && !GetGridOnly.Checked)
                     {
-                        System.DateTime time = Convert.ToDateTime(SingleLabelCombox.SelectedValue.ToString().Split('#')[2]);
-                        SingleDoc = lbl.Documents.Open(BaseUtil.GetLabelUrl(SingleLabelCombox.SelectedValue.ToString().Split('#')[1], SingleLabelCombox.Text, time));
+                        if (PrintMethod == "CodeSoft")
+                            SingleDoc = lbl.Documents.Open(BaseUtil.GetLabelUrl(SingleLabelCombox.SelectedValue.ToString().Split('#')[1], SingleLabelCombox.Text, time));
+                        else
+                            SingleFormat = engine.Documents.Open(BaseUtil.GetLabelUrl(SingleLabelCombox.SelectedValue.ToString().Split('#')[1], SingleLabelCombox.Text, time));
                     }
                 }
             }
@@ -1848,10 +1926,15 @@ namespace UAS_LabelMachine
                 {
                     if (MidDoc != null)
                         MidDoc.Close();
+                    if (MidFormat != null)
+                        MidFormat.Close(SaveOptions.DoNotSaveChanges);
                     if (MidLabelCombox.Text != "" && MidLabelCombox.SelectedValue != null && !GetGridOnly.Checked)
                     {
                         System.DateTime time = Convert.ToDateTime(MidLabelCombox.SelectedValue.ToString().Split('#')[2]);
-                        MidDoc = lbl.Documents.Open(BaseUtil.GetLabelUrl(MidLabelCombox.SelectedValue.ToString().Split('#')[1], MidLabelCombox.Text, time));
+                        if (PrintMethod == "CodeSoft")
+                            MidDoc = lbl.Documents.Open(BaseUtil.GetLabelUrl(MidLabelCombox.SelectedValue.ToString().Split('#')[1], MidLabelCombox.Text, time));
+                        else
+                            MidFormat = engine.Documents.Open(BaseUtil.GetLabelUrl(MidLabelCombox.SelectedValue.ToString().Split('#')[1], MidLabelCombox.Text, time));
                     }
                 }
             }
@@ -1871,10 +1954,15 @@ namespace UAS_LabelMachine
                 {
                     if (OutBoxDoc != null)
                         OutBoxDoc.Close();
+                    if (OutFormat != null)
+                        OutFormat.Close(SaveOptions.DoNotSaveChanges);
+                    System.DateTime time = Convert.ToDateTime(OutBoxCombox.SelectedValue.ToString().Split('#')[2]);
                     if (OutBoxCombox.Text != "" && OutBoxCombox.SelectedValue != null && !GetGridOnly.Checked)
                     {
-                        System.DateTime time = Convert.ToDateTime(OutBoxCombox.SelectedValue.ToString().Split('#')[2]);
-                        OutBoxDoc = lbl.Documents.Open(BaseUtil.GetLabelUrl(OutBoxCombox.SelectedValue.ToString().Split('#')[1], OutBoxCombox.Text, time));
+                        if (PrintMethod == "CodeSoft")
+                            OutBoxDoc = lbl.Documents.Open(BaseUtil.GetLabelUrl(OutBoxCombox.SelectedValue.ToString().Split('#')[1], OutBoxCombox.Text, time));
+                        else
+                            OutFormat = engine.Documents.Open(BaseUtil.GetLabelUrl(OutBoxCombox.SelectedValue.ToString().Split('#')[1], OutBoxCombox.Text, time));
                     }
                 }
             }
@@ -1974,9 +2062,9 @@ namespace UAS_LabelMachine
 
         private void AttachInfo_Click(object sender, EventArgs e)
         {
-            if (pi_cardcode.Text != "")
+            if (cu_code.Text != "")
             {
-                附件内容打印 att = new 附件内容打印(pi_cardcode.Text);
+                附件内容打印 att = new 附件内容打印(cu_code.Text);
                 att.ShowDialog();
             }
             else MessageBox.Show("请先获取出库单信息");
@@ -2000,11 +2088,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,20 +2103,86 @@ 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 (PrintMethod == "CodeSoft")
+                    {
+                        if (OutBoxDoc != null)
+                            OutBoxDoc.Printer.SwitchTo(OutBoxLabelPrint.Text);
+                    }
+                    else
+                    {
+                        if (OutFormat != null)
+                            OutFormat.PrintSetup.PrinterName = OutBoxPrinter.Text;
+                    }
+                    break;
+                default:
+                    break;
+            }
+        }
+
+        private void DocRefresh_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
+        {
+            switch ((sender as Control).Name)
+            {
+                case "SingleDocRefresh":
+                    if (SingleDoc != null)
+                        SingleDoc.Close();
+                    if (SingleLabelCombox.Text != "" && SingleLabelCombox.SelectedValue != null && !GetGridOnly.Checked)
+                    {
+                        System.DateTime time = Convert.ToDateTime(SingleLabelCombox.SelectedValue.ToString().Split('#')[2]);
+                        SingleDoc = lbl.Documents.Open(BaseUtil.GetLabelUrl(SingleLabelCombox.SelectedValue.ToString().Split('#')[1], SingleLabelCombox.Text, time));
+                    }
+                    break;
+                case "MidDocRefresh":
+                    if (MidDoc != null)
+                        MidDoc.Close();
+                    if (MidLabelCombox.Text != "" && MidLabelCombox.SelectedValue != null && !GetGridOnly.Checked)
+                    {
+                        System.DateTime time = Convert.ToDateTime(MidLabelCombox.SelectedValue.ToString().Split('#')[2]);
+                        MidDoc = lbl.Documents.Open(BaseUtil.GetLabelUrl(MidLabelCombox.SelectedValue.ToString().Split('#')[1], MidLabelCombox.Text, time));
+                    }
+                    break;
+                case "OutDocRefresh":
                     if (OutBoxDoc != null)
-                        OutBoxDoc.Printer.SwitchTo(OutBoxLabelPrint.Text);
+                        OutBoxDoc.Close();
+                    if (OutBoxCombox.Text != "" && OutBoxCombox.SelectedValue != null && !GetGridOnly.Checked)
+                    {
+                        System.DateTime time = Convert.ToDateTime(OutBoxCombox.SelectedValue.ToString().Split('#')[2]);
+                        OutBoxDoc = lbl.Documents.Open(BaseUtil.GetLabelUrl(OutBoxCombox.SelectedValue.ToString().Split('#')[1], OutBoxCombox.Text, time));
+                    }
                     break;
                 default:
                     break;
             }
         }
+
+        private void cu_code_UserControlTextChanged(object sender, EventArgs e)
+        {
+            if (!InitGetLabel)
+                GetInOutInfAndLabelFile();
+        }
     }
 }

+ 0 - 9
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>
@@ -159,12 +156,6 @@
   <metadata name="pr_unit.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>
-  <metadata name="pib_cusbarcode.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
-  <metadata name="pib_cusoutboxcode.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
   <metadata name="pib_datecode1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</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;
     }
 }

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

@@ -1,11 +1,8 @@
-using LabelManager2;
-using System;
+using System;
 using System.Data;
-using System.Drawing;
 using System.Text;
 using System.IO;
 using System.Windows.Forms;
-using UAS_LabelMachine.CustomControl;
 using UAS_LabelMachine.Properties;
 using UAS_LabelMachine.PublicMethod;
 using UAS_LabelMachine.Entity;
@@ -25,8 +22,6 @@ namespace UAS_LabelMachine
         StringBuilder condition = new StringBuilder();
         StringBuilder sql = new StringBuilder();
         /*CodeSoft新建打印机引擎*/
-        ApplicationClass lbl;
-        Document doc;
         /*BarTender新建打印机引擎*/
         //private Engine engine = null;
         //private LabelFormatDocument format ;
@@ -85,11 +80,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;
@@ -98,7 +101,6 @@ namespace UAS_LabelMachine
             LoadData();
             Width = Width + 1;
             asc.controllInitializeSize(this);
-            lbl = new ApplicationClass();
             Width = Width + 1;
         }
 
@@ -106,10 +108,6 @@ namespace UAS_LabelMachine
         {
             if (LabelDataGridView.Columns[e.ColumnIndex].HeaderText == "预览")
             {
-                if (lbl.Documents.Count > 0)
-                {
-                    lbl.ActiveDocument.Close();
-                }
                 //获取路径和标签名称
                 LabelPath = LabelDataGridView.Rows[e.RowIndex].Cells["cl_labelurl"].Value.ToString();
                 LabelCode = LabelDataGridView.Rows[e.RowIndex].Cells["cl_labelcode"].Value.ToString();
@@ -127,14 +125,7 @@ namespace UAS_LabelMachine
                 if (CodeSoft.Checked)
                 {
                     string LabelName = LabelDataGridView.Rows[e.RowIndex].Cells["cl_labelname"].Value.ToString();
-                    doc = lbl.Documents.Open(BaseUtil.GetLabelUrl(LabelPath, LabelName,time));
-                    Bitmap bit = new Bitmap(doc.CopyImageToFile());
-                    pictureBox1.Image = bit;
                     //如果文件已不存在则进行提示
-                    if (doc == null)
-                    {
-                        return;
-                    }
                 }
             }
             if (LabelDataGridView.Columns[e.ColumnIndex].HeaderText == "编辑")
@@ -192,6 +183,10 @@ namespace UAS_LabelMachine
             {
                 LabelSoft = "CodeSoft";
             }
+            if (BarTender.Checked)
+            {
+                LabelSoft = "BarTender";
+            }
             DataTable dt = (DataTable)LabelDataGridView.DataSource;
             //如果有改变的行才传递到后台
             if (dt.GetChanges() != null)
@@ -228,6 +223,10 @@ namespace UAS_LabelMachine
             {
                 openFileDialog1.Filter = "(*.lab)|*.lab";
             }
+            if (BarTender.Checked)
+            {
+                openFileDialog1.Filter = "(*.btw)|*.btw";
+            }
             DialogResult result = openFileDialog1.ShowDialog();
             if (result == DialogResult.OK)
             {
@@ -297,8 +296,7 @@ namespace UAS_LabelMachine
         {
             if (LabelCode != "")
             {
-                doc.Printer.SwitchTo(PrinterList.Text);
-                doc.PrintDocument();
+          
             }
         }
 
@@ -306,8 +304,7 @@ namespace UAS_LabelMachine
         {
             try
             {
-                lbl.Documents.CloseAll();
-                lbl.Application.Quit();
+             
             }
             catch (Exception)
             {
@@ -338,7 +335,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();

+ 80 - 63
UAS-出货标签管理(贸易版)/生成条码.cs

@@ -195,11 +195,11 @@ namespace UAS_LabelMachine
                     string pd_orderdetno = ProdIoInfDGV.Rows[i].Cells["pd_orderdetno"].FormattedValue.ToString();
                     string pr_brand = ProdIoInfDGV.Rows[i].Cells["pr_brand"].FormattedValue.ToString();
                     //总数
-                    int pd_totalqty = int.Parse(ProdIoInfDGV.Rows[i].Cells["pd_totalqty"].FormattedValue.ToString());
+                    decimal pd_totalqty = decimal.Parse(ProdIoInfDGV.Rows[i].Cells["pd_totalqty"].FormattedValue.ToString());
                     //本次数量
-                    int pd_qty = int.Parse(ProdIoInfDGV.Rows[i].Cells["pd_qty"].FormattedValue.ToString());
+                    decimal pd_qty = decimal.Parse(ProdIoInfDGV.Rows[i].Cells["pd_qty"].FormattedValue.ToString());
                     //最小包装数
-                    int pr_zxbzs = int.Parse(ProdIoInfDGV.Rows[i].Cells["pr_zxbzs"].FormattedValue.ToString());
+                    decimal pr_zxbzs = decimal.Parse(ProdIoInfDGV.Rows[i].Cells["pr_zxbzs"].FormattedValue.ToString());
                     //中盒容量
                     int mid_qty;
                     try
@@ -214,14 +214,14 @@ namespace UAS_LabelMachine
                     //如果中盘盒数量为1且有尾数则表示一箱未装满
                     int mid_num = int.Parse(ProdIoInfDGV.Rows[i].Cells["mid_num"].FormattedValue.ToString());
                     //中盒尾数
-                    int mid_remain = int.Parse(ProdIoInfDGV.Rows[i].Cells["mid_remain"].FormattedValue.ToString());
+                    decimal mid_remain = decimal.Parse(ProdIoInfDGV.Rows[i].Cells["mid_remain"].FormattedValue.ToString());
                     string pib_barcode = dh.getFieldDataByCondition("prodiobarcode", "max(pib_barcode)", "PIB_INOUTNO='" + pi_inoutno.Text + "'").ToString();
                     //中盒数量*中盒容量=需要打印的单盘标签
                     ArrayList<string> midcode = new ArrayList<string>();
                     ArrayList<string> barcode = new ArrayList<string>();
                     ArrayList<string> custbarcode = new ArrayList<string>();
                     int restqty1 = 0;
-                    if (ProdIoInfDGV.Rows[i].Cells["pib_restqty1"].Value.ToString() != "")
+                    if (ProdIoInfDGV.Rows[i].Cells["pib_restqty1"].Value != null && ProdIoInfDGV.Rows[i].Cells["pib_restqty1"].Value.ToString() != "")
                     {
                         string[] restqty = ProdIoInfDGV.Rows[i].Cells["pib_restqty1"].Value.ToString().Split(',');
                         for (int k = 0; k < restqty.Length; k++)
@@ -241,11 +241,19 @@ namespace UAS_LabelMachine
                         string mid_code = dh.getFieldDataByCondition("PRODIOBARCODE", "nvl(max(to_number(PIB_OUTBOXCODE1)),0)+" + (j + 1), "PIB_INOUTNO='" + pi_inoutno.Text + "'").ToString();
                         //如果尾数不为0,并且已经遍历到了最后一箱(未装满的箱)
                         int count = 0;
-                        int AddNum = pr_zxbzs;
+                        decimal AddNum = pr_zxbzs;
                         if (mid_remain != 0 && j + 1 == mid_num)
                         {
                             //剩下的尾数刚好够整数的最小包或者加上一个未装满的最小包
-                            count = mid_remain % pr_zxbzs == 0 ? mid_remain / pr_zxbzs : (mid_remain / pr_zxbzs) + 1;
+                            int num = 0;
+                            if (int.TryParse((mid_remain % pr_zxbzs).ToString(), out num))
+                            {
+                                count = int.Parse(Math.Floor(mid_remain / pr_zxbzs).ToString());
+                            }
+                            else
+                            {
+                                count = int.Parse(Math.Ceiling(mid_remain / pr_zxbzs).ToString());
+                            }
                         }
                         else
                         {
@@ -267,11 +275,11 @@ namespace UAS_LabelMachine
                     {
                         //插入条码
                         sql.Clear();
-                        sql.Append("insert into prodiobarcode (PIB_ID,PIB_PRODCODE,PIB_INDATE,PIB_INOUTNO,PIB_PIID,pib_brand,PIB_BARCODE,PIB_CUSTBARCODE,PIB_PDNO,");
-                        sql.Append("PIB_PDID,PIB_PICLASS,PIB_QTY,PIB_PRODID,PIB_IFPRINT,PIB_IFPICK,PIB_ORDERCODE,PIB_CUSTPO,pib_orderdetno)");
-                        sql.Append(" values (prodiobarcode_seq.nextval,'" + pd_prodcode + "',sysdate,'" + pi_inoutno.Text + "'," + pi_id + ",'" + pr_brand + "',:barcode,:custbarcode,'" + pd_pdno + "','" + pd_id + "',");
-                        sql.Append("'" + pi_class.Text + "',:pib_inqty,'" + pr_id + "',0,0,'" + pd_ordercode + "','','" + pd_orderdetno + "')");
-                        dh.BatchInsert(sql.ToString(), new string[] { "barcode", "custbarcode", "pib_inqty" }, barcode.ToArray(), custbarcode.ToArray(), pib_inqty.ToArray());
+                        sql.Append("insert into prodiobarcode (PIB_ID,PIB_PRODCODE,pib_inman,PIB_INDATE,PIB_INOUTNO,PIB_PIID,pib_brand,PIB_BARCODE,PIB_CUSTBARCODE,PIB_PDNO,");
+                        sql.Append("PIB_PDID,PIB_PICLASS,PIB_QTY,PIB_PRODID,PIB_OUTBOXCODE1,PIB_IFPRINT,PIB_IFPICK,PIB_ORDERCODE,PIB_CUSTPO,pib_orderdetno)");
+                        sql.Append(" values (prodiobarcode_seq.nextval,'" + pd_prodcode + "','" + User.UserName + "',sysdate,'" + pi_inoutno.Text + "'," + pi_id + ",'" + pr_brand + "',:barcode,:custbarcode,'" + pd_pdno + "','" + pd_id + "',");
+                        sql.Append("'" + pi_class.Text + "',:pib_inqty,'" + pr_id + "',:midcode,0,0,'" + pd_ordercode + "','','" + pd_orderdetno + "')");
+                        dh.BatchInsert(sql.ToString(), new string[] { "barcode", "custbarcode", "pib_inqty", "midcode" }, barcode.ToArray(), custbarcode.ToArray(), pib_inqty.ToArray(), midcode.ToArray());
                         //更新最大流水号
                         dh.UpdateByCondition("RuleMaxNum", "rmn_maxnumber='" + custserialnum + "'", "rmn_nrcode='" + NrCode + "' and rmn_prefix='" + Prefix + "'");
                     }
@@ -392,7 +400,7 @@ namespace UAS_LabelMachine
             object mid_qty = ProdIoInfDGV.Rows[e.RowIndex].Cells["mid_qty"].Value;
             object pd_totalqty = ProdIoInfDGV.Rows[e.RowIndex].Cells["pd_totalqty"].Value;
             int restqty1 = 0;
-            if (ProdIoInfDGV.Rows[e.RowIndex].Cells["pib_restqty1"].Value.ToString() != "")
+            if (ProdIoInfDGV.Rows[e.RowIndex].Cells["pib_restqty1"].Value != null && ProdIoInfDGV.Rows[e.RowIndex].Cells["pib_restqty1"].Value.ToString() != "")
             {
                 string[] restqty = ProdIoInfDGV.Rows[e.RowIndex].Cells["pib_restqty1"].Value.ToString().Split(',');
                 for (int k = 0; k < restqty.Length; k++)
@@ -404,30 +412,22 @@ namespace UAS_LabelMachine
             }
             if (pr_zxbzs != null && pd_qty != null && mid_qty != null)
             {
-                int 最小包装量 = int.Parse(pr_zxbzs.ToString());
-                int 中盘容量 = int.Parse(mid_qty.ToString());
-                int 本次数量 = int.Parse(pd_qty.ToString());
-                int 总数 = int.Parse(pd_totalqty.ToString());
-                if (最小包装量 > 0)
+                decimal 最小包装量 = decimal.Parse(pr_zxbzs.ToString());
+                decimal 中盘容量 = decimal.Parse(mid_qty.ToString());
+                decimal 本次数量 = decimal.Parse(pd_qty.ToString());
+                decimal 总数 = decimal.Parse(pd_totalqty.ToString());
+                //计算中盘数量
+                decimal mid_num = 本次数量 / (最小包装量 * 中盘容量);
+                int num = 0;
+                if (int.TryParse(mid_num.ToString(), out num))
                 {
-                    if (本次数量 > 总数)
-                    {
-                        MessageBox.Show("本次数量不能大于总数");
-                        return;
-                    }
-                    if (中盘容量 <= 0 || 最小包装量 <= 0)
-                    {
-                        MessageBox.Show("中盘容量和单盘数量必须是正整数");
-                        return;
-                    }
-                    //计算中盘数量
-                    int mid_num = (本次数量 - restqty1) / (最小包装量 * 中盘容量);
-                    //计算中盘尾数
-                    if (((本次数量 - restqty1)) % (最小包装量 * 中盘容量) == 0)
-                        ProdIoInfDGV.Rows[e.RowIndex].Cells["mid_num"].Value = mid_num;
-                    else
-                        ProdIoInfDGV.Rows[e.RowIndex].Cells["mid_num"].Value = mid_num + 1;
-                    ProdIoInfDGV.Rows[e.RowIndex].Cells["mid_remain"].Value = 本次数量 - restqty1 - mid_num * 最小包装量 * 中盘容量;
+                    ProdIoInfDGV.Rows[e.RowIndex].Cells["mid_num"].Value = mid_num;
+                    ProdIoInfDGV.Rows[e.RowIndex].Cells["mid_remain"].Value = 本次数量 - mid_num * 最小包装量 * 中盘容量;
+                }
+                else
+                {
+                    ProdIoInfDGV.Rows[e.RowIndex].Cells["mid_num"].Value = Math.Floor(mid_num) + 1;
+                    ProdIoInfDGV.Rows[e.RowIndex].Cells["mid_remain"].Value = 本次数量 - Math.Floor(mid_num) * 最小包装量 * 中盘容量;
                 }
             }
         }
@@ -437,8 +437,9 @@ namespace UAS_LabelMachine
         {
             for (int i = 0; i < ProdIoInfDGV.Rows.Count; i++)
             {
+                ProdIoInfDGV.Rows[i].Cells["mid_qty"].Value = MidCapacity.Text;
                 int restqty1 = 0;
-                if (ProdIoInfDGV.Rows[i].Cells["pib_restqty1"].Value.ToString() != "")
+                if (ProdIoInfDGV.Rows[i].Cells["pib_restqty1"].Value != null && ProdIoInfDGV.Rows[i].Cells["pib_restqty1"].Value.ToString() != "")
                 {
                     string[] restqty = ProdIoInfDGV.Rows[i].Cells["pib_restqty1"].Value.ToString().Split(',');
                     for (int k = 0; k < restqty.Length; k++)
@@ -448,27 +449,28 @@ namespace UAS_LabelMachine
                         restqty1 += qty;
                     }
                 }
-                ProdIoInfDGV.Rows[i].Cells["mid_qty"].Value = MidCapacity.Text;
+                object pr_zxbzs = ProdIoInfDGV.Rows[i].Cells["pr_zxbzs"].Value;
+                object pd_qty = ProdIoInfDGV.Rows[i].Cells["pd_qty"].Value;
+                object mid_qty = ProdIoInfDGV.Rows[i].Cells["mid_qty"].Value;
+                object pd_totalqty = ProdIoInfDGV.Rows[i].Cells["pd_totalqty"].Value;
                 if (ProdIoInfDGV.Rows[i].Cells["pr_zxbzs"].Value.ToString() != "" && ProdIoInfDGV.Rows[i].Cells["pd_qty"].Value.ToString() != "" && ProdIoInfDGV.Rows[i].Cells["mid_qty"].Value.ToString() != "" && ProdIoInfDGV.Rows[i].Cells["pr_zxbzs"].Value.ToString() != "0")
                 {
-                    object pr_zxbzs = ProdIoInfDGV.Rows[i].Cells["pr_zxbzs"].Value;
-                    object pd_qty = ProdIoInfDGV.Rows[i].Cells["pd_qty"].Value;
-                    object mid_qty = ProdIoInfDGV.Rows[i].Cells["mid_qty"].Value;
-                    object pd_totalqty = ProdIoInfDGV.Rows[i].Cells["pd_totalqty"].Value;
-                    if (pr_zxbzs != null && pd_qty != null && mid_qty != null)
+                    decimal 最小包装量 = decimal.Parse(pr_zxbzs.ToString());
+                    decimal 中盘容量 = decimal.Parse(mid_qty.ToString());
+                    decimal 本次数量 = decimal.Parse(pd_qty.ToString());
+                    decimal 总数 = decimal.Parse(pd_totalqty.ToString());
+                    //计算中盘数量
+                    decimal mid_num = 本次数量 / (最小包装量 * 中盘容量);
+                    int num = 0;
+                    if (int.TryParse(mid_num.ToString(), out num))
                     {
-                        int 最小包装量 = int.Parse(pr_zxbzs.ToString());
-                        int 中盘容量 = int.Parse(mid_qty.ToString());
-                        int 本次数量 = int.Parse(pd_qty.ToString());
-                        int 总数 = int.Parse(pd_totalqty.ToString());
-                        //计算中盘数量
-                        int mid_num = (本次数量 - restqty1) / (最小包装量 * 中盘容量);
-                        //计算中盘尾数
-                        if (((本次数量 - restqty1)) % (最小包装量 * 中盘容量) == 0)
-                            ProdIoInfDGV.Rows[i].Cells["mid_num"].Value = mid_num;
-                        else
-                            ProdIoInfDGV.Rows[i].Cells["mid_num"].Value = mid_num + 1;
-                        ProdIoInfDGV.Rows[i].Cells["mid_remain"].Value = (本次数量 - restqty1) - mid_num * 最小包装量 * 中盘容量;
+                        ProdIoInfDGV.Rows[i].Cells["mid_num"].Value = mid_num;
+                        ProdIoInfDGV.Rows[i].Cells["mid_remain"].Value = 本次数量 - mid_num * 最小包装量 * 中盘容量;
+                    }
+                    else
+                    {
+                        ProdIoInfDGV.Rows[i].Cells["mid_num"].Value = Math.Floor(mid_num) + 1;
+                        ProdIoInfDGV.Rows[i].Cells["mid_remain"].Value = 本次数量 - Math.Floor(mid_num) * 最小包装量 * 中盘容量;
                     }
                 }
             }
@@ -484,14 +486,29 @@ namespace UAS_LabelMachine
             {
                 pi_id = dt.Rows[0]["pi_id"].ToString();
                 BaseUtil.SetFormValue(this.Controls, dt);
-                //查询出入库的类型
-                dt = (DataTable)dh.ExecuteSql("select ds_inorout from documentsetup where ds_name='" + pi_class.Text + "'", "select");
-                sql.Clear();
-                sql.Append("select '' pib_restqty1,pd_piid,pd_id,pr_id,pr_brand,pr_unit,pr_detail,pr_spec,pr_zxbzs,outqty pd_totalqty,pd_ordercode,pd_orderdetno,pd_pdno, ");
-                sql.Append("pd_prodcode,pd_piclass,pd_qty from (select pd_piid,pd_id,pr_id,pr_brand,pr_unit,pr_detail,pr_spec,pr_zxbzs,outqty,pd_ordercode,pd_orderdetno,pd_pdno,pd_prodcode,pd_piclass,");
-                sql.Append("outqty-nvl((select sum(nvl(pib_qty,0)) from PRODIOBARCODE where PIB_PIID=pd_piid and pib_pdno=pd_pdno),0)pd_qty from (select pd_piid,min(pd_id) pd_id,sum(pd_outqty)outqty, ");
-                sql.Append("pd_ordercode,pd_orderdetno,pd_pdno,max(pd_prodcode)pd_prodcode,max(pd_piclass)pd_piclass from prodiodetail where pd_piclass='出货单' group by pd_piid,pd_ordercode,pd_orderdetno,pd_pdno)T ");
-                sql.Append("left join product on pr_code=pd_prodcode where nvl(pr_zxbzs,0)>0)  where  pd_piid='" + pi_id + "'");
+                switch (pi_class.Text)
+                {
+                    case "出货单":
+                        sql.Clear();
+                        sql.Append("select pd_piid,pd_id,pr_id,pr_brand,pr_madein,pr_unit,pr_detail,pr_spec,pr_zxbzs,outqty pd_totalqty,pd_ordercode,pd_orderdetno,pd_pdno,pd_prodcode,");
+                        sql.Append("pd_piclass,pd_qty from (select pd_piid,pd_id,pr_id,pr_brand,pr_madein,pr_unit,pr_detail,pr_spec,pr_zxbzs,outqty,pd_ordercode,pd_orderdetno,pd_pdno,");
+                        sql.Append("pd_prodcode,pd_piclass,outqty-nvl((select sum(nvl(pib_qty,0)) from PRODIOBARCODE where PIB_PIID=pd_piid and pib_pdno=pd_pdno ),0)pd_qty ");
+                        sql.Append("from (select pd_piid,min(pd_id) pd_id,sum(pd_outqty)outqty,pd_ordercode,pd_orderdetno,pd_pdno,max(pd_prodcode)pd_prodcode,max(pd_piclass)pd_piclass ");
+                        sql.Append("from prodiodetail  group by pd_piid,pd_ordercode, pd_orderdetno,pd_pdno)T left join product ");
+                        sql.Append("on pr_code=pd_prodcode where nvl(pr_zxbzs,0)>0)  where  pd_piid='" + pi_id + "'");
+                        break;
+                    case "完工入库单":
+                        sql.Clear();
+                        sql.Append("select pd_piid,pd_id,pr_id,pr_brand,pr_madein,pr_unit,pr_detail,pr_spec,pr_zxbzs,inqty pd_totalqty,pd_ordercode,pd_orderdetno,pd_pdno,pd_prodcode,");
+                        sql.Append("pd_piclass,pd_qty from (select pd_piid,pd_id,pr_id,pr_brand,pr_madein,pr_unit,pr_detail,pr_spec,pr_zxbzs,inqty,pd_ordercode,pd_orderdetno,pd_pdno,");
+                        sql.Append("pd_prodcode,pd_piclass,inqty-nvl((select sum(nvl(pib_qty,0)) from PRODIOBARCODE where PIB_PIID=pd_piid and pib_pdno=pd_pdno ),0)pd_qty ");
+                        sql.Append("from (select pd_piid,min(pd_id) pd_id,sum(pd_inqty)inqty,pd_ordercode,pd_orderdetno,pd_pdno,max(pd_prodcode)pd_prodcode,max(pd_piclass)pd_piclass ");
+                        sql.Append("from prodiodetail  group by pd_piid,pd_ordercode, pd_orderdetno,pd_pdno)T left join product ");
+                        sql.Append("on pr_code=pd_prodcode )  where  pd_piid='" + pi_id + "'");
+                        break;
+                    default:
+                        break;
+                }
                 dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
                 BaseUtil.FillDgvWithDataTable(ProdIoInfDGV, dt);
             }