public ActionResult AddReceiveDetail(ReceiveDetailModel model) { var productModel = _productService.GetProductByCode(model.ProductCode); if (productModel == null) { return(Json(new { IsProductSkusNotFound = true })); } if (_receiveService.CheckProductExistedInReceive(model.ReceiveId, productModel.Id)) { return(Json(new { IsDupp = true })); } model.ProductId = productModel.Id; model.Quantity = model.Quantity; _receiveService.InsertReceiveDetail(model); return(Json(new { })); }
public ActionResult ProductAddPopup(string btnId, string formId, int receiveId, ProductListSelected request) { if (request.ProductIds != null) { if (!string.IsNullOrEmpty(request.ProductIds)) { var productIds = request.ProductIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (var productId in productIds) { var id = Int32.Parse(productId); var isExisted = _receiveService.CheckProductExistedInReceive(receiveId, id); if (isExisted) { continue; } var receiveDetailModel = new ReceiveDetailModel() { Quantity = 1, VatRate = 0, DiscountRate = 0, ProductId = id, ReceiveId = receiveId, UnitPrice = 0 }; _receiveService.InsertReceiveDetail(receiveDetailModel); } } } return(RedirectToAction("Edit", new { id = receiveId })); }
public static WeakReceiveDetailsEntity ToDto(ReceiveDetailModel model) { return(new WeakReceiveDetailsEntity { RecOID = model.RecOID, AmountRec = model.AmountRec, OrdID = model.OrdID, OrdNo = model.OrdNo, OrdDate = model.OrdDate, OffID = model.OffID, OfdNo = model.OfdNo, PrdID = model.PrdID, SupID = model.SupID, SupName = model.SupName, SubAddress = model.SubAddress, ClrID = model.ClrID, ClrName = model.ClrName, TypeProductID = model.TypeProductID, TypeName = model.TypeName, TrdID = model.TrdID, TrdName = model.TrdName, BrandID = model.BrandID, BrandName = model.BrandName, Description = model.Description, Waranty = model.Waranty, PrdEnabled = model.PrdEnabled, //Amount = model.Amount, TotalCost = model.TotalCost, Cost = model.Cost, }); }
public static ReceiveDetailModel _ToDto(ReceiveDetailModel entity) { if (entity == null) { return(null); } return(new ReceiveDetailModel { RecOID = entity.RecOID, AmountRec = entity.AmountRec, OrdID = entity.TypeName, OrdNo = entity.OrdNo, OffID = entity.OffID, OfdNo = entity.OfdNo, PrdID = entity.PrdID, Cost = entity.Cost, TotalCost = entity.TotalCost, TrdID = entity.TrdID, TrdName = entity.TrdName, BrandID = entity.BrandID, BrandName = entity.BrandName, ClrID = entity.ClrID, ClrName = entity.ClrName, TypeProductID = entity.TypeProductID, TypeName = entity.TypeName, Description = entity.Description, Waranty = entity.Waranty, PrdEnabled = entity.PrdEnabled, SupID = entity.SupID, SupName = entity.SupName, SubAddress = entity.SubAddress, }); }
public void InsertReceiveDetail(ReceiveDetailModel receiveDetailModel) { var receiveDetail = Mapper.Map <ReceiveDetail>(receiveDetailModel); _shoppingContext.ReceiveDetails.Add(receiveDetail); _shoppingContext.SaveChanges(); }
private void CalculateAmount(ReceiveDetailModel receiveDetailModel) { receiveDetailModel.SubAmount = receiveDetailModel.UnitPrice * receiveDetailModel.Quantity; receiveDetailModel.DiscountAmount = receiveDetailModel.SubAmount * receiveDetailModel.DiscountRate / 100; receiveDetailModel.VatAmount = (receiveDetailModel.SubAmount - receiveDetailModel.DiscountAmount) * receiveDetailModel.VatRate / 100; receiveDetailModel.Amount = receiveDetailModel.SubAmount - receiveDetailModel.DiscountAmount + receiveDetailModel.VatAmount; }
public void UpdateReceiveDetail(ReceiveDetailModel receiveDetailModel) { var receiveDetail = _shoppingContext.ReceiveDetails.Find(receiveDetailModel.Id); if (receiveDetail == null) { return; } receiveDetail = Mapper.Map <ReceiveDetail>(receiveDetailModel); _shoppingContext.ReceiveDetails.AddOrUpdate(receiveDetail); _shoppingContext.SaveChanges(); }
public ActionResult ReceiveDetailEdit(ReceiveDetailModel model) { var detail = _receiveService.GetReceiveDetailById(model.Id); if (detail == null) { return(Json(new DataSourceResult { Errors = "Product is not exists." })); } if (!ModelState.IsValid) { return(Json(new DataSourceResult { Errors = ModelState.SerializeErrors() })); } _receiveService.UpdateReceiveDetail(model); return(new NullJsonResult()); }