Pārlūkot izejas kodu

封装条码导入的方法

章政 5 gadi atpakaļ
vecāks
revīzija
3892877bc3

+ 318 - 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,316 @@ namespace UAS_LabelMachine.PublicMethod
             dh.CallProcedure("sp_GenerateBarCode", ref param);
             oSQL = param[2];
         }
+
+        public static void ImportExcel(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 = "";
+            LogicHandler.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)
+                {
+                    LogicHandler.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
+                {
+                    LogicHandler.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;
+        }
     }
 }

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

@@ -908,7 +908,7 @@
             // 
             this.label18.AutoSize = true;
             this.label18.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label18.Location = new System.Drawing.Point(66, 135);
+            this.label18.Location = new System.Drawing.Point(68, 138);
             this.label18.Name = "label18";
             this.label18.Size = new System.Drawing.Size(13, 17);
             this.label18.TabIndex = 90;
@@ -942,7 +942,7 @@
             // 
             this.label16.AutoSize = true;
             this.label16.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label16.Location = new System.Drawing.Point(65, 62);
+            this.label16.Location = new System.Drawing.Point(68, 65);
             this.label16.Name = "label16";
             this.label16.Size = new System.Drawing.Size(13, 17);
             this.label16.TabIndex = 87;
@@ -976,7 +976,7 @@
             // 
             this.label12.AutoSize = true;
             this.label12.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label12.Location = new System.Drawing.Point(5, 97);
+            this.label12.Location = new System.Drawing.Point(3, 95);
             this.label12.Name = "label12";
             this.label12.Size = new System.Drawing.Size(56, 17);
             this.label12.TabIndex = 77;
@@ -986,7 +986,7 @@
             // 
             this.label7.AutoSize = true;
             this.label7.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label7.Location = new System.Drawing.Point(5, 23);
+            this.label7.Location = new System.Drawing.Point(3, 21);
             this.label7.Name = "label7";
             this.label7.Size = new System.Drawing.Size(56, 17);
             this.label7.TabIndex = 76;
@@ -1039,7 +1039,7 @@
             // 
             this.Capacity.AutoSize = true;
             this.Capacity.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.Capacity.Location = new System.Drawing.Point(57, 65);
+            this.Capacity.Location = new System.Drawing.Point(55, 63);
             this.Capacity.Name = "Capacity";
             this.Capacity.Size = new System.Drawing.Size(0, 17);
             this.Capacity.TabIndex = 75;
@@ -1048,7 +1048,7 @@
             // 
             this.Process_midboxcode.AutoSize = true;
             this.Process_midboxcode.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.Process_midboxcode.Location = new System.Drawing.Point(57, 109);
+            this.Process_midboxcode.Location = new System.Drawing.Point(55, 107);
             this.Process_midboxcode.Name = "Process_midboxcode";
             this.Process_midboxcode.Size = new System.Drawing.Size(15, 17);
             this.Process_midboxcode.TabIndex = 74;
@@ -1058,7 +1058,7 @@
             // 
             this.Process_outboxcode.AutoSize = true;
             this.Process_outboxcode.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.Process_outboxcode.Location = new System.Drawing.Point(57, 85);
+            this.Process_outboxcode.Location = new System.Drawing.Point(55, 83);
             this.Process_outboxcode.Name = "Process_outboxcode";
             this.Process_outboxcode.Size = new System.Drawing.Size(15, 17);
             this.Process_outboxcode.TabIndex = 73;
@@ -1069,7 +1069,7 @@
             this.TotalCount.AutoSize = true;
             this.TotalCount.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.TotalCount.ForeColor = System.Drawing.Color.Blue;
-            this.TotalCount.Location = new System.Drawing.Point(91, 17);
+            this.TotalCount.Location = new System.Drawing.Point(89, 15);
             this.TotalCount.Name = "TotalCount";
             this.TotalCount.Size = new System.Drawing.Size(15, 17);
             this.TotalCount.TabIndex = 72;
@@ -1079,7 +1079,7 @@
             // 
             this.label17.AutoSize = true;
             this.label17.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label17.Location = new System.Drawing.Point(77, 17);
+            this.label17.Location = new System.Drawing.Point(75, 15);
             this.label17.Name = "label17";
             this.label17.Size = new System.Drawing.Size(13, 17);
             this.label17.TabIndex = 71;
@@ -1090,7 +1090,7 @@
             this.CollectedCount.AutoSize = true;
             this.CollectedCount.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.CollectedCount.ForeColor = System.Drawing.Color.Red;
-            this.CollectedCount.Location = new System.Drawing.Point(59, 17);
+            this.CollectedCount.Location = new System.Drawing.Point(57, 15);
             this.CollectedCount.Name = "CollectedCount";
             this.CollectedCount.Size = new System.Drawing.Size(15, 17);
             this.CollectedCount.TabIndex = 70;
@@ -1100,7 +1100,7 @@
             // 
             this.label14.AutoSize = true;
             this.label14.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label14.Location = new System.Drawing.Point(7, 85);
+            this.label14.Location = new System.Drawing.Point(5, 83);
             this.label14.Name = "label14";
             this.label14.Size = new System.Drawing.Size(32, 17);
             this.label14.TabIndex = 69;
@@ -1110,7 +1110,7 @@
             // 
             this.label11.AutoSize = true;
             this.label11.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label11.Location = new System.Drawing.Point(7, 108);
+            this.label11.Location = new System.Drawing.Point(5, 106);
             this.label11.Name = "label11";
             this.label11.Size = new System.Drawing.Size(32, 17);
             this.label11.TabIndex = 68;
@@ -1120,7 +1120,7 @@
             // 
             this.label13.AutoSize = true;
             this.label13.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label13.Location = new System.Drawing.Point(7, 45);
+            this.label13.Location = new System.Drawing.Point(5, 43);
             this.label13.Name = "label13";
             this.label13.Size = new System.Drawing.Size(44, 17);
             this.label13.TabIndex = 67;
@@ -1130,7 +1130,7 @@
             // 
             this.Installed.AutoSize = true;
             this.Installed.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.Installed.Location = new System.Drawing.Point(57, 45);
+            this.Installed.Location = new System.Drawing.Point(55, 43);
             this.Installed.Name = "Installed";
             this.Installed.Size = new System.Drawing.Size(0, 17);
             this.Installed.TabIndex = 66;
@@ -1139,7 +1139,7 @@
             // 
             this.Process.AutoSize = true;
             this.Process.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.Process.Location = new System.Drawing.Point(7, 17);
+            this.Process.Location = new System.Drawing.Point(5, 15);
             this.Process.Name = "Process";
             this.Process.Size = new System.Drawing.Size(44, 17);
             this.Process.TabIndex = 65;
@@ -1521,7 +1521,7 @@
             // 
             this.LabelSpace.AutoSize = true;
             this.LabelSpace.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.LabelSpace.Location = new System.Drawing.Point(10, 135);
+            this.LabelSpace.Location = new System.Drawing.Point(8, 133);
             this.LabelSpace.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.LabelSpace.Name = "LabelSpace";
             this.LabelSpace.Size = new System.Drawing.Size(75, 21);
@@ -1534,7 +1534,7 @@
             // 
             this.label8.AutoSize = true;
             this.label8.Font = new System.Drawing.Font("微软雅黑", 10F);
-            this.label8.Location = new System.Drawing.Point(6, 20);
+            this.label8.Location = new System.Drawing.Point(4, 21);
             this.label8.Name = "label8";
             this.label8.Size = new System.Drawing.Size(55, 20);
             this.label8.TabIndex = 116;
@@ -1543,7 +1543,7 @@
             // SingleDocRefresh
             // 
             this.SingleDocRefresh.AutoSize = true;
-            this.SingleDocRefresh.Location = new System.Drawing.Point(64, 20);
+            this.SingleDocRefresh.Location = new System.Drawing.Point(62, 21);
             this.SingleDocRefresh.Name = "SingleDocRefresh";
             this.SingleDocRefresh.Size = new System.Drawing.Size(42, 21);
             this.SingleDocRefresh.TabIndex = 89;
@@ -1578,7 +1578,7 @@
             // 
             this.SingleLabelAutoPrint.AutoSize = true;
             this.SingleLabelAutoPrint.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.SingleLabelAutoPrint.Location = new System.Drawing.Point(11, 107);
+            this.SingleLabelAutoPrint.Location = new System.Drawing.Point(9, 105);
             this.SingleLabelAutoPrint.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.SingleLabelAutoPrint.Name = "SingleLabelAutoPrint";
             this.SingleLabelAutoPrint.Size = new System.Drawing.Size(75, 21);
@@ -1638,7 +1638,7 @@
             // 
             this.label9.AutoSize = true;
             this.label9.Font = new System.Drawing.Font("微软雅黑", 10F);
-            this.label9.Location = new System.Drawing.Point(6, 20);
+            this.label9.Location = new System.Drawing.Point(4, 21);
             this.label9.Name = "label9";
             this.label9.Size = new System.Drawing.Size(55, 20);
             this.label9.TabIndex = 117;
@@ -1647,7 +1647,7 @@
             // MidDocRefresh
             // 
             this.MidDocRefresh.AutoSize = true;
-            this.MidDocRefresh.Location = new System.Drawing.Point(59, 20);
+            this.MidDocRefresh.Location = new System.Drawing.Point(57, 21);
             this.MidDocRefresh.Name = "MidDocRefresh";
             this.MidDocRefresh.Size = new System.Drawing.Size(42, 21);
             this.MidDocRefresh.TabIndex = 90;
@@ -1659,7 +1659,7 @@
             // 
             this.MidLabelNum.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.MidLabelNum.ID = null;
-            this.MidLabelNum.Location = new System.Drawing.Point(51, 165);
+            this.MidLabelNum.Location = new System.Drawing.Point(53, 174);
             this.MidLabelNum.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.MidLabelNum.Name = "MidLabelNum";
             this.MidLabelNum.Size = new System.Drawing.Size(64, 23);
@@ -1672,7 +1672,7 @@
             // 
             this.label5.AutoSize = true;
             this.label5.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label5.Location = new System.Drawing.Point(11, 166);
+            this.label5.Location = new System.Drawing.Point(11, 177);
             this.label5.Name = "label5";
             this.label5.Size = new System.Drawing.Size(32, 17);
             this.label5.TabIndex = 50;
@@ -1682,7 +1682,7 @@
             // 
             this.label4.AutoSize = true;
             this.label4.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label4.Location = new System.Drawing.Point(11, 134);
+            this.label4.Location = new System.Drawing.Point(11, 146);
             this.label4.Name = "label4";
             this.label4.Size = new System.Drawing.Size(32, 17);
             this.label4.TabIndex = 49;
@@ -1702,7 +1702,7 @@
             // 
             this.label15.AutoSize = true;
             this.label15.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label15.Location = new System.Drawing.Point(99, 136);
+            this.label15.Location = new System.Drawing.Point(102, 147);
             this.label15.Name = "label15";
             this.label15.Size = new System.Drawing.Size(20, 17);
             this.label15.TabIndex = 40;
@@ -1711,7 +1711,7 @@
             // MidBoxCapacity
             // 
             this.MidBoxCapacity.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.MidBoxCapacity.Location = new System.Drawing.Point(52, 135);
+            this.MidBoxCapacity.Location = new System.Drawing.Point(54, 144);
             this.MidBoxCapacity.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.MidBoxCapacity.Name = "MidBoxCapacity";
             this.MidBoxCapacity.Size = new System.Drawing.Size(44, 23);
@@ -1734,7 +1734,7 @@
             // 
             this.MidLabelAutoPrint.AutoSize = true;
             this.MidLabelAutoPrint.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.MidLabelAutoPrint.Location = new System.Drawing.Point(10, 106);
+            this.MidLabelAutoPrint.Location = new System.Drawing.Point(8, 109);
             this.MidLabelAutoPrint.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.MidLabelAutoPrint.Name = "MidLabelAutoPrint";
             this.MidLabelAutoPrint.Size = new System.Drawing.Size(75, 21);
@@ -1799,7 +1799,7 @@
             // 
             this.cu_print_ordercode.AutoSize = true;
             this.cu_print_ordercode.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.cu_print_ordercode.Location = new System.Drawing.Point(6, 65);
+            this.cu_print_ordercode.Location = new System.Drawing.Point(6, 63);
             this.cu_print_ordercode.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.cu_print_ordercode.Name = "cu_print_ordercode";
             this.cu_print_ordercode.Size = new System.Drawing.Size(75, 21);
@@ -1811,7 +1811,7 @@
             // 
             this.cu_print_outpo.AutoSize = true;
             this.cu_print_outpo.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.cu_print_outpo.Location = new System.Drawing.Point(6, 42);
+            this.cu_print_outpo.Location = new System.Drawing.Point(6, 40);
             this.cu_print_outpo.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.cu_print_outpo.Name = "cu_print_outpo";
             this.cu_print_outpo.Size = new System.Drawing.Size(75, 21);
@@ -1823,7 +1823,7 @@
             // 
             this.cu_print_outdc.AutoSize = true;
             this.cu_print_outdc.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.cu_print_outdc.Location = new System.Drawing.Point(6, 113);
+            this.cu_print_outdc.Location = new System.Drawing.Point(6, 111);
             this.cu_print_outdc.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.cu_print_outdc.Name = "cu_print_outdc";
             this.cu_print_outdc.Size = new System.Drawing.Size(44, 21);
@@ -1835,7 +1835,7 @@
             // 
             this.cu_print_outlotno.AutoSize = true;
             this.cu_print_outlotno.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.cu_print_outlotno.Location = new System.Drawing.Point(6, 88);
+            this.cu_print_outlotno.Location = new System.Drawing.Point(6, 86);
             this.cu_print_outlotno.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.cu_print_outlotno.Name = "cu_print_outlotno";
             this.cu_print_outlotno.Size = new System.Drawing.Size(63, 21);
@@ -1847,7 +1847,7 @@
             // 
             this.cu_print_outprod.AutoSize = true;
             this.cu_print_outprod.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.cu_print_outprod.Location = new System.Drawing.Point(6, 17);
+            this.cu_print_outprod.Location = new System.Drawing.Point(6, 15);
             this.cu_print_outprod.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.cu_print_outprod.Name = "cu_print_outprod";
             this.cu_print_outprod.Size = new System.Drawing.Size(75, 21);
@@ -1859,7 +1859,7 @@
             // 
             this.label19.AutoSize = true;
             this.label19.Font = new System.Drawing.Font("微软雅黑", 10F);
-            this.label19.Location = new System.Drawing.Point(4, 20);
+            this.label19.Location = new System.Drawing.Point(3, 22);
             this.label19.Name = "label19";
             this.label19.Size = new System.Drawing.Size(55, 20);
             this.label19.TabIndex = 118;
@@ -1868,7 +1868,7 @@
             // OutDocRefresh
             // 
             this.OutDocRefresh.AutoSize = true;
-            this.OutDocRefresh.Location = new System.Drawing.Point(59, 20);
+            this.OutDocRefresh.Location = new System.Drawing.Point(58, 22);
             this.OutDocRefresh.Name = "OutDocRefresh";
             this.OutDocRefresh.Size = new System.Drawing.Size(42, 21);
             this.OutDocRefresh.TabIndex = 91;
@@ -1879,7 +1879,7 @@
             // LogingOut
             // 
             this.LogingOut.AutoSize = true;
-            this.LogingOut.Location = new System.Drawing.Point(105, 7);
+            this.LogingOut.Location = new System.Drawing.Point(103, 5);
             this.LogingOut.Name = "LogingOut";
             this.LogingOut.Size = new System.Drawing.Size(42, 21);
             this.LogingOut.TabIndex = 77;
@@ -1903,7 +1903,7 @@
             // 
             this.OutBoxNum.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.OutBoxNum.ID = null;
-            this.OutBoxNum.Location = new System.Drawing.Point(130, 136);
+            this.OutBoxNum.Location = new System.Drawing.Point(130, 139);
             this.OutBoxNum.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.OutBoxNum.Name = "OutBoxNum";
             this.OutBoxNum.Size = new System.Drawing.Size(37, 23);
@@ -1916,7 +1916,7 @@
             // 
             this.label10.AutoSize = true;
             this.label10.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label10.Location = new System.Drawing.Point(91, 137);
+            this.label10.Location = new System.Drawing.Point(92, 140);
             this.label10.Name = "label10";
             this.label10.Size = new System.Drawing.Size(32, 17);
             this.label10.TabIndex = 90;
@@ -1926,7 +1926,7 @@
             // 
             this.label6.AutoSize = true;
             this.label6.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label6.Location = new System.Drawing.Point(90, 108);
+            this.label6.Location = new System.Drawing.Point(92, 110);
             this.label6.Name = "label6";
             this.label6.Size = new System.Drawing.Size(32, 17);
             this.label6.TabIndex = 87;
@@ -1945,7 +1945,7 @@
             // OutboxCapacity
             // 
             this.OutboxCapacity.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.OutboxCapacity.Location = new System.Drawing.Point(128, 109);
+            this.OutboxCapacity.Location = new System.Drawing.Point(129, 109);
             this.OutboxCapacity.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.OutboxCapacity.Name = "OutboxCapacity";
             this.OutboxCapacity.Size = new System.Drawing.Size(38, 23);

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

@@ -29,7 +29,7 @@ namespace UAS_LabelMachine
         SqliteDBHelper sdh;
 
         DataTable dt;
-      
+
         StringBuilder sql = new StringBuilder();
         /// <summary>
         /// CodeSoft新建打印机引擎
@@ -1135,7 +1135,7 @@ namespace UAS_LabelMachine
                 //打开空标签文件
                 if (EmptySingleFormat == null)
                 {
-                    EmptySingleFormat = engine.Documents.Open(System.Windows.Forms.Application.StartupPath+ @"\Empty.btw");
+                    EmptySingleFormat = engine.Documents.Open(System.Windows.Forms.Application.StartupPath + @"\Empty.btw");
                     EmptySingleFormat.PrintSetup.PrinterName = SingleLabelPrinter.Text;
                 }
                 if (EmptyOutFormat == null)
@@ -2437,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()
         {
@@ -2555,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(ImportExcel.FileName, PI_ID, pi_inoutno.Text, cu_code.Text);
+                LoadGridData();
             }
             catch (Exception ex)
             {