public void CheckExists(AdjustStorePrice model) { if (_db.Table.Exists <AdjustStorePrice>(n => n.Code == model.Code)) { throw new Exception("调价单号已经存在"); } }
public void Update(AdjustStorePrice model) { if (_db.Table.Exists <AdjustStorePriceItem>(n => n.AdjustStorePriceId == model.Id)) { _db.Delete <AdjustStorePriceItem>(n => n.AdjustStorePriceId == model.Id); } _db.Insert <AdjustStorePriceItem>(model.Items.ToArray()); _db.Update(model); }
public AdjustStorePrice Create(Product product, decimal adjustPrice, string code, int editBy) { AdjustStorePrice model = new AdjustStorePrice(); model.Code = code; model.Status = ValueObject.AdjustStorePriceStatus.Create; model.CreatedBy = editBy; model.UpdatedBy = editBy; model.AddItem(product, adjustPrice); return(model); }
public void UpdateStoreSalePrice(AdjustStorePrice entity) { if (entity.Items.Count() == 0) { throw new FriendlyException("明细为空"); } var parma = entity.Items.Select(n => new { StoreId = entity.StoreId, ProductId = n.ProductId, AdjustPrice = n.AdjustPrice }).ToArray(); string sql = "update StoreInventory set StoreSalePrice =@AdjustPrice where StoreId=@StoreId and ProductId=@ProductId"; _db.Command.AddExecute(sql, parma); }
public void Create(AdjustStorePriceModel model) { var entity = new AdjustStorePrice(); entity = model.MapTo <AdjustStorePrice>(); entity.AddItems(model.ConvertJsonToItem()); entity.CreatedBy = model.UpdatedBy; entity.Code = _sequenceService.GenerateNewCode(BillIdentity.AdjustStorePrice); _db.Insert(entity); var reason = "创建门店调价单"; var history = new ProcessHistory(model.UpdatedBy, model.UpdatedByName, (int)entity.Status, entity.Id, BillIdentity.AdjustStorePrice.ToString(), reason); _db.Command.AddExecute(history.CreateSql(entity.GetType().Name, entity.Code), history); _db.SaveChange(); }