DealsEntity getDeal() { DealsEntity deal = new DealsEntity(); deal.Id = Guid.NewGuid(); deal.Price = FNumber.ConvertDecimal(txtPrice.Text.Trim()); deal.PoPrice = FNumber.ConvertDecimal(txtPoPrice.Text.Trim()); deal.CreatedBy = Util.CurrentUserName; deal.ProductId = ProductId; return deal; }
public string[] UpdatePrice(string _ProductId, string _Price) { string[] updates = null; decimal Price = 0; if (Util.IsGuid(_ProductId) && FNumber.IsDecimal(_Price)) { Guid productId = new Guid(_ProductId); Price = FNumber.ConvertDecimal(_Price); string action = ""; ProductsEntity product = ProductsManager.CreateInstant().SelectOne(productId); if (product != null) { product.Price = Price; product.UpdatedBy = Util.CurrentUserName; product.UpdatedDate = DateTime.Now; ProductsManager.CreateInstant().Update(product); } ProductInfoEntity info = ProductInfoManager.CreateInstant().SelectOne(productId); if (info != null) { action = EnumsAction.UpdatePrice.Replace("[priceold/]", FNumber.FormatNumber(info.PriceSell)).Replace("[pricenew/]", FNumber.FormatNumber(Price)); info.PriceSell = Price; ProductInfoManager.CreateInstant().Update(info); DealsEntity deal = new DealsEntity(); deal.ProductId = info.Id; deal.PoPrice = info.PriceBuy; deal.Price = info.PriceSell; deal.CreatedBy = Util.CurrentUserName; DealsManager.CreateInstant().Insert(deal); HistoryProductManager.CreateInstant().AddHistory(action, productId); } updates = new string[1]; updates[0] = FNumber.FormatNumber(Price); } return updates; }
DealsEntity getDeal(ProductsEntity product) { DealsEntity deal = new DealsEntity(); deal.ProductId = product.Id; deal.Price = product.Price; deal.PoPrice = FNumber.ConvertDecimal(txtPricePo.Text.Trim()); deal.CreatedBy = Util.CurrentUserName; deal.CreatedDate = DateTime.Now; return deal; }
protected void btnAdd_Click(object sender, EventArgs e) { if (Page.IsValid) { ProductInfoEntity info = ProductInfoManager.CreateInstant().SelectOne(ProductId); ProductsEntity product = ProductsManager.CreateInstant().SelectOne(ProductId); if (info != null && product != null) { StorageEntity store = new StorageEntity(); store.Id = Guid.NewGuid(); store.ProductId = ProductId; store.CreatedBy = Util.CurrentUserName; string action = ""; if (rdoCapNhat.Checked) { store.Price = FNumber.ConvertDecimal(txtPrice.Text.Trim()); store.PoPrice = FNumber.ConvertDecimal(txtPoPrice.Text.Trim()); store.Import = FNumber.ConvertInt(txtAmount.Text.Trim()); store.Export = 0; action = EnumsAction.UpdatePrice.Replace("[priceold/]", FNumber.FormatNumber(info.PriceSell)).Replace("[pricenew/]", FNumber.FormatNumber(store.Price)) + "<br/>"; action += EnumsAction.UpdatePricePo.Replace("[priceold/]", FNumber.FormatNumber(info.PriceBuy)).Replace("[pricenew/]", FNumber.FormatNumber(store.PoPrice)) + "<br/>"; action += EnumsAction.UpdateStore.Replace("[amountold/]", product.Amount.ToString()).Replace("[amountnew/]", store.Import.ToString()); info.PriceSell = store.Price; info.PriceBuy = store.PoPrice; if (product.Amount != -1) product.Amount += store.Import; else product.Amount = store.Import; product.Price = store.Price; product.UpdatedBy = Util.CurrentUserName; product.UpdatedDate = DateTime.Now; DealsEntity deal = new DealsEntity(); deal.Price = store.Price; deal.PoPrice = store.PoPrice; deal.ProductId = product.Id; deal.Currency = info.Currency; deal.CreatedBy = Util.CurrentUserName; StorageManager.CreateInstant().Insert(store); DealsManager.CreateInstant().Insert(deal); } else if (rdoNoPrice.Checked) { store.Price = info.PriceSell; store.PoPrice = info.PriceBuy; store.Import = FNumber.ConvertInt(txtAmount.Text.Trim()); store.Export = 0; action += EnumsAction.UpdateStore.Replace("[amountold/]", product.Amount.ToString()).Replace("[amountnew/]", store.Import.ToString()); if (product.Amount != -1) product.Amount += store.Import; else product.Amount = store.Import; StorageManager.CreateInstant().Insert(store); } else if (rdoNoAmount.Checked) { action += EnumsAction.UpdateStore.Replace("[amountold/]", product.Amount.ToString()).Replace("[amountnew/]", "-1"); product.Amount = -1; } ProductInfoManager.CreateInstant().Update(info); ProductsManager.CreateInstant().Update(product); HistoryProductManager.CreateInstant().AddHistory(action, product.Id); Refresh(); } } }