public JsonResult GetPendingProductHelpList(string searchTerm, int pageSize, int pageNum, int filter)//Order Header ID { var Records = new JobReceiveQALineService(db, _unitOfWork).GetPendingProductHelpList(filter, searchTerm); var temp = Records.Skip(pageSize * (pageNum - 1)).Take(pageSize).ToList(); var count = Records.Count(); ComboBoxPagedResult Data = new ComboBoxPagedResult(); Data.Results = temp; Data.Total = count; return(new JsonpResult { Data = Data, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
private ActionResult _Modify(int id) { JobReceiveQAPenaltyViewModel temp = _JobReceiveQAPenaltyService.GetJobReceiveQAPenaltyForEdit(id); JobReceiveQALine L = new JobReceiveQALineService(db, _unitOfWork).Find(temp.JobReceiveQALineId); JobReceiveQAHeader Header = new JobReceiveQAHeaderService(db).Find(L.JobReceiveQAHeaderId); DocumentType D = new DocumentTypeService(_unitOfWork).Find(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 = "Edit"; } PrepareViewBag(); //ViewBag.DocNo = D.DocumentTypeName + "-" + Header.DocNo; ViewBag.DocNo = D.DocumentTypeName + "-" + Header.DocNo + " ( Deal Qty : " + L.DealQty.ToString() + " )"; return(PartialView("_Create", temp)); }
public ActionResult _Create(int Id) //Id ==> JobReceiveQALineId { JobReceiveQALine L = new JobReceiveQALineService(db, _unitOfWork).Find(Id); JobReceiveQAHeader H = new JobReceiveQAHeaderService(db).Find(L.JobReceiveQAHeaderId); DocumentType D = new DocumentTypeService(_unitOfWork).Find(H.DocTypeId); JobReceiveQAPenaltyViewModel s = new JobReceiveQAPenaltyViewModel(); s.DocTypeId = H.DocTypeId; s.JobReceiveQALineId = Id; //Getting Settings PrepareViewBag(); if (!string.IsNullOrEmpty((string)TempData["CSEXCL"])) { ViewBag.CSEXCL = TempData["CSEXCL"]; TempData["CSEXCL"] = null; } ViewBag.LineMode = "Create"; ViewBag.DocNo = D.DocumentTypeName + "-" + H.DocNo; return(PartialView("_Create", s)); }
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)); }
public ActionResult DeletePost(JobReceiveQAPenaltyViewModel vm) { JobReceiveQALine L = new JobReceiveQALineService(db, _unitOfWork).Find(vm.JobReceiveQALineId); #region BeforeSave bool BeforeSave = true; try { BeforeSave = JobReceiveQADocEvents.beforeLineDeleteEvent(this, new JobEventArgs(L.JobReceiveQAHeaderId, vm.JobReceiveQAPenaltyId), ref db); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; EventException = true; } if (!BeforeSave) { TempData["CSEXC"] += "Validation failed before delete."; } #endregion if (BeforeSave && !EventException) { List <LogTypeViewModel> LogList = new List <LogTypeViewModel>(); JobReceiveQAPenalty JobReceiveQAPenalty = (from p in db.JobReceiveQAPenalty where p.JobReceiveQAPenaltyId == vm.JobReceiveQAPenaltyId select p).FirstOrDefault(); JobReceiveQAHeader header = new JobReceiveQAHeaderService(db).Find(L.JobReceiveQAHeaderId); LogList.Add(new LogTypeViewModel { ExObj = Mapper.Map <JobReceiveQAPenalty>(JobReceiveQAPenalty), }); _JobReceiveQAPenaltyService.Delete(JobReceiveQAPenalty); if (header.Status != (int)StatusConstants.Drafted && header.Status != (int)StatusConstants.Import) { header.Status = (int)StatusConstants.Modified; new JobReceiveQAHeaderService(db).Update(header, User.Identity.Name); } XElement Modifications = new ModificationsCheckService().CheckChanges(LogList); try { JobReceiveQADocEvents.onLineDeleteEvent(this, new JobEventArgs(L.JobReceiveQAHeaderId, JobReceiveQAPenalty.JobReceiveQAPenaltyId), 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(); ViewBag.LineMode = "Delete"; return(PartialView("_Create", vm)); } try { JobReceiveQADocEvents.afterLineDeleteEvent(this, new JobEventArgs(L.JobReceiveQAHeaderId, JobReceiveQAPenalty.JobReceiveQAPenaltyId), ref db); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = header.DocTypeId, DocId = header.JobReceiveQAHeaderId, DocLineId = JobReceiveQAPenalty.JobReceiveQAPenaltyId, ActivityType = (int)ActivityTypeContants.Deleted, DocNo = header.DocNo, xEModifications = Modifications, DocDate = header.DocDate, DocStatus = header.Status, })); } return(Json(new { success = true })); }
public void Update(JobReceiveQAAttributeViewModel pt, string UserName) { JobReceiveQAHeader header = new JobReceiveQAHeaderService(db).Find(pt.JobReceiveQAHeaderId); header.DocDate = pt.DocDate; header.DocNo = pt.DocNo; header.QAById = pt.QAById; header.Remark = pt.Remark; _JobReceiveQAHeaderService.Update(header, UserName); JobReceiveQALine Line = new JobReceiveQALineService(db, _unitOfWork).Find(pt.JobReceiveQALineId); Line.Marks = pt.Marks; Line.PenaltyRate = pt.PenaltyRate; Line.PenaltyAmt = pt.PenaltyAmt; Line.Weight = pt.Weight; Line.UnitConversionMultiplier = pt.UnitConversionMultiplier; Line.DealQty = pt.DealQty; Line.FailQty = Line.QAQty - Line.Qty; Line.FailDealQty = Line.FailQty * Line.UnitConversionMultiplier; new JobReceiveLineStatusService(_unitOfWork).UpdateJobReceiveQtyOnQA(Mapper.Map <JobReceiveQALineViewModel>(Line), pt.DocDate, ref db); new JobReceiveQALineService(db, _unitOfWork).Update(Line, UserName); JobReceiveQALineExtended LineExtended = (from Ld in db.JobReceiveQALineExtended where Ld.JobReceiveQALineId == pt.JobReceiveQALineId select Ld).FirstOrDefault(); if (LineExtended != null) { LineExtended.Length = pt.Length; LineExtended.Width = pt.Width; LineExtended.Height = pt.Height; LineExtended.ObjectState = ObjectState.Modified; db.JobReceiveQALineExtended.Add(LineExtended); } List <QAGroupLineLineViewModel> tem = pt.QAGroupLine; if (tem != null) { foreach (var item in tem) { if (item.JobReceiveQAAttributeId != null && item.JobReceiveQAAttributeId != 0) { JobReceiveQAAttribute pa = Find((int)item.JobReceiveQAAttributeId); pa.QAGroupLineId = item.QAGroupLineId; pa.Value = item.Value; pa.Remark = item.Remarks; pa.ModifiedBy = UserName; pa.ModifiedDate = DateTime.Now; pa.ObjectState = ObjectState.Modified; db.JobReceiveQAAttribute.Add(pa); } else { JobReceiveQAAttribute pa = new JobReceiveQAAttribute(); pa.JobReceiveQALineId = Line.JobReceiveQALineId; pa.QAGroupLineId = item.QAGroupLineId; pa.Value = item.Value; pa.Remark = item.Remarks; pa.CreatedBy = UserName; pa.ModifiedBy = UserName; pa.CreatedDate = DateTime.Now; pa.ModifiedDate = DateTime.Now; pa.ObjectState = ObjectState.Added; db.JobReceiveQAAttribute.Add(pa); } } } }