public ActionResult CancelRequisition(int HeaderId, int DocTypeId) { //var PersonId = new EmployeeService(_unitOfWork).GetEmloyeeForUser(System.Web.HttpContext.Current.User.Identity.GetUserId()); bool Flag = false; Flag = new RequisitionCancelHeaderService(_unitOfWork).CancelPendingWeavingRequisitions(HeaderId, User.Identity.Name, DocTypeId); return(Json(new { Success = Flag })); }
public ActionResult _Detail(int id) { RequisitionCancelLineViewModel temp = _RequisitionCancelLineService.GetRequisitionCancelLine(id); RequisitionCancelHeader header = new RequisitionCancelHeaderService(_unitOfWork).Find(temp.RequisitionCancelHeaderId); //Getting Settings var settings = new RequisitionSettingService(_unitOfWork).GetRequisitionSettingForDocument(header.DocTypeId, header.DivisionId, header.SiteId); temp.RequisitionSettings = Mapper.Map <RequisitionSetting, RequisitionSettingsViewModel>(settings); if (temp == null) { return(HttpNotFound()); } return(PartialView("_Create", temp)); }
private ActionResult _Delete(int id) { RequisitionCancelLineViewModel temp = _RequisitionCancelLineService.GetRequisitionCancelLine(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"; } RequisitionCancelHeader header = new RequisitionCancelHeaderService(_unitOfWork).Find(temp.RequisitionCancelHeaderId); //Getting Settings var settings = new RequisitionSettingService(_unitOfWork).GetRequisitionSettingForDocument(header.DocTypeId, header.DivisionId, header.SiteId); temp.RequisitionSettings = Mapper.Map <RequisitionSetting, RequisitionSettingsViewModel>(settings); return(PartialView("_Create", temp)); }
public ActionResult _Create(int Id, int sid) //Id ==>Sale Order Header Id { RequisitionCancelHeader header = new RequisitionCancelHeaderService(_unitOfWork).Find(Id); RequisitionCancelLineViewModel svm = new RequisitionCancelLineViewModel(); //Getting Settings var settings = new RequisitionSettingService(_unitOfWork).GetRequisitionSettingForDocument(header.DocTypeId, header.DivisionId, header.SiteId); svm.RequisitionSettings = Mapper.Map <RequisitionSetting, RequisitionSettingsViewModel>(settings); svm.RequisitionCancelHeaderId = Id; svm.PersonId = sid; if (!string.IsNullOrEmpty((string)TempData["CSEXCL"])) { ViewBag.CSEXCL = TempData["CSEXCL"]; TempData["CSEXCL"] = null; } ViewBag.LineMode = "Create"; return(PartialView("_Create", svm)); }
public ActionResult _ResultsPost(RequisitionCancelListModel vm) { Dictionary <int, decimal> LineStatus = new Dictionary <int, decimal>(); var Header = new RequisitionCancelHeaderService(_unitOfWork).Find(vm.RequisitionCancelViewModels.FirstOrDefault().RequisitionCancelHeaderId); bool BeforeSave = true; try { BeforeSave = MaterialRequestCancelDocEvents.beforeLineSaveBulkEvent(this, new StockEventArgs(vm.RequisitionCancelViewModels.FirstOrDefault().RequisitionCancelHeaderId), ref db); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; EventException = true; } if (!BeforeSave) { ModelState.AddModelError("", "Validation failed before save"); } if (ModelState.IsValid && BeforeSave && !EventException) { foreach (var item in vm.RequisitionCancelViewModels) { decimal balqty = (from p in db.ViewRequisitionBalance where p.RequisitionLineId == item.RequisitionLineId select p.BalanceQty).FirstOrDefault(); if (item.Qty > 0 && item.Qty <= balqty) { RequisitionCancelLine line = new RequisitionCancelLine(); line.RequisitionCancelHeaderId = item.RequisitionCancelHeaderId; line.RequisitionLineId = item.RequisitionLineId; 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; LineStatus.Add(line.RequisitionLineId, line.Qty); //_RequisitionCancelLineService.Create(line); line.ObjectState = Model.ObjectState.Added; db.RequisitionCancelLine.Add(line); } } new RequisitionLineStatusService(_unitOfWork).UpdateRequisitionQtyCancelMultiple(LineStatus, Header.DocDate, ref db); try { MaterialRequestCancelDocEvents.onLineSaveBulkEvent(this, new StockEventArgs(vm.RequisitionCancelViewModels.FirstOrDefault().RequisitionCancelHeaderId), ref db); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXCL"] += message; EventException = true; } try { if (EventException) { throw new Exception(); } db.SaveChanges(); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXCL"] += message; return(PartialView("_Results", vm)); } try { MaterialRequestCancelDocEvents.afterLineSaveBulkEvent(this, new StockEventArgs(vm.RequisitionCancelViewModels.FirstOrDefault().RequisitionCancelHeaderId), ref db); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = Header.DocTypeId, DocId = Header.RequisitionCancelHeaderId, 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(RequisitionCancelLineViewModel vm) { bool BeforeSave = true; try { BeforeSave = MaterialRequestCancelDocEvents.beforeLineDeleteEvent(this, new StockEventArgs(vm.RequisitionCancelHeaderId, vm.RequisitionCancelLineId), ref db); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; EventException = true; } if (!BeforeSave) { TempData["CSEXC"] += "Validation failed before delete."; } if (BeforeSave && !EventException) { List <LogTypeViewModel> LogList = new List <LogTypeViewModel>(); RequisitionCancelLine RequisitionLine = (from p in db.RequisitionCancelLine where p.RequisitionCancelLineId == vm.RequisitionCancelLineId select p).FirstOrDefault(); //RequisitionCancelLine RequisitionLine = _RequisitionCancelLineService.Find(vm.RequisitionCancelLineId); RequisitionCancelHeader header = new RequisitionCancelHeaderService(_unitOfWork).Find(RequisitionLine.RequisitionCancelHeaderId); RequisitionCancelLine ExRec = new RequisitionCancelLine(); ExRec = Mapper.Map <RequisitionCancelLine>(RequisitionLine); LogList.Add(new LogTypeViewModel { ExObj = ExRec, }); new RequisitionLineStatusService(_unitOfWork).UpdateRequisitionQtyOnCancel(RequisitionLine.RequisitionLineId, RequisitionLine.RequisitionCancelLineId, header.DocDate, 0, ref db, true); RequisitionLine.ObjectState = Model.ObjectState.Deleted; db.RequisitionCancelLine.Remove(RequisitionLine); 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; header.ObjectState = Model.ObjectState.Modified; db.RequisitionCancelHeader.Add(header); } XElement Modifications = new ModificationsCheckService().CheckChanges(LogList); try { MaterialRequestCancelDocEvents.onLineDeleteEvent(this, new StockEventArgs(RequisitionLine.RequisitionCancelHeaderId, RequisitionLine.RequisitionCancelLineId), ref db); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXCL"] += message; EventException = true; } try { if (EventException) { throw new Exception(); } db.SaveChanges(); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXCL"] += message; return(PartialView("_Create", vm)); } try { MaterialRequestCancelDocEvents.afterLineDeleteEvent(this, new StockEventArgs(RequisitionLine.RequisitionCancelHeaderId, RequisitionLine.RequisitionCancelLineId), ref db); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = header.DocTypeId, DocId = header.RequisitionCancelHeaderId, DocLineId = RequisitionLine.RequisitionCancelLineId, ActivityType = (int)ActivityTypeContants.Deleted, DocNo = header.DocNo, xEModifications = Modifications, DocDate = header.DocDate, DocStatus = header.Status, })); } return(Json(new { success = true })); }
public ActionResult _CreatePost(RequisitionCancelLineViewModel svm) { bool BeforeSave = true; try { if (svm.RequisitionLineId <= 0) { BeforeSave = MaterialRequestCancelDocEvents.beforeLineSaveEvent(this, new StockEventArgs(svm.RequisitionCancelHeaderId, EventModeConstants.Add), ref db); } else { BeforeSave = MaterialRequestCancelDocEvents.beforeLineSaveEvent(this, new StockEventArgs(svm.RequisitionCancelHeaderId, EventModeConstants.Edit), ref db); } } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXCL"] += message; EventException = true; } if (!BeforeSave) { ModelState.AddModelError("", "Validation failed before save."); } if (svm.RequisitionCancelLineId <= 0) { ViewBag.LineMode = "Create"; } else { ViewBag.LineMode = "Edit"; } if (svm.RequisitionCancelLineId <= 0) { RequisitionCancelHeader temp = new RequisitionCancelHeaderService(_unitOfWork).Find(svm.RequisitionCancelHeaderId); RequisitionCancelLine s = new RequisitionCancelLine(); decimal balqty = (from p in db.ViewRequisitionBalance where p.RequisitionLineId == svm.RequisitionLineId 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 && BeforeSave && !EventException) { s.Remark = svm.Remark; s.RequisitionCancelHeaderId = svm.RequisitionCancelHeaderId; s.RequisitionLineId = svm.RequisitionLineId; s.Qty = svm.Qty; s.CreatedDate = DateTime.Now; s.ModifiedDate = DateTime.Now; s.CreatedBy = User.Identity.Name; s.ModifiedBy = User.Identity.Name; s.ObjectState = Model.ObjectState.Added; db.RequisitionCancelLine.Add(s); //_RequisitionCancelLineService.Create(s); new RequisitionLineStatusService(_unitOfWork).UpdateRequisitionQtyOnCancel(s.RequisitionLineId, s.RequisitionCancelLineId, temp.DocDate, s.Qty, ref db, true); if (temp.Status != (int)StatusConstants.Drafted && temp.Status != (int)StatusConstants.Import) { temp.Status = (int)StatusConstants.Modified; temp.ModifiedBy = User.Identity.Name; temp.ModifiedDate = DateTime.Now; temp.ObjectState = Model.ObjectState.Modified; db.RequisitionCancelHeader.Add(temp); } try { MaterialRequestCancelDocEvents.onLineSaveEvent(this, new StockEventArgs(s.RequisitionCancelHeaderId, s.RequisitionLineId, EventModeConstants.Add), ref db); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXCL"] += message; EventException = true; } try { if (EventException) { throw new Exception(); } db.SaveChanges(); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXCL"] += message; return(PartialView("_Create", svm)); } try { MaterialRequestCancelDocEvents.afterLineSaveEvent(this, new StockEventArgs(s.RequisitionCancelHeaderId, s.RequisitionLineId, EventModeConstants.Add), ref db); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXCL"] += message; } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = temp.DocTypeId, DocId = temp.RequisitionCancelHeaderId, DocLineId = s.RequisitionCancelLineId, ActivityType = (int)ActivityTypeContants.Added, DocNo = temp.DocNo, DocDate = temp.DocDate, DocStatus = temp.Status, })); return(RedirectToAction("_Create", new { id = s.RequisitionCancelHeaderId, sid = svm.PersonId })); } return(PartialView("_Create", svm)); } else { List <LogTypeViewModel> LogList = new List <LogTypeViewModel>(); RequisitionCancelHeader temp = new RequisitionCancelHeaderService(_unitOfWork).Find(svm.RequisitionCancelHeaderId); int status = temp.Status; StringBuilder logstring = new StringBuilder(); RequisitionCancelLine s = _RequisitionCancelLineService.Find(svm.RequisitionCancelLineId); RequisitionCancelLine ExRec = new RequisitionCancelLine(); ExRec = Mapper.Map <RequisitionCancelLine>(s); decimal balqty = (from p in db.ViewRequisitionBalance where p.RequisitionLineId == svm.RequisitionLineId select p.BalanceQty).FirstOrDefault(); if (balqty + s.Qty < svm.Qty) { ModelState.AddModelError("Qty", "Qty Exceeding Balance Qty"); } if (ModelState.IsValid && BeforeSave) { if (svm.Qty > 0) { s.Remark = svm.Remark; s.Qty = svm.Qty; s.ModifiedBy = User.Identity.Name; s.ModifiedDate = DateTime.Now; new RequisitionLineStatusService(_unitOfWork).UpdateRequisitionQtyOnCancel(s.RequisitionLineId, s.RequisitionCancelLineId, temp.DocDate, s.Qty, ref db, true); } //_RequisitionCancelLineService.Update(s); s.ObjectState = Model.ObjectState.Modified; db.RequisitionCancelLine.Add(s); LogList.Add(new LogTypeViewModel { ExObj = ExRec, Obj = s, }); if (temp.Status != (int)StatusConstants.Drafted) { temp.Status = (int)StatusConstants.Modified; temp.ObjectState = Model.ObjectState.Modified; db.RequisitionCancelHeader.Add(temp); //new RequisitionCancelHeaderService(_unitOfWork).Update(temp); } XElement Modifications = new ModificationsCheckService().CheckChanges(LogList); try { MaterialRequestCancelDocEvents.onLineSaveEvent(this, new StockEventArgs(s.RequisitionCancelHeaderId, s.RequisitionCancelLineId, EventModeConstants.Edit), ref db); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; EventException = true; } try { if (EventException) { throw new Exception(); } db.SaveChanges(); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXCL"] += message; return(PartialView("_Create", svm)); } try { MaterialRequestCancelDocEvents.afterLineSaveEvent(this, new StockEventArgs(s.RequisitionCancelHeaderId, s.RequisitionCancelLineId, EventModeConstants.Edit), ref db); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; } //SAving the Activity Log:: LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = temp.DocTypeId, DocId = temp.RequisitionCancelHeaderId, DocLineId = s.RequisitionCancelLineId, ActivityType = (int)ActivityTypeContants.Modified, DocNo = temp.DocNo, xEModifications = Modifications, DocDate = temp.DocDate, DocStatus = temp.Status, })); //End Of Saving Activity Log return(Json(new { success = true })); } return(PartialView("_Create", svm)); } }
public ActionResult Reviewed(int Id, string IndexType, string UserRemark, string IsContinue) { bool BeforeSave = true; try { BeforeSave = MaterialRequestCancelDocEvents.beforeHeaderApproveEvent(this, new StockEventArgs(Id), ref db); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; } if (!BeforeSave) { TempData["CSEXC"] += "Falied validation before Review."; } RequisitionCancelHeader pd = new RequisitionCancelHeaderService(_unitOfWork).Find(Id); if (ModelState.IsValid && BeforeSave) { pd.ReviewCount = (pd.ReviewCount ?? 0) + 1; pd.ReviewBy += User.Identity.Name + ", "; pd.ObjectState = Model.ObjectState.Modified; db.RequisitionCancelHeader.Add(pd); //_RequisitionCancelHeaderService.Update(pd); try { MaterialRequestCancelDocEvents.onHeaderApproveEvent(this, new StockEventArgs(Id), ref db); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; } //_unitOfWork.Save(); db.SaveChanges(); try { MaterialRequestCancelDocEvents.afterHeaderApproveEvent(this, new StockEventArgs(Id), ref db); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = pd.DocTypeId, DocId = pd.RequisitionCancelHeaderId, ActivityType = (int)ActivityTypeContants.Reviewed, UserRemark = UserRemark, DocNo = pd.DocNo, DocDate = pd.DocDate, DocStatus = pd.Status, })); //SendEmail_POApproved(Id); 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 Submitted(int Id, string IndexType, string UserRemark, string IsContinue) { bool BeforeSave = true; try { BeforeSave = MaterialRequestCancelDocEvents.beforeHeaderSubmitEvent(this, new StockEventArgs(Id), ref db); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; EventException = true; } if (!BeforeSave) { TempData["CSEXC"] += "Falied validation before submit."; } RequisitionCancelHeader pd = new RequisitionCancelHeaderService(_unitOfWork).Find(Id); if (ModelState.IsValid && BeforeSave && !EventException) { if (User.Identity.Name == pd.ModifiedBy || UserRoles.Contains("Admin")) { int ActivityType; pd.Status = (int)StatusConstants.Submitted; ActivityType = (int)ActivityTypeContants.Submitted; pd.ReviewBy = null; pd.ObjectState = Model.ObjectState.Modified; db.RequisitionCancelHeader.Add(pd); try { MaterialRequestCancelDocEvents.onHeaderSubmitEvent(this, new StockEventArgs(Id), ref db); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; EventException = true; } try { if (EventException) { throw new Exception(); } db.SaveChanges(); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; return(RedirectToAction("Index", new { id = pd.DocTypeId, IndexType = IndexType })); } try { MaterialRequestCancelDocEvents.afterHeaderSubmitEvent(this, new StockEventArgs(Id), ref db); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = pd.DocTypeId, DocId = pd.RequisitionCancelHeaderId, 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(RedirectToAction("Index", new { id = pd.DocTypeId, IndexType = IndexType })); }