public ActionResult _Create(int Id) //Id ==>Sale Order Header Id { int ProductTypeId = (from p in db.Product where p.ProductId == Id select new { ProductTypeId = p.ProductGroup.ProductTypeId }).FirstOrDefault().ProductTypeId; ProductConsumptionLineViewModel s = new ProductConsumptionLineViewModel(); s.BaseProductId = Id; var settings = new ProductTypeSettingsService(_unitOfWork).GetProductTypeSettingsForDocument(ProductTypeId); s.ProductTypeSettings = Mapper.Map <ProductTypeSettings, ProductTypeSettingsViewModel>(settings); var MainContens = _BomDetailService.GetConsumptionForIndex(Id); var LastMainContentLine = (from L in MainContens orderby L.BomDetailId descending select new { BomDetailId = L.BomDetailId, ProductId = L.ProductId }).FirstOrDefault(); if (LastMainContentLine != null) { s.ProductId = LastMainContentLine.ProductId; } PrepareViewBag(s); return(PartialView("_Create", s)); }
public ActionResult DeletePost(ProductConsumptionLineViewModel vm) { List <LogTypeViewModel> LogList = new List <LogTypeViewModel>(); BomDetail BomDetail = _BomDetailService.Find(vm.BomDetailId); LogList.Add(new LogTypeViewModel { ExObj = BomDetail, }); _BomDetailService.Delete(vm.BomDetailId); XElement Modifications = new ModificationsCheckService().CheckChanges(LogList); try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); ModelState.AddModelError("", message); return(PartialView("EditSize", vm)); } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.ProductConsumption).DocumentTypeId, DocId = vm.BomDetailId, ActivityType = (int)ActivityTypeContants.Deleted, xEModifications = Modifications, })); return(Json(new { success = true })); }
public ActionResult _Edit(int id) { ProductConsumptionLineViewModel s = _BomDetailService.GetDesignConsumptionLineForEditForProduct(id); ProductConsumptionLineViewModel temp = _BomDetailService.GetBaseProductDetailForProduct(s.BaseProductId); s.ProductName = temp.ProductName; s.QualityName = temp.QualityName; s.Weight = temp.Weight; if (s == null) { return(HttpNotFound()); } return(PartialView("_Create", s)); }
public ActionResult DeletePost(ProductConsumptionLineViewModel vm) { BomDetail BomDetail = _BomDetailService.Find(vm.BomDetailId); _BomDetailService.Delete(vm.BomDetailId); try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); ModelState.AddModelError("", message); return(PartialView("EditSize", vm)); } return(Json(new { success = true })); }
public ActionResult _Edit(int id) { ProductConsumptionLineViewModel s = _BomDetailService.GetProductConsumptionLineForEdit(id); PrepareViewBag(s); int ProductTypeId = (from p in db.Product where p.ProductId == s.BaseProductId select new { ProductTypeId = p.ProductGroup.ProductTypeId }).FirstOrDefault().ProductTypeId; var settings = new ProductTypeSettingsService(_unitOfWork).GetProductTypeSettingsForDocument(ProductTypeId); s.ProductTypeSettings = Mapper.Map <ProductTypeSettings, ProductTypeSettingsViewModel>(settings); if (s == null) { return(HttpNotFound()); } return(PartialView("_Create", s)); }
public ActionResult _CreatePost(ProductConsumptionLineViewModel svm) { if (ModelState.IsValid) { if (svm.BomDetailId == 0) { BomDetail bomdetail = new BomDetail(); bomdetail.BaseProductId = svm.BaseProductId; bomdetail.BatchQty = 1; //bomdetail.ProcessId = new ProcessService(_unitOfWork).Find(ProcessConstants.Silai).ProcessId; bomdetail.BaseProcessId = new ProcessService(_unitOfWork).Find(ProcessConstants.Manufacturing).ProcessId; bomdetail.ProductId = svm.ProductId; bomdetail.ProcessId = svm.ProcessId; bomdetail.Dimension1Id = svm.Dimension1Id; bomdetail.Dimension2Id = svm.Dimension2Id; bomdetail.Dimension3Id = svm.Dimension3Id; bomdetail.Dimension4Id = svm.Dimension4Id; bomdetail.Qty = svm.Qty; bomdetail.MBQ = svm.MBQ; bomdetail.StdCost = svm.StdCost; bomdetail.StdTime = svm.StdTime; bomdetail.CreatedDate = DateTime.Now; bomdetail.ModifiedDate = DateTime.Now; bomdetail.CreatedBy = User.Identity.Name; bomdetail.ModifiedBy = User.Identity.Name; bomdetail.ObjectState = Model.ObjectState.Added; _BomDetailService.Create(bomdetail); try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); ModelState.AddModelError("", message); return(PartialView("_Create", svm)); } return(RedirectToAction("_Create", new { id = svm.BaseProductId })); } else { BomDetail bomdetail = _BomDetailService.Find(svm.BomDetailId); StringBuilder logstring = new StringBuilder(); bomdetail.BaseProductId = svm.BaseProductId; bomdetail.BatchQty = 1; bomdetail.BaseProcessId = new ProcessService(_unitOfWork).Find(ProcessConstants.Manufacturing).ProcessId; bomdetail.ProductId = svm.ProductId; bomdetail.ProcessId = svm.ProcessId; bomdetail.Dimension1Id = svm.Dimension1Id; bomdetail.Dimension2Id = svm.Dimension2Id; bomdetail.Dimension3Id = svm.Dimension3Id; bomdetail.Dimension4Id = svm.Dimension4Id; bomdetail.Qty = svm.Qty; bomdetail.MBQ = svm.MBQ; bomdetail.StdCost = svm.StdCost; bomdetail.StdTime = svm.StdTime; bomdetail.ModifiedDate = DateTime.Now; bomdetail.ModifiedBy = User.Identity.Name; bomdetail.ObjectState = Model.ObjectState.Modified; _BomDetailService.Update(bomdetail); //Saving the Activity Log ActivityLog al = new ActivityLog() { ActivityType = (int)ActivityTypeContants.Modified, DocId = bomdetail.BomDetailId, CreatedDate = DateTime.Now, Narration = logstring.ToString(), CreatedBy = User.Identity.Name, //DocTypeId = new DocumentTypeService(_unitOfWork).FindByName(TransactionDocCategoryConstants.BomDetail).DocumentTypeId, }; new ActivityLogService(_unitOfWork).Create(al); //End of Saving the Activity Log try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); ModelState.AddModelError("", message); return(PartialView("_Create", svm)); } return(Json(new { success = true })); } } PrepareViewBag(svm); return(PartialView("_Create", svm)); }
private void PrepareViewBag(ProductConsumptionLineViewModel svm) { }
public ActionResult _CreatePost(ProductConsumptionLineViewModel svm) { if (ModelState.IsValid) { if (svm.BomDetailId == 0) { BomDetail bomdetail = new BomDetail(); bomdetail.BaseProductId = svm.BaseProductId; bomdetail.BatchQty = 1; bomdetail.ConsumptionPer = svm.ConsumptionPer; bomdetail.Dimension1Id = svm.Dimension1Id; bomdetail.ProcessId = new ProcessService(_unitOfWork).Find(ProcessConstants.Weaving).ProcessId; bomdetail.ProductId = svm.ProductId; bomdetail.Qty = svm.Qty; bomdetail.CreatedDate = DateTime.Now; bomdetail.ModifiedDate = DateTime.Now; bomdetail.CreatedBy = User.Identity.Name; bomdetail.ModifiedBy = User.Identity.Name; bomdetail.ObjectState = Model.ObjectState.Added; _BomDetailService.Create(bomdetail); if (bomdetail.BaseProductId == bomdetail.ProductId) { //return View(svm).Danger(DataValidationMsg); ModelState.AddModelError("", "Invalid Product is Selected!"); return(PartialView("_Create", svm)); } try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); ModelState.AddModelError("", message); return(PartialView("_Create", svm)); } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.ProductConsumption).DocumentTypeId, DocId = bomdetail.BomDetailId, ActivityType = (int)ActivityTypeContants.Added, })); return(RedirectToAction("_Create", new { id = svm.BaseProductId })); } else { List <LogTypeViewModel> LogList = new List <LogTypeViewModel>(); BomDetail bomdetail = _BomDetailService.Find(svm.BomDetailId); BomDetail ExRec = Mapper.Map <BomDetail>(bomdetail); bomdetail.BaseProductId = svm.BaseProductId; bomdetail.BatchQty = 1; bomdetail.ConsumptionPer = svm.ConsumptionPer; bomdetail.Dimension1Id = svm.Dimension1Id; bomdetail.ProductId = svm.ProductId; bomdetail.Qty = svm.Qty; bomdetail.ModifiedDate = DateTime.Now; bomdetail.ModifiedBy = User.Identity.Name; bomdetail.ObjectState = Model.ObjectState.Modified; _BomDetailService.Update(bomdetail); LogList.Add(new LogTypeViewModel { ExObj = ExRec, Obj = bomdetail, }); XElement Modifications = new ModificationsCheckService().CheckChanges(LogList); try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); ModelState.AddModelError("", message); return(PartialView("_Create", svm)); } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.ProductConsumption).DocumentTypeId, DocId = bomdetail.BomDetailId, ActivityType = (int)ActivityTypeContants.Modified, xEModifications = Modifications, })); return(Json(new { success = true })); } } return(PartialView("_Create", svm)); }
public ActionResult _Create(int Id) //Id ==>Sale Order Header Id { ProductConsumptionLineViewModel temp = _BomDetailService.GetBaseProductDetailForProduct(Id); return(PartialView("_Create", temp)); }