private void btnConfirm_Click(object sender, EventArgs e) { string txtPrice = txtDiscountPrice.EditValue == null ? "" : txtDiscountPrice.EditValue.ToString(); if (string.IsNullOrEmpty(txtPrice)) { ShowMessage("现价不能为空!"); txtDiscountPrice.Focus(); return; } else if (decimal.Parse(txtPrice) < 0) { ShowMessage("现价必须大于等于0"); return; } else { PosExt.RetailPrice = decimal.Parse(txtPrice); ModifyPriceEvent(PosExt); string outBarID = string.Empty; decimal orginalPrice = 0.0m; var listGoodsBase = Ingpal.BusinessStore.Business.SysBLL.Instance.GetALL <GoodsBaseEntity>(where : $"barID='{PosExt.BarID}'"); if (null != listGoodsBase && listGoodsBase.Count > 0) { outBarID = listGoodsBase.FirstOrDefault().OuterBarID; orginalPrice = listGoodsBase.FirstOrDefault().RetailPrice; } UserInfo userInfo = UserInfo.Instance; PriceChangeLog priceChangeLog = new PriceChangeLog(); priceChangeLog.Account = userInfo.Account; priceChangeLog.StoreName = userInfo.StoreName; priceChangeLog.BarID = PosExt.BarID; priceChangeLog.GoodsName = PosExt.Name; priceChangeLog.OrginalPrice = orginalPrice; priceChangeLog.StoreID = userInfo.StoreID.ToString(); priceChangeLog.RealPrice = decimal.Parse(txtPrice); priceChangeLog.IPAddress = Net.Ip; priceChangeLog.OutBarID = outBarID; priceChangeLog.Description = $"【{userInfo.StoreName}】门店用户,【{userInfo.Account}】于【{DateTime.Now.ToString()}】修改商品【{PosExt.Name}】零售价由原价【{priceChangeLog.OrginalPrice}】修改为【{priceChangeLog.RealPrice}】"; Ingpal.BusinessStore.Business.SysBLL.Instance.Insert(priceChangeLog); Close(); } }
public Product UpdatePrice(UpdatePriceDto data) { var product = _productRepository.Get(data.ProductId); if (product == null) { return(null); } var currentPrice = product.Price; product.Price = data.NewPrice; _productRepository.Update(product, data.ProductId); var log = new PriceChangeLog { DateChange = DateTime.Now, NewPrice = data.NewPrice, OldPrice = currentPrice, ProductId = data.ProductId }; _priceChangeLogRepository.Insert(log); return(product); }