/// <summary> /// 保存数据 /// </summary> public override void SaveImportData(IEnumerable <Spl_WareDetailsModel> list) { try { using (DBContainer db = new DBContainer()) { foreach (var model in list) { Spl_WareDetails entity = new Spl_WareDetails(); entity.Id = ResultHelper.NewId; entity.Name = model.Name; entity.Code = model.Code; entity.BarCode = model.BarCode; entity.WareCategoryId = model.WareCategoryId; entity.Unit = model.Unit; entity.SalePrice = model.SalePrice; entity.Brand = model.Brand; entity.Size = model.Size; entity.Vender = model.Vender; entity.Material = model.Material; entity.Enable = model.Enable; entity.CreateTime = ResultHelper.NowTime; entity.Remark = ""; db.Spl_WareDetails.Add(entity); } db.SaveChanges(); } } catch (Exception ex) { throw; } }
/// <summary> /// 保存数据 /// </summary> public virtual void SaveImportData(IEnumerable <Spl_WareDetailsModel> list) { try { using (DBContainer db = new DBContainer()) { foreach (var model in list) { Spl_WareDetails entity = new Spl_WareDetails(); entity.Id = ResultHelper.NewId; entity.Name = model.Name; entity.Code = model.Code; entity.BarCode = model.BarCode; entity.WareCategoryId = model.WareCategoryId; entity.Unit = model.Unit; entity.Lable = model.Lable; entity.BuyPrice = model.BuyPrice; entity.SalePrice = model.SalePrice; entity.RetailPrice = model.RetailPrice; entity.Remark = model.Remark; entity.Vender = model.Vender; entity.Brand = model.Brand; entity.Color = model.Color; entity.Material = model.Material; entity.Size = model.Size; entity.Weight = model.Weight; entity.ComeFrom = model.ComeFrom; entity.UpperLimit = model.UpperLimit; entity.LowerLimit = model.LowerLimit; entity.PrimeCost = model.PrimeCost; entity.Price1 = model.Price1; entity.Price2 = model.Price2; entity.Price3 = model.Price3; entity.Price4 = model.Price4; entity.Price5 = model.Price5; entity.Photo1 = model.Photo1; entity.Photo2 = model.Photo2; entity.Photo3 = model.Photo3; entity.Photo4 = model.Photo4; entity.Photo5 = model.Photo5; entity.Enable = model.Enable; entity.CreateTime = ResultHelper.NowTime; db.Spl_WareDetails.Add(entity); } db.SaveChanges(); } } catch (Exception ex) { throw; } }
public virtual async Task <Spl_WareDetailsModel> GetByIdAsync(object id) { if (IsExists(id)) { Spl_WareDetails entity = await m_Rep.GetByIdAsync(id); Spl_WareDetailsModel model = new Spl_WareDetailsModel(); model.Id = entity.Id; model.Name = entity.Name; model.Code = entity.Code; model.BarCode = entity.BarCode; model.WareCategoryId = entity.WareCategoryId; model.Unit = entity.Unit; model.Lable = entity.Lable; model.BuyPrice = entity.BuyPrice; model.SalePrice = entity.SalePrice; model.RetailPrice = entity.RetailPrice; model.Remark = entity.Remark; model.Vender = entity.Vender; model.Brand = entity.Brand; model.Color = entity.Color; model.Material = entity.Material; model.Size = entity.Size; model.Weight = entity.Weight; model.ComeFrom = entity.ComeFrom; model.UpperLimit = entity.UpperLimit; model.LowerLimit = entity.LowerLimit; model.PrimeCost = entity.PrimeCost; model.Price1 = entity.Price1; model.Price2 = entity.Price2; model.Price3 = entity.Price3; model.Price4 = entity.Price4; model.Price5 = entity.Price5; model.Photo1 = entity.Photo1; model.Photo2 = entity.Photo2; model.Photo3 = entity.Photo3; model.Photo4 = entity.Photo4; model.Photo5 = entity.Photo5; model.Enable = entity.Enable; model.CreateTime = entity.CreateTime; return(model); } else { return(null); } }
public virtual async Task <Tuple <ValidationErrors, bool> > EditAsync(Spl_WareDetailsModel model) { ValidationErrors errors = new ValidationErrors(); try { Spl_WareDetails entity = await m_Rep.GetByIdAsync(model.Id); if (entity == null) { errors.Add(Resource.Disable); return(new Tuple <ValidationErrors, bool>(errors, false)); } entity.Id = model.Id; entity.Name = model.Name; entity.Code = model.Code; entity.BarCode = model.BarCode; entity.WareCategoryId = model.WareCategoryId; entity.Unit = model.Unit; entity.Lable = model.Lable; entity.BuyPrice = model.BuyPrice; entity.SalePrice = model.SalePrice; entity.RetailPrice = model.RetailPrice; entity.Remark = model.Remark; entity.Vender = model.Vender; entity.Brand = model.Brand; entity.Color = model.Color; entity.Material = model.Material; entity.Size = model.Size; entity.Weight = model.Weight; entity.ComeFrom = model.ComeFrom; entity.UpperLimit = model.UpperLimit; entity.LowerLimit = model.LowerLimit; entity.PrimeCost = model.PrimeCost; entity.Price1 = model.Price1; entity.Price2 = model.Price2; entity.Price3 = model.Price3; entity.Price4 = model.Price4; entity.Price5 = model.Price5; entity.Photo1 = model.Photo1; entity.Photo2 = model.Photo2; entity.Photo3 = model.Photo3; entity.Photo4 = model.Photo4; entity.Photo5 = model.Photo5; entity.Enable = model.Enable; entity.CreateTime = model.CreateTime; if (await m_Rep.EditAsync(entity)) { return(new Tuple <ValidationErrors, bool>(errors, true)); } else { errors.Add(Resource.NoDataChange); return(new Tuple <ValidationErrors, bool>(errors, false)); } } catch (Exception ex) { errors.Add(ex.Message); ExceptionHander.WriteException(ex); return(new Tuple <ValidationErrors, bool>(errors, false)); } }
public virtual bool Create(ref ValidationErrors errors, Spl_WareDetailsModel model) { try { Spl_WareDetails entity = m_Rep.GetById(model.Id); if (entity != null) { errors.Add(Resource.PrimaryRepeat); return(false); } entity = new Spl_WareDetails(); entity.Id = model.Id; entity.Name = model.Name; entity.Code = model.Code; entity.BarCode = model.BarCode; entity.WareCategoryId = model.WareCategoryId; entity.Unit = model.Unit; entity.Lable = model.Lable; entity.BuyPrice = model.BuyPrice; entity.SalePrice = model.SalePrice; entity.RetailPrice = model.RetailPrice; entity.Remark = model.Remark; entity.Vender = model.Vender; entity.Brand = model.Brand; entity.Color = model.Color; entity.Material = model.Material; entity.Size = model.Size; entity.Weight = model.Weight; entity.ComeFrom = model.ComeFrom; entity.UpperLimit = model.UpperLimit; entity.LowerLimit = model.LowerLimit; entity.PrimeCost = model.PrimeCost; entity.Price1 = model.Price1; entity.Price2 = model.Price2; entity.Price3 = model.Price3; entity.Price4 = model.Price4; entity.Price5 = model.Price5; entity.Photo1 = model.Photo1; entity.Photo2 = model.Photo2; entity.Photo3 = model.Photo3; entity.Photo4 = model.Photo4; entity.Photo5 = model.Photo5; entity.Enable = model.Enable; entity.CreateTime = model.CreateTime; if (m_Rep.Create(entity)) { return(true); } else { errors.Add(Resource.InsertFail); return(false); } } catch (Exception ex) { errors.Add(ex.Message); ExceptionHander.WriteException(ex); return(false); } }