瀏覽代碼

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

caosy 6 年之前
父節點
當前提交
ea9d88b3e9

+ 4 - 2
PLCDataReader/PublicMethod/BaseUtil.cs

@@ -423,13 +423,15 @@ namespace UAS_PLCDataReader.PublicMethod
                         {
                             if (Convert.ToInt32("0x" + (RealData.Substring(i, DataSize).Substring(0, 4)), 16) / 1 != 0)
                                 ReturnData.Add(Convert.ToInt32("0x" + (RealData.Substring(i, DataSize).Substring(0, 4)), 16));
+                            if (Convert.ToInt32("0x" + (RealData.Substring(i, DataSize).Substring(4, 4)), 16) / 1 != 0)
+                                ReturnData.Add(Convert.ToInt32("0x" + (RealData.Substring(i, DataSize).Substring(4, 4)), 16));
                         }
                     }
                 }
             }
-            catch (Exception)
+            catch (Exception ex)
             {
-
+                Console.WriteLine(ex.Message);
             }
             return ReturnData.ToArray();
         }

+ 35 - 20
UAS-出货标签管理(泽天)/UAS_出货标签管理.Designer.cs

@@ -167,6 +167,7 @@
             this.MidLabelAutoPrint = new System.Windows.Forms.CheckBox();
             this.MidLabelCombox = new System.Windows.Forms.ComboBox();
             this.OutBoxLabel = new UAS_LabelMachine.CustomControl.GroupBoxWithBorder.GroupBoxWithBorder();
+            this.BoxCount = new System.Windows.Forms.Label();
             this.DiffLotNo = new System.Windows.Forms.CheckBox();
             this.DiffDC = new System.Windows.Forms.CheckBox();
             this.OnlyOneRow = new System.Windows.Forms.CheckBox();
@@ -180,7 +181,7 @@
             this.OutboxCapacity = new System.Windows.Forms.NumericUpDown();
             this.OutBoxLabelPrint = new System.Windows.Forms.Button();
             this.OutBoxCombox = new System.Windows.Forms.ComboBox();
-            this.BoxCount = new System.Windows.Forms.Label();
+            this.CloseSerialPort = new System.Windows.Forms.Button();
             ((System.ComponentModel.ISupportInitialize)(this.MidSource)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
             this.groupBoxWithBorder2.SuspendLayout();
@@ -758,14 +759,15 @@
             // 
             // groupBoxWithBorder2
             // 
+            this.groupBoxWithBorder2.Controls.Add(this.CloseSerialPort);
             this.groupBoxWithBorder2.Controls.Add(this.ConnectCom);
             this.groupBoxWithBorder2.Controls.Add(this.ButtonWeigh);
             this.groupBoxWithBorder2.Controls.Add(this.Weight);
-            this.groupBoxWithBorder2.Location = new System.Drawing.Point(1135, 222);
+            this.groupBoxWithBorder2.Location = new System.Drawing.Point(1124, 222);
             this.groupBoxWithBorder2.Margin = new System.Windows.Forms.Padding(2);
             this.groupBoxWithBorder2.Name = "groupBoxWithBorder2";
             this.groupBoxWithBorder2.Padding = new System.Windows.Forms.Padding(2);
-            this.groupBoxWithBorder2.Size = new System.Drawing.Size(123, 155);
+            this.groupBoxWithBorder2.Size = new System.Drawing.Size(134, 155);
             this.groupBoxWithBorder2.TabIndex = 113;
             this.groupBoxWithBorder2.TabStop = false;
             this.groupBoxWithBorder2.Text = "称重";
@@ -773,7 +775,7 @@
             // ConnectCom
             // 
             this.ConnectCom.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.ConnectCom.Location = new System.Drawing.Point(27, 93);
+            this.ConnectCom.Location = new System.Drawing.Point(7, 93);
             this.ConnectCom.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.ConnectCom.Name = "ConnectCom";
             this.ConnectCom.Size = new System.Drawing.Size(80, 26);
@@ -785,10 +787,10 @@
             // ButtonWeigh
             // 
             this.ButtonWeigh.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.ButtonWeigh.Location = new System.Drawing.Point(27, 123);
+            this.ButtonWeigh.Location = new System.Drawing.Point(7, 123);
             this.ButtonWeigh.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.ButtonWeigh.Name = "ButtonWeigh";
-            this.ButtonWeigh.Size = new System.Drawing.Size(81, 26);
+            this.ButtonWeigh.Size = new System.Drawing.Size(66, 26);
             this.ButtonWeigh.TabIndex = 97;
             this.ButtonWeigh.Text = "称量箱重";
             this.ButtonWeigh.UseVisualStyleBackColor = true;
@@ -852,7 +854,7 @@
             this.GridPrcode.MultiSelect = false;
             this.GridPrcode.Name = "GridPrcode";
             this.GridPrcode.RowTemplate.Height = 23;
-            this.GridPrcode.Size = new System.Drawing.Size(1134, 158);
+            this.GridPrcode.Size = new System.Drawing.Size(1119, 158);
             this.GridPrcode.TabIndex = 88;
             this.GridPrcode.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.GridPrcode_CellClick);
             this.GridPrcode.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.GridPrcode_CellEndEdit);
@@ -1609,6 +1611,15 @@
             this.OutBoxLabel.TabStop = false;
             this.OutBoxLabel.Text = "外箱标签";
             // 
+            // BoxCount
+            // 
+            this.BoxCount.AutoSize = true;
+            this.BoxCount.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.BoxCount.Location = new System.Drawing.Point(8, 183);
+            this.BoxCount.Name = "BoxCount";
+            this.BoxCount.Size = new System.Drawing.Size(0, 17);
+            this.BoxCount.TabIndex = 97;
+            // 
             // DiffLotNo
             // 
             this.DiffLotNo.AutoSize = true;
@@ -1763,14 +1774,17 @@
             this.OutBoxCombox.TabIndex = 78;
             this.OutBoxCombox.SelectedIndexChanged += new System.EventHandler(this.OutBoxCombox_SelectedIndexChanged);
             // 
-            // BoxCount
+            // CloseSerialPort
             // 
-            this.BoxCount.AutoSize = true;
-            this.BoxCount.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.BoxCount.Location = new System.Drawing.Point(8, 183);
-            this.BoxCount.Name = "BoxCount";
-            this.BoxCount.Size = new System.Drawing.Size(0, 17);
-            this.BoxCount.TabIndex = 97;
+            this.CloseSerialPort.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.CloseSerialPort.Location = new System.Drawing.Point(74, 123);
+            this.CloseSerialPort.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+            this.CloseSerialPort.Name = "CloseSerialPort";
+            this.CloseSerialPort.Size = new System.Drawing.Size(55, 26);
+            this.CloseSerialPort.TabIndex = 115;
+            this.CloseSerialPort.Text = "关闭";
+            this.CloseSerialPort.UseVisualStyleBackColor = true;
+            this.CloseSerialPort.Click += new System.EventHandler(this.CloseSerialPort_Click);
             // 
             // UAS_出货标签打印
             // 
@@ -1831,21 +1845,21 @@
             this.SizeChanged += new System.EventHandler(this.贴标机条码打印_SizeChanged);
             ((System.ComponentModel.ISupportInitialize)(this.MidSource)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
-            this.groupBoxWithBorder2.ResumeLayout(false);
+            this.groupBoxWithBorder2.ResumeLayout(true);
             this.groupBoxWithBorder2.PerformLayout();
             ((System.ComponentModel.ISupportInitialize)(this.GridPrcode)).EndInit();
-            this.groupBoxWithBorder1.ResumeLayout(false);
+            this.groupBoxWithBorder1.ResumeLayout(true);
             this.groupBoxWithBorder1.PerformLayout();
             ((System.ComponentModel.ISupportInitialize)(this.LabelInf)).EndInit();
-            this.SingleLabel.ResumeLayout(false);
+            this.SingleLabel.ResumeLayout(true);
             this.SingleLabel.PerformLayout();
-            this.MidLabel.ResumeLayout(false);
+            this.MidLabel.ResumeLayout(true);
             this.MidLabel.PerformLayout();
             ((System.ComponentModel.ISupportInitialize)(this.MidboxCapacity)).EndInit();
-            this.OutBoxLabel.ResumeLayout(false);
+            this.OutBoxLabel.ResumeLayout(true);
             this.OutBoxLabel.PerformLayout();
             ((System.ComponentModel.ISupportInitialize)(this.OutboxCapacity)).EndInit();
-            this.ResumeLayout(false);
+            this.ResumeLayout(true);
             this.PerformLayout();
 
         }
@@ -2001,5 +2015,6 @@
         private System.Windows.Forms.DataGridViewTextBoxColumn pjd_zxbzs_user;
         private System.Windows.Forms.DataGridViewTextBoxColumn pr_spec1;
         private System.Windows.Forms.Label BoxCount;
+        private System.Windows.Forms.Button CloseSerialPort;
     }
 }

+ 31 - 9
UAS-出货标签管理(泽天)/UAS_出货标签管理.cs

@@ -405,7 +405,7 @@ namespace UAS_LabelMachine
             }
             catch (Exception)
             {
-                dh.UpdateByCondition("RULEMAXNUM", "rmn_maxnumber='" + (MaxNum + 1) + "'", "rmn_nrcode='" + (NrCode == "" ? "Default" : NrCode) + "' and rmn_prefix='" + Prefix + "' and rmn_type='" + ReSetType + "'");
+                dh.UpdateByCondition("RULEMAXNUM", "rmn_maxnumber='" + (MaxNum + 1) + "'", "rmn_nrcode='" + (NrCode == "" ? "Default" : NrCode) + "' and rmn_prefix='" + Prefix + "' and nvl(rmn_type,' ')='" + ReSetType + "'");
                 CollectInputData();
                 return;
             }
@@ -1714,7 +1714,7 @@ namespace UAS_LabelMachine
                         else
                         {
                             MaxNum = int.Parse(maxnum);
-                            dh.UpdateByCondition("RULEMAXNUM", "rmn_maxnumber='" + (MaxNum + Count) + "'", "rmn_nrcode='" + (NrCode == "" ? "Default" : NrCode) + "' and rmn_prefix='" + Prefix + "' and rmn_type='" + ReSetType + "'");
+                            dh.UpdateByCondition("RULEMAXNUM", "rmn_maxnumber='" + (MaxNum + Count) + "'", "rmn_nrcode='" + (NrCode == "" ? "Default" : NrCode) + "' and rmn_prefix='" + Prefix + "' and nvl(rmn_type,' ')='" + ReSetType + "'");
                         }
                         SerialNumLength = int.Parse(Nr.Rows[m]["nrd_length"].ToString());
                         Radix = int.Parse(Nr.Rows[m]["nrd_radix"].ToString());
@@ -1914,6 +1914,7 @@ namespace UAS_LabelMachine
                 GetBarCodeRule(out Prefix, out Suffix, out MaxNum, out NumLength, out Radix, GetNumCount);
                 List<string> OutBoxCode = new List<string>();
                 List<string> PIBID = new List<string>();
+                string Str_OutBoxCode = "";
                 for (int i = 0; i < LabelInf.Rows.Count; i++)
                 {
                     if (LabelInf.Rows[i].Cells["pib_custoutboxcode"].Value.ToString() == "")
@@ -1942,10 +1943,23 @@ namespace UAS_LabelMachine
                             }
                         }
                         OutBoxCode.Add(Prefix + serialcode + Suffix);
+                        Str_OutBoxCode += "'" + Prefix + serialcode + Suffix + "',";
                     }
                 }
-                dh.BatchInsert("update prodiobarcode set pib_custoutboxcode=:pib_custoutboxcode where pib_id=:pib_id and pib_custoutboxcode is null", new string[] { "pib_custoutboxcode", "pib_outboxcode2" }, OutBoxCode.ToArray(), PIBID.ToArray());
-                LoadGridData(sender, e);
+                if (OutBoxCode.ToArray().Length > 0)
+                {
+                    if (!dh.CheckExist("prodiobarcode", "pib_custcode='" + pi_cardcode.Text + "' and pib_custoutboxcode in (" + Str_OutBoxCode.Substring(0, Str_OutBoxCode.Length - 1) + ")"))
+                    {
+                        dh.BatchInsert("update prodiobarcode set pib_custoutboxcode=:pib_custoutboxcode where pib_id=:pib_id and pib_custoutboxcode is null", new string[] { "pib_custoutboxcode", "pib_outboxcode2" }, OutBoxCode.ToArray(), PIBID.ToArray());
+                    }
+                    else
+                    {
+                        dh.UpdateByCondition("RULEMAXNUM", "rmn_maxnumber='" + (MaxNum + 1) + "'", "rmn_nrcode='" + (NrCode == "" ? "Default" : NrCode) + "' and rmn_prefix='" + Prefix + "' and nvl(rmn_type,' ')='" + ReSetType + "'");
+                        Pack_Click(sender, e);
+                        return;
+                    }
+                    LoadGridData(sender, e);
+                }
             }
         }
 
@@ -2192,18 +2206,26 @@ namespace UAS_LabelMachine
                 int len = Com.BytesToRead;
                 byte[] readBuffer = new byte[len];
                 Com.Read(readBuffer, 0, len); //将数据读入缓存
-                Weight.Text = reg.Match(Encoding.ASCII.GetString(readBuffer, 0, len)).Value;
-                //读不到数据的时间删掉
-                if (Weight.Text == "")
+                string value = reg.Match(Encoding.ASCII.GetString(readBuffer, 0, len)).Value;
+                if (value != "")
                 {
-                    Com.DataReceived -= Com_DataReceived;
-                    return;
+                    Weight.Text = value;
                 }
+                //读不到数据的时间删掉
             }
             catch (Exception)
             {
                 return;
             }
         }
+
+        private void CloseSerialPort_Click(object sender, EventArgs e)
+        {
+            if (Com.IsOpen)
+            {
+                Com.Close();
+                Com.DataReceived -= Com_DataReceived;
+            }
+        }
     }
 }

+ 5 - 0
UAS-出货标签管理(贸易版)/Entity/SystemInf.cs

@@ -11,6 +11,11 @@ namespace UAS_LabelMachine.Entity
 
         public static SqliteDBHelper sdh;
 
+        /// <summary>
+        /// 账套
+        /// </summary>
+        public static string Master;
+
         public static bool CheckDcAndLotNo = false;
     }
 }

+ 2 - 0
UAS-出货标签管理(贸易版)/Login.cs

@@ -81,6 +81,8 @@ namespace UAS_LabelMachine
             //切换至用户选择的数据源
             string ConnectionString = "Connection Timeout=0;Pooling=false;Password=" + Ms_Pwd + ";User ID=" + MasterCombox.SelectedValue.ToString() + ";Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=" + IP.Text + ")(PORT=" + DataHelper.OraclePort + ")))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
             DataHelper.DBConnectionString = ConnectionString;
+            //设置当前账套
+            SystemInf.Master = MasterCombox.SelectedValue.ToString();
             //设置了Connection,重新执行构造函数,重置数据库连接
             dh = new DataHelper();
             string oMsg = "";

+ 334 - 1
UAS-出货标签管理(贸易版)/PublicMethod/LogicHandler.cs

@@ -1,4 +1,10 @@
-using UAS_LabelMachine.Entity;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Windows.Forms;
+using UAS_LabelMachine.Entity;
 
 namespace UAS_LabelMachine.PublicMethod
 {
@@ -82,5 +88,332 @@ namespace UAS_LabelMachine.PublicMethod
             dh.CallProcedure("sp_GenerateBarCode", ref param);
             oSQL = param[2];
         }
+
+        public static void ImportExcel(string iMaster, string iFileName, string iPiID, string iInOutNo, string iCustCode)
+        {
+
+            switch (iMaster)
+            {
+                //海创
+                case "N_HC":
+                    ImportExcel_HC(iFileName, iPiID, iInOutNo, iCustCode);
+                    break;
+                default:
+                    break;
+            }
+        }
+
+        //海创的导入方法
+        public static void ImportExcel_HC(string iFileName, string iPiID, string iInOutNo, string iCustCode)
+        {
+            StringBuilder sql = new StringBuilder();
+            //获取最大的流水号
+            DataTable dt = ExcelHandler.ExcelToDataTable(iFileName, true);
+            if (dt == null)
+            {
+                MessageBox.Show("文件" + iFileName + "被占用或者格式不正确");
+                return;
+            }
+            string outsql = "";
+            GenerateBarCode(iPiID, iCustCode, out outsql);
+            sql.Clear();
+            sql.Append(outsql);
+            DataTable dt1 = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
+            //需要插入的参数
+            ArrayList<string> barcode = new ArrayList<string>();
+            ArrayList<string> custbarcode = new ArrayList<string>();
+            ArrayList<string> datecode = new ArrayList<string>();
+            ArrayList<string> lotno = new ArrayList<string>();
+            ArrayList<string> pib_inqty = new ArrayList<string>();
+            ArrayList<string> piboutboxcode2 = new ArrayList<string>();
+            ArrayList<string> pdordercode = new ArrayList<string>();
+            ArrayList<string> pdorderdetno = new ArrayList<string>();
+            ArrayList<string> pdpdno = new ArrayList<string>();
+            ArrayList<string> pdid = new ArrayList<string>();
+            ArrayList<string> prbrand = new ArrayList<string>();
+            ArrayList<string> pdprodcode = new ArrayList<string>();
+            ArrayList<string> pib_custoutboxcode = new ArrayList<string>();
+            ArrayList<string> brand = new ArrayList<string>();
+            ArrayList<string> madein = new ArrayList<string>();
+            ArrayList<string> prdetail = new ArrayList<string>();
+            ArrayList<string> ordercode = new ArrayList<string>();
+            ArrayList<string> size = new ArrayList<string>();
+            ArrayList<string> weight = new ArrayList<string>();
+            //用于数量的校验
+            Dictionary<string, decimal> sumqty = new Dictionary<string, decimal>();
+            Dictionary<string, Dictionary<string, decimal>> outsumqty = new Dictionary<string, Dictionary<string, decimal>>();
+            for (int i = 0; i < dt.Rows.Count; i++)
+            {
+                string pr_spec = dt.Rows[i]["规格型号"].ToString().Trim();
+                if (pr_spec.Trim() == "")
+                {
+                    break;
+                }
+                string qty = Regex.Replace(dt.Rows[i]["数量"].ToString(), @"[^\d]*", ""); ;
+                //累计Excel该型号的数量
+                if (!sumqty.ContainsKey(pr_spec))
+                {
+                    sumqty.Add(pr_spec, 0);
+                }
+                //累计Excel该型号的数量
+                sumqty[pr_spec] += decimal.Parse(qty);
+            }
+            for (int i = 0; i < dt1.Rows.Count; i++)
+            {
+                //不包含型号则进行添加
+                string pr_spec = dt1.Rows[i]["pr_spec"].ToString().Trim();
+                string pd_pdno = dt1.Rows[i]["pd_pdno"].ToString();
+                decimal pd_outqty = decimal.Parse(dt1.Rows[i]["pd_outqty"].ToString());
+                if (!outsumqty.ContainsKey(pr_spec))
+                {
+                    Dictionary<string, decimal> dic = new Dictionary<string, decimal>();
+                    dic.Add(pd_pdno, pd_outqty);
+                    outsumqty.Add(pr_spec, dic);
+                }
+                else
+                {
+                    outsumqty[pr_spec].Add(pd_pdno, pd_outqty);
+                }
+            }
+            //上一个的最小外箱号,如果箱号没有发生变化则外箱条码也不变化
+            for (int i = 0; i < dt.Rows.Count; i++)
+            {
+                string pr_spec = dt.Rows[i]["规格型号"].ToString().Trim();
+                string 品牌 = dt.Rows[i]["品牌"].ToString().Trim();
+                string 产地 = dt.Rows[i]["产地"].ToString().Trim();
+                string 尺寸 = dt.Rows[i]["尺寸"].ToString().Trim();
+                string 重量 = dt.Rows[i]["重量"].ToString().Trim();
+                string 产品名称 = dt.Rows[i]["产品名称"].ToString().Trim();
+                string 订单编号 = dt.Rows[i]["订单编号"].ToString().Trim();
+                if (pr_spec.Trim() == "")
+                {
+                    break;
+                }
+                string qty = dt.Rows[i]["数量"].ToString();
+                string DateCode = "";
+                string LotNo = "";
+                if (dt.Columns.Contains("DC/LOT NO"))
+                {
+                    if (dt.Rows[i]["DC/LOT NO"].ToString().IndexOf("-") > 0)
+                    {
+                        DateCode = dt.Rows[i]["DC/LOT NO"].ToString().Split('-')[0];
+                        LotNo = dt.Rows[i]["DC/LOT NO"].ToString().Split('-')[1];
+                    }
+                    else if (dt.Rows[i]["DC/LOT NO"].ToString().IndexOf(" ") > 0)
+                    {
+                        DateCode = dt.Rows[i]["DC/LOT NO"].ToString().Split(' ')[0];
+                        LotNo = dt.Rows[i]["DC/LOT NO"].ToString().Split(' ')[1];
+                    }
+                }
+                if (dt.Columns.Contains("DC") && DateCode == "")
+                {
+                    DateCode = dt.Rows[i]["DC"].ToString();
+                }
+                if (dt.Columns.Contains("LOT NO") && LotNo == "")
+                {
+                    LotNo = dt.Rows[i]["LOT NO"].ToString();
+                }
+                string pib_outboxcode2 = dt.Rows[i]["箱号"].ToString();
+                DataRow[] dr = dt1.Select("pr_spec='" + pr_spec + "'");
+                if (dr.Length == 0)
+                {
+                    FilterData(iCustCode, "FUDAN", pr_spec, qty, DateCode, LotNo, out pr_spec, out qty, out DateCode, out LotNo);
+                    dr = dt1.Select("pr_spec='" + pr_spec + "'");
+                }
+                else
+                {
+                    FilterData(iCustCode, dr[0]["pr_brand"].ToString(), pr_spec, qty, DateCode, LotNo, out pr_spec, out qty, out DateCode, out LotNo);
+                }
+                if (dr.Length == 0)
+                {
+                    MessageBox.Show("出货单" + iInOutNo + "不包含型号" + pr_spec);
+                    return;
+                }
+                decimal outqty = decimal.Parse(Regex.Replace(qty, @"[^\d]*", ""));
+                for (int k = 0; k < dr.Length; k++)
+                {
+                    string pd_orderdetno = dr[k]["pd_orderdetno"].ToString();
+                    string pd_prodcode = dr[k]["pd_prodcode"].ToString();
+                    string pd_ordercode = dr[k]["pd_ordercode"].ToString();
+                    string pd_piid = dr[k]["pd_piid"].ToString();
+                    string pr_brand = dr[k]["pr_brand"].ToString();
+                    string pd_pdno = dr[k]["pd_pdno"].ToString();
+                    string pd_id = dr[k]["pd_id"].ToString();
+                    string pd_piclass = dr[k]["pd_piclass"].ToString();
+                    string pr_id = dr[k]["pr_id"].ToString();
+                    string pr_madein = dr[k]["pr_madein"].ToString();
+                    //已导入数量
+                    decimal zxbzs = decimal.Parse(dr[k]["pr_zxbzs"].ToString());
+                    decimal pd_outqty = 0;
+                    decimal barcodenum = 0;
+                    if (outsumqty[pr_spec][pd_pdno] == 0)
+                    {
+                        continue;
+                    }
+                    //如果导入行的数量小于改明细的出货数量
+                    if (outsumqty[pr_spec][pd_pdno] >= outqty)
+                    {
+                        //使用导入明细行数量
+                        pd_outqty = outqty;
+                    }
+                    else
+                    {
+                        ////使用该出货单明细行数量,并且数量置为0
+                        pd_outqty = outsumqty[pr_spec][pd_pdno];
+                    }
+                    string pib_barcode = dh.getFieldDataByCondition("prodiobarcode", "max(pib_barcode)", "PIB_INOUTNO='" + iInOutNo + "'").ToString();
+                    if (pd_outqty % zxbzs != 0)
+                    {
+                        barcodenum = Math.Floor(pd_outqty / zxbzs) + 1;
+                        //如果有余数先加上所有最小包最后加尾数
+                        for (int j = 0; j < barcodenum - 1; j++)
+                        {
+                            barcode.Add(BaseUtil.BarcodeMethod1(pd_id, pr_id, pib_barcode));
+                            custbarcode.Add(BarcodeMethod1(UAS_出货标签打印.PrefixFixed, UAS_出货标签打印.Suffix, UAS_出货标签打印.SerialNumIndex, UAS_出货标签打印.SerialNumLength, UAS_出货标签打印.Radix));
+                            pib_custoutboxcode.Add(pib_outboxcode2);
+                            piboutboxcode2.Add(pib_outboxcode2);
+                            pib_inqty.Add(zxbzs);
+                            datecode.Add(DateCode);
+                            lotno.Add(LotNo);
+                            pdordercode.Add(订单编号 == "" ? pd_ordercode : 订单编号);
+                            pdorderdetno.Add(pd_orderdetno);
+                            pdpdno.Add(pd_pdno);
+                            pdid.Add(pd_id);
+                            prbrand.Add(品牌 == "" ? pr_brand : 品牌);
+                            madein.Add(产地 == "" ? pr_madein : 产地);
+                            size.Add(尺寸);
+                            weight.Add(重量);
+                            prdetail.Add(产品名称);
+                            ordercode.Add(订单编号);
+                            pdprodcode.Add(pd_prodcode);
+                        }
+                        custbarcode.Add(BarcodeMethod1(UAS_出货标签打印.PrefixFixed, UAS_出货标签打印.Suffix, UAS_出货标签打印.SerialNumIndex, UAS_出货标签打印.SerialNumLength, UAS_出货标签打印.Radix));
+                        pib_custoutboxcode.Add(pib_outboxcode2);
+                        barcode.Add(BaseUtil.BarcodeMethod1(pd_id, pr_id, pib_barcode));
+                        pib_inqty.Add(pd_outqty % zxbzs);
+                        piboutboxcode2.Add(pib_outboxcode2);
+                        datecode.Add(DateCode);
+                        lotno.Add(LotNo);
+                        pdordercode.Add(订单编号 == "" ? pd_ordercode : 订单编号);
+                        pdorderdetno.Add(pd_orderdetno);
+                        pdpdno.Add(pd_pdno);
+                        pdid.Add(pd_id);
+                        prbrand.Add(品牌 == "" ? pr_brand : 品牌);
+                        madein.Add(产地 == "" ? pr_madein : 产地);
+                        size.Add(尺寸);
+                        weight.Add(重量);
+                        prdetail.Add(产品名称);
+                        ordercode.Add(订单编号);
+                        pdprodcode.Add(pd_prodcode);
+                    }
+                    else
+                    {
+                        barcodenum = pd_outqty / zxbzs;
+                        for (int j = 0; j < barcodenum; j++)
+                        {
+                            barcode.Add(BaseUtil.BarcodeMethod1(pd_id, pr_id, pib_barcode));
+                            custbarcode.Add(BarcodeMethod1(UAS_出货标签打印.PrefixFixed, UAS_出货标签打印.Suffix, UAS_出货标签打印.SerialNumIndex, UAS_出货标签打印.SerialNumLength, UAS_出货标签打印.Radix));
+                            pib_custoutboxcode.Add(pib_outboxcode2);
+                            pib_inqty.Add(zxbzs);
+                            piboutboxcode2.Add(pib_outboxcode2);
+                            datecode.Add(DateCode);
+                            lotno.Add(LotNo);
+                            pdordercode.Add(订单编号 == "" ? pd_ordercode : 订单编号);
+                            pdorderdetno.Add(pd_orderdetno);
+                            pdpdno.Add(pd_pdno);
+                            pdid.Add(pd_id);
+                            prbrand.Add(品牌 == "" ? pr_brand : 品牌);
+                            madein.Add(产地 == "" ? pr_madein : 产地);
+                            size.Add(尺寸);
+                            weight.Add(重量);
+                            prdetail.Add(产品名称);
+                            pdprodcode.Add(pd_prodcode);
+                        }
+                    }
+                    outqty -= outsumqty[pr_spec][pd_pdno];
+                    outsumqty[pr_spec][pd_pdno] -= pd_outqty;
+                }
+            }
+            string Lastoutbox = "";
+            string Lastoutboxcode = "";
+            List<string> custoutboxcode = new List<string>();
+            //根据记录的箱号,在料盘的流水之后拼接外箱的流水
+            for (int i = 0; i < pib_custoutboxcode.Count; i++)
+            {
+                if (Lastoutbox != pib_custoutboxcode[i].ToString())
+                {
+                    Lastoutboxcode = BarcodeMethod1(UAS_出货标签打印.PrefixFixed, UAS_出货标签打印.Suffix, UAS_出货标签打印.SerialNumIndex, UAS_出货标签打印.SerialNumLength, UAS_出货标签打印.Radix);
+                    custoutboxcode.Add(Lastoutboxcode);
+                    Lastoutbox = pib_custoutboxcode[i].ToString();
+                }
+                else
+                {
+                    custoutboxcode.Add(Lastoutboxcode);
+                }
+            }
+            //插叙所有的统计数量
+            string ErrMsg = "";
+            foreach (var item in sumqty)
+            {
+                dt = (DataTable)dh.ExecuteSql("select nvl(sum(pd_outqty),0)pd_outqty,pr_spec from prodiodetail left join product on pr_code=pd_prodcode where pd_piid='" + iPiID + "' group by pr_spec", "select");
+                dt1 = (DataTable)dh.ExecuteSql("select nvl(sum(pib_qty),0)pib_qty,pr_spec  from prodiobarcode left join product on pib_prodcode=pr_code where pib_piid='" + iPiID + "' group by pr_spec", "select");
+                DataRow[] dr = dt.Select("pr_spec='" + item.Key + "'");
+                DataRow[] dr1 = dt1.Select("pr_spec='" + item.Key + "'");
+                if (dr.Length > 0)
+                {
+                    decimal pd_outqty = decimal.Parse(dr[0]["pd_outqty"].ToString());
+                    decimal pib_qty = 0;
+                    //如果有已导入的数量
+                    if (dr1.Length > 0)
+                    {
+                        pib_qty = decimal.Parse(dr1[0]["pib_qty"].ToString());
+                    }
+                    //本次导入的数量和原有导入数量累加和出库数量做对比
+                    if (pd_outqty < item.Value + pib_qty)
+                    {
+                        ErrMsg += "型号" + dr[0]["pr_spec"].ToString() + "出货数量" + pd_outqty + ",已导入数量" + pib_qty + ",本次导入" + item.Value + ",超出数量" + (item.Value + pib_qty - pd_outqty) + "\n";
+                    }
+                }
+            }
+            if (ErrMsg == "")
+            {
+                if (pdprodcode.Count > 0)
+                {
+                    sql.Clear();
+                    sql.Append("insert into prodiobarcode (PIB_ID,PIB_PRODCODE,pib_inman,PIB_INDATE,PIB_INOUTNO,PIB_PIID,pib_brand,PIB_BARCODE,PIB_PDNO,");
+                    sql.Append("PIB_PDID,PIB_PICLASS,PIB_QTY,pib_datecode,pib_lotno,PIB_IFPRINT,PIB_IFPICK,PIB_ORDERCODE,pib_orderdetno,");
+                    sql.Append("pib_outboxcode2,pib_custbarcode,pib_custoutboxcode,pib_madein,pib_size,pib_weight,pib_prdetail)values(prodiobarcode_seq.nextval,:pd_prodcode,'" + User.UserName + "',sysdate,");
+                    sql.Append("'" + iInOutNo + "'," + iPiID + ",:pr_brand,:barcode,:pd_pdno,:pd_id,'',:pib_inqty,");
+                    sql.Append(":pib_datecode,:pib_lotno,0,-1,:pd_ordercode,:pd_orderdetno,:outboxcode,:custbarcode,:pib_custoutboxcode,:pib_madein,:pib_size,:pib_weight,:pib_prdetail)");
+                    dh.BatchInsert(sql.ToString(), new string[] { "pd_prodcode", "pr_brand", "barcode", "pd_pdno", "pd_id", "pib_inqty", "pib_datecode", "pib_lotno", "pd_ordercode", "pd_orderdetno", "outboxcode", "custbarcode", "pib_custoutboxcode", "pib_madein", "pib_size", "pib_weight", "pib_prdetail" }, pdprodcode.ToArray(), prbrand.ToArray(), barcode.ToArray(), pdpdno.ToArray(), pdid.ToArray(), pib_inqty.ToArray(), datecode.ToArray(), lotno.ToArray(), pdordercode.ToArray(), pdorderdetno.ToArray(), piboutboxcode2.ToArray(), custbarcode.ToArray(), custoutboxcode.ToArray(), madein.ToArray(), size.ToArray(), weight.ToArray(), prdetail.ToArray());
+                    //更新流水
+                    dh.UpdateByCondition("RuleMaxNum", "rmn_maxnumber='" + UAS_出货标签打印.custserialnum + "'", "rmn_nrcode='" + UAS_出货标签打印.NrCode + "' and rmn_prefix='" + UAS_出货标签打印.Prefix + "'");
+                }
+                else
+                {
+                    MessageBox.Show("解析数据不包含出货单数据,请重新导入", "提示");
+                }
+            }
+            else
+            {
+                MessageBox.Show(ErrMsg, "超出数量提醒");
+            }
+        }
+
+        //生成客户条码
+        public static string BarcodeMethod1(string Prefix, string Suffix, int Index, int Length, int radix)
+        {
+            string str = Prefix;
+            //如果是流水则需要在前面加0
+            string serialcode = BaseUtil.DToAny(UAS_出货标签打印.custserialnum, radix);
+            for (int j = serialcode.ToString().Length; j < Length; j++)
+            {
+                serialcode = "0" + serialcode;
+            }
+            str += serialcode;
+            str += Suffix;
+            UAS_出货标签打印.custserialnum = UAS_出货标签打印.custserialnum + 1;
+            return str;
+        }
     }
 }

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

@@ -198,12 +198,17 @@ namespace UAS_LabelMachine.PublicMethod
         {
             public static void SinglePrint(LabelFormatDocument SingleFormat, DataTable SingleLabelParam, string pib_id)
             {
+                if (pib_id == "-1")
+                {
+                    SingleFormat.Print();
+                    return;
+                }
                 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 && dr1[0]["lp_valuetype"].ToString() == "字符串" && dr1[0]["lp_sql"].ToString() != "")
+                    if (dr1.Length > 0 && (dr1[0]["lp_valuetype"].ToString() == "字符串" || dr1[0]["lp_valuetype"].ToString() == "text") && dr1[0]["lp_sql"].ToString() != "")
                     {
                         sql.Append(dr1[0]["lp_sql"].ToString() + ",");
                     }
@@ -213,7 +218,7 @@ namespace UAS_LabelMachine.PublicMethod
                 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() == "字符串" && dr1[0]["lp_sql"].ToString() != "")
+                    if (dr1.Length > 0 && (dr1[0]["lp_valuetype"].ToString() == "字符串" || dr1[0]["lp_valuetype"].ToString() == "text") && dr1[0]["lp_sql"].ToString() != "")
                     {
                         SingleFormat.SubStrings[j].Value = dt.Rows[0][dr1[0]["lp_sql"].ToString()].ToString();
                     }
@@ -264,7 +269,7 @@ namespace UAS_LabelMachine.PublicMethod
                 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() == "字符串" && dr1[0]["lp_sql"].ToString() != "")
+                    if (dr1.Length > 0 && (dr1[0]["lp_valuetype"].ToString() == "字符串" || dr1[0]["lp_valuetype"].ToString() == "text") && dr1[0]["lp_sql"].ToString() != "")
                     {
                         sql.Append(dr1[0]["lp_sql"].ToString() + ",");
                     }
@@ -274,7 +279,7 @@ namespace UAS_LabelMachine.PublicMethod
                 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() == "字符串" && dr1[0]["lp_sql"].ToString() != "")
+                    if (dr1.Length > 0 && (dr1[0]["lp_valuetype"].ToString() == "字符串" || dr1[0]["lp_valuetype"].ToString() == "text") && dr1[0]["lp_sql"].ToString() != "")
                     {
                         MidFormat.SubStrings[j].Value = dt.Rows[0][dr1[0]["lp_sql"].ToString()].ToString();
                     }
@@ -328,12 +333,18 @@ namespace UAS_LabelMachine.PublicMethod
 
             public static void OutPrint(LabelFormatDocument OutFormat, DataTable OutLabelParam, string pi_inoutno, string pib_id, string pib_outboxcode2, bool iCustProdCode, bool iCustPo, bool iDC, bool iLotNo, bool iOrderCode)
             {
+                if (pib_outboxcode2 == "-1")
+                {
+                    OutFormat.PrintSetup.IdenticalCopiesOfLabel = 1;
+                    OutFormat.Print();
+                    return;
+                }
                 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() == "字符串" && dr1[0]["lp_sql"].ToString() != "")
+                    if (dr1.Length > 0 && (dr1[0]["lp_valuetype"].ToString() == "字符串" || dr1[0]["lp_valuetype"].ToString() == "text") && dr1[0]["lp_sql"].ToString() != "")
                     {
                         sql.Append(dr1[0]["lp_sql"].ToString() + ",");
                     }
@@ -364,14 +375,14 @@ namespace UAS_LabelMachine.PublicMethod
                 {
                     GroupByCondition = " group by " + (GroupByCondition.Substring(0, GroupByCondition.Length - 1));
                 }
-                sql.Append("1,");
+                sql.Append("max(pib_id),");
                 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) + GroupByCondition, "select");
                 for (int m = 0; m < dt.Rows.Count; m++)
                 {
                     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() == "字符串" && dr1[0]["lp_sql"].ToString() != "")
+                        if (dr1.Length > 0 && (dr1[0]["lp_valuetype"].ToString() == "字符串"||dr1[0]["lp_valuetype"].ToString() == "text") && dr1[0]["lp_sql"].ToString() != "")
                         {
                             OutFormat.SubStrings[j].Value = dt.Rows[m][dr1[0]["lp_sql"].ToString()].ToString();
                         }
@@ -419,12 +430,12 @@ namespace UAS_LabelMachine.PublicMethod
                     try
                     {
                         OutFormat.PrintSetup.IdenticalCopiesOfLabel = 1;
+                        OutFormat.Print();
                     }
                     catch (Exception)
                     {
 
                     }
-                    OutFormat.Print();
                 }
             }
         }

File diff suppressed because it is too large
+ 319 - 314
UAS-出货标签管理(贸易版)/UAS_出货标签管理.Designer.cs


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

@@ -29,10 +29,7 @@ namespace UAS_LabelMachine
         SqliteDBHelper sdh;
 
         DataTable dt;
-        /// <summary>
-        /// 已经打印过的Vivo外箱号
-        /// </summary>
-        List<string> PrintedVivoOutboxCode = new List<string>();
+
         StringBuilder sql = new StringBuilder();
         /// <summary>
         /// CodeSoft新建打印机引擎
@@ -96,6 +93,9 @@ namespace UAS_LabelMachine
         /// BarTender引擎
         /// </summary>
         Engine engine;
+        LabelFormatDocument EmptySingleFormat;
+
+        LabelFormatDocument EmptyOutFormat;
         /// <summary>
         /// BarTender单盘
         /// </summary>
@@ -156,6 +156,10 @@ namespace UAS_LabelMachine
         public static DataTable Attach;
 
         public string PrintMethod = "CodeSoft";
+        /// <summary>
+        /// 用于记录外箱号和当前的箱号进行比对,判断当前行和上一行是否是同一个箱号,从而判断是否要打印空白页
+        /// </summary>
+        public string Last_OutboxCode = "";
 
         public UAS_出货标签打印(string Master)
         {
@@ -246,6 +250,11 @@ namespace UAS_LabelMachine
             asc.controlAutoSize(this);
             string Code = dh.GetConfig("PrintMethod", "CodeOrBar").ToString();
             SystemInf.CheckDcAndLotNo = dh.GetConfig("PrintCheck", "CheckDcAndLotNo").ToString() == "" ? false : true;
+            if (dh.GetConfig("isSpeac", "LabelSpace").ToString() == "" ? false : true)
+            {
+                LabelSpace.Visible = true;
+                LabelSpace.Checked = true;
+            }
             if (Code == "")
             {
                 try
@@ -525,6 +534,7 @@ namespace UAS_LabelMachine
                             if (LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString() == LabelInf.Rows[CurrentRowIndex].Cells["pib_outboxcode1"].Value.ToString())
                             {
                                 string pibid = LabelInf.Rows[i].Cells["pib_id1"].Value.ToString();
+                                string outboxcode = LabelInf.Rows[i].Cells["pib_outboxcode2"].Value.ToString();
                                 dt.Rows[i]["pib_lotno"] = lotno;
                                 dt.Rows[i]["pib_datecode"] = datecode;
                                 dt.Rows[i]["pib_year"] = year;
@@ -538,7 +548,7 @@ namespace UAS_LabelMachine
                                 CurrentRowIndex = i;
                                 if (SingleLabelAutoPrint.Checked)
                                 {
-                                    AutoPrintSingleLabel(pibid);
+                                    AutoPrintSingleLabel(pibid, outboxcode);
                                 }
                                 if (MidLabelAutoPrint.Checked)
                                     AutoPrintMidLabel();
@@ -547,6 +557,7 @@ namespace UAS_LabelMachine
                         }
                         pibid1.Append("1");
                         sdh.ExecuteSql("update prodiobarcode set pib_ifpick=-1,pib_lotno='" + lotno + "',pib_datecode='" + datecode + "',pib_year='" + year + "',pib_month='" + month + "',pib_day='" + day + "' where pib_id in (" + pibid1 + ")", "update");
+                        Last_OutboxCode = "";
                     }
                     else if (CollectionUnit.Text == "全部")
                     {
@@ -583,7 +594,8 @@ namespace UAS_LabelMachine
                         {
                             if (SingleLabelCombox.SelectedValue != null)
                             {
-                                AutoPrintSingleLabel(LabelInf.Rows[CurrentRowIndex].Cells["pib_id1"].Value.ToString());
+                                AutoPrintSingleLabel(LabelInf.Rows[CurrentRowIndex].Cells["pib_id1"].Value.ToString(), LabelInf.Rows[CurrentRowIndex].Cells["pib_outboxcode2"].Value.ToString());
+                                Last_OutboxCode = "";
                             }
                             else
                             {
@@ -656,12 +668,31 @@ namespace UAS_LabelMachine
             }
         }
 
-        private void AutoPrintSingleLabel(string pib_id)
+        private void AutoPrintSingleLabel(string pib_id, string outboxcode)
         {
+            bool PrintBlankLabel = false;
             if (PrintMethod == "CodeSoft")
                 Print.CodeSoft.SinglePrint(SingleDoc, SingleLabelParam, pib_id);
             else
+            {
+                //第一箱不打印空标签
+                if (outboxcode != "" && Last_OutboxCode == "")
+                {
+                    PrintBlankLabel = false;
+                }
+                //如果外箱不相等
+                else if (outboxcode != "" && Last_OutboxCode != "" && outboxcode != Last_OutboxCode)
+                {
+                    PrintBlankLabel = true;
+                }
+                Last_OutboxCode = outboxcode;
+                //打印一张空白标签
+                if (LabelSpace.Checked && PrintBlankLabel)
+                {
+                    Print.BarTender.SinglePrint(EmptySingleFormat, SingleLabelParam, "-1");
+                }
                 Print.BarTender.SinglePrint(SingleFormat, SingleLabelParam, pib_id);
+            }
             LabelInf.Rows[CurrentRowIndex].Cells["pib_ifprint"].Value = true;
             sdh.ExecuteSql("update prodiobarcode set pib_ifprint=-1 where pib_id='" + pib_id + "'", "update");
         }
@@ -1008,6 +1039,7 @@ namespace UAS_LabelMachine
                 {
                     SingleDoc = lbl.Documents.Open(ftpOperater.DownLoadTo + SingleLabelCombox.Text);
                     SingleDoc.Printer.SwitchTo(SingleLabelPrinter.Text);
+
                 }
                 else
                 {
@@ -1097,6 +1129,24 @@ namespace UAS_LabelMachine
                     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");
+            }
+            try
+            {
+                //打开空标签文件
+                if (EmptySingleFormat == null)
+                {
+                    EmptySingleFormat = engine.Documents.Open(System.Windows.Forms.Application.StartupPath + @"\Empty.btw");
+                    EmptySingleFormat.PrintSetup.PrinterName = SingleLabelPrinter.Text;
+                }
+                if (EmptyOutFormat == null)
+                {
+                    EmptyOutFormat = engine.Documents.Open(System.Windows.Forms.Application.StartupPath + @"\Empty1.btw");
+                    EmptyOutFormat.PrintSetup.PrinterName = OutBoxPrinter.Text;
+                }
+            }
+            catch (Exception)
+            {
+
             }
             //缓存外箱参数
             ComBoxClickChangeLabelDoc = true;
@@ -1222,7 +1272,8 @@ namespace UAS_LabelMachine
                         try
                         {
                             string pib_id = LabelInf.Rows[i].Cells["pib_id1"].Value.ToString();
-                            AutoPrintSingleLabel(pib_id);
+                            string outboxcode = LabelInf.Rows[i].Cells["pib_outboxcode2"].Value.ToString();
+                            AutoPrintSingleLabel(pib_id, outboxcode);
                             if (MidLabelAutoPrint.Checked)
                             {
                                 //判断当前行的盒号和下一行不相等或者已经是最后一行了
@@ -1244,6 +1295,7 @@ namespace UAS_LabelMachine
                         catch (Exception ex) { LogManager.DoLog(ex.Message); }
                     }
                 }
+                Last_OutboxCode = "";
                 dh.BatchInsert("update prodiobarcode set pib_printdate=sysdate where pib_id=:pib_id", new string[] { "pib_id" }, SingleID.ToArray());
                 if (CheckedRowCount == 0)
                     MessageBox.Show("未勾选打印明细!");
@@ -1502,7 +1554,13 @@ namespace UAS_LabelMachine
             if (PrintMethod == "CodeSoft")
                 Print.CodeSoft.OutPrint(OutBoxDoc, OutLabelParam, pi_inoutno.Text, pib_id, pib_outboxcode2, cu_print_outprod.Checked, cu_print_outpo.Checked, cu_print_outdc.Checked, cu_print_outlotno.Checked, cu_print_ordercode.Checked);
             else
+            {
                 Print.BarTender.OutPrint(OutFormat, OutLabelParam, pi_inoutno.Text, pib_id, pib_outboxcode2, cu_print_outprod.Checked, cu_print_outpo.Checked, cu_print_outdc.Checked, cu_print_outlotno.Checked, cu_print_ordercode.Checked);
+                if (LabelSpace.Checked)
+                {
+                    Print.BarTender.OutPrint(EmptyOutFormat, OutLabelParam, pi_inoutno.Text, pib_id, "-1", cu_print_outprod.Checked, cu_print_outpo.Checked, cu_print_outdc.Checked, cu_print_outlotno.Checked, cu_print_ordercode.Checked);
+                }
+            }
         }
 
         private void CleanDetail_Click(object sender, EventArgs e)
@@ -1965,6 +2023,7 @@ namespace UAS_LabelMachine
                         {
                             SingleFormat = engine.Documents.Open(BaseUtil.GetLabelUrl(SingleLabelCombox.SelectedValue.ToString().Split('#')[1], SingleLabelCombox.Text, time));
                             SingleFormat.PrintSetup.PrinterName = SingleLabelPrinter.Text;
+                            EmptySingleFormat.PrintSetup.PrinterName = SingleLabelPrinter.Text;
                         }
                     }
                 }
@@ -2033,6 +2092,7 @@ namespace UAS_LabelMachine
                         {
                             OutFormat = engine.Documents.Open(BaseUtil.GetLabelUrl(OutBoxCombox.SelectedValue.ToString().Split('#')[1], OutBoxCombox.Text, time));
                             OutFormat.PrintSetup.PrinterName = OutBoxPrinter.Text;
+                            EmptyOutFormat.PrintSetup.PrinterName = OutBoxPrinter.Text;
                         }
                     }
                 }
@@ -2377,21 +2437,21 @@ namespace UAS_LabelMachine
         }
 
         //前缀
-        string Prefix = "";
+        public static string Prefix = "";
         //后缀
-        string Suffix = "";
+        public static string Suffix = "";
         //编码规则编号
-        string NrCode = "";
+        public static string NrCode = "";
 
-        string PrefixFixed = "";
+        public static string PrefixFixed = "";
         //流水号的索引
-        int SerialNumIndex = 0;
+        public static int SerialNumIndex = 0;
         //流水长度
-        int SerialNumLength = 0;
+        public static int SerialNumLength = 0;
         //存放键值对
-        int Radix = 10;
+        public static int Radix = 10;
         //客户的流水号
-        int custserialnum = 0;
+        public static int custserialnum = 0;
 
         public void GetCustRule()
         {
@@ -2495,298 +2555,8 @@ namespace UAS_LabelMachine
             try
             {
                 GetCustRule();
-                //获取最大的流水号
-                DataTable dt = ExcelHandler.ExcelToDataTable(ImportExcel.FileName, true);
-                if (dt == null)
-                {
-                    MessageBox.Show("文件" + ImportExcel.FileName + "被占用或者格式不正确");
-                    return;
-                }
-                string outsql = "";
-                LogicHandler.GenerateBarCode(PI_ID, cu_code.Text, out outsql);
-                sql.Clear();
-                sql.Append(outsql);
-                DataTable dt1 = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
-                //需要插入的参数
-                ArrayList<string> barcode = new ArrayList<string>();
-                ArrayList<string> custbarcode = new ArrayList<string>();
-                ArrayList<string> datecode = new ArrayList<string>();
-                ArrayList<string> lotno = new ArrayList<string>();
-                ArrayList<string> pib_inqty = new ArrayList<string>();
-                ArrayList<string> piboutboxcode2 = new ArrayList<string>();
-                ArrayList<string> pdordercode = new ArrayList<string>();
-                ArrayList<string> pdorderdetno = new ArrayList<string>();
-                ArrayList<string> pdpdno = new ArrayList<string>();
-                ArrayList<string> pdid = new ArrayList<string>();
-                ArrayList<string> prbrand = new ArrayList<string>();
-                ArrayList<string> pdprodcode = new ArrayList<string>();
-                ArrayList<string> pib_custoutboxcode = new ArrayList<string>();
-                ArrayList<string> brand = new ArrayList<string>();
-                ArrayList<string> madein = new ArrayList<string>();
-                ArrayList<string> prdetail = new ArrayList<string>();
-                ArrayList<string> ordercode = new ArrayList<string>();
-                ArrayList<string> size = new ArrayList<string>();
-                ArrayList<string> weight = new ArrayList<string>();
-                //用于数量的校验
-                Dictionary<string, decimal> sumqty = new Dictionary<string, decimal>();
-                Dictionary<string, Dictionary<string, decimal>> outsumqty = new Dictionary<string, Dictionary<string, decimal>>();
-                for (int i = 0; i < dt.Rows.Count; i++)
-                {
-                    string pr_spec = dt.Rows[i]["规格型号"].ToString().Trim();
-                    if (pr_spec.Trim() == "")
-                    {
-                        break;
-                    }
-                    string qty = Regex.Replace(dt.Rows[i]["数量"].ToString(), @"[^\d]*", ""); ;
-                    //累计Excel该型号的数量
-                    if (!sumqty.ContainsKey(pr_spec))
-                    {
-                        sumqty.Add(pr_spec, 0);
-                    }
-                    //累计Excel该型号的数量
-                    sumqty[pr_spec] += decimal.Parse(qty);
-                }
-                for (int i = 0; i < dt1.Rows.Count; i++)
-                {
-                    //不包含型号则进行添加
-                    string pr_spec = dt1.Rows[i]["pr_spec"].ToString().Trim();
-                    string pd_pdno = dt1.Rows[i]["pd_pdno"].ToString();
-                    decimal pd_outqty = decimal.Parse(dt1.Rows[i]["pd_outqty"].ToString());
-                    if (!outsumqty.ContainsKey(pr_spec))
-                    {
-                        Dictionary<string, decimal> dic = new Dictionary<string, decimal>();
-                        dic.Add(pd_pdno, pd_outqty);
-                        outsumqty.Add(pr_spec, dic);
-                    }
-                    else
-                    {
-                        outsumqty[pr_spec].Add(pd_pdno, pd_outqty);
-                    }
-                }
-                //上一个的最小外箱号,如果箱号没有发生变化则外箱条码也不变化
-                for (int i = 0; i < dt.Rows.Count; i++)
-                {
-                    string pr_spec = dt.Rows[i]["规格型号"].ToString().Trim();
-                    string 品牌 = dt.Rows[i]["品牌"].ToString().Trim();
-                    string 产地 = dt.Rows[i]["产地"].ToString().Trim();
-                    string 尺寸 = dt.Rows[i]["尺寸"].ToString().Trim();
-                    string 重量 = dt.Rows[i]["重量"].ToString().Trim();
-                    string 产品名称 = dt.Rows[i]["产品名称"].ToString().Trim();
-                    string 订单编号 = dt.Rows[i]["订单编号"].ToString().Trim();
-                    if (pr_spec.Trim() == "")
-                    {
-                        break;
-                    }
-                    string qty = dt.Rows[i]["数量"].ToString();
-                    string DateCode = "";
-                    string LotNo = "";
-                    if (dt.Columns.Contains("DC/LOT NO"))
-                    {
-                        if (dt.Rows[i]["DC/LOT NO"].ToString().IndexOf("-") > 0)
-                        {
-                            DateCode = dt.Rows[i]["DC/LOT NO"].ToString().Split('-')[0];
-                            LotNo = dt.Rows[i]["DC/LOT NO"].ToString().Split('-')[1];
-                        }
-                        else if (dt.Rows[i]["DC/LOT NO"].ToString().IndexOf(" ") > 0)
-                        {
-                            DateCode = dt.Rows[i]["DC/LOT NO"].ToString().Split(' ')[0];
-                            LotNo = dt.Rows[i]["DC/LOT NO"].ToString().Split(' ')[1];
-                        }
-                    }
-                    if (dt.Columns.Contains("DC") && DateCode == "")
-                    {
-                        DateCode = dt.Rows[i]["DC"].ToString();
-                    }
-                    if (dt.Columns.Contains("LOT NO") && LotNo == "")
-                    {
-                        LotNo = dt.Rows[i]["LOT NO"].ToString();
-                    }
-                    string pib_outboxcode2 = dt.Rows[i]["箱号"].ToString();
-                    DataRow[] dr = dt1.Select("pr_spec='" + pr_spec + "'");
-                    if (dr.Length == 0)
-                    {
-                        LogicHandler.FilterData(cu_code.Text, "FUDAN", pr_spec, qty, DateCode, LotNo, out pr_spec, out qty, out DateCode, out LotNo);
-                        dr = dt1.Select("pr_spec='" + pr_spec + "'");
-                    }
-                    else
-                    {
-                        LogicHandler.FilterData(cu_code.Text, dr[0]["pr_brand"].ToString(), pr_spec, qty, DateCode, LotNo, out pr_spec, out qty, out DateCode, out LotNo);
-                    }
-                    if (dr.Length == 0)
-                    {
-                        MessageBox.Show("出货单" + pi_inoutno.Text + "不包含型号" + pr_spec);
-                        return;
-                    }
-                    decimal outqty = decimal.Parse(Regex.Replace(qty, @"[^\d]*", ""));
-                    for (int k = 0; k < dr.Length; k++)
-                    {
-                        string pd_orderdetno = dr[k]["pd_orderdetno"].ToString();
-                        string pd_prodcode = dr[k]["pd_prodcode"].ToString();
-                        string pd_ordercode = dr[k]["pd_ordercode"].ToString();
-                        string pd_piid = dr[k]["pd_piid"].ToString();
-                        string pr_brand = dr[k]["pr_brand"].ToString();
-                        string pd_pdno = dr[k]["pd_pdno"].ToString();
-                        string pd_id = dr[k]["pd_id"].ToString();
-                        string pd_piclass = dr[k]["pd_piclass"].ToString();
-                        string pr_id = dr[k]["pr_id"].ToString();
-                        string pr_madein = dr[k]["pr_madein"].ToString();
-                        //已导入数量
-                        decimal zxbzs = decimal.Parse(dr[k]["pr_zxbzs"].ToString());
-                        decimal pd_outqty = 0;
-                        decimal barcodenum = 0;
-                        if (outsumqty[pr_spec][pd_pdno] == 0)
-                        {
-                            continue;
-                        }
-                        //如果导入行的数量小于改明细的出货数量
-                        if (outsumqty[pr_spec][pd_pdno] >= outqty)
-                        {
-                            //使用导入明细行数量
-                            pd_outqty = outqty;
-                        }
-                        else
-                        {
-                            ////使用该出货单明细行数量,并且数量置为0
-                            pd_outqty = outsumqty[pr_spec][pd_pdno];
-                        }
-                        string pib_barcode = dh.getFieldDataByCondition("prodiobarcode", "max(pib_barcode)", "PIB_INOUTNO='" + pi_inoutno.Text + "'").ToString();
-                        if (pd_outqty % zxbzs != 0)
-                        {
-                            barcodenum = Math.Floor(pd_outqty / zxbzs) + 1;
-                            //如果有余数先加上所有最小包最后加尾数
-                            for (int j = 0; j < barcodenum - 1; j++)
-                            {
-                                barcode.Add(BaseUtil.BarcodeMethod1(pd_id, pr_id, pib_barcode));
-                                custbarcode.Add(BarcodeMethod1(PrefixFixed, Suffix, SerialNumIndex, SerialNumLength, Radix));
-                                pib_custoutboxcode.Add(pib_outboxcode2);
-                                piboutboxcode2.Add(pib_outboxcode2);
-                                pib_inqty.Add(zxbzs);
-                                datecode.Add(DateCode);
-                                lotno.Add(LotNo);
-                                pdordercode.Add(订单编号 == "" ? pd_ordercode : 订单编号);
-                                pdorderdetno.Add(pd_orderdetno);
-                                pdpdno.Add(pd_pdno);
-                                pdid.Add(pd_id);
-                                prbrand.Add(品牌 == "" ? pr_brand : 品牌);
-                                madein.Add(产地 == "" ? pr_madein : 产地);
-                                size.Add(尺寸);
-                                weight.Add(重量);
-                                prdetail.Add(产品名称);
-                                ordercode.Add(订单编号);
-                                pdprodcode.Add(pd_prodcode);
-                            }
-                            custbarcode.Add(BarcodeMethod1(PrefixFixed, Suffix, SerialNumIndex, SerialNumLength, Radix));
-                            pib_custoutboxcode.Add(pib_outboxcode2);
-                            barcode.Add(BaseUtil.BarcodeMethod1(pd_id, pr_id, pib_barcode));
-                            pib_inqty.Add(pd_outqty % zxbzs);
-                            piboutboxcode2.Add(pib_outboxcode2);
-                            datecode.Add(DateCode);
-                            lotno.Add(LotNo);
-                            pdordercode.Add(订单编号 == "" ? pd_ordercode : 订单编号);
-                            pdorderdetno.Add(pd_orderdetno);
-                            pdpdno.Add(pd_pdno);
-                            pdid.Add(pd_id);
-                            prbrand.Add(品牌 == "" ? pr_brand : 品牌);
-                            madein.Add(产地 == "" ? pr_madein : 产地);
-                            size.Add(尺寸);
-                            weight.Add(重量);
-                            prdetail.Add(产品名称);
-                            ordercode.Add(订单编号);
-                            pdprodcode.Add(pd_prodcode);
-                        }
-                        else
-                        {
-                            barcodenum = pd_outqty / zxbzs;
-                            for (int j = 0; j < barcodenum; j++)
-                            {
-                                barcode.Add(BaseUtil.BarcodeMethod1(pd_id, pr_id, pib_barcode));
-                                custbarcode.Add(BarcodeMethod1(PrefixFixed, Suffix, SerialNumIndex, SerialNumLength, Radix));
-                                pib_custoutboxcode.Add(pib_outboxcode2);
-                                pib_inqty.Add(zxbzs);
-                                piboutboxcode2.Add(pib_outboxcode2);
-                                datecode.Add(DateCode);
-                                lotno.Add(LotNo);
-                                pdordercode.Add(订单编号 == "" ? pd_ordercode : 订单编号);
-                                pdorderdetno.Add(pd_orderdetno);
-                                pdpdno.Add(pd_pdno);
-                                pdid.Add(pd_id);
-                                prbrand.Add(品牌 == "" ? pr_brand : 品牌);
-                                madein.Add(产地 == "" ? pr_madein : 产地);
-                                size.Add(尺寸);
-                                weight.Add(重量);
-                                prdetail.Add(产品名称);
-                                pdprodcode.Add(pd_prodcode);
-                            }
-                        }
-                        outqty -= outsumqty[pr_spec][pd_pdno];
-                        outsumqty[pr_spec][pd_pdno] -= pd_outqty;
-                    }
-                }
-                string Lastoutbox = "";
-                string Lastoutboxcode = "";
-                List<string> custoutboxcode = new List<string>();
-                //根据记录的箱号,在料盘的流水之后拼接外箱的流水
-                for (int i = 0; i < pib_custoutboxcode.Count; i++)
-                {
-                    if (Lastoutbox != pib_custoutboxcode[i].ToString())
-                    {
-                        Lastoutboxcode = BarcodeMethod1(PrefixFixed, Suffix, SerialNumIndex, SerialNumLength, Radix);
-                        custoutboxcode.Add(Lastoutboxcode);
-                        Lastoutbox = pib_custoutboxcode[i].ToString();
-                    }
-                    else
-                    {
-                        custoutboxcode.Add(Lastoutboxcode);
-                    }
-                }
-                //插叙所有的统计数量
-                string ErrMsg = "";
-                foreach (var item in sumqty)
-                {
-                    dt = (DataTable)dh.ExecuteSql("select nvl(sum(pd_outqty),0)pd_outqty,pr_spec from prodiodetail left join product on pr_code=pd_prodcode where pd_piid='" + PI_ID + "' group by pr_spec", "select");
-                    dt1 = (DataTable)dh.ExecuteSql("select nvl(sum(pib_qty),0)pib_qty,pr_spec  from prodiobarcode left join product on pib_prodcode=pr_code where pib_piid='" + PI_ID + "' group by pr_spec", "select");
-                    DataRow[] dr = dt.Select("pr_spec='" + item.Key + "'");
-                    DataRow[] dr1 = dt1.Select("pr_spec='" + item.Key + "'");
-                    if (dr.Length > 0)
-                    {
-                        decimal pd_outqty = decimal.Parse(dr[0]["pd_outqty"].ToString());
-                        decimal pib_qty = 0;
-                        //如果有已导入的数量
-                        if (dr1.Length > 0)
-                        {
-                            pib_qty = decimal.Parse(dr1[0]["pib_qty"].ToString());
-                        }
-                        //本次导入的数量和原有导入数量累加和出库数量做对比
-                        if (pd_outqty < item.Value + pib_qty)
-                        {
-                            ErrMsg += "型号" + dr[0]["pr_spec"].ToString() + "出货数量" + pd_outqty + ",已导入数量" + pib_qty + ",本次导入" + item.Value + ",超出数量" + (item.Value + pib_qty - pd_outqty) + "\n";
-                        }
-                    }
-                }
-                if (ErrMsg == "")
-                {
-                    if (pdprodcode.Count > 0)
-                    {
-                        sql.Clear();
-                        sql.Append("insert into prodiobarcode (PIB_ID,PIB_PRODCODE,pib_inman,PIB_INDATE,PIB_INOUTNO,PIB_PIID,pib_brand,PIB_BARCODE,PIB_PDNO,");
-                        sql.Append("PIB_PDID,PIB_PICLASS,PIB_QTY,pib_datecode,pib_lotno,PIB_IFPRINT,PIB_IFPICK,PIB_ORDERCODE,pib_orderdetno,");
-                        sql.Append("pib_outboxcode2,pib_custbarcode,pib_custoutboxcode,pib_madein,pib_size,pib_weight,pib_prdetail)values(prodiobarcode_seq.nextval,:pd_prodcode,'" + User.UserName + "',sysdate,");
-                        sql.Append("'" + pi_inoutno.Text + "'," + PI_ID + ",:pr_brand,:barcode,:pd_pdno,:pd_id,'" + pi_class.Text + "',:pib_inqty,");
-                        sql.Append(":pib_datecode,:pib_lotno,0,-1,:pd_ordercode,:pd_orderdetno,:outboxcode,:custbarcode,:pib_custoutboxcode,:pib_madein,:pib_size,:pib_weight,:pib_prdetail)");
-                        dh.BatchInsert(sql.ToString(), new string[] { "pd_prodcode", "pr_brand", "barcode", "pd_pdno", "pd_id", "pib_inqty", "pib_datecode", "pib_lotno", "pd_ordercode", "pd_orderdetno", "outboxcode", "custbarcode", "pib_custoutboxcode", "pib_madein", "pib_size", "pib_weight", "pib_prdetail" }, pdprodcode.ToArray(), prbrand.ToArray(), barcode.ToArray(), pdpdno.ToArray(), pdid.ToArray(), pib_inqty.ToArray(), datecode.ToArray(), lotno.ToArray(), pdordercode.ToArray(), pdorderdetno.ToArray(), piboutboxcode2.ToArray(), custbarcode.ToArray(), custoutboxcode.ToArray(), madein.ToArray(), size.ToArray(), weight.ToArray(), prdetail.ToArray());
-                        //更新流水
-                        dh.UpdateByCondition("RuleMaxNum", "rmn_maxnumber='" + custserialnum + "'", "rmn_nrcode='" + NrCode + "' and rmn_prefix='" + Prefix + "'");
-                        LoadGridData();
-                    }
-                    else
-                    {
-                        MessageBox.Show("解析数据不包含出货单数据,请重新导入", "提示");
-                    }
-                }
-                else
-                {
-                    MessageBox.Show(ErrMsg, "超出数量提醒");
-                }
+                LogicHandler.ImportExcel(SystemInf.Master, ImportExcel.FileName, PI_ID, pi_inoutno.Text, cu_code.Text);
+                LoadGridData();
             }
             catch (Exception ex)
             {

Some files were not shown because too many files changed in this diff