public ActionResult Submit(int id, string IndexType, string TransactionType) { #region DocTypeTimeLineValidation QAGroup s = context.QAGroup.Find(id); try { TimePlanValidation = DocumentValidation.ValidateDocument(Mapper.Map <DocumentUniqueId>(s), DocumentTimePlanTypeConstants.Submit, User.Identity.Name, out ExceptionMsg, out Continue); TempData["CSEXC"] += ExceptionMsg; } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; TimePlanValidation = false; } if (!TimePlanValidation && !Continue) { return(RedirectToAction("Index", new { id = s.DocTypeId, IndexType = IndexType })); } #endregion return(RedirectToAction("Detail", new { id = id, IndexType = IndexType, transactionType = string.IsNullOrEmpty(TransactionType) ? "submit" : TransactionType })); }
public ActionResult DeleteAfter_Approve(int id) { QAGroup header = _QAGroupService.Find(id); if (header.Status == (int)StatusConstants.Approved) { return(Remove(id)); } else { return(HttpNotFound()); } }
public ActionResult Delete(int id) { QAGroup header = _QAGroupService.Find(id); if (header.Status == (int)StatusConstants.Drafted || header.Status == (int)StatusConstants.Import) { return(Remove(id)); } else { return(HttpNotFound()); } }
public ActionResult ModifyAfter_Approve(int id, string IndexType) { QAGroup header = _QAGroupService.Find(id); if (header.Status == (int)StatusConstants.Approved) { return(Edit(id, IndexType)); } else { return(HttpNotFound()); } }
public ActionResult Modify(int id, string IndexType) { QAGroup header = _QAGroupService.Find(id); if (header.Status == (int)StatusConstants.Drafted || header.Status == (int)StatusConstants.Import) { return(Edit(id, IndexType)); } else { return(HttpNotFound()); } }
private ActionResult Remove(int id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } QAGroup QAGroup = _QAGroupService.Find(id); if (QAGroup == null) { return(HttpNotFound()); } #region DocTypeTimeLineValidation try { TimePlanValidation = DocumentValidation.ValidateDocument(Mapper.Map <DocumentUniqueId>(QAGroup), DocumentTimePlanTypeConstants.Delete, User.Identity.Name, out ExceptionMsg, out Continue); TempData["CSEXC"] += ExceptionMsg; } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; TimePlanValidation = false; } if (!TimePlanValidation && !Continue) { return(PartialView("AjaxError")); } #endregion ReasonViewModel rvm = new ReasonViewModel() { id = id, }; return(PartialView("_Reason", rvm)); }
public ActionResult DeletePost(QAGroupLineViewModel vm) { bool BeforeSave = true; //try //{ // BeforeSave = JobOrderDocEvents.beforeLineDeleteEvent(this, new JobEventArgs(vm.QAGroupId, vm.QAGroupLineId), 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) { int?StockId = 0; int?StockProcessId = 0; List <LogTypeViewModel> LogList = new List <LogTypeViewModel>(); QAGroupLine QAGroupLine = (from p in db.QAGroupLine where p.QAGroupLineId == vm.QAGroupLineId select p).FirstOrDefault(); QAGroup header = (from p in db.QAGroup where p.QAGroupId == QAGroupLine.QAGroupId select p).FirstOrDefault(); LogList.Add(new LogTypeViewModel { Obj = Mapper.Map <QAGroupLine>(QAGroupLine), }); //_JobOrderLineService.Delete(JobOrderLine); QAGroupLine.ObjectState = Model.ObjectState.Deleted; db.QAGroupLine.Remove(QAGroupLine); 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; db.QAGroup.Add(header); } XElement Modifications = new ModificationsCheckService().CheckChanges(LogList); try { if (EventException) { throw new Exception(); } db.SaveChanges(); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXCL"] += message; PrepareViewBag(vm); ViewBag.LineMode = "Delete"; return(PartialView("_Create", vm)); } try { JobOrderDocEvents.afterLineDeleteEvent(this, new JobEventArgs(QAGroupLine.QAGroupId, QAGroupLine.QAGroupLineId), ref db); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; } //Saving the Activity Log LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = header.DocTypeId, DocId = header.QAGroupId, DocLineId = QAGroupLine.QAGroupLineId, ActivityType = (int)ActivityTypeContants.Deleted, DocNo = header.QaGroupName, xEModifications = Modifications, DocDate = header.CreatedDate, DocStatus = header.Status, })); } return(Json(new { success = true })); }
public void Update(QAGroup pt) { pt.ObjectState = ObjectState.Modified; _unitOfWork.Repository <QAGroup>().Update(pt); }
public void Delete(QAGroup pt) { _unitOfWork.Repository <QAGroup>().Delete(pt); }
public QAGroup Create(QAGroup pt) { pt.ObjectState = ObjectState.Added; _unitOfWork.Repository <QAGroup>().Insert(pt); return(pt); }
public QAGroup Add(QAGroup pt) { _unitOfWork.Repository <QAGroup>().Insert(pt); return(pt); }
public ActionResult Reviewed(int Id, string IndexType, string UserRemark, string IsContinue) { QAGroup pd = context.QAGroup.Find(Id); if (ModelState.IsValid) { pd.ReviewCount = (pd.ReviewCount ?? 0) + 1; pd.ReviewBy += User.Identity.Name + ", "; pd.ObjectState = Model.ObjectState.Modified; context.QAGroup.Add(pd); try { JobOrderDocEvents.onHeaderReviewEvent(this, new JobEventArgs(Id), ref context); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; } context.SaveChanges(); try { JobOrderDocEvents.afterHeaderReviewEvent(this, new JobEventArgs(Id), ref context); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = pd.DocTypeId, DocId = pd.QAGroupId, ActivityType = (int)ActivityTypeContants.Reviewed, UserRemark = UserRemark, DocNo = pd.QaGroupName, DocDate = pd.CreatedDate, DocStatus = pd.Status, })); string ReturnUrl = System.Configuration.ConfigurationManager.AppSettings["CurrentDomain"] + "/" + "QAGroup" + "/" + "Index" + "/" + pd.DocTypeId + "?IndexType=" + IndexType; if (!string.IsNullOrEmpty(IsContinue) && IsContinue == "True") { int nextId = new NextPrevIdService(_unitOfWork).GetNextPrevId(Id, pd.DocTypeId, User.Identity.Name, ForActionConstants.PendingToReview, "Web.QAGroups", "QAGroupId", PrevNextConstants.Next); if (nextId == 0) { var PendingtoSubmitCount = _QAGroupService.GetQAGroupListPendingToSubmit(pd.DocTypeId, User.Identity.Name).Count(); if (PendingtoSubmitCount > 0) { ReturnUrl = System.Configuration.ConfigurationManager.AppSettings["CurrentDomain"] + "/" + "QAGroup" + "/" + "Index_PendingToReview" + "/" + pd.DocTypeId + "?IndexType=" + IndexType; } else { ReturnUrl = System.Configuration.ConfigurationManager.AppSettings["CurrentDomain"] + "/" + "QAGroup" + "/" + "Index" + "/" + pd.DocTypeId + "?IndexType=" + IndexType; } } else { ReturnUrl = System.Configuration.ConfigurationManager.AppSettings["CurrentDomain"] + "/" + "QAGroup" + "/" + "Review" + "/" + nextId + "?TransactionType=ReviewContinue&IndexType=" + IndexType; } } return(Redirect(ReturnUrl)); } return(RedirectToAction("Index", new { id = pd.DocTypeId, IndexType = IndexType }).Warning("Error in Reviewing.")); }
public ActionResult Submitted(int Id, string IndexType, string UserRemark, string IsContinue, string GenGatePass) { bool BeforeSave = true; try { BeforeSave = JobOrderDocEvents.beforeHeaderSubmitEvent(this, new JobEventArgs(Id), ref context); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; EventException = true; } if (!BeforeSave) { TempData["CSEXC"] += "Falied validation before submit."; } QAGroup pd = context.QAGroup.Find(Id); if (ModelState.IsValid && BeforeSave && !EventException) { int Cnt = 0; int CountUid = 0; //JobOrderHeader pd = new JobOrderHeaderService(_unitOfWork).Find(Id); int ActivityType; if (User.Identity.Name == pd.ModifiedBy || UserRoles.Contains("Admin")) { pd.Status = (int)StatusConstants.Submitted; ActivityType = (int)ActivityTypeContants.Submitted; pd.ReviewBy = null; pd.ObjectState = Model.ObjectState.Modified; context.QAGroup.Add(pd); try { JobOrderDocEvents.onHeaderSubmitEvent(this, new JobEventArgs(Id), ref context); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; EventException = true; } try { if (EventException) { throw new Exception(); } context.SaveChanges(); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; return(RedirectToAction("Index", new { id = pd.DocTypeId })); } try { JobOrderDocEvents.afterHeaderSubmitEvent(this, new JobEventArgs(Id), ref context); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = pd.DocTypeId, DocId = pd.QAGroupId, ActivityType = ActivityType, UserRemark = UserRemark, DocNo = pd.QaGroupName, DocDate = pd.CreatedDate, DocStatus = pd.Status, })); string ReturnUrl = System.Configuration.ConfigurationManager.AppSettings["CurrentDomain"] + "/" + "QAGroup" + "/" + "Index" + "/" + pd.DocTypeId + "?IndexType=" + IndexType; if (!string.IsNullOrEmpty(IsContinue) && IsContinue == "True") { int nextId = new NextPrevIdService(_unitOfWork).GetNextPrevId(Id, pd.DocTypeId, User.Identity.Name, ForActionConstants.PendingToSubmit, "Web.QAGroups", "QAGroupId", PrevNextConstants.Next); if (nextId == 0) { var PendingtoSubmitCount = _QAGroupService.GetQAGroupListPendingToSubmit(pd.DocTypeId, User.Identity.Name).Count(); if (PendingtoSubmitCount > 0) { ReturnUrl = System.Configuration.ConfigurationManager.AppSettings["CurrentDomain"] + "/" + "QAGroup" + "/" + "Index_PendingToSubmit" + "/" + pd.DocTypeId + "?IndexType=" + IndexType; } else { ReturnUrl = System.Configuration.ConfigurationManager.AppSettings["CurrentDomain"] + "/" + "QAGroup" + "/" + "Index" + "/" + pd.DocTypeId + "?IndexType=" + IndexType; } } else { ReturnUrl = System.Configuration.ConfigurationManager.AppSettings["CurrentDomain"] + "/" + "QAGroup" + "/" + "Submit" + "/" + nextId + "?TransactionType=submitContinue&IndexType=" + IndexType; } } } 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 })); }
public ActionResult Post(QAGroupViewModel svm) { bool BeforeSave = true; bool CostCenterGenerated = false; QAGroup s = Mapper.Map <QAGroupViewModel, QAGroup>(svm); #region BeforeSaveEvents try { if (svm.QAGroupId <= 0) { BeforeSave = JobOrderDocEvents.beforeHeaderSaveEvent(this, new JobEventArgs(svm.QAGroupId, EventModeConstants.Add), ref context); } else { BeforeSave = JobOrderDocEvents.beforeHeaderSaveEvent(this, new JobEventArgs(svm.QAGroupId, EventModeConstants.Edit), ref context); } } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; EventException = true; } if (!BeforeSave) { TempData["CSEXC"] += "Failed validation before save"; } #endregion #region DocTypeTimeLineValidation try { if (svm.QAGroupId <= 0) { TimePlanValidation = DocumentValidation.ValidateDocument(Mapper.Map <DocumentUniqueId>(svm), DocumentTimePlanTypeConstants.Create, User.Identity.Name, out ExceptionMsg, out Continue); } else { TimePlanValidation = DocumentValidation.ValidateDocument(Mapper.Map <DocumentUniqueId>(svm), DocumentTimePlanTypeConstants.Modify, User.Identity.Name, out ExceptionMsg, out Continue); } } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; TimePlanValidation = false; } if (!TimePlanValidation) { TempData["CSEXC"] += ExceptionMsg; } #endregion if (ModelState.IsValid && BeforeSave && !EventException && (TimePlanValidation || Continue)) { //CreateLogic #region CreateRecord if (svm.QAGroupId <= 0) { // s.GodownId= (int)System.Web.HttpContext.Current.Session["DefaultGodownId"]; s.CreatedDate = DateTime.Now; s.ModifiedDate = DateTime.Now; s.CreatedBy = User.Identity.Name; s.ModifiedBy = User.Identity.Name; s.Status = (int)StatusConstants.Drafted; s.ObjectState = Model.ObjectState.Added; context.QAGroup.Add(s); try { JobOrderDocEvents.onHeaderSaveEvent(this, new JobEventArgs(s.QAGroupId, EventModeConstants.Add), ref context); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; EventException = true; } try { if (EventException) { throw new Exception(); } //_unitOfWork.Save(); context.SaveChanges(); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; PrepareViewBag(svm.DocTypeId); ViewBag.Mode = "Add"; return(View("Create", svm)); } try { JobOrderDocEvents.afterHeaderSaveEvent(this, new JobEventArgs(s.QAGroupId, EventModeConstants.Add), ref context); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = s.DocTypeId, DocId = s.QAGroupId, ActivityType = (int)ActivityTypeContants.Added, DocNo = s.QaGroupName, DocDate = s.CreatedDate, DocStatus = s.Status, })); //Update DocId in COstCenter return(RedirectToAction("Modify", "QAGroup", new { Id = s.QAGroupId }).Success("Data saved successfully")); } #endregion //EditLogic #region EditRecord else { bool GodownChanged = false; List <LogTypeViewModel> LogList = new List <LogTypeViewModel>(); QAGroup temp = context.QAGroup.Find(s.QAGroupId); QAGroup ExRec = Mapper.Map <QAGroup>(temp); int status = temp.Status; if (temp.Status != (int)StatusConstants.Drafted && temp.Status != (int)StatusConstants.Import) { temp.Status = (int)StatusConstants.Modified; } temp.QaGroupName = s.QaGroupName; temp.Description = s.Description; temp.ModifiedDate = DateTime.Now; temp.ModifiedBy = User.Identity.Name; temp.ObjectState = Model.ObjectState.Modified; context.QAGroup.Add(temp); LogList.Add(new LogTypeViewModel { ExObj = ExRec, Obj = temp, }); XElement Modifications = new ModificationsCheckService().CheckChanges(LogList); try { JobOrderDocEvents.onHeaderSaveEvent(this, new JobEventArgs(s.QAGroupId, EventModeConstants.Edit), ref context); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; EventException = true; } try { if (EventException) { throw new Exception(); } context.SaveChanges(); //_unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); PrepareViewBag(svm.DocTypeId); TempData["CSEXC"] += message; ViewBag.id = svm.DocTypeId; ViewBag.Mode = "Edit"; return(View("Create", svm)); } try { JobOrderDocEvents.afterHeaderSaveEvent(this, new JobEventArgs(s.QAGroupId, EventModeConstants.Edit), ref context); } catch (Exception ex) { string message = _exception.HandleException(ex); TempData["CSEXC"] += message; } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = temp.DocTypeId, DocId = temp.QAGroupId, ActivityType = (int)ActivityTypeContants.Modified, DocNo = temp.QaGroupName, xEModifications = Modifications, DocDate = temp.CreatedDate, DocStatus = temp.Status, })); return(RedirectToAction("Index", new { id = svm.DocTypeId }).Success("Data saved successfully")); } #endregion } PrepareViewBag(svm.DocTypeId); ViewBag.Mode = "Add"; return(View("Create", svm)); }
/// <summary> /// Helper method for creating a list of ktExaminedGroup /// from an Excel worksheet. /// </summary> public void LoadQAGroups(Worksheet worksheet, SharedStringTable sharedString) { //Initialize the ktExaminedGroup list. List <QAGroup> result = new List <QAGroup>(); //LINQ query to skip first row with column names. IEnumerable <Row> dataRows = from row in worksheet.Descendants <Row>() where row.RowIndex > 1 select row; foreach (Row row in dataRows) { //LINQ query to return the row's cell values. //Where clause filters out any cells that do not contain a value. //Select returns the value of a cell unless the cell contains // a Shared String. //If the cell contains a Shared String, its value will be a // reference id which will be used to look up the value in the // Shared String table. //IEnumerable<String> textValues = // from cell in row.Descendants<Cell>() // where cell.CellValue != null // select // (cell.DataType != null // && cell.DataType.HasValue // && cell.DataType == CellValues.SharedString // ? sharedString.ChildElements[ // int.Parse(cell.CellValue.InnerText)].InnerText // : cell.CellValue.InnerText) // ; IEnumerable <String> textValues = from cell in row.Descendants <Cell>() where cell.CellValue != null select (cell.DataType != null && cell.DataType.HasValue && cell.DataType == CellValues.SharedString ?sharedString.ChildElements[ int.Parse(cell.CellValue.InnerText)].InnerText : cell.CellValue.InnerText) ; //Check to verify the row contained data. if (textValues.Count() > 0) { //Create a ktExaminedGroup and add it to the list. var textArray = textValues.ToArray(); QAGroup qaGroup = new QAGroup(); qaGroup.TypeID = textArray[0]; qaGroup.Type = textArray[1]; result.Add(qaGroup); } else { //If no cells, then you have reached the end of the table. break; } //Return populated list of ktExaminedGroup. QAGroupsList = result; } }