public ActionResult Create(int id, int DocTypeId)//JobReceiveLineId { //JobReceiveQAAttributeViewModel vm = new JobReceiveQAAttributeViewModel(); JobReceiveQAAttributeViewModel vm = _JobReceiveQAAttributeService.GetJobReceiveLineDetail(id); vm.DivisionId = (int)System.Web.HttpContext.Current.Session["DivisionId"]; vm.SiteId = (int)System.Web.HttpContext.Current.Session["SiteId"]; vm.CreatedDate = DateTime.Now; var temp = _JobReceiveQAAttributeService.GetJobReceiveQAAttribute(id); vm.QAGroupLine = temp; LastValues LastValues = _JobReceiveQAAttributeService.GetLastValues(DocTypeId); if (LastValues != null) { if (LastValues.QAById != null) { vm.QAById = (int)LastValues.QAById; } } //Getting Settings var settings = new JobReceiveQASettingsService(db).GetJobReceiveQASettingsForDocument(DocTypeId, vm.DivisionId, vm.SiteId); if (settings == null && UserRoles.Contains("SysAdmin")) { return(RedirectToAction("Create", "JobReceiveQASettings", new { id = DocTypeId }).Warning("Please create job Inspection settings")); } else if (settings == null && !UserRoles.Contains("SysAdmin")) { return(View("~/Views/Shared/InValidSettings.cshtml")); } vm.JobReceiveQASettings = Mapper.Map <JobReceiveQASettings, JobReceiveQASettingsViewModel>(settings); vm.DocumentTypeSettings = new DocumentTypeSettingsService(_unitOfWork).GetDocumentTypeSettingsForDocument(DocTypeId); vm.ProcessId = settings.ProcessId; vm.DocDate = DateTime.Now; vm.DocTypeId = DocTypeId; vm.DocNo = new JobReceiveQAHeaderService(db).FGetNewDocNo("DocNo", ConfigurationManager.AppSettings["DataBaseSchema"] + ".JobReceiveQAHeaders", vm.DocTypeId, vm.DocDate, vm.DivisionId, vm.SiteId); PrepareViewBag(DocTypeId); ViewBag.Mode = "Add"; return(View("Create", vm)); }
public ActionResult Edit(int id) { JobReceiveQAAttributeViewModel pt = _JobReceiveQAAttributeService.GetJobReceiveQAAttributeDetailForEdit(id); if (pt == null) { return(HttpNotFound()); } var temp = _JobReceiveQAAttributeService.GetJobReceiveQAAttributeForEdit(id); pt.QAGroupLine = temp; //Getting Settings var settings = new JobReceiveQASettingsService(db).GetJobReceiveQASettingsForDocument(pt.DocTypeId, pt.DivisionId, pt.SiteId); if (settings == null && UserRoles.Contains("SysAdmin")) { return(RedirectToAction("Create", "JobReceiveQASettings", new { id = pt.DocTypeId }).Warning("Please create job Inspection settings")); } else if (settings == null && !UserRoles.Contains("SysAdmin")) { return(View("~/Views/Shared/InValidSettings.cshtml")); } pt.JobReceiveQASettings = Mapper.Map <JobReceiveQASettings, JobReceiveQASettingsViewModel>(settings); pt.DocumentTypeSettings = new DocumentTypeSettingsService(_unitOfWork).GetDocumentTypeSettingsForDocument(pt.DocTypeId); PrepareViewBag(pt.DocTypeId); ViewBag.Mode = "Edit"; if ((System.Web.HttpContext.Current.Request.UrlReferrer.PathAndQuery).Contains("Create")) { LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = pt.DocTypeId, DocId = pt.JobReceiveQAHeaderId, ActivityType = (int)ActivityTypeContants.Detail, DocNo = pt.DocNo, DocDate = pt.DocDate, DocStatus = pt.Status, })); } return(View("Create", pt)); }
public ActionResult Create(int id)//DocumentTypeId { PrepareViewBag(id); JobReceiveQAHeaderViewModel vm = new JobReceiveQAHeaderViewModel(); vm.DivisionId = (int)System.Web.HttpContext.Current.Session["DivisionId"]; vm.SiteId = (int)System.Web.HttpContext.Current.Session["SiteId"]; //Getting Settings var settings = new JobReceiveQASettingsService(db).GetJobReceiveQASettingsForDocument(id, vm.DivisionId, vm.SiteId); vm.JobReceiveQASettings = Mapper.Map <JobReceiveQASettings, JobReceiveQASettingsViewModel>(settings); vm.DocTypeId = id; vm.DocDate = DateTime.Now; vm.DocNo = new DocumentTypeService(_unitOfWork).FGetNewDocNo("DocNo", ConfigurationManager.AppSettings["DataBaseSchema"] + ".JobReceiveQAHeaders", vm.DocTypeId, vm.DocDate, vm.DivisionId, vm.SiteId); ViewBag.Mode = "Add"; return(View("Create", vm)); }
public ActionResult ReceiveQAWizard(int id)//DocumentTypeId { PrepareViewBag(id); JobReceiveQAHeaderViewModel vm = new JobReceiveQAHeaderViewModel(); vm.DivisionId = (int)System.Web.HttpContext.Current.Session["DivisionId"]; vm.SiteId = (int)System.Web.HttpContext.Current.Session["SiteId"]; //Getting Settings var settings = new JobReceiveQASettingsService(db).GetJobReceiveQASettingsForDocument(id, vm.DivisionId, vm.SiteId); if (settings == null && UserRoles.Contains("SysAdmin")) { return(RedirectToAction("CreateJobReceiveQA", "JobReceiveQASettings", new { id = id }).Warning("Please create Purchase order cancel settings")); } else if (settings == null && !UserRoles.Contains("SysAdmin")) { return(View("~/Views/Shared/InValidSettings.cshtml")); } ViewBag.ProcId = settings.ProcessId; return(View()); }
public ActionResult ConfirmedJobReceives(List <JobReceiveQAWizardViewModel> ConfirmedList, int DocTypeId, string UserRemark, int QAById) { //System.Web.HttpContext.Current.Session["BalanceQtyAmendmentWizardOrders"] = ConfirmedList; //return Json(new { Success = "URL", Data = "/JobReceiveQAWizard/Create/" + DocTypeId }, JsonRequestBehavior.AllowGet); if (ConfirmedList.Count() > 0 && ConfirmedList.GroupBy(m => m.JobWorkerId).Count() > 1) { return(Json(new { Success = false, Data = " Multiple Headers are selected. " }, JsonRequestBehavior.AllowGet)); } else if (ConfirmedList.Count() == 0) { return(Json(new { Success = false, Data = " No Records are selected. " }, JsonRequestBehavior.AllowGet)); } else { int DivisionId = (int)System.Web.HttpContext.Current.Session["DivisionId"]; int SiteId = (int)System.Web.HttpContext.Current.Session["SiteId"]; bool BeforeSave = true; int Serial = 1; List <JobReceiveQALineViewModel> LineStatus = new List <JobReceiveQALineViewModel>(); try { BeforeSave = JobReceiveQADocEvents.beforeWizardSaveEvent(this, new JobEventArgs(0), ref db); } catch (Exception ex) { string message = _exception.HandleException(ex); return(Json(new { Success = false, Data = message }, JsonRequestBehavior.AllowGet)); } if (!BeforeSave) { TempData["CSEXC"] += "Failed validation before save"; } int Cnt = 0; int Sr = 0; JobReceiveQASettings Settings = new JobReceiveQASettingsService(db).GetJobReceiveQASettingsForDocument(DocTypeId, DivisionId, SiteId); int?MaxLineId = 0; if (ModelState.IsValid && BeforeSave && !EventException) { JobReceiveQAHeader pt = new JobReceiveQAHeader(); //Getting Settings pt.SiteId = SiteId; pt.JobWorkerId = ConfirmedList.FirstOrDefault().JobWorkerId; pt.DivisionId = DivisionId; pt.QAById = QAById; pt.ProcessId = Settings.ProcessId; pt.Remark = UserRemark; pt.DocTypeId = DocTypeId; pt.DocDate = DateTime.Now; pt.DocNo = new DocumentTypeService(_unitOfWork).FGetNewDocNo("DocNo", ConfigurationManager.AppSettings["DataBaseSchema"] + ".JobReceiveQAHeaders", pt.DocTypeId, pt.DocDate, pt.DivisionId, pt.SiteId); pt.ModifiedBy = User.Identity.Name; pt.ModifiedDate = DateTime.Now; pt.CreatedBy = User.Identity.Name; pt.CreatedDate = DateTime.Now; pt.Status = (int)StatusConstants.Drafted; pt.ObjectState = Model.ObjectState.Added; db.JobReceiveQAHeader.Add(pt); var SelectedJobReceives = ConfirmedList; var JobReceiveLineIds = SelectedJobReceives.Select(m => m.JobReceiveLineId).ToArray(); var JobReceiveBalanceRecords = (from p in db.ViewJobReceiveBalanceForQA where JobReceiveLineIds.Contains(p.JobReceiveLineId) select p).AsNoTracking().ToList(); var JobReceiveRecords = (from p in db.JobReceiveLine.Include(m => m.JobOrderLine) where JobReceiveLineIds.Contains(p.JobReceiveLineId) select p).AsNoTracking().ToList(); foreach (var item in SelectedJobReceives) { JobReceiveLine Recline = JobReceiveRecords.Where(m => m.JobReceiveLineId == item.JobReceiveLineId).FirstOrDefault(); var balRecline = JobReceiveBalanceRecords.Where(m => m.JobReceiveLineId == item.JobReceiveLineId).FirstOrDefault(); if (item.InspectionQty <= JobReceiveBalanceRecords.Where(m => m.JobReceiveLineId == item.JobReceiveLineId).FirstOrDefault().BalanceQty) { JobReceiveQALine line = new JobReceiveQALine(); line.JobReceiveQAHeaderId = pt.JobReceiveQAHeaderId; line.JobReceiveLineId = item.JobReceiveLineId; line.QAQty = balRecline.BalanceQty; line.UnitConversionMultiplier = Recline.JobOrderLine.UnitConversionMultiplier; line.Qty = item.Qty; line.DealQty = line.Qty * line.UnitConversionMultiplier; line.FailQty = line.QAQty - line.Qty; line.FailDealQty = line.FailQty * line.UnitConversionMultiplier; line.InspectedQty = item.InspectionQty; line.PenaltyAmt = item.PenaltyAmount; line.Remark = item.Remark; line.ProductUidId = Recline.ProductUidId; line.Sr = Serial++; line.JobReceiveQALineId = Cnt; line.CreatedDate = DateTime.Now; line.ModifiedDate = DateTime.Now; line.CreatedBy = User.Identity.Name; line.ModifiedBy = User.Identity.Name; LineStatus.Add(Mapper.Map <JobReceiveQALineViewModel>(line)); line.ObjectState = Model.ObjectState.Added; db.JobReceiveQALine.Add(line); Cnt = Cnt + 1; } } new JobReceiveLineStatusService(_unitOfWork).UpdateJobReceiveQtyQAMultiple(LineStatus, pt.DocDate, ref db); try { JobReceiveQADocEvents.onWizardSaveEvent(this, new JobEventArgs(pt.JobReceiveQAHeaderId, EventModeConstants.Add), ref db); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; EventException = true; } try { if (EventException) { throw new Exception(); } db.SaveChanges(); //_unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); return(Json(new { Success = false, Data = message }, JsonRequestBehavior.AllowGet)); } try { JobReceiveQADocEvents.afterWizardSaveEvent(this, new JobEventArgs(pt.JobReceiveQAHeaderId, EventModeConstants.Add), ref db); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; } LogActivity.LogActivityDetail(new ActiivtyLogViewModel { DocTypeId = pt.DocTypeId, DocId = pt.JobReceiveQAHeaderId, ActivityType = (int)ActivityTypeContants.Added, User = User.Identity.Name, DocNo = pt.DocNo, DocDate = pt.DocDate }); return(Json(new { Success = "URL", Data = "/JobReceiveQAHeader/Submit/" + pt.JobReceiveQAHeaderId }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { Success = false, Data = "ModelState is Invalid" }, JsonRequestBehavior.AllowGet)); } } }
// here we simulate SQL search, sorting and paging operations private IQueryable <JobReceiveQAWizardViewModel> FilterData(int DocType, DateTime?FromDate, DateTime?ToDate, string JobReceiveHeaderId, string JobWorkerId, string ProductId, string Dimension1Id, string Dimension2Id, string ProductGroupId, string ProductCategoryId, decimal?BalanceQty, decimal InspectionQty, decimal?MultiplierGT, decimal?MultiplierLT, string Sample) { List <int> JobReceiveHeaderIds = new List <int>(); if (!string.IsNullOrEmpty(JobReceiveHeaderId)) { foreach (var item in JobReceiveHeaderId.Split(',')) { JobReceiveHeaderIds.Add(Convert.ToInt32(item)); } } List <int> JobWorkerIds = new List <int>(); if (!string.IsNullOrEmpty(JobWorkerId)) { foreach (var item in JobWorkerId.Split(',')) { JobWorkerIds.Add(Convert.ToInt32(item)); } } //List<int> ProductIds = new List<int>(); //if (!string.IsNullOrEmpty(ProductId)) // foreach (var item in ProductId.Split(',')) // ProductIds.Add(Convert.ToInt32(item)); List <int> Dimension1Ids = new List <int>(); if (!string.IsNullOrEmpty(Dimension1Id)) { foreach (var item in Dimension1Id.Split(',')) { Dimension1Ids.Add(Convert.ToInt32(item)); } } List <int> Dimension2Ids = new List <int>(); if (!string.IsNullOrEmpty(Dimension2Id)) { foreach (var item in Dimension2Id.Split(',')) { Dimension2Ids.Add(Convert.ToInt32(item)); } } //List<int> ProductGroupIds = new List<int>(); //if (!string.IsNullOrEmpty(ProductGroupId)) // foreach (var item in ProductGroupId.Split(',')) // ProductGroupIds.Add(Convert.ToInt32(item)); int DivisionId = (int)System.Web.HttpContext.Current.Session["DivisionId"]; int SiteId = (int)System.Web.HttpContext.Current.Session["SiteId"]; var Settings = new JobReceiveQASettingsService(db).GetJobReceiveQASettingsForDocument(DocType, DivisionId, SiteId); string[] contraDocTypes = null; if (!string.IsNullOrEmpty(Settings.filterContraDocTypes)) { contraDocTypes = Settings.filterContraDocTypes.Split(",".ToCharArray()); } else { contraDocTypes = new string[] { "NA" }; } IQueryable <JobReceiveQAWizardViewModel> _data = from p in db.ViewJobReceiveBalanceForQA join t in db.JobReceiveLine on p.JobReceiveLineId equals t.JobReceiveLineId join jrh in db.JobReceiveHeader on p.JobReceiveHeaderId equals jrh.JobReceiveHeaderId join jw in db.Persons on p.JobWorkerId equals jw.PersonID into jwtable from jwtab in jwtable.DefaultIfEmpty() join prod in db.FinishedProduct on p.ProductId equals prod.ProductId into prodtable from prodtab in prodtable.DefaultIfEmpty() join jol in db.JobOrderLine on t.JobOrderLineId equals jol.JobOrderLineId join dim1 in db.Dimension1 on jol.Dimension1Id equals dim1.Dimension1Id into dimtable from dimtab in dimtable.DefaultIfEmpty() join dim2 in db.Dimension2 on jol.Dimension2Id equals dim2.Dimension2Id into dim2table from dim2tab in dim2table.DefaultIfEmpty() join pg in db.ProductGroups on prodtab.ProductGroupId equals pg.ProductGroupId into pgtable from pgtab in pgtable.DefaultIfEmpty() join pc in db.ProductCategory on prodtab.ProductCategoryId equals pc.ProductCategoryId into pctable from pctab in pctable.DefaultIfEmpty() join ProdUid in db.ProductUid on p.ProductUidId equals ProdUid.ProductUIDId into produidtable from produidtab in produidtable.DefaultIfEmpty() where p.BalanceQty > 0 && jrh.ProcessId == Settings.ProcessId select new JobReceiveQAWizardViewModel { OrderDate = p.OrderDate, OrderNo = p.JobReceiveNo, JobReceiveLineId = p.JobReceiveLineId, BalanceQty = p.BalanceQty, Qty = p.BalanceQty, InspectionQty = p.BalanceQty, JobWorkerName = jwtab.Name, ProductName = prodtab.ProductName, Dimension1Name = dimtab.Dimension1Name, Dimension2Name = dim2tab.Dimension2Name, JobReceiveHeaderId = p.JobReceiveHeaderId, JobWorkerId = p.JobWorkerId, ProductGroupId = pgtab.ProductGroupId, ProductGroupName = pgtab.ProductGroupName, ProductCategoryId = pctab.ProductCategoryId, ProductCategoryName = pctab.ProductCategoryName, ProdId = p.ProductId, Dimension1Id = dimtab.Dimension1Id, Dimension2Id = dim2tab.Dimension2Id, UnitConversionMultiplier = jol.UnitConversionMultiplier, DocTypeId = p.DocTypeId, ProductUidName = produidtab.ProductUidName, PenaltyAmount = t.PenaltyAmt, }; //if (FromDate.HasValue) // _data = from p in _data // where p.OrderDate >= FromDate // select p; if (!string.IsNullOrEmpty(Settings.filterContraDocTypes)) { _data = _data.Where(m => contraDocTypes.Contains(m.DocTypeId.ToString())); } if (FromDate.HasValue) { _data = _data.Where(m => m.OrderDate >= FromDate); } if (ToDate.HasValue) { _data = _data.Where(m => m.OrderDate <= ToDate); } if (BalanceQty.HasValue && BalanceQty.Value > 0) { _data = _data.Where(m => m.BalanceQty == BalanceQty.Value); } if (MultiplierGT.HasValue) { _data = _data.Where(m => m.UnitConversionMultiplier >= MultiplierGT.Value); } if (MultiplierLT.HasValue) { _data = _data.Where(m => m.UnitConversionMultiplier <= MultiplierLT.Value); } if (!string.IsNullOrEmpty(JobReceiveHeaderId)) { _data = _data.Where(m => JobReceiveHeaderIds.Contains(m.JobReceiveHeaderId)); } if (!string.IsNullOrEmpty(JobWorkerId)) { _data = _data.Where(m => JobWorkerIds.Contains(m.JobWorkerId)); } if (!string.IsNullOrEmpty(ProductId)) { _data = _data.Where(m => m.ProductName.Contains(ProductId)); } if (!string.IsNullOrEmpty(Dimension1Id)) { _data = _data.Where(m => Dimension1Ids.Contains(m.Dimension1Id ?? 0)); } if (!string.IsNullOrEmpty(Dimension2Id)) { _data = _data.Where(m => Dimension2Ids.Contains(m.Dimension2Id ?? 0)); } if (!string.IsNullOrEmpty(ProductGroupId)) { _data = _data.Where(m => m.ProductGroupName.Contains(ProductGroupId)); } if (!string.IsNullOrEmpty(ProductCategoryId)) { _data = _data.Where(m => m.ProductCategoryName.Contains(ProductCategoryId)); } //if (!string.IsNullOrEmpty(Sample) && Sample != "Include") //{ // if (Sample == "Exclude") // _data = _data.Where(m => m.Sample == false); // else if (Sample == "Only") // _data = _data.Where(m => m.Sample == true); //} _data = _data.OrderBy(m => m.OrderDate).ThenBy(m => m.OrderNo); // get just one page of data return(_data.Select(m => new JobReceiveQAWizardViewModel { OrderDate = m.OrderDate, OrderNo = m.OrderNo, JobReceiveLineId = m.JobReceiveLineId, BalanceQty = m.BalanceQty, Qty = m.Qty, InspectionQty = m.InspectionQty, JobWorkerName = m.JobWorkerName, ProductName = m.ProductName, Dimension1Name = m.Dimension1Name, Dimension2Name = m.Dimension2Name, JobReceiveHeaderId = m.JobReceiveHeaderId, JobWorkerId = m.JobWorkerId, ProductGroupId = m.ProductGroupId, ProductGroupName = m.ProductGroupName, ProductCategoryId = m.ProductCategoryId, ProductCategoryName = m.ProductCategoryName, ProdId = m.ProdId, Dimension1Id = m.Dimension1Id, Dimension2Id = m.Dimension2Id, UnitConversionMultiplier = m.UnitConversionMultiplier, DocTypeId = m.DocTypeId, ProductUidName = m.ProductUidName, PenaltyAmount = m.PenaltyAmount, })); }
public ActionResult _CreatePost(JobReceiveQAPenaltyViewModel svm) { JobReceiveQALine L = new JobReceiveQALineService(db, _unitOfWork).Find(svm.JobReceiveQALineId); JobReceiveQAPenalty s = Mapper.Map <JobReceiveQAPenaltyViewModel, JobReceiveQAPenalty>(svm); JobReceiveQAHeader temp = new JobReceiveQAHeaderService(db).Find(L.JobReceiveQAHeaderId); #region BeforeSave bool BeforeSave = true; try { if (svm.JobReceiveQAPenaltyId <= 0) { BeforeSave = JobReceiveQADocEvents.beforeLineSaveEvent(this, new JobEventArgs(svm.JobReceiveQAPenaltyId, EventModeConstants.Add), ref db); } else { BeforeSave = JobReceiveQADocEvents.beforeLineSaveEvent(this, new JobEventArgs(svm.JobReceiveQAPenaltyId, 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."); } #endregion var settings = new JobReceiveQASettingsService(db).GetJobReceiveQASettingsForDocument(temp.DocTypeId, temp.DivisionId, temp.SiteId); if (svm.JobReceiveQAPenaltyId <= 0) { ViewBag.LineMode = "Create"; } else { ViewBag.LineMode = "Edit"; } //if (svm.JobReceiveLineId <= 0) // ModelState.AddModelError("JobReceiveLineId", "The JobReceiveLine field is required"); if (ModelState.IsValid && BeforeSave && !EventException) { if (svm.JobReceiveQAPenaltyId <= 0) { _JobReceiveQAPenaltyService.Create(s, User.Identity.Name); try { db.SaveChanges(); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXCL"] += message; PrepareViewBag(); return(PartialView("_Create", svm)); } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = temp.DocTypeId, DocId = temp.JobReceiveQAHeaderId, DocLineId = s.JobReceiveQAPenaltyId, ActivityType = (int)ActivityTypeContants.Added, DocNo = temp.DocNo, DocDate = temp.DocDate, DocStatus = temp.Status, })); return(RedirectToAction("_Create", new { id = svm.JobReceiveQALineId })); } else { List <LogTypeViewModel> LogList = new List <LogTypeViewModel>(); StringBuilder logstring = new StringBuilder(); JobReceiveQAPenalty temp1 = _JobReceiveQAPenaltyService.Find(svm.JobReceiveQAPenaltyId); JobReceiveQAPenalty ExRec = new JobReceiveQAPenalty(); ExRec = Mapper.Map <JobReceiveQAPenalty>(temp1); temp1.ReasonId = svm.ReasonId; temp1.Amount = svm.Amount; temp1.Remark = svm.Remark; _JobReceiveQAPenaltyService.Update(temp1, User.Identity.Name); //List<JobReceiveQAPenalty> PenaltyLines = (from Pl in db.JobReceiveQAPenalty where Pl.JobReceiveQALineId == L.JobReceiveQALineId select Pl).ToList(); LogList.Add(new LogTypeViewModel { ExObj = ExRec, Obj = temp1, }); if (temp.Status != (int)StatusConstants.Drafted && temp.Status != (int)StatusConstants.Import) { temp.Status = (int)StatusConstants.Modified; } List <JobReceiveQAPenalty> PenaltyLinesList = (from Pl in db.JobReceiveQAPenalty where Pl.JobReceiveQALineId == L.JobReceiveQALineId && Pl.JobReceiveQAPenaltyId != svm.JobReceiveQAPenaltyId select Pl).ToList(); Decimal TotalPenalty = 0; if (PenaltyLinesList.Count() != 0) { TotalPenalty = PenaltyLinesList.Sum(i => i.Amount) + svm.Amount; } else { TotalPenalty = svm.Amount; } L.PenaltyAmt = TotalPenalty; new JobReceiveQALineService(db, _unitOfWork).Update(L, User.Identity.Name); new JobReceiveQAHeaderService(db).Update(temp, User.Identity.Name); XElement Modifications = new ModificationsCheckService().CheckChanges(LogList); try { JobReceiveQADocEvents.onLineSaveEvent(this, new JobEventArgs(temp.JobReceiveQAHeaderId, temp1.JobReceiveQAPenaltyId, 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; PrepareViewBag(); return(PartialView("_Create", svm)); } try { JobReceiveQADocEvents.afterLineSaveEvent(this, new JobEventArgs(temp.JobReceiveQAHeaderId, temp1.JobReceiveQAPenaltyId, EventModeConstants.Edit), ref db); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = temp.DocTypeId, DocId = temp.JobReceiveQAHeaderId, DocLineId = temp1.JobReceiveQAPenaltyId, ActivityType = (int)ActivityTypeContants.Modified, DocNo = temp.DocNo, xEModifications = Modifications, DocDate = temp.DocDate, DocStatus = temp.Status, })); return(Json(new { success = true })); } } PrepareViewBag(); return(PartialView("_Create", svm)); }