Пример #1
0
 protected void dgProduct_RowDataBound(object sender, GridViewRowEventArgs e)
 {
     if (e.Row.RowType == DataControlRowType.DataRow)
     {
         NModel.Product p         = e.Row.DataItem as NModel.Product;
         Repeater       rptImages = e.Row.FindControl("rptImages") as Repeater;
         rptImages.DataSource = p.ProductImageUrls;
         rptImages.DataBind();
     }
 }
Пример #2
0
        public void SaveTest()
        {
            var finfo = new System.IO.FileInfo(Environment.CurrentDirectory + (@"\config\log4net.config"));
            log4net.Config.XmlConfigurator.Configure(finfo);
            NDAL.DalBase<Product> dal = new NDAL.DALProduct();
            Product p = new Product();
            p.SupplierCode = "00013";// "开平市祥云卫浴制品有限公司";
            p.ModelNumber = "XY-3918";
            p.NTSCode = "01.012.0000400013";
            dal.Save(p);

            Product p2 = dal.GetOne(p.Id);

            Assert.AreEqual(p.Id, p2.Id);
              //  dal.Delete(p);
        }
Пример #3
0
 //此操作对应的单据
 public void CloneFromProduct(Product p)
 {
     this.ProductId = p.Id;
     if (p.CategoryCode != this.CategoryCode)
     {
         this.CategoryCode = p.CategoryCode;
         this.NTSCode = null;
     }
     if (p.SupplierCode != this.SupplierCode)
     {
         this.SupplierCode = p.SupplierCode;
         this.NTSCode = null;
     }
     this.ImageState = p.ImageState;
     this.PriceDate = p.PriceDate;
     this.PriceOfFactory = p.PriceOfFactory;
     this.PriceValidPeriod = p.PriceValidPeriod;
     this.ProductionCycle = p.ProductionCycle;
     this.TaxRate = p.TaxRate;
 }
Пример #4
0
        public Product PopulateFromRow(DataRow row)
        {
            //根据 名称值 判断该产品信息的语言.

            StringBuilder sb = new StringBuilder();
            Product p = new Product();
            ProductLanguage pl = new ProductLanguage();
            pl.Name = row["产品名称"].ToString();

            pl.PlaceOfOrigin = row["产地"].ToString();
            pl.PlaceOfDelivery = row["交货地"].ToString();
            p.ImageState = row["图片"].ToString();
            pl.Memo = row["备注"].ToString();
            p.PriceDate = row["报价日期"].ToString();
            p.PriceValidPeriod = row["报价有效期"].ToString();

            //分类编码:非空,格式正确
            string categoryCode = StringHelper.ReplaceSpace(row["分类编码"].ToString());
            if (string.IsNullOrEmpty(categoryCode))
            {
                string errmsg = string.Format("分类编码不能为空.可能原因:1)分类编码为空 2)有空白行.供应商编码:{0}", p.SupplierCode);
                NLibrary.NLogger.Logger.Error(errmsg);
                throw new Exception(errmsg);
            }
            string categoryCodePatern = @"\d{2}\.\d{3}";
            if (!Regex.IsMatch(categoryCode, categoryCodePatern))
            {
                string errmsg = string.Format("分类编码格式有误.名称:{0},编码:{1}", pl.Name, categoryCode);
                NLibrary.NLogger.Logger.Error(errmsg);
                throw new Exception(errmsg);
            }
            p.CategoryCode = categoryCode;
            //产品型号:特殊符号用美元符号代替,删除所有空格
            string modelNumber = row["产品型号"].ToString();
            modelNumber = StringHelper.ReplaceInvalidChaInFileName(modelNumber, "$");
            string originalModelNumber = row["产品原始型号"] ==null?modelNumber: row["产品原始型号"].ToString();
            p.ModelNumber = modelNumber;
            p.ModelNumber_Original = originalModelNumber;

            p.SupplierCode =NLibrary.StringHelper.FullFillWidth(row["供应商编码"].ToString(),"00000",5,true);
            pl.ProductParameters = row["规格参数"].ToString();
            pl.Unit = row["单位"].ToString();
            pl.ProductDescription = row["产品描述"].ToString();
            p.MoneyType = row["币别"].ToString();
            pl.Language = StringHelper.LanguageTypeDetermine(pl.Name + pl.ProductDescription + pl.ProductParameters + pl.Memo);

            //nts编码
            //已删除,该类不负责nts编码的创建

            //税率
            string strRate = row["税率"].ToString();
            strRate = strRate.Replace("%", "");
            if (!string.IsNullOrEmpty(strRate))
            {
                try
                {
                    p.TaxRate = Convert.ToDecimal(strRate);
                }
                catch
                {
                    throw new Exception(string.Format("税率 数据格式有误.供应商:{0},产品型号:{1}",
                                        p.SupplierCode, p.ModelNumber
                                ));
                }
            }

            //出厂价
            decimal price = 0;
            string strFactoryPrice = row["出厂价"].ToString();
            if (!string.IsNullOrEmpty(strFactoryPrice))
            {
                try
                {
                    price = decimal.Parse(Regex.Replace(strFactoryPrice, @"[^\d.]", ""));
                }
                catch
                {
                    throw new Exception(string.Format("出厂价数据格式有误.供应商:{0},产品型号:{1}",
                                    p.SupplierCode, p.ModelNumber
                            ));
                }
            }
            p.PriceOfFactory = strFactoryPrice;
            //生产周期
            string productionCycle = row["生产周期"].ToString();
            int 生产周期 = 0;
            if (!string.IsNullOrEmpty(productionCycle))
            {
                生产周期 = int.Parse(Regex.Replace(productionCycle, @"[^\d.]", ""));
            }
            p.ProductionCycle = 生产周期;
            //最小订货量
            string strMinOrderAmount = row["最小起订量"].ToString();
            int 最小订货量 = 0;
            if (!string.IsNullOrEmpty(strMinOrderAmount))
            {
                if (!int.TryParse(Regex.Replace(strMinOrderAmount, @"[^\d.]", ""), out 最小订货量))
                {
                    NLibrary.NLogger.Logger.Debug(
                        string.Format(@"最小起定量数据格式异常,已设置为0.供应商:{0},产品型号:{1}"
                       , p.SupplierCode, p.ModelNumber
                        ));
                }
            }
            p.OrderAmountMin = 最小订货量;

            p.ProductMultiLangues.Add(pl);

            return p;
        }
Пример #5
0
        public Product PopulateFromRow(DataRow row)
        {
            Product p = new Product();
            ProductLanguage pl = new ProductLanguage();
            p.ProductMultiLangues.Add(pl);
            pl.PlaceOfOrigin = row["备注"].ToString();
            // p.PlaceOfDelivery = row["交货地"].ToString();
            pl.Name = row["名称"].ToString();

            string categoryCode = StringHelper.ReplaceSpace(row["分类编码"].ToString());

            if (string.IsNullOrEmpty(pl.PlaceOfOrigin) && string.IsNullOrEmpty(pl.Name)
                && string.IsNullOrEmpty(categoryCode))
            {
                throw new Exception("未导入.请确认非内容单元格已彻底清除.");
            }
            //erp的代码包含了供应商和流水号,应该去除
            if (string.IsNullOrEmpty(categoryCode))
            {
                string errmsg = string.Format("分类编码不能为空.名称:{0}", pl.Name);
                NLibrary.NLogger.Logger.Error(errmsg);
                throw new Exception(errmsg);
            }

            p.CategoryCode = categoryCode.Substring(0, 6);
            //产品型号:
            string modelNumber = row["产品型号"].ToString();
            p.ModelNumber = modelNumber;
            pl.ProductParameters = row["规格参数"].ToString();
            pl.Unit = row["计量单位组_FName"].ToString();
            p.SupplierCode = NLibrary.StringHelper.FullFillWidth(row["来源_FNumber"].ToString(), "00000", 5, true);
            pl.ProductDescription = row["描述/卖点"].ToString();
            pl.Language = StringHelper.LanguageTypeDetermine(pl.Name+pl.ProductDescription+pl.ProductParameters+pl.Memo);
            //nts编码
            //已删除,该类不负责nts编码的创建

            //税率
            string strRate = row["税率(%)"].ToString();
            strRate = strRate.Replace("%", "");
            if (!string.IsNullOrEmpty(strRate))
            {
                p.TaxRate = Convert.ToDecimal(strRate);
            }

            //出厂价
            decimal price = 0;
            string strFactoryPrice = row["含税出厂价"].ToString();
            if (!string.IsNullOrEmpty(strFactoryPrice))
            {
                try
                {
                    price = decimal.Parse(Regex.Replace(strFactoryPrice, @"[^\d.]", ""));
                }
                catch
                {
                    throw new Exception(string.Format("出厂价数据格式有误.供应商:{0},产品型号:{1}",
                                    p.SupplierCode, p.ModelNumber
                            ));
                }
            }
            p.PriceOfFactory = strFactoryPrice;
            //生产周期
            string productionCycle = row["固定提前期"].ToString();
            int 生产周期 = 0;
            if (!string.IsNullOrEmpty(productionCycle))
            {
                生产周期 = int.Parse(Regex.Replace(productionCycle, @"[^\d.]", ""));
            }
            p.ProductionCycle = 生产周期;
            //最小订货量
            string strMinOrderAmount = row["最小订货量"].ToString();
            int 最小订货量 = 0;
            if (!string.IsNullOrEmpty(strMinOrderAmount))
            {
                if (!int.TryParse(Regex.Replace(strMinOrderAmount, @"[^\d.]", ""), out 最小订货量))
                {
                    NLibrary.NLogger.Logger.Debug(
                        string.Format(@"最小起定量数据格式异常,已设置为0.供应商:{0},产品型号:{1}"
                       , p.SupplierCode, p.ModelNumber
                        ));
                }
            }
            p.OrderAmountMin = 最小订货量;
            return p;
        }
Пример #6
0
 /// <summary>
 /// 更新现有product. 
 /// 基础资料和 多语言  
 /// </summary>
 /// <param name="newPro"></param>
 public virtual void UpdateByNewVersion(Product newPro)
 {
     //基础资料
     //如果这两者变了,那需要重新生成NTSCode
     if (newPro.CategoryCode != this.CategoryCode)
     {
         this.CategoryCode = newPro.CategoryCode;
         this.NTSCode = null;
     }
     if (newPro.SupplierCode != this.SupplierCode)
     {
         this.SupplierCode = newPro.SupplierCode;
         this.NTSCode = null;
     }
     this.ImageState = newPro.ImageState;
     this.PriceDate = newPro.PriceDate;
     this.PriceOfFactory = newPro.PriceOfFactory;
     this.PriceValidPeriod = newPro.PriceValidPeriod;
     this.ProductionCycle = newPro.ProductionCycle;
     this.TaxRate = newPro.TaxRate;
     this.LastUpdateTime = DateTime.Now;
     foreach (ProductLanguage piNew in newPro.ProductMultiLangues)
     {
         //如果该语言不存在 则增加
         var pll = ProductMultiLangues.Where(x => x.Language == piNew.Language).ToList();
         if ( pll.Count == 0)
         {
             ProductMultiLangues.Add(piNew);
         }
         else  //更新
         {
             if (pll.Count == 1)
             {
                pll[0].UpdateByNewVersion(piNew);
             }
             else
             {
                 throw new Exception("同一种产品出现多条同种语言的信息.型号:"+this.ModelNumber+",供应商编码:"+this.SupplierCode);
             }
         }
     }
 }
Пример #7
0
        //获取某种
        public virtual Product GetProductOfSpecialLanguage(string language)
        {
            var pl= ProductMultiLangues.Where(x => x.Language.Equals(language, StringComparison.OrdinalIgnoreCase));
              int languageVersionCount=pl.Count();
            if (languageVersionCount>1)
            {
                string msg1 = "产品信息的多语言版本有误:" + this.NTSCode + " 的" + language + " 版本有 " + languageVersionCount + " 种";

                log.Error(msg1);
                throw new Exception(msg1);
            }
            else if (languageVersionCount == 0)
            {
                //log.Error("该产品没有对应的语言版本:" + this.Id + "," + language);
                return null;
            }
            Product p = new Product();
            ProductLanguage plOfThis = pl.ToArray()[0];
            p.Memo = plOfThis.Memo ?? string.Empty;
            p.Name = plOfThis.Name;
              p.PlaceOfDelivery=   plOfThis.PlaceOfDelivery ;
              p.PlaceOfOrigin=  plOfThis.PlaceOfOrigin ;
              p.ProductDescription = plOfThis.ProductDescription;
              p.ProductParameters = plOfThis.ProductParameters;
              p.Unit = plOfThis.Unit;

              p.CategoryCode = this.CategoryCode;
              p.CreateTime = this.CreateTime;
              p.Id = this.Id;
              p.ImageState = this.ImageState;
              p.ModelNumber = this.ModelNumber;
              p.MoneyType = this.MoneyType;
              p.NTSCode = this.NTSCode;
              p.ProductCode = this.ProductCode;
              p.OrderAmountMin = this.OrderAmountMin;
              p.PriceDate = this.PriceDate;
              p.PriceOfFactory = this.PriceOfFactory;
              p.PriceValidPeriod = this.PriceValidPeriod;
              p.ProductImageList = this.ProductImageList;
              p.State = this.State;
              p.ProductionCycle = this.ProductionCycle;
              p.SupplierCode = this.SupplierCode;
              p.TaxRate = this.TaxRate;
              p.ProductCode = this.ProductCode;

            return p;
        }
Пример #8
0
        public Product PopulateFromRow(DataRow row)
        {
            Product p = new Product();
            p.PlaceOfOrigin = row["产地"].ToString();
            p.PlaceOfDelivery = row["交货地"].ToString();
            p.Name = row["产品名称"].ToString();
            //分类编码:非空,格式正确
            string categoryCode = StringHelper.ReplaceSpace(row["分类编码"].ToString());
            if (string.IsNullOrEmpty(categoryCode))
            {
                string errmsg = string.Format("分类编码不能为空.名称:{0}", p.Name);
                NLibrary.NLogger.Logger.Error(errmsg);
                throw new Exception(errmsg);
            }
            string categoryCodePatern = @"\d{2}\.\d{3}";
            if (!Regex.IsMatch(categoryCode, categoryCodePatern))
            {
                string errmsg = string.Format("分类编码格式有误.名称:{0},编码:{1}", p.Name, categoryCode);
                NLibrary.NLogger.Logger.Error(errmsg);
                throw new Exception(errmsg);
            }
            p.CategoryCode = categoryCode;
            //产品型号:
            string modelNumber = row["产品型号"].ToString();
            p.ModelNumber = modelNumber;
            p.ProductParameters = row["规格参数"].ToString();
            p.Unit = row["单位"].ToString();
            p.SupplierName = row["供应商名称"].ToString();
            p.ProductDescription = row["产品描述"].ToString();
            //nts编码
            //已删除,该类不负责nts编码的创建

            //税率
            string strRate = row["税率"].ToString();
            strRate = strRate.Replace("%", "");
            if (!string.IsNullOrEmpty(strRate))
            {
                p.TaxRate = Convert.ToDecimal(strRate);
            }

            //出厂价
            decimal price = 0;
            string strFactoryPrice = row["出厂价"].ToString();
            if (!string.IsNullOrEmpty(strFactoryPrice))
            {
                try
                {
                    price = decimal.Parse(Regex.Replace(strFactoryPrice, @"[^\d.]", ""));
                }
                catch
                {
                    throw new Exception(string.Format("出厂价数据格式有误.供应商:{0},产品型号:{1}",
                                    p.SupplierName, p.ModelNumber
                            ));
                }
            }
            p.PriceOfFactory = strFactoryPrice;
            //生产周期
            string productionCycle = row["生产周期"].ToString();
            int 生产周期 = 0;
            if (!string.IsNullOrEmpty(productionCycle))
            {
                生产周期 = int.Parse(Regex.Replace(productionCycle, @"[^\d.]", ""));
            }
            p.ProductionCycle = 生产周期;
            //最小订货量
            string strMinOrderAmount = row["最小起订量"].ToString();
            int 最小订货量 = 0;
            if (!string.IsNullOrEmpty(strMinOrderAmount))
            {
                if (!int.TryParse(Regex.Replace(strMinOrderAmount, @"[^\d.]", ""), out 最小订货量))
                {
                    NLibrary.NLogger.Logger.Debug(
                        string.Format(@"最小起定量数据格式异常,已设置为0.供应商:{0},产品型号:{1}"
                       , p.SupplierName, p.ModelNumber
                        ));
                }
            }
            p.OrderAmountMin = 最小订货量;
            return p;
        }