예제 #1
0
        private StopWorksViewModel GetByStopWorkID(int id)
        {
            StopWorksBLL       StopWorkBLL = new StopWorksBLL().GetByStopWorkID(id);
            StopWorksViewModel StopWorkVM  = new StopWorksViewModel();

            if (StopWorkBLL != null)
            {
                StopWorkVM.StopWorkID                  = StopWorkBLL.StopWorkID;
                StopWorkVM.StopWorkStartDate           = StopWorkBLL.StopWorkStartDate.Date;
                StopWorkVM.StopWorkEndDate             = StopWorkBLL.StopWorkEndDate;
                StopWorkVM.StartStopWorkDecisionNumber = StopWorkBLL.StartStopWorkDecisionNumber;
                StopWorkVM.StartStopWorkDecisionDate   = StopWorkBLL.StartStopWorkDecisionDate;
                StopWorkVM.EndStopWorkDecisionNumber   = StopWorkBLL.EndStopWorkDecisionNumber;
                StopWorkVM.EndStopWorkDecisionDate     = StopWorkBLL.EndStopWorkDecisionDate;
                StopWorkVM.Note = StopWorkBLL.Note;
                //StopWorkVM.IsConvicted = StopWorkBLL.IsConvicted.HasValue ? StopWorkBLL.IsConvicted.Value : false;
                StopWorkVM.IsConvicted           = StopWorkBLL.IsConvicted;
                StopWorkVM.StopPoint             = StopWorkBLL.StopPoint;
                StopWorkVM.StopWorkCategory      = StopWorkBLL.StopWorkType.StopWorkCategory;
                StopWorkVM.StopWorkType          = StopWorkBLL.StopWorkType;
                StopWorkVM.CreatedDate           = StopWorkBLL.CreatedDate;
                StopWorkVM.CreatedBy             = StopWorkVM.GetCreatedByDisplayed(StopWorkBLL.CreatedBy);
                StopWorkVM.EmployeeCareerHistory = StopWorkBLL.EmployeeCareerHistory;
                StopWorkVM.Employee = new EmployeesViewModel()
                {
                    EmployeeCodeID = StopWorkBLL.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID,
                    EmployeeCodeNo = StopWorkBLL.EmployeeCareerHistory.EmployeeCode.EmployeeCodeNo,
                    EmployeeNameAr = StopWorkBLL.EmployeeCareerHistory.EmployeeCode.Employee.EmployeeNameAr
                };
            }
            return(StopWorkVM);
        }
예제 #2
0
        public ActionResult Delete(StopWorksViewModel StopWorkVM)
        {
            StopWorksBLL stopWorkBll = new StopWorksBLL();

            stopWorkBll.StopWorkID = StopWorkVM.StopWorkID;
            stopWorkBll.Remove();
            return(RedirectToAction("Index"));
        }
예제 #3
0
        public ActionResult EndStopWork(StopWorksViewModel StopWorkVM)
        {
            StopWorksBLL StopWork = new StopWorksBLL().GetByStopWorkID(StopWorkVM.StopWorkID);

            StopWork.IsConvicted           = StopWorkVM.IsConvicted;
            StopWork.StopWorkEndDate       = StopWorkVM.StopWorkEndDate;
            StopWork.Note                  = StopWorkVM.Note;
            StopWork.LoginIdentity         = UserIdentity;
            StopWork.EmployeeCareerHistory = StopWork.EmployeeCareerHistory;
            Result result = StopWork.EndStopWork();

            StopWorksBLL StopWorkEntity = (StopWorksBLL)result.Entity;

            if ((System.Type)result.EnumType == typeof(StopWorkValidationEnum))
            {
                if (result.EnumMember == StopWorkValidationEnum.RejectedBecauseOfEndDateShouldBeMoreThanStartDate.ToString())
                {
                    throw new CustomException(Resources.Globalization.ValidationEndDateShouldBeMoreThanStartDateText);
                }
            }
            if ((System.Type)result.EnumType == typeof(NoConflictWithOtherProcessValidationEnum))
            {
                Classes.Helpers.CommonHelper.ConflictValidationMessage(result);
                //else if (result.EnumMember == NoConflictWithOtherProcessValidationEnum.RejectedBecauseOfConflictWithStopWork.ToString())
                //{
                //    //throw new CustomException(Resources.Globalization.ValidationConflictWithStopWorkText);
                //    throw new CustomException(Resources.Globalization.ValidationConflictWithAssigningText);
                //}
                //else if (result.EnumMember == NoConflictWithOtherProcessValidationEnum.RejectedBecauseOfConflictWithVacation.ToString())
                //{
                //    throw new CustomException(Resources.Globalization.ValidationConflictWithVacationText);
                //}
                //else if (result.EnumMember == NoConflictWithOtherProcessValidationEnum.RejectedBecauseOfConflictWithOverTime.ToString())
                //{
                //    throw new CustomException(Resources.Globalization.ValidationConflictWithOverTimeText);
                //}
                //else if (result.EnumMember == NoConflictWithOtherProcessValidationEnum.RejectedBecauseOfConflictWithInternshipScholarship.ToString())
                //{
                //    throw new CustomException(Resources.Globalization.ValidationConflictWithInternshipScholarshipText);
                //}
                //else if (result.EnumMember == NoConflictWithOtherProcessValidationEnum.RejectedBecauseOfConflictWithDelegation.ToString())
                //{
                //    throw new CustomException(Resources.Globalization.ValidationConflictWithDelegationText);
                //}
            }


            return(View(GetByStopWorkID(StopWorkVM.StopWorkID)));
        }
예제 #4
0
        public ActionResult GetStopWorks(int EmployeeCarrerHistoryID, int PromotionPeriodID)
        {
            EmployeesCareersHistoryBLL emp = new EmployeesCareersHistoryBLL().GetByEmployeeCareerHistoryID(EmployeeCarrerHistoryID);
            PromotionsPeriodsBLL       PromotionPeriodBLL = new PromotionsPeriodsBLL().GetByPromotionPeriodID(PromotionPeriodID);
            var data = new StopWorksBLL().GetByEmployeeCodeIDConvicted(emp.EmployeeCode.EmployeeCodeID, emp.JoinDate.Date, PromotionPeriodBLL.PromotionEndDate).Select(x => new
            {
                StopWorkID        = x.StopWorkID,
                StopWorkStartDate = x.StopWorkStartDate,
                StopWorkPeriod    = x.StopWorkPeriod,
                StopWorkEndDate   = x.StopWorkEndDate,
                IsConvicted       = x.IsConvicted
            });

            return(Json(new { data = data }, JsonRequestBehavior.AllowGet));

            //return Json(new { data = new EmployeesCodesBLL().GetVacationsWithDetailsByEmployeeCodeID(id) }, JsonRequestBehavior.AllowGet);
        }
예제 #5
0
        //[HttpPost]
        //[IgnoreModelProperties("StopWorkID,Task")]
        //public HttpResponseMessage CreateStopWorkDetail(StopWorksViewModel StopWorkVM)
        //{
        //    //StopWorksViewModel StopWorkVM = new StopWorksViewModel();
        //    List<StopWorksDetailsBLL> StopWorkEmployeesList = GetStopWorkDetailsFromSession();

        //    if (string.IsNullOrEmpty(StopWorkVM.StopWorkDetailRequest.EmployeeCareerHistory.EmployeeCode.EmployeeCodeNo))
        //    {
        //        throw new CustomException(Resources.Globalization.RequiredEmployeeCodeNoText);
        //    }
        //    else if (StopWorkEmployeesList.FindIndex(e => e.EmployeeCareerHistory.EmployeeCode.EmployeeCodeNo.Equals(StopWorkVM.StopWorkDetailRequest.EmployeeCareerHistory.EmployeeCode.EmployeeCodeNo)) > -1)
        //    {
        //        throw new CustomException(Resources.Globalization.ValidationEmployeeAlreadyExist);
        //    }

        //    DateTime StartDate, EndDate;
        //    StartDate = StopWorkVM.StopWorkStartDate;
        //    EndDate = (DateTime)StopWorkVM.StopWorkEndDate;

        //    StopWorksBLL overtime = new StopWorksBLL()
        //    {
        //        StopWorkStartDate = StartDate,
        //        StopWorkEndDate = EndDate,
        //    };

        //    Result result = new StopWorksDetailsBLL()
        //    {
        //        StopWorks = overtime,
        //        EmployeeCareerHistory = new EmployeesCareersHistoryBLL()
        //        {
        //            EmployeeCareerHistoryID = StopWorkVM.StopWorkDetailRequest.EmployeeCareerHistory.EmployeeCareerHistoryID,
        //            EmployeeCode = new EmployeesCodesBLL() { EmployeeCodeID = StopWorkVM.StopWorkDetailRequest.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID }
        //        }
        //    }.IsValid();


        //    if (result.EnumMember == StopWorkValidationEnum.Done.ToString())
        //    {
        //        StopWorkEmployeesList.Add(StopWorkVM.StopWorkDetailRequest);
        //        Session["StopWorksEmployees"] = StopWorkEmployeesList;
        //    }
        //    else if (result.EnumMember == StopWorkValidationEnum.RejectedBecauseOfStopWorkDatesMustBeInSameFinancialYear.ToString())
        //    {
        //        FinancialYearsBLL FinancialYearBLL = (FinancialYearsBLL)result.Entity;
        //        throw new CustomException(Resources.Globalization.ValidationStopWorkDatesMustBeInSameFinancialYearText + "NewLine" +
        //                                                        Resources.Globalization.FinancialYearInfoText + FinancialYearBLL.FinancialYear + ": NewLine" +
        //                                                        Resources.Globalization.FinancialYearStartDateText + FinancialYearBLL.FinancialYearStartDate.Date.ToString(System.Configuration.ConfigurationManager.AppSettings["DateFormat"]) + "NewLine" +
        //                                                        Resources.Globalization.FinancialYearEndDateText + FinancialYearBLL.FinancialYearEndDate.Date.ToString(System.Configuration.ConfigurationManager.AppSettings["DateFormat"]));
        //    }
        //    else if (result.EnumMember == NoConflictWithOtherProcessValidationEnum.RejectedBecauseOfConflictWithDelegation.ToString())
        //    {
        //        throw new CustomException(Resources.Globalization.ValidationConflictWithDelegationText);
        //    }
        //    else if (result.EnumMember == NoConflictWithOtherProcessValidationEnum.RejectedBecauseOfConflictWithStopWork.ToString())
        //    {
        //        throw new CustomException(Resources.Globalization.ValidationConflictWithStopWorkText);
        //    }
        //    else if (result.EnumMember == NoConflictWithOtherProcessValidationEnum.RejectedBecauseOfConflictWithInternshipScholarship.ToString())
        //    {
        //        throw new CustomException(Resources.Globalization.ValidationConflictWithInternshipScholarshipText);
        //    }
        //    else if (result.EnumMember == NoConflictWithOtherProcessValidationEnum.RejectedBecauseOfConflictWithVacation.ToString())
        //    {
        //        throw new CustomException(Resources.Globalization.ValidationConflictWithVacationText);
        //    }


        //    return new HttpResponseMessage(HttpStatusCode.OK);
        //}

        //[HttpPost]
        //[IgnoreModelProperties("StopWorkID,StopWorkStartDate,StopWorkEndDate,StopWorkPeriod,Task,StopWorkDetailRequest")]
        //public HttpResponseMessage RemoveEmployeeFromStopWork(StopWorksViewModel StopWorkVM)
        //{
        //    List<StopWorksDetailsBLL> StopWorkEmployeesList = GetStopWorkDetailsFromSession();
        //    StopWorkEmployeesList.RemoveAt(StopWorkEmployeesList.FindIndex(e => e.EmployeeCareerHistory.EmployeeCode.EmployeeCodeNo.Equals(StopWorkVM.StopWorkDetailRequest.EmployeeCareerHistory.EmployeeCode.EmployeeCodeNo)));
        //    return new HttpResponseMessage(HttpStatusCode.OK);
        //}

        //public JsonResult GetStopWorkEmployees()
        //{
        //    List<StopWorksDetailsBLL> StopWorkEmployeesList;
        //    if (Session["StopWorksEmployees"] != null)
        //        StopWorkEmployeesList = (List<StopWorksDetailsBLL>)Session["StopWorksEmployees"];
        //    else
        //        StopWorkEmployeesList = new List<StopWorksDetailsBLL>();

        //    return Json(new { data = StopWorkEmployeesList }, JsonRequestBehavior.AllowGet);
        //}


        //[HttpPost]
        //[IgnoreModelProperties("StopWorkID,StopWorkStartDate,StopWorkEndDate,StopWorkPeriod,Task,StopWorkDetailRequest")]
        //public HttpResponseMessage ResetEmployeeFromSession()
        //{
        //    ClearStopWorkDetailsFromSession();
        //    return new HttpResponseMessage(HttpStatusCode.OK);
        //}

        public JsonResult GetStopWorks()
        {
            var data = new StopWorksBLL().GetStopWorks()
                       .Select(x => new
            {
                x.StopWorkID,
                EmployeeNameAr = x.EmployeeCareerHistory.EmployeeCode.Employee.EmployeeNameAr,
                EmployeeCodeNo = x.EmployeeCareerHistory.EmployeeCode.EmployeeCodeNo,
                EmployeeIDNo   = x.EmployeeCareerHistory.EmployeeCode.Employee.EmployeeIDNo,
                //DelegationStartDate = Globals.Calendar.GetUmAlQuraDate(x.DelegationStartDate),
                x.StopWorkStartDate,
                x.StopWorkEndDate,
                IsApproved = x.IsConvicted,
                x.IsConvicted
            });

            return(Json(new { data = data }, JsonRequestBehavior.AllowGet));
        }
예제 #6
0
        public ActionResult Create(StopWorksViewModel stopWorkVM)
        {
            //--== StopWork Master DataBind ===
            StopWorksBLL stopWork = new StopWorksBLL();

            stopWork.StopWorkStartDate           = stopWorkVM.StopWorkStartDate;
            stopWork.StopWorkEndDate             = stopWorkVM.StopWorkEndDate;
            stopWork.StartStopWorkDecisionNumber = stopWorkVM.StartStopWorkDecisionNumber;
            stopWork.StartStopWorkDecisionDate   = stopWorkVM.StartStopWorkDecisionDate;
            stopWork.EndStopWorkDecisionNumber   = stopWorkVM.EndStopWorkDecisionNumber;
            stopWork.EndStopWorkDecisionDate     = stopWorkVM.EndStopWorkDecisionDate;
            stopWork.Note                  = stopWorkVM.Note;
            stopWork.StopPoint             = stopWorkVM.StopPoint;
            stopWork.StopWorkType          = stopWorkVM.StopWorkType;
            stopWork.IsConvicted           = stopWorkVM.IsConvicted;
            stopWork.EmployeeCareerHistory = new EmployeesCareersHistoryBLL().GetActiveByEmployeeCareerHistoryID(stopWorkVM.EmployeeCareerHistoryID);
            stopWork.LoginIdentity         = UserIdentity;
            Result result = stopWork.Add();

            Session["StopWorkID"] = stopWork.StopWorkID;


            if ((System.Type)result.EnumType == typeof(StopWorkValidationEnum))
            {
                if (result.EnumMember == StopWorkValidationEnum.RejectedBecauseOfEndDateShouldBeMoreThanStartDate.ToString())
                {
                    throw new CustomException(Resources.Globalization.ValidationEndDateShouldBeMoreThanStartDateText);
                }
            }
            if ((System.Type)result.EnumType == typeof(StopWorkValidationEnum))
            {
                if (result.EnumMember == StopWorkValidationEnum.RejectedBecauseOfThereIsAnotherStopWorkNotEnding.ToString())
                {
                    throw new CustomException(Resources.Globalization.ValidationThereIsAnotherStopWorkNotEndingText);
                }
            }


            if ((System.Type)result.EnumType == typeof(NoConflictWithOtherProcessValidationEnum))
            {
                if (result.EnumMember == NoConflictWithOtherProcessValidationEnum.RejectedBecauseOfConflictWithStopWork.ToString())
                {
                    //throw new CustomException(Resources.Globalization.ValidationConflictWithStopWorkText);
                    throw new CustomException(Resources.Globalization.ValidationConflictWithAssigningText);
                }
                Classes.Helpers.CommonHelper.ConflictValidationMessage(result);
                //else if (result.EnumMember == NoConflictWithOtherProcessValidationEnum.RejectedBecauseOfConflictWithVacation.ToString())
                //{
                //    throw new CustomException(Resources.Globalization.ValidationConflictWithVacationText);
                //}
                //else if (result.EnumMember == NoConflictWithOtherProcessValidationEnum.RejectedBecauseOfConflictWithOverTime.ToString())
                //{
                //    throw new CustomException(Resources.Globalization.ValidationConflictWithOverTimeText);
                //}
                //else if (result.EnumMember == NoConflictWithOtherProcessValidationEnum.RejectedBecauseOfConflictWithInternshipScholarship.ToString())
                //{
                //    throw new CustomException(Resources.Globalization.ValidationConflictWithInternshipScholarshipText);
                //}
                //else if (result.EnumMember == NoConflictWithOtherProcessValidationEnum.RejectedBecauseOfConflictWithDelegation.ToString())
                //{
                //    throw new CustomException(Resources.Globalization.ValidationConflictWithDelegationText);
                //}
            }
            //return View("Index");
            return(Json(new { StopWorkID = stopWork.StopWorkID }, JsonRequestBehavior.AllowGet));
        }