private void FillPurchaseModelViews(PurchaseModelView purchaseModelView) { var purchasedProducts = _purchasedProductManager.GetAll(); foreach (PurchasedProduct purchasedProduct in purchasedProducts) { PurchaseModelView purchase = new PurchaseModelView { Id = purchasedProduct.Id, Date = _purchaseManager.GetById(purchasedProduct.PurchaseId).Date, BillNo = _purchaseManager.GetById(purchasedProduct.PurchaseId).BillNo, SupplierId = _purchaseManager.GetById(purchasedProduct.PurchaseId).SupplierId, CategoryId = _productManager.GetById(purchasedProduct.ProductId).CategoryId, ProductId = purchasedProduct.ProductId, ExpireDate = purchasedProduct.ExpireDate, ManufactureDate = purchasedProduct.ManufactureDate, Mrp = purchasedProduct.Mrp, Quantity = purchasedProduct.Quantity, Remarks = purchasedProduct.Remarks, TotalPrice = purchasedProduct.Quantity * purchasedProduct.UnitPrice }; purchaseModelView.PurchaseModelViews.Add(purchase); } }
public JsonResult GetProductInfoJsonResult(int productId) { PurchaseModelView purchaseModelView = new PurchaseModelView { ProductCode = _productManager.GetById(productId).Code }; purchaseModelView.PurchasedProducts = _purchasedProductManager.GetAll() .Where(c => c.ProductId == productId).ToList(); if (purchaseModelView.PurchasedProducts.Count != 0) { var lId = 0; foreach (var purchasedProduct in purchaseModelView.PurchasedProducts) { if (purchasedProduct.Id > lId) { purchaseModelView.PreviousMrp = purchasedProduct.Mrp; purchaseModelView.PreviousUnitPrice = purchasedProduct.UnitPrice; } } } return(Json(purchaseModelView)); }
public void AddToPurchaseCart(PurchaseModelView purchaseModelView) { PurchasedProduct purchasedProduct = Mapper.Map <PurchasedProduct>(purchaseModelView); purchaseModelView.PurchasedProducts.Add(purchasedProduct); }
public ActionResult Add(PurchaseModelView purchaseModelView) { if (purchaseModelView.PurchasedProducts.Count > 0) { var purchase = Mapper.Map <Purchase>(purchaseModelView); _purchaseManager.Add(purchase); var purchaseId = 0; foreach (Purchase purchase1 in _purchaseManager.GetAll()) { purchaseId = Math.Max(purchaseId, purchase1.Id); } foreach (PurchasedProduct purchasedProduct in purchaseModelView.PurchasedProducts) { purchasedProduct.PurchaseId = purchaseId; _purchasedProductManager.Add(purchasedProduct); } } FillComboBox(purchaseModelView); return(View(purchaseModelView)); }
public ActionResult Add() { PurchaseModelView purchaseModelView = new PurchaseModelView(); fillComboBox(purchaseModelView); return(View(purchaseModelView)); }
public JsonResult GetQuantityByProduct(int productcode) { //var productList = _purchasedProductManager.GetAll().Where(c => c.ProductId == productcode).ToList(); ////var productList = _purchaseDetailManager.GetAll().Where(c => c.Code == productcode).ToList(); //var products = from s in productList select (new { s.Quantity, s.Mrp }); //return Json(products, JsonRequestBehavior.AllowGet); PurchaseModelView purchaseModelView = new PurchaseModelView(); var allPurchased = _purchasedProductManager.GetAll().Where(c => c.ProductId == productcode).ToList(); //var productCode = _productManager.GetById(productId).Code; var allSold = _salesDetailManager.GetAll().Where(c => c.ProductId == productcode).ToList(); var aq = 0.0; foreach (var d in allPurchased) { aq += d.Quantity; } foreach (var d in allSold) { aq -= d.Quantity; } purchaseModelView.Quantity = aq; purchaseModelView.Mrp = _purchaseDetailManager.GetAll().FirstOrDefault(c => c.ProductId == productcode).Mrp; return(Json(purchaseModelView, JsonRequestBehavior.AllowGet)); }
public ActionResult Search() { PurchaseModelView purchaseModelView = new PurchaseModelView(); FillComboBox(purchaseModelView); FillPurchaseModelViews(purchaseModelView); return(View(purchaseModelView)); }
private void FillComboBox(PurchaseModelView purchaseModelView) { purchaseModelView.CategorySelectListItems = _categoryManager.GetAll() .Select(c => new SelectListItem() { Value = c.Id.ToString(), Text = c.Name }).ToList(); purchaseModelView.SupplierSelectListItems = _supplierManager.GetAll() .Select(c => new SelectListItem() { Value = c.Id.ToString(), Text = c.Name }).ToList(); purchaseModelView.ProductSelectListItems = new List <SelectListItem>(); }
public ActionResult AddToPurchaseCart(PurchaseModelView purchaseModelView) { purchaseModelView.ProductSelectListItems = _productManager.GetAll() .Where(c => c.CategoryId == purchaseModelView.CategoryId).Select(c => new SelectListItem() { Value = c.Id.ToString(), Text = c.Name }).ToList(); PurchasedProduct purchasedProduct = Mapper.Map <PurchasedProduct>(purchaseModelView); purchaseModelView.PurchasedProducts.Add(purchasedProduct); return(PartialView("Purchase/_InCartProducts", purchaseModelView)); }
public ActionResult Search(PurchaseModelView purchaseModelView) { FillPurchaseModelViews(purchaseModelView); FillComboBox(purchaseModelView); if (!string.IsNullOrEmpty(purchaseModelView.BillNo)) { purchaseModelView.PurchaseModelViews = purchaseModelView.PurchaseModelViews.Where(p => p.Date.ToLower().Contains(purchaseModelView.BillNo.ToLower()) || p.BillNo.ToLower().Contains(purchaseModelView.BillNo.ToLower()) || p.ExpireDate.ToLower().Contains(purchaseModelView.BillNo.ToLower()) || p.ManufactureDate.ToLower().Contains(purchaseModelView.BillNo.ToLower()) || p.Mrp.ToString().ToLower().Contains(purchaseModelView.BillNo.ToLower()) || p.Quantity.ToString().ToLower().Contains(purchaseModelView.BillNo.ToLower()) || p.Remarks.ToLower().Contains(purchaseModelView.BillNo.ToLower()) || p.TotalPrice.ToString().ToLower().Contains(purchaseModelView.BillNo.ToLower()) || (_supplierManager.GetById(p.SupplierId).Name).ToLower().Contains(purchaseModelView.BillNo.ToLower()) || (_productManager.GetById(p.ProductId).Name).ToLower().Contains(purchaseModelView.BillNo.ToLower()) || (_categoryManager.GetById(p.CategoryId).Name).ToLower().Contains(purchaseModelView.BillNo.ToLower())).ToList(); } return(View(purchaseModelView)); }
public JsonResult GetProductInfoJsonResult(int productId) { PurchaseModelView purchaseModelView = new PurchaseModelView { ProductCode = _productManager.GetById(productId).Code }; purchaseModelView.PurchasedProducts = _purchasedProductManager.GetAll() .Where(c => c.ProductId == productId).ToList(); if (purchaseModelView.PurchasedProducts.Count != 0) { var lId = 0; foreach (var purchasedProduct in purchaseModelView.PurchasedProducts) { if (purchasedProduct.Id > lId) { purchaseModelView.PreviousMrp = purchasedProduct.Mrp; purchaseModelView.PreviousUnitPrice = purchasedProduct.UnitPrice; } } } purchaseModelView.AvailableQuantity = 0; var allPurchased = _purchasedProductManager.GetAll().Where(c => c.ProductId == productId).ToList(); var productCode = _productManager.GetById(productId).Code; var allSold = _salesDetailManager.GetAll().Where(c => c.ProductId == productId).ToList(); foreach (var d in allPurchased) { purchaseModelView.AvailableQuantity += d.Quantity; } foreach (var d in allSold) { purchaseModelView.AvailableQuantity -= d.Quantity; } return(Json(purchaseModelView, JsonRequestBehavior.AllowGet)); }
public ActionResult Add(PurchaseModelView purchaseModelView) { FillComboBox(purchaseModelView); return(View(purchaseModelView)); }