Пример #1
0
 /// <summary>
 /// 更新货物档案明细
 /// </summary>
 /// <param name="mod">货物档案明细</param>
 public abstract void UpdateModList(DsWhGoodsManagementList mod);
Пример #2
0
 /// <summary>
 /// 添加货物档案明细
 /// </summary>
 /// <param name="mod">货物档案明细</param>
 /// <returns></returns>
 public abstract int InsertModList(DsWhGoodsManagementList mod);
Пример #3
0
 /// <summary>
 /// 添加货物档案明细
 /// </summary>
 /// <param name="mod">货物档案明细</param>
 /// <returns></returns>
 public int InsertModList(DsWhGoodsManagementList mod)
 {
     return(IDsWhGoodsManagementDao.Instance.InsertModList(mod));
 }
Пример #4
0
 /// <summary>
 /// 更新货物档案明细
 /// </summary>
 /// <param name="mod">货物档案明细</param>
 public void UpdateModList(DsWhGoodsManagementList mod)
 {
     IDsWhGoodsManagementDao.Instance.UpdateModList(mod);
 }
Пример #5
0
        /// <summary>
        /// 货物商品导入
        /// </summary>
        /// <param name="stream">数据源</param>
        /// <param name="SysNo">客户编号</param>
        /// <param name="DsSysNo">经销商编号</param>
        /// <param name="CusCode">客户编码</param>
        /// <returns></returns>
        public Model.Result ImportExcel(System.IO.Stream stream, int SysNo, int DsSysNo, string CusCode)
        {
            DataTable dt = null;
            //DataTable dt_Item = null;
            var cols      = DicGoodsColsMapping.Select(p => p.Value).ToArray();
            var cols_Item = DicItemColsMapping.Select(p => p.Value).ToArray();
            var existlst  = new List <DsWhProduct>();

            try
            {
                HSSFWorkbook hssfwb = null;
                dt = ExcelUtil.ImportExcel(stream, ref hssfwb, cols);

                // dt_Item = ExcelUtil.ImportExcel(stream, 1, hssfwb, cols_Item);
            }
            catch (Exception ex)
            {
                //exception happened,some not caughted
                return(new Model.Result
                {
                    Message = string.Format("数据导入错误,请选择正确的excel文件"),
                    Status = false
                });
            }
            if (dt == null)
            {
                //not all the cols mapped
                return(new Model.Result
                {
                    Message = string.Format("请选择正确的excel文件!"),
                    Status = false
                });
            }
            List <DsWhGoodsManagement>     managementList     = new List <DsWhGoodsManagement>();
            List <DsWhGoodsManagementList> managementItemList = new List <DsWhGoodsManagementList>();
            string batchNumber = DateTime.Now.ToString("yyyyMMddHHmmssffff");
            int    indx        = 0;

            foreach (DataRow row in dt.Rows)
            {
                if (string.IsNullOrEmpty(row[DicGoodsColsMapping["GoodsList"]].ToString().Trim()))
                {
                    continue;
                }
                indx++;
                decimal totalWeight = 0;
                decimal.TryParse(row[DicGoodsColsMapping["WeightValue"]].ToString().Trim(), out totalWeight);
                DsWhGoodsManagement mod = new DsWhGoodsManagement();
                mod.BatchNumber    = batchNumber;
                mod.CustomerCode   = CusCode;
                mod.StatusCode     = "0";
                mod.SysNo          = indx; //Convert.ToInt32(row[DicGoodsColsMapping["SysNo"]].ToString().Trim());
                mod.CourierNumber  = (row[DicGoodsColsMapping["AssNumber"]].ToString().Trim());
                mod.Dis            = (row[DicGoodsColsMapping["Dis"]].ToString().Trim());
                mod.SendUser       = (row[DicGoodsColsMapping["SendUser"]].ToString().Trim());
                mod.SendTelephone  = (row[DicGoodsColsMapping["SendTelephone"]].ToString().Trim());
                mod.SendAddress    = (row[DicGoodsColsMapping["SendAddress"]].ToString().Trim());
                mod.Receipter      = (row[DicGoodsColsMapping["Receipter"]].ToString().Trim());
                mod.IDCard         = (row[DicGoodsColsMapping["IDCard"]].ToString().Trim());
                mod.ReceiptTele    = (row[DicGoodsColsMapping["ReceiptTele"]].ToString().Trim());
                mod.ReceiptCity    = (row[DicGoodsColsMapping["Provinces"]].ToString().Trim()) + "-" + (row[DicGoodsColsMapping["City"]].ToString().Trim());
                mod.ReceiptMall    = (row[DicGoodsColsMapping["ReceiptMall"]].ToString().Trim());
                mod.ReceiptAddress = (row[DicGoodsColsMapping["ReceiptAddress"]].ToString().Trim());
                mod.WeightValue    = totalWeight;
                mod.Currency       = row[DicGoodsColsMapping["Currency"]].ToString().Trim();
                mod.ServiceType    = row[DicGoodsColsMapping["ServiceType"]].ToString().Trim();
                mod.CreateTime     = DateTime.Now;
                managementList.Add(mod);

                string   goodsListText = row[DicGoodsColsMapping["GoodsList"]].ToString().Replace(",", ",").Trim();
                string[] rowsList      = goodsListText.Split(',');
                foreach (string subTRow in rowsList)
                {
                    string[] rowInfo = subTRow.Split('*');

                    int     quantity = 0;
                    decimal price    = 0;
                    decimal weight   = 0;
                    int.TryParse(rowInfo[1].Trim(), out quantity);
                    //decimal.TryParse(row[DicItemColsMapping["GoodsWeight"]].ToString().Trim(), out weight);

                    DsWhGoodsManagementList item = new DsWhGoodsManagementList();
                    item.PSysNo      = indx;
                    item.GoodsName   = rowInfo[0];
                    item.Quantiyt    = quantity;
                    item.GoodsPrice  = price;
                    item.GoodsUnit   = "";
                    item.GoodsWeight = weight;
                    //item.GoodsPostTax = row[DicItemColsMapping["GoodsPostTax"]].ToString().Trim();
                    item.GoodsSpec = ""; //row[DicItemColsMapping["GoodsSpec"]].ToString().Trim()
                    item.BrandName = ""; //row[DicItemColsMapping["BrandName"]].ToString().Trim()
                    //item.GoodsCusCode = row[DicItemColsMapping["GoodsCusCode"]].ToString().Trim();
                    managementItemList.Add(item);
                }

                /*string goodsListText = row[DicGoodsColsMapping["GoodsList"]].ToString().Trim();
                 * string[] rowsList = goodsListText.Replace("||||||", "░").Split('░');
                 * foreach(string subTRow in rowsList)
                 * {
                 *  string[] rowInfo = subTRow.Replace("::::::", "∷").Split('∷');
                 *
                 *  int quantity = 0;
                 *  decimal price = 0;
                 *  decimal weight = 0;
                 *  int.TryParse(rowInfo[5].Trim(), out quantity);
                 *  decimal.TryParse(rowInfo[3], out price);
                 *  //decimal.TryParse(row[DicItemColsMapping["GoodsWeight"]].ToString().Trim(), out weight);
                 *
                 *  DsWhGoodsManagementList item = new DsWhGoodsManagementList();
                 *  item.PSysNo = indx;
                 *  item.GoodsName = rowInfo[0];
                 *  item.Quantiyt = quantity;
                 *  item.GoodsPrice = price;
                 *  item.GoodsUnit = rowInfo[4];
                 *  item.GoodsWeight = weight;
                 *  //item.GoodsPostTax = row[DicItemColsMapping["GoodsPostTax"]].ToString().Trim();
                 *  item.GoodsSpec = rowInfo[2];//row[DicItemColsMapping["GoodsSpec"]].ToString().Trim()
                 *  item.BrandName = rowInfo[1];//row[DicItemColsMapping["BrandName"]].ToString().Trim()
                 *  //item.GoodsCusCode = row[DicItemColsMapping["GoodsCusCode"]].ToString().Trim();
                 *  managementItemList.Add(item);
                 * }*/
            }

            //foreach (DataRow row in dt_Item.Rows)
            //{
            //    int quantity = 0;
            //    decimal price = 0;
            //    decimal weight = 0;
            //    int.TryParse(row[DicItemColsMapping["Quantiyt"]].ToString().Trim(), out quantity);
            //    decimal.TryParse(row[DicItemColsMapping["GoodsPrice"]].ToString().Trim(), out price);
            //    decimal.TryParse(row[DicItemColsMapping["GoodsWeight"]].ToString().Trim(), out weight);

            //    DsWhGoodsManagementList item = new DsWhGoodsManagementList();
            //    item.PSysNo = Convert.ToInt32(row[DicItemColsMapping["SysNo"]].ToString().Trim());
            //    item.GoodsName = row[DicItemColsMapping["ProductName"]].ToString().Trim();
            //    item.Quantiyt = quantity;
            //    item.GoodsUnit = row[DicItemColsMapping["GoodsUnit"]].ToString().Trim();
            //    item.GoodsPrice = price;
            //    item.GoodsUnit = row[DicItemColsMapping["GoodsUnit"]].ToString().Trim();
            //    item.GoodsWeight = weight;
            //    item.GoodsPostTax = row[DicItemColsMapping["GoodsPostTax"]].ToString().Trim();
            //    item.GoodsSpec = row[DicItemColsMapping["GoodsSpec"]].ToString().Trim();
            //    item.BrandName = row[DicItemColsMapping["BrandName"]].ToString().Trim();
            //    item.GoodsCusCode = row[DicItemColsMapping["GoodsCusCode"]].ToString().Trim();
            //    managementItemList.Add(item);
            //}

            using (var tran = new TransactionScope())
            {
                foreach (var mod in managementList)
                {
                    var sysNo = mod.SysNo;
                    mod.SysNo     = 0;
                    mod.PayStatus = "0";
                    List <DsWhGoodsManagementList> itemList = managementItemList.FindAll(p => p.PSysNo == sysNo);
                    mod.SysNo = InsertMod(mod);
                    int     totalPageNum = 0;
                    string  PageName     = "";
                    decimal weight       = 0;
                    foreach (var item in itemList)
                    {
                        item.PSysNo = mod.SysNo;
                        InsertModList(item);
                        totalPageNum += item.Quantiyt;
                        PageName     += item.GoodsName + "*" + item.Quantiyt + "  ";
                        weight       += item.GoodsWeight;
                    }
                    mod.ReceiptPageNum  = totalPageNum.ToString();
                    mod.ReceiptPageName = PageName;
                    // mod.WeightValue = weight;
                    UpdateMod(mod);
                }
                tran.Complete();
            }

            return(new Model.Result <string>
            {
                Message = "操作成功,通过商品编码检查导入的商品新增更新与否-" + batchNumber,
                Data = batchNumber,
                Status = true
            });
        }