public ActionResult Reviewed(int Id, string IndexType, string UserRemark, string IsContinue) { SaleOrderCancelHeader pd = new SaleOrderCancelHeaderService(_unitOfWork).Find(Id); if (ModelState.IsValid) { pd.ReviewCount = (pd.ReviewCount ?? 0) + 1; pd.ReviewBy += User.Identity.Name + ", "; _SaleOrderCancelHeaderService.Update(pd); _unitOfWork.Save(); LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = pd.DocTypeId, DocId = pd.SaleOrderCancelHeaderId, 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 DeletePost(SaleOrderCancelLineViewModel vm) { List <LogTypeViewModel> LogList = new List <LogTypeViewModel>(); SaleOrderCancelLine SaleOrderLine = _SaleOrderCancelLineService.Find(vm.SaleOrderCancelLineId); LogList.Add(new LogTypeViewModel { ExObj = SaleOrderLine, }); SaleOrderCancelHeader header = new SaleOrderCancelHeaderService(_unitOfWork).Find(SaleOrderLine.SaleOrderCancelHeaderId); new SaleOrderLineStatusService(_unitOfWork).UpdateSaleQtyOnCancel(SaleOrderLine.SaleOrderLineId, SaleOrderLine.SaleOrderCancelLineId, header.DocDate, 0); _SaleOrderCancelLineService.Delete(vm.SaleOrderCancelLineId); if (header.Status != (int)StatusConstants.Drafted && header.Status != (int)StatusConstants.Import) { header.Status = (int)StatusConstants.Modified; header.ModifiedDate = DateTime.Now; header.ModifiedBy = User.Identity.Name; new SaleOrderCancelHeaderService(_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.SaleOrderCancelHeaderId, DocLineId = SaleOrderLine.SaleOrderCancelLineId, ActivityType = (int)ActivityTypeContants.Deleted, DocNo = header.DocNo, xEModifications = Modifications, DocDate = header.DocDate, DocStatus = header.Status, })); return(Json(new { success = true })); }
public ActionResult _CreateMultiple(int id, int bid) { SaleOrderCancelFilterViewModel vm = new SaleOrderCancelFilterViewModel(); vm.SaleOrderCancelHeaderId = id; vm.BuyerId = bid; SaleOrderCancelHeader H = new SaleOrderCancelHeaderService(_unitOfWork).Find(id); var settings = new SaleOrderSettingsService(_unitOfWork).GetSaleOrderSettings(H.DocTypeId, H.DivisionId, H.SiteId); vm.SaleOrderSettings = Mapper.Map <SaleOrderSettings, SaleOrderSettingsViewModel>(settings); vm.DocumentTypeSettings = new DocumentTypeSettingsService(_unitOfWork).GetDocumentTypeSettingsForDocument(H.DocTypeId); return(PartialView("_Filters", vm)); }
public ActionResult _Create(int Id, int bid) //Id ==>Sale Order Header Id { SaleOrderCancelLineViewModel svm = new SaleOrderCancelLineViewModel(); var header = new SaleOrderCancelHeaderService(_unitOfWork).Find(Id); svm.SaleOrderCancelHeaderId = Id; svm.BuyerId = bid; var settings = new SaleOrderSettingsService(_unitOfWork).GetSaleOrderSettings(header.DocTypeId, header.DivisionId, header.SiteId); svm.SaleOrderSettings = Mapper.Map <SaleOrderSettings, SaleOrderSettingsViewModel>(settings); svm.DocumentTypeSettings = new DocumentTypeSettingsService(_unitOfWork).GetDocumentTypeSettingsForDocument(header.DocTypeId); ViewBag.LineMode = "Create"; return(PartialView("_Create", svm)); }
public ActionResult _Delete(int id) { SaleOrderCancelLineViewModel temp = _SaleOrderCancelLineService.GetSaleOrderCancelLineForEdit(id); SaleOrderCancelHeader Header = new SaleOrderCancelHeaderService(_unitOfWork).Find(temp.SaleOrderCancelHeaderId); var settings = new SaleOrderSettingsService(_unitOfWork).GetSaleOrderSettings(Header.DocTypeId, Header.DivisionId, Header.SiteId); temp.SaleOrderSettings = Mapper.Map <SaleOrderSettings, SaleOrderSettingsViewModel>(settings); temp.DocumentTypeSettings = new DocumentTypeSettingsService(_unitOfWork).GetDocumentTypeSettingsForDocument(Header.DocTypeId); 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"; } return(PartialView("_Create", temp)); }
public ActionResult Submitted(int Id, string IndexType, string UserRemark, string IsContinue) { SaleOrderCancelHeader pd = new SaleOrderCancelHeaderService(_unitOfWork).Find(Id); if (ModelState.IsValid) { if (User.Identity.Name == pd.ModifiedBy || UserRoles.Contains("Admin")) { pd.Status = (int)StatusConstants.Submitted; pd.ReviewBy = null; _SaleOrderCancelHeaderService.Update(pd); _unitOfWork.Save(); //SendEmail_PODrafted(Id); LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = pd.DocTypeId, DocId = pd.SaleOrderCancelHeaderId, ActivityType = pd.Status, 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 CompleteSaleOrderCancelLine(SaleOrderCancelMasterDetailModel vm) { int SaleOrderCancelHeaderId = 0; if (ModelState.IsValid) { foreach (var item in vm.SaleOrderCancelViewModels) { decimal balqty = (from p in db.ViewSaleOrderBalanceForCancellation where p.SaleOrderLineId == item.SaleOrderLineId select p.BalanceQty).FirstOrDefault(); if (balqty < item.Qty) { return(View(vm).Danger("Qty Exceeding Bal Qty")); } if (item.Qty > 0) { SaleOrderCancelLine line = new SaleOrderCancelLine(); line.SaleOrderCancelHeaderId = item.SaleOrderCancelHeaderId; line.SaleOrderLineId = item.SaleOrderLineId ?? 0; 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.LineRemark; _SaleOrderCancelLineService.Create(line); } SaleOrderCancelHeaderId = item.SaleOrderCancelHeaderId; } //_unitOfWork.Save(); SaleOrderCancelHeader header = new SaleOrderCancelHeaderService(_unitOfWork).Find(SaleOrderCancelHeaderId); if (header.Status != (int)StatusConstants.Drafted && header.Status != (int)StatusConstants.Import) { header.Status = (int)StatusConstants.Submitted; header.ModifiedBy = User.Identity.Name; header.ModifiedDate = DateTime.Now; } //Activity Log ActivityLog al = new ActivityLog() { ActivityType = (int)StatusConstants.Submitted, DocId = header.SaleOrderCancelHeaderId, UserRemark = header.Remark, Narration = "Sale Order Cancel Submitted with Cancel no:" + header.DocNo, CreatedDate = DateTime.Now, CreatedBy = User.Identity.Name, DocTypeId = header.DocTypeId, }; new SaleOrderCancelHeaderService(_unitOfWork).Update(header); _ActivityLogService.Create(al); _unitOfWork.Save(); return(RedirectToActionPermanent("Index", "SaleOrderCancelHeader")); } return(View(vm)); }
public ActionResult _CreatePost(SaleOrderCancelLineViewModel svm) { SaleOrderCancelHeader temp2 = new SaleOrderCancelHeaderService(_unitOfWork).Find(svm.SaleOrderCancelHeaderId); if (svm.SaleOrderCancelLineId <= 0) { SaleOrderCancelLine s = new SaleOrderCancelLine(); 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.LineRemark; s.SaleOrderCancelHeaderId = svm.SaleOrderCancelHeaderId; s.SaleOrderLineId = svm.SaleOrderLineId ?? 0; s.Qty = svm.Qty; s.CreatedDate = DateTime.Now; s.ModifiedDate = DateTime.Now; s.CreatedBy = User.Identity.Name; s.ModifiedBy = User.Identity.Name; _SaleOrderCancelLineService.Create(s); new SaleOrderLineStatusService(_unitOfWork).UpdateSaleQtyOnCancel(s.SaleOrderLineId, s.SaleOrderCancelLineId, temp2.DocDate, s.Qty); 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 SaleOrderCancelHeaderService(_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.SaleOrderCancelHeaderId, DocLineId = s.SaleOrderCancelLineId, ActivityType = (int)ActivityTypeContants.Added, DocNo = temp2.DocNo, DocDate = temp2.DocDate, DocStatus = temp2.Status, })); return(RedirectToAction("_Create", new { id = s.SaleOrderCancelHeaderId, bid = svm.BuyerId })); } return(PartialView("_Create", svm)); } else { List <LogTypeViewModel> LogList = new List <LogTypeViewModel>(); SaleOrderCancelHeader temp = new SaleOrderCancelHeaderService(_unitOfWork).Find(svm.SaleOrderCancelHeaderId); int status = temp.Status; StringBuilder logstring = new StringBuilder(); SaleOrderCancelLine s = _SaleOrderCancelLineService.Find(svm.SaleOrderCancelLineId); SaleOrderCancelLine ExRec = new SaleOrderCancelLine(); ExRec = Mapper.Map <SaleOrderCancelLine>(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) { //Tracking the Modification:: if (status == (int)StatusConstants.Approved) { logstring.Append("Editing SaleOrderCancelLineId No:" + svm.SaleOrderCancelLineId + "::\n"); if ((s.Remark != svm.Remark)) { logstring.Append(s.Remark + " Remark Modified to " + svm.Remark + "::\n"); } if ((s.Qty != svm.Qty)) { logstring.Append(s.Qty + " Qty Modified to " + svm.Qty + "::\n"); } } //Ennd of Checking Modifications s.Remark = svm.LineRemark; s.Qty = svm.Qty; s.ModifiedBy = User.Identity.Name; s.ModifiedDate = DateTime.Now; new SaleOrderLineStatusService(_unitOfWork).UpdateSaleQtyOnCancel(s.SaleOrderLineId, s.SaleOrderCancelLineId, temp.DocDate, s.Qty); } _SaleOrderCancelLineService.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 SaleOrderCancelHeaderService(_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)); } //SAving the Activity Log:: LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = temp.DocTypeId, DocId = temp.SaleOrderCancelHeaderId, DocLineId = s.SaleOrderCancelLineId, 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 _ResultsPost(SaleOrderCancelMasterDetailModel vm) { Dictionary <int, decimal> LineStatus = new Dictionary <int, decimal>(); var Header = new SaleOrderCancelHeaderService(_unitOfWork).Find(vm.SaleOrderCancelViewModels.FirstOrDefault().SaleOrderCancelHeaderId); if (ModelState.IsValid) { foreach (var item in vm.SaleOrderCancelViewModels) { decimal balqty = (from p in db.ViewSaleOrderBalanceForCancellation where p.SaleOrderLineId == item.SaleOrderLineId select p.BalanceQty).FirstOrDefault(); if (balqty < item.Qty) { return(View("_Results", vm).Danger("Qty Exceeding Bal Qty")); } if (item.Qty > 0) { SaleOrderCancelLine line = new SaleOrderCancelLine(); line.SaleOrderCancelHeaderId = item.SaleOrderCancelHeaderId; line.SaleOrderLineId = item.SaleOrderLineId ?? 0; 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.LineRemark; LineStatus.Add(line.SaleOrderLineId, line.Qty); _SaleOrderCancelLineService.Create(line); } } if (Header.Status != (int)StatusConstants.Drafted && Header.Status != (int)StatusConstants.Import) { Header.Status = (int)StatusConstants.Modified; Header.ObjectState = Model.ObjectState.Modified; new SaleOrderCancelHeaderService(_unitOfWork).Update(Header); } new SaleOrderLineStatusService(_unitOfWork).UpdateSaleQtyCancelMultiple(LineStatus, Header.DocDate); try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXCL"] += message; return(PartialView("_Results", vm)); } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = Header.DocTypeId, DocId = Header.SaleOrderCancelHeaderId, ActivityType = (int)ActivityTypeContants.MultipleCreate, DocNo = Header.DocNo, DocDate = Header.DocDate, DocStatus = Header.Status, })); return(Json(new { success = true })); } return(PartialView("_Results", vm)); }