Beispiel #1
0
        public ActionResult Reviewed(int Id, string IndexType, string UserRemark, string IsContinue)
        {
            PurchaseOrderAmendmentHeader pd = new PurchaseOrderAmendmentHeaderService(db).Find(Id);

            if (ModelState.IsValid)
            {
                pd.ReviewCount = (pd.ReviewCount ?? 0) + 1;
                pd.ReviewBy   += User.Identity.Name + ", ";

                pd.ObjectState = Model.ObjectState.Modified;
                db.PurchaseOrderAmendmentHeader.Add(pd);

                db.SaveChanges();

                LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
                {
                    DocTypeId    = pd.DocTypeId,
                    DocId        = pd.PurchaseOrderAmendmentHeaderId,
                    ActivityType = (int)ActivityTypeContants.Reviewed,
                    UserRemark   = UserRemark,
                    DocNo        = pd.DocNo,
                    DocDate      = pd.DocDate,
                    DocStatus    = pd.Status,
                }));

                if (!string.IsNullOrEmpty(IsContinue) && IsContinue == "True")
                {
                    PurchaseOrderAmendmentHeader HEader = _PurchaseOrderAmendmentHeaderService.Find(Id);

                    int nextId = new NextPrevIdService(_unitOfWork).GetNextPrevId(Id, HEader.DocTypeId, User.Identity.Name, ForActionConstants.PendingToReview, "Web.PurchaseOrderAmendmentHeaders", "PurchaseOrderAmendmentHeaderId", PrevNextConstants.Next);
                    if (nextId == 0)
                    {
                        var PendingtoSubmitCount = PendingToReviewCount(HEader.DocTypeId);
                        if (PendingtoSubmitCount > 0)
                        {
                            return(RedirectToAction("Index_PendingToReview", new { id = HEader.DocTypeId, IndexType = IndexType }).Success("Record Reviewed Successfully."));
                        }
                        else
                        {
                            return(RedirectToAction("Index", new { id = HEader.DocTypeId, IndexType = IndexType }).Success("Record Reviewed Successfully."));
                        }
                    }

                    ViewBag.PendingToReview = PendingToReviewCount(Id);
                    return(RedirectToAction("Detail", new { id = nextId, transactionType = "ReviewContinue", IndexType = IndexType }).Success("Record Reviewed Successfully."));
                }


                else
                {
                    return(RedirectToAction("Index", new { id = pd.DocTypeId, IndexType = IndexType }).Success("Record Reviewed Successfully."));
                }
            }

            return(RedirectToAction("Index", new { id = pd.DocTypeId, IndexType = IndexType }));
        }
        public ActionResult PrevPage(int DocId, int DocTypeId)//CurrentHeaderId
        {
            var PrevId = new NextPrevIdService(_unitOfWork).GetNextPrevId(DocId, DocTypeId, User.Identity.Name, "", "Web.SaleOrderHeaders", "SaleOrderHeaderId", PrevNextConstants.Prev);

            return(Edit(PrevId, ""));
        }
Beispiel #3
0
        public ActionResult NextPage(int DocId, int DocTypeId)//CurrentHeaderId
        {
            var nextId = new NextPrevIdService(_unitOfWork).GetNextPrevId(DocId, DocTypeId, User.Identity.Name, "", "Web.PackingHeaders", "PackingHeaderId", PrevNextConstants.Next);

            return(Edit(nextId, ""));
        }
Beispiel #4
0
        public ActionResult Submitted(int Id, string IndexType, string UserRemark, string IsContinue)
        {
            #region BeforeSave
            bool BeforeSave = true;
            try
            {
                BeforeSave = PurchaseOrderAmendmentDocEvents.beforeHeaderSubmitEvent(this, new PurchaseEventArgs(Id), ref db);
            }
            catch (Exception ex)
            {
                string message = _exception.HandleException(ex);
                TempData["CSEXC"] += message;
                EventException     = true;
            }

            if (!BeforeSave)
            {
                TempData["CSEXC"] += "Falied validation before submit.";
            }
            #endregion

            PurchaseOrderAmendmentHeader pd = new PurchaseOrderAmendmentHeaderService(db).Find(Id);

            if (ModelState.IsValid && BeforeSave && !EventException)
            {
                int ActivityType;
                if (User.Identity.Name == pd.ModifiedBy || UserRoles.Contains("Admin"))
                {
                    pd.Status    = (int)StatusConstants.Submitted;
                    ActivityType = (int)ActivityTypeContants.Submitted;

                    //_PurchaseOrderAmendmentHeaderService.Update(pd);

                    //_unitOfWork.Save();
                    pd.ReviewBy    = null;
                    pd.ObjectState = Model.ObjectState.Modified;
                    db.PurchaseOrderAmendmentHeader.Add(pd);

                    try
                    {
                        PurchaseOrderAmendmentDocEvents.onHeaderSubmitEvent(this, new PurchaseEventArgs(Id), 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);
                        TempData["CSEXC"] += message;
                        return(RedirectToAction("Index", new { id = pd.DocTypeId }));
                    }

                    try
                    {
                        PurchaseOrderAmendmentDocEvents.afterHeaderSubmitEvent(this, new PurchaseEventArgs(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.PurchaseOrderAmendmentHeaderId,
                        ActivityType = ActivityType,
                        UserRemark   = UserRemark,
                        DocNo        = pd.DocNo,
                        DocDate      = pd.DocDate,
                        DocStatus    = pd.Status,
                    }));

                    if (!string.IsNullOrEmpty(IsContinue) && IsContinue == "True")
                    {
                        int nextId = new NextPrevIdService(_unitOfWork).GetNextPrevId(Id, pd.DocTypeId, User.Identity.Name, ForActionConstants.PendingToSubmit, "Web.PurchaseOrderAmendmentHeaders", "PurchaseOrderAmendmentHeaderId", PrevNextConstants.Next);

                        if (nextId == 0)
                        {
                            var PendingtoSubmitCount = PendingToSubmitCount(pd.DocTypeId);
                            if (PendingtoSubmitCount > 0)
                            {
                                return(RedirectToAction("Index_PendingToSubmit", new { id = pd.DocTypeId, IndexType = IndexType }).Success("Receive " + pd.DocNo + " submitted successfully."));
                            }
                            else
                            {
                                return(RedirectToAction("Index", new { id = pd.DocTypeId, IndexType = IndexType }).Success("Receive " + pd.DocNo + " submitted successfully."));
                            }
                        }

                        return(RedirectToAction("Detail", new { id = nextId, TransactionType = "submitContinue", IndexType = IndexType }).Success("Receive " + pd.DocNo + " submitted successfully."));
                    }
                    else
                    {
                        return(RedirectToAction("Index", new { id = pd.DocTypeId, IndexType = IndexType }).Success("Receive " + pd.DocNo + " 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 }));
        }
Beispiel #5
0
        public ActionResult Reviewed(int Id, string IndexType, string UserRemark, string IsContinue)
        {
            PurchaseIndentCancelHeader pd = new PurchaseIndentCancelHeaderService(_unitOfWork).Find(Id);

            bool BeforeSave = true;

            try
            {
                BeforeSave = PurchaseIndentCancelDocEvents.beforeHeaderReviewEvent(this, new PurchaseEventArgs(Id), ref db);
            }
            catch (Exception ex)
            {
                string message = _exception.HandleException(ex);
                TempData["CSEXC"] += message;
                EventException     = true;
            }

            if (!BeforeSave)
            {
                TempData["CSEXC"] += "Falied validation before submit.";
            }

            if (ModelState.IsValid && BeforeSave && !EventException)
            {
                pd.ReviewCount = (pd.ReviewCount ?? 0) + 1;
                pd.ReviewBy   += User.Identity.Name + ", ";
                pd.ObjectState = Model.ObjectState.Modified;
                db.PurchaseIndentCancelHeader.Add(pd);

                try
                {
                    PurchaseIndentCancelDocEvents.onHeaderReviewEvent(this, new PurchaseEventArgs(Id), 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);
                    TempData["CSEXC"] += message;
                    return(RedirectToAction("Index", new { id = pd.DocTypeId }));
                }

                try
                {
                    PurchaseIndentCancelDocEvents.afterHeaderReviewEvent(this, new PurchaseEventArgs(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.PurchaseIndentCancelHeaderId,
                    ActivityType = (int)ActivityTypeContants.Reviewed,
                    UserRemark   = UserRemark,
                    DocNo        = pd.DocNo,
                    DocDate      = pd.DocDate,
                    DocStatus    = pd.Status,
                }));


                if (!string.IsNullOrEmpty(IsContinue) && IsContinue == "True")
                {
                    PurchaseIndentCancelHeader HEader = _PurchaseIndentCancelHeaderService.Find(Id);

                    int nextId = new NextPrevIdService(_unitOfWork).GetNextPrevId(Id, HEader.DocTypeId, User.Identity.Name, ForActionConstants.PendingToReview, "Web.PurchaseIndentCancelHeaders", "PurchaseIndentCancelHeaderId", PrevNextConstants.Next);
                    if (nextId == 0)
                    {
                        var PendingtoSubmitCount = _PurchaseIndentCancelHeaderService.GetPurchaseIndentCancelPendingToReview(HEader.DocTypeId, User.Identity.Name).Count();
                        if (PendingtoSubmitCount > 0)
                        {
                            return(RedirectToAction("Index_PendingToReview", new { id = HEader.DocTypeId, IndexType = IndexType }).Success("Record Reviewed Successfully"));
                        }
                        else
                        {
                            return(RedirectToAction("Index", new { id = HEader.DocTypeId, IndexType = IndexType }).Success("Record Reviewed Successfully"));
                        };
                    }

                    ViewBag.PendingToReview = PendingToReviewCount(Id);
                    return(RedirectToAction("Detail", new { id = nextId, transactionType = "ReviewContinue", IndexType = IndexType }).Success("Record Reviewed Successfully"));;
                }


                else
                {
                    return(RedirectToAction("Index", new { id = pd.DocTypeId, IndexType = IndexType }).Success("Record Reviewed Successfully"));
                }
            }

            return(RedirectToAction("Index", new { id = pd.DocTypeId, IndexType = IndexType }));
        }
        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 }));
        }