public ActionResult Reviewed(int Id, string IndexType, string UserRemark, string IsContinue) { SaleDeliveryOrderHeader pd = new SaleDeliveryOrderHeaderService(_unitOfWork).Find(Id); if (ModelState.IsValid) { pd.ReviewCount = (pd.ReviewCount ?? 0) + 1; pd.ReviewBy += User.Identity.Name + ", "; _SaleDeliveryOrderHeaderService.Update(pd); _unitOfWork.Save(); LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = pd.DocTypeId, DocId = pd.SaleDeliveryOrderHeaderId, ActivityType = (int)ActivityTypeContants.Reviewed, UserRemark = UserRemark, DocNo = pd.DocNo, DocDate = pd.DocDate, DocStatus = pd.Status, })); return(RedirectToAction("Index", new { id = pd.DocTypeId, IndexType = IndexType }).Success("Record reviewed successfully.")); } return(RedirectToAction("Index", new { id = pd.DocTypeId, IndexType = IndexType }).Warning("Error in reviewing.")); }
public ActionResult _ResultsPost(SaleDeliveryMasterDetailModel vm) { if (ModelState.IsValid) { SaleDeliveryOrderHeader Header = new SaleDeliveryOrderHeaderService(_unitOfWork).Find(vm.SaleDeliveryOrderLineViewModel.FirstOrDefault().SaleDeliveryOrderHeaderId); foreach (var item in vm.SaleDeliveryOrderLineViewModel) { decimal balqty = (from p in db.ViewSaleOrderBalanceForCancellation where p.SaleOrderLineId == item.SaleOrderLineId select p.BalanceQty).FirstOrDefault(); if (item.Qty > 0 && item.Qty <= balqty) { SaleDeliveryOrderLine line = new SaleDeliveryOrderLine(); line.SaleDeliveryOrderHeaderId = item.SaleDeliveryOrderHeaderId; line.SaleOrderLineId = item.SaleOrderLineId; line.Qty = item.Qty; line.CreatedDate = DateTime.Now; line.ModifiedDate = DateTime.Now; line.CreatedBy = User.Identity.Name; line.ModifiedBy = User.Identity.Name; line.Remark = item.Remark; _SaleDeliveryOrderLineService.Create(line); } } if (Header.Status != (int)StatusConstants.Drafted && Header.Status != (int)StatusConstants.Import) { Header.Status = (int)StatusConstants.Modified; Header.ObjectState = Model.ObjectState.Modified; new SaleDeliveryOrderHeaderService(_unitOfWork).Update(Header); } try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); ModelState.AddModelError("", message); return(PartialView("_Results", vm)); } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = Header.DocTypeId, DocId = Header.SaleDeliveryOrderHeaderId, ActivityType = (int)ActivityTypeContants.MultipleCreate, DocNo = Header.DocNo, DocDate = Header.DocDate, DocStatus = Header.Status, })); return(Json(new { success = true })); } return(PartialView("_Results", vm)); }
public ActionResult DeletePost(SaleDeliveryOrderLineViewModel vm) { List <LogTypeViewModel> LogList = new List <LogTypeViewModel>(); SaleDeliveryOrderLine SaleOrderLine = _SaleDeliveryOrderLineService.Find(vm.SaleDeliveryOrderLineId); LogList.Add(new LogTypeViewModel { ExObj = SaleOrderLine, }); _SaleDeliveryOrderLineService.Delete(vm.SaleDeliveryOrderLineId); SaleDeliveryOrderHeader header = new SaleDeliveryOrderHeaderService(_unitOfWork).Find(SaleOrderLine.SaleDeliveryOrderHeaderId); if (header.Status != (int)StatusConstants.Drafted && header.Status != (int)StatusConstants.Import) { header.Status = (int)StatusConstants.Modified; header.ModifiedBy = User.Identity.Name; header.ModifiedDate = DateTime.Now; new SaleDeliveryOrderHeaderService(_unitOfWork).Update(header); } XElement Modifications = new ModificationsCheckService().CheckChanges(LogList); try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXCL"] += message; return(PartialView("_Create", vm)); } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = header.DocTypeId, DocId = header.SaleDeliveryOrderHeaderId, DocLineId = SaleOrderLine.SaleDeliveryOrderLineId, ActivityType = (int)ActivityTypeContants.Deleted, DocNo = header.DocNo, xEModifications = Modifications, DocDate = header.DocDate, DocStatus = header.Status, })); return(Json(new { success = true })); }
public ActionResult _Create(int Id) //Id ==>Sale Order Header Id { SaleDeliveryOrderLineViewModel svm = new SaleDeliveryOrderLineViewModel(); SaleDeliveryOrderHeader H = new SaleDeliveryOrderHeaderService(_unitOfWork).Find(Id); //Getting Settings var settings = new SaleDeliveryOrderSettingsService(_unitOfWork).GetSaleDeliveryOrderSettingsForDocument(H.DocTypeId, H.DivisionId, H.SiteId); svm.SaleDeliveryOrderSettings = Mapper.Map <SaleDeliveryOrderSettings, SaleDeliveryOrderSettingsViewModel>(settings); ViewBag.LineMode = "Create"; svm.SaleDeliveryOrderHeaderId = Id; return(PartialView("_Create", svm)); }
private ActionResult _Detail(int id) { SaleDeliveryOrderLineViewModel temp = _SaleDeliveryOrderLineService.GetSaleDeliveryOrderLine(id); if (temp == null) { return(HttpNotFound()); } SaleDeliveryOrderHeader H = new SaleDeliveryOrderHeaderService(_unitOfWork).Find(temp.SaleDeliveryOrderHeaderId); //Getting Settings var settings = new SaleDeliveryOrderSettingsService(_unitOfWork).GetSaleDeliveryOrderSettingsForDocument(H.DocTypeId, H.DivisionId, H.SiteId); temp.SaleDeliveryOrderSettings = Mapper.Map <SaleDeliveryOrderSettings, SaleDeliveryOrderSettingsViewModel>(settings); return(PartialView("_Create", temp)); }
private ActionResult _Delete(int id) { SaleDeliveryOrderLineViewModel temp = _SaleDeliveryOrderLineService.GetSaleDeliveryOrderLine(id); if (temp == null) { return(HttpNotFound()); } #region DocTypeTimeLineValidation try { TimePlanValidation = DocumentValidation.ValidateDocumentLine(new DocumentUniqueId { LockReason = temp.LockReason }, User.Identity.Name, out ExceptionMsg, out Continue); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXCL"] += message; TimePlanValidation = false; } if (!TimePlanValidation) { TempData["CSEXCL"] += ExceptionMsg; } #endregion if ((TimePlanValidation || Continue)) { ViewBag.LineMode = "Delete"; } SaleDeliveryOrderHeader H = new SaleDeliveryOrderHeaderService(_unitOfWork).Find(temp.SaleDeliveryOrderHeaderId); //Getting Settings var settings = new SaleDeliveryOrderSettingsService(_unitOfWork).GetSaleDeliveryOrderSettingsForDocument(H.DocTypeId, H.DivisionId, H.SiteId); temp.SaleDeliveryOrderSettings = Mapper.Map <SaleDeliveryOrderSettings, SaleDeliveryOrderSettingsViewModel>(settings); return(PartialView("_Create", temp)); }
public ActionResult Submitted(int Id, string IndexType, string UserRemark, string IsContinue) { SaleDeliveryOrderHeader pd = new SaleDeliveryOrderHeaderService(_unitOfWork).Find(Id); if (ModelState.IsValid) { if (User.Identity.Name == pd.ModifiedBy || UserRoles.Contains("Admin")) { int ActivityType; pd.Status = (int)StatusConstants.Submitted; ActivityType = (int)ActivityTypeContants.Submitted; pd.ReviewBy = null; _SaleDeliveryOrderHeaderService.Update(pd); _unitOfWork.Save(); LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = pd.DocTypeId, DocId = pd.SaleDeliveryOrderHeaderId, ActivityType = ActivityType, UserRemark = UserRemark, DocNo = pd.DocNo, DocDate = pd.DocDate, DocStatus = pd.Status, })); return(RedirectToAction("Index", new { id = pd.DocTypeId, IndexType = IndexType }).Success("Record Submitted successfully.")); } else { return(RedirectToAction("Index", new { id = pd.DocTypeId, IndexType = IndexType }).Warning("Record can be submitted by user " + pd.ModifiedBy + " only.")); } } return(View()); }
public ActionResult _CreatePost(SaleDeliveryOrderLineViewModel svm) { if (svm.SaleDeliveryOrderLineId <= 0) { ViewBag.LineMode = "Create"; } else { ViewBag.LineMode = "Edit"; } if (svm.SaleDeliveryOrderLineId <= 0) { SaleDeliveryOrderLine s = new SaleDeliveryOrderLine(); decimal balqty = (from p in db.ViewSaleOrderBalanceForCancellation where p.SaleOrderLineId == svm.SaleOrderLineId select p.BalanceQty).FirstOrDefault(); if (balqty < svm.Qty) { ModelState.AddModelError("Qty", "Qty Exceeding Balance Qty"); } if (svm.Qty <= 0) { ModelState.AddModelError("Qty", "Please Check Qty"); } if (ModelState.IsValid) { s.Remark = svm.Remark; s.SaleDeliveryOrderHeaderId = svm.SaleDeliveryOrderHeaderId; s.SaleOrderLineId = svm.SaleOrderLineId; s.Qty = svm.Qty; s.DueDate = svm.DueDate; s.CreatedDate = DateTime.Now; s.ModifiedDate = DateTime.Now; s.CreatedBy = User.Identity.Name; s.ModifiedBy = User.Identity.Name; _SaleDeliveryOrderLineService.Create(s); SaleDeliveryOrderHeader temp2 = new SaleDeliveryOrderHeaderService(_unitOfWork).Find(s.SaleDeliveryOrderHeaderId); if (temp2.Status != (int)StatusConstants.Drafted && temp2.Status != (int)StatusConstants.Import) { temp2.Status = (int)StatusConstants.Modified; temp2.ModifiedBy = User.Identity.Name; temp2.ModifiedDate = DateTime.Now; } new SaleDeliveryOrderHeaderService(_unitOfWork).Update(temp2); try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXCL"] += message; return(PartialView("_Create", svm)); } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = temp2.DocTypeId, DocId = temp2.SaleDeliveryOrderHeaderId, DocLineId = s.SaleDeliveryOrderLineId, ActivityType = (int)ActivityTypeContants.Added, DocNo = temp2.DocNo, DocDate = temp2.DocDate, DocStatus = temp2.Status, })); return(RedirectToAction("_Create", new { id = s.SaleDeliveryOrderHeaderId })); } return(PartialView("_Create", svm)); } else { List <LogTypeViewModel> LogList = new List <LogTypeViewModel>(); SaleDeliveryOrderHeader temp = new SaleDeliveryOrderHeaderService(_unitOfWork).Find(svm.SaleDeliveryOrderHeaderId); int status = temp.Status; StringBuilder logstring = new StringBuilder(); SaleDeliveryOrderLine s = _SaleDeliveryOrderLineService.Find(svm.SaleDeliveryOrderLineId); SaleDeliveryOrderLine ExRec = new SaleDeliveryOrderLine(); ExRec = Mapper.Map <SaleDeliveryOrderLine>(s); decimal balqty = (from p in db.ViewSaleOrderBalanceForCancellation where p.SaleOrderLineId == svm.SaleOrderLineId select p.BalanceQty).FirstOrDefault(); if (balqty + s.Qty < svm.Qty) { ModelState.AddModelError("Qty", "Qty Exceeding Balance Qty"); } if (ModelState.IsValid) { if (svm.Qty > 0) { s.Remark = svm.Remark; s.Qty = svm.Qty; s.ModifiedBy = User.Identity.Name; s.ModifiedDate = DateTime.Now; } _SaleDeliveryOrderLineService.Update(s); if (temp.Status != (int)StatusConstants.Drafted && temp.Status != (int)StatusConstants.Import) { temp.Status = (int)StatusConstants.Modified; temp.ModifiedDate = DateTime.Now; temp.ModifiedBy = User.Identity.Name; new SaleDeliveryOrderHeaderService(_unitOfWork).Update(temp); } LogList.Add(new LogTypeViewModel { ExObj = ExRec, Obj = s, }); XElement Modifications = new ModificationsCheckService().CheckChanges(LogList); try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXCL"] += message; return(PartialView("_Create", svm)); } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = temp.DocTypeId, DocId = s.SaleDeliveryOrderHeaderId, DocLineId = s.SaleDeliveryOrderLineId, ActivityType = (int)ActivityTypeContants.Modified, DocNo = temp.DocNo, xEModifications = Modifications, DocDate = temp.DocDate, DocStatus = temp.Status, })); return(Json(new { success = true })); } return(PartialView("_Create", svm)); } }