Esempio n. 1
0
        public HttpResponseMessage GetVacationBalanceByEmployeeCodeNo(VacationsTypesEnum VacationType, string EmployeeCodeNo)
        {
            if (string.IsNullOrEmpty(EmployeeCodeNo))
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }

            EmployeesCodesBLL emp = new EmployeesCodesBLL().GetByEmployeeCodeNo(EmployeeCodeNo);

            if (emp != null)
            {
                BaseVacationsBLL Vacation = GenericFactoryPattern <BaseVacationsBLL, NormalVacationsBLL> .CreateInstance();

                DateTime CurrentDate = DateTime.Now.Date;
                int      MaturityYearFromCurrentDate  = Globals.Calendar.GetUmAlQuraYear(CurrentDate);
                int      MaturityMonthFromCurrentDate = Globals.Calendar.GetUmAlQuraMonth(CurrentDate);
                int      MaturityDayFromCurrentDate   = Globals.Calendar.GetUmAlQuraDay(CurrentDate);

                ((NormalVacationsBLL)Vacation).GetVacationBalances(emp.EmployeeCodeID, MaturityYearFromCurrentDate, MaturityMonthFromCurrentDate, MaturityDayFromCurrentDate);

                return(Request.CreateResponse(HttpStatusCode.OK, (NormalVacationsBLL)Vacation));

                //return Request.CreateResponse(HttpStatusCode.OK, new
                //{
                //    EmployeeCodeID = ((NormalVacationsBLL)Vacation).EmployeeCareerHistory.EmployeeCode.EmployeeCodeID,
                //    EmployeeCodeNo = ((NormalVacationsBLL)Vacation).EmployeeCareerHistory.EmployeeCode.EmployeeCodeNo,
                //    EmployeeNameAr = ((NormalVacationsBLL)Vacation).EmployeeCareerHistory.EmployeeCode.Employee.EmployeeNameAr,

                //    DeservedOldBalance = ((NormalVacationsBLL)Vacation).DeservedOldBalance,
                //    ConsumedOldBalance = ((NormalVacationsBLL)Vacation).ConsumedOldBalance,
                //    RemainingOldBalance = ((NormalVacationsBLL)Vacation).RemainingOldBalance,

                //    DeservedCurrentBalance = ((NormalVacationsBLL)Vacation).DeservedCurrentBalance,
                //    ConsumedCurrentBalance = ((NormalVacationsBLL)Vacation).ConsumedCurrentBalance,
                //    ExpiredCurrentBalance = ((NormalVacationsBLL)Vacation).ExpiredCurrentBalance,
                //    RemainingCurrentBalance = ((NormalVacationsBLL)Vacation).RemainingCurrentBalance,

                //    TotalDeservedBalance = ((NormalVacationsBLL)Vacation).TotalDeservedBalance,
                //    TotalConsumedBalance = ((NormalVacationsBLL)Vacation).TotalConsumedBalance,
                //    TotalRemainingBalance = ((NormalVacationsBLL)Vacation).TotalRemainingBalance,

                //    TotalConsumedSeparatedDays = ((NormalVacationsBLL)Vacation).TotalConsumedSeparatedDays,

                //    InAdvanceBalance = ((NormalVacationsBLL)Vacation).InAdvanceBalance,

                //    TotalAvailableVacationBalance = ((NormalVacationsBLL)Vacation).TotalAvailableVacationBalance,

                //}.ToXml());
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, "Employee not found!"));
            }
        }
Esempio n. 2
0
        public JsonResult GetEmployeesVacationsAsRanksCategories(int VacationTypeID, DateTime VacationDate, int OrganizationID)
        {
            IQueryable <EmployeesVacationsBasedOnAssigngingsDTO> Vacations;

            Vacations = new BaseVacationsBLL().GetEmployeesVacationsBasedOnAssigningsAsRanksCategories(VacationTypeID, VacationDate, OrganizationID);
            Session["EmployeesVacationsDetails"] = Vacations;

            var VacationsByRanksCategories = Vacations
                                             .GroupBy(x => x.RankCategoryName)
                                             .Select(y => new
            {
                KeyName = y.Key,
                Value   = y.Count()
            });

            return(Json(new { data = VacationsByRanksCategories }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 3
0
        public List <DateTime> GetDaysBetweenStartAndEndDate(int OverTimeID, int OverTimeDetailID)
        {
            List <DateTime>     VacationDates  = new List <DateTime>();
            OverTimesBLL        Overtime       = new OverTimesBLL().GetByOverTimeID(OverTimeID);
            OverTimesDetailsBLL OvertimeDetail = new OverTimesDetailsBLL().GetOverTimeDetailsByID(OverTimeDetailID);

            BaseVacationsBLL        Vacation;
            List <BaseVacationsBLL> vacations = new BaseVacationsBLL().GetByEmployeeCodeID(OvertimeDetail.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID);

            foreach (OverTimesDaysBLL OTDay in Overtime.OverTimesDays)
            {
                Vacation = vacations.FirstOrDefault(e => OTDay.OverTimeDay >= e.VacationStartDate && OTDay.OverTimeDay <= e.VacationEndDate);
                if (Vacation != null && Vacation.VacationID > 0)
                {
                    VacationDates.Add(OTDay.OverTimeDay);
                }
            }

            return(VacationDates);
        }
Esempio n. 4
0
        public ActionResult VacationApproval(string VacationID, string ApprovalType)
        {
            BaseVacationsBLL Vacation = new BaseVacationsBLL()
            {
                VacationID    = int.Parse(VacationID),
                LoginIdentity = this.UserIdentity
            };
            Result result = new Result();

            if (ApprovalType == "Approve")
            {
                result = Vacation.Approve();
            }
            else
            {
                result = Vacation.ApproveCancel();
            }

            return(View());
        }
Esempio n. 5
0
        public ActionResult ReportEmployeesVacationsDuringPeriod(ReportEmployeesVacationsDuringPeriodViewModel VM)
        {
            HCMBLL.BaseVacationsBLL vacationsBLL = new BaseVacationsBLL()
            {
                Search   = Search,
                Order    = Order,
                OrderDir = OrderDir,
                StartRec = StartRec,
                PageSize = PageSize
            };
            VacationsTypesEnum?vacationsTypesEnum = null;

            if (VM.VacationTypeID != null)
            {
                vacationsTypesEnum = (VacationsTypesEnum)VM.VacationTypeID;
            }
            var data = vacationsBLL.GetValidEmployeesVacationsDuringPeriod(vacationsTypesEnum, VM.StartDate, VM.EndDate);

            Session["EmployeesVacationsDuringPeriod"] = data.ToList();
            return(Json(new { draw = Convert.ToInt32(Draw), recordsTotal = TotalRecordsOut, recordsFiltered = RecFilterOut, data = data }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 6
0
        public virtual Result Update()
        {
            Result result = new Result();

            //result = IsNoConflictWithOtherSportsSeasonsSettings(this.SportsSeasonStartDate, this.SportsSeasonEndDate);
            //if (result != null)
            //    return result;

            #region  Validate if the season that wanted to updated has vaacation or not
            List <BaseVacationsBLL> BaseVacationsBLLList = new BaseVacationsBLL().GetVacationsBySportsSeasonID(this.SportsSeasonID);
            if (BaseVacationsBLLList.Count > 0)
            {
                result            = new Result();
                result.EnumType   = typeof(SportsSeasonsValidationEnum);
                result.EnumMember = SportsSeasonsValidationEnum.RejectedBecauseOfAlreadyCreatedVacationOnTheSeason.ToString();
                return(result);
            }
            #endregion


            SportsSeasons SportsSeasons = new SportsSeasons();
            SportsSeasons.MaturityYearID          = this.MaturityYear.MaturityYearID;
            SportsSeasons.SportsSeasonStartDate   = this.SportsSeasonStartDate;
            SportsSeasons.SportsSeasonEndDate     = this.SportsSeasonEndDate;
            SportsSeasons.SportsSeasonDescription = this.SportsSeasonDescription;
            SportsSeasons.UpdatedDate             = DateTime.Now;
            SportsSeasons.Updatedby      = this.LoginIdentity.EmployeeCodeID;
            SportsSeasons.SportsSeasonID = this.SportsSeasonID;

            this.SportsSeasonID = new SportsSeasonsDAL().Update(SportsSeasons);
            if (this.SportsSeasonID != 0)
            {
                result.Entity     = this;
                result.EnumType   = typeof(LookupsValidationEnum);
                result.EnumMember = LookupsValidationEnum.Done.ToString();
            }
            return(result);
        }
Esempio n. 7
0
        public Result Update()
        {
            try
            {
                Result result = new Result();

                #region Validation to check if EmployeeCareerHistory Exist in PromotionsRecordsEmployees as NewEmployeeCareerHistory or CurrentEmployeeCareerHistory
                //check if OrganizationJob Exist in PromotionsRecordsJobsVacancies as PromotionRecordJobVacancyID
                // Then Can't update OrganizationID,RankID,JobID
                List <PromotionsRecordsEmployeesBLL> PromotionsRecordsEmployeesList = new PromotionsRecordsEmployeesBLL().GetByEmployeeCareerHistoryID(this.EmployeeCareerHistoryID);
                if (PromotionsRecordsEmployeesList.Count != 0)
                {
                    result.EnumType   = typeof(CareersHistoryValidationEnum);
                    result.EnumMember = CareersHistoryValidationEnum.RejectedBecauseOfExistsInPromotionsRecordsEmployees.ToString();
                    return(result);
                }
                #endregion

                #region Check about is hiring exists before or not
                if (this.CareerHistoryType.CareerHistoryTypeID.Equals((int)CareersHistoryTypesEnum.Hiring))
                {
                    EmployeesCareersHistoryBLL Hr = this.GetHiringRecordByEmployeeCodeID(this.EmployeeCode.EmployeeCodeID);
                    if (Hr != null)
                    {
                        if (Hr.EmployeeCareerHistoryID != this.EmployeeCareerHistoryID)
                        {
                            result.Entity     = Hr;
                            result.EnumType   = typeof(CareersHistoryValidationEnum);
                            result.EnumMember = CareersHistoryValidationEnum.RejectedBecauseOfAlreadyHiringBefore.ToString();
                            return(result);
                        }
                    }
                }
                #endregion

                #region TASK 260 : check new employee career history record date must be less than 'Join Date' of hiring record
                if (this.CareerHistoryType.CareerHistoryTypeID != (int)CareersHistoryTypesEnum.Hiring)
                {
                    EmployeesCareersHistoryBLL oo = this.GetHiringRecordByEmployeeCodeID(this.EmployeeCode.EmployeeCodeID);
                    if (oo != null && oo.JoinDate.Date >= this.JoinDate.Date)
                    {
                        result.Entity     = oo;
                        result.EnumType   = typeof(CareersHistoryValidationEnum);
                        result.EnumMember = CareersHistoryValidationEnum.RejectedBecauseOfJoinDateMustBeLessThanHiringRecordJoinDate.ToString();
                        return(result);
                    }
                }
                #endregion

                #region if the record is hiring ... Check about there is vacation transactions before new hiring date or not
                if (this.CareerHistoryType.CareerHistoryTypeID.Equals((int)CareersHistoryTypesEnum.Hiring))
                {
                    bool IsVacationExists = new BaseVacationsBLL().IsEmployeeVacationExistsBeforeDate(this.EmployeeCode.EmployeeCodeID, this.JoinDate.Date);
                    if (IsVacationExists)
                    {
                        //result.Entity = Hr;
                        result.EnumType   = typeof(CareersHistoryValidationEnum);
                        result.EnumMember = CareersHistoryValidationEnum.RejectedHiringDateUpdatingBecauseOfAlreadyActionsBefore.ToString();
                        return(result);
                    }
                }
                #endregion

                #region Update record
                EmployeesCareersHistory EmployeeCareerHistory = new EmployeesCareersHistory()
                {
                    EmployeeCareerHistoryID = this.EmployeeCareerHistoryID,
                    CareerHistoryTypeID     = this.CareerHistoryType.CareerHistoryTypeID,
                    CareerDegreeID          = this.CareerDegree.CareerDegreeID,
                    OrganizationJobID       = this.OrganizationJob.OrganizationJobID,
                    JoinDate             = this.JoinDate.Date,
                    TransactionStartDate = this.JoinDate.Date,
                    LastUpdatedBy        = this.LoginIdentity != null ? this.LoginIdentity.EmployeeCodeID : (int?)null,
                    LastUpdatedDate      = DateTime.Now,
                    IsActive             = this.IsActive,
                };
                new EmployeesCareersHistoryDAL().Update(EmployeeCareerHistory);
                #endregion

                #region Change current job
                ChangeCurrentJobByEmployeeCodeID(this.EmployeeCode.EmployeeCodeID);
                #endregion

                result.Entity     = this;
                result.EnumType   = typeof(CareersHistoryValidationEnum);
                result.EnumMember = CareersHistoryValidationEnum.Done.ToString();
                return(result);
            }
            catch
            {
                throw;
            }
        }
Esempio n. 8
0
        public Result MakeDecisionOfEVacationRequest(EVacationsRequestsBLL EVacationRequestObj, EVacationRequestStatusEnum EVacationRequestStatus)
        {
            try
            {
                Result result = null;
                EVacationRequestObj.ApprovedBy = new EmployeesCodesBLL().GetByEmployeeCodeNo(EVacationRequestObj.ApprovedBy.EmployeeCodeNo);
                EVacationsRequestsBLL EVacationsRequestsData = new EVacationsRequestsBLL().GetEVacationsRequestsByEVacationRequestID(EVacationRequestObj.EVacationRequestID);

                #region Validate there is a decision of this e vacation request or not
                if (EVacationsRequestsData.EVacationRequestStatus.EVacationRequestStatusID != (int)EVacationRequestStatusEnum.Pending)
                {
                    result            = new Result();
                    result.Entity     = EVacationsRequestsData;
                    result.EnumMember = VacationsValidationEnum.RejectedBecauseOfEVacationRequestStatusNotPending.ToString();
                    return(result);
                }
                #endregion

                #region Validate the approver person is authorized to employee manager or not
                EmployeesCodesBLL ActualAuthorizedPerson = new EServicesAuthorizationsBLL().GetOrganizationAuthorizedPerson(EVacationsRequestsData.ActualEmployeeOrganization.OrganizationID, EServicesTypesEnum.Vacation).AuthorizedPerson;
                if (ActualAuthorizedPerson.EmployeeCodeNo != EVacationRequestObj.ApprovedBy.EmployeeCodeNo)
                {
                    result            = new Result();
                    result.EnumMember = VacationsValidationEnum.RejectedBeacuseOfApproverIsNotAuthorizedPerson.ToString();
                    result.Entity     = ActualAuthorizedPerson;
                    return(result);
                }
                #endregion

                string SMSMessage = string.Empty;
                // in case of approval, send the vacation data to vacations module to be added, after that change the status in e vacation requests module
                if (EVacationRequestStatus == EVacationRequestStatusEnum.Approved)
                {
                    #region Send vacation to vacations module
                    BaseVacationsBLL Vacation = new BaseVacationsBLL()
                    {
                        IsApprovedFromManager = true,
                        EVacationsRequest     = EVacationsRequestsData,
                        EmployeeCareerHistory = EVacationsRequestsData.EmployeeCareerHistory,
                        VacationType          = VacationsTypesEnum.Normal,
                        VacationStartDate     = EVacationsRequestsData.VacationStartDate,
                        VacationEndDate       = EVacationsRequestsData.VacationEndDate,
                        Notes         = EVacationsRequestsData.CreatorNotes,
                        ApprovedBy    = EVacationRequestObj.ApprovedBy,
                        LoginIdentity = EVacationsRequestsData.CreatedBy,
                        CreatedDate   = DateTime.Now,
                        IsCanceled    = false,
                    };
                    result = Vacation.Add();
                    #endregion

                    #region Update IsApproved in vacations module
                    result = Vacation.Approve();
                    #endregion

                    if (result.EnumMember == VacationsValidationEnum.Done.ToString())
                    {
                        result = ApproveEVacationRequest(EVacationRequestObj, EVacationRequestStatus);
                    }

                    SMSMessage = string.Format(Globalization.SMSEVacationRequestApprovedText, EVacationsRequestsData.VacationType.VacationTypeName, EVacationsRequestsData.VacationStartDate, EVacationsRequestsData.VacationPeriod);
                }
                else  // in case of refuse, change the status in e vacation requests module only
                {
                    result     = ApproveEVacationRequest(EVacationRequestObj, EVacationRequestStatus);
                    SMSMessage = Globalization.SMSEVacationRequestRefusedText;
                }

                #region Sending sms to employee to notify him the authorized person decision
                SMSBLL sMSBLL = new SMSBLL();
                sMSBLL.SendSMS(new SMSLogsBLL()
                {
                    BusinssSubCategory = BusinessSubCategoriesEnum.AuthorizedPersonDecisionForEVacationRequest,
                    DetailID           = EVacationsRequestsData.EVacationRequestID,
                    MobileNo           = EVacationsRequestsData.EmployeeCareerHistory?.EmployeeCode?.Employee?.EmployeeMobileNo,
                    Message            = SMSMessage,
                    CreatedBy          = EVacationRequestObj.ApprovedBy,
                });
                #endregion

                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 9
0
        public virtual Result Add()
        {
            try
            {
                Result result = new Result();

                if (this.StartDate.ToString().Contains("0001"))
                {
                    result            = new Result();
                    result.Entity     = null;
                    result.EnumType   = typeof(EServicesProxiesEnum);
                    result.EnumMember = EServicesProxiesEnum.RejectedBecauseStartDateRequried.ToString();

                    return(result);
                }
                else if (this.LoginIdentity.EmployeeCodeID == this.ToEmployee.EmployeeCodeID)
                {
                    result            = new Result();
                    result.Entity     = null;
                    result.EnumType   = typeof(EServicesProxiesEnum);
                    result.EnumMember = EServicesProxiesEnum.RejectedBecauseLoginManagerIsSameAsProxyEmployee.ToString();

                    return(result);
                }
                else
                {
                    EServicesProxiesBLL bll = this.GetActiveByFromEmployeeCodeID(this.FromEmployee.EmployeeCodeID, (EServicesTypesEnum)this.EServiceType.EServiceTypeID);
                    if (bll != null && bll.EServiceProxyID > 0)
                    {
                        result            = new Result();
                        result.Entity     = bll;
                        result.EnumType   = typeof(EServicesProxiesEnum);
                        result.EnumMember = EServicesProxiesEnum.RejectedBecauseThereIsAlreadyActiveProxyExist.ToString();

                        return(result);
                    }

                    // Validate if ToEmployee has already EVacation Request Pending Exist
                    EmployeesCodes ToEmployee = new EmployeesCodesDAL().GetByEmployeeCodeID(this.ToEmployee.EmployeeCodeID);
                    result = new EVacationsRequestsBLL().IsEVacationRequestPendingExist(ToEmployee.EmployeeCodeNo);
                    if (result != null)
                    {
                        result            = new Result();
                        result.Entity     = null;
                        result.EnumType   = typeof(EServicesProxiesEnum);
                        result.EnumMember = EServicesProxiesEnum.RejectedBecauseThereIsPendingEVacationRequestExist.ToString();

                        return(result);
                    }

                    // Validate if ToEmployee has already Vacation Exist
                    List <BaseVacationsBLL> lst = new BaseVacationsBLL().GetByEmployeeCodeID(this.ToEmployee.EmployeeCodeID, this.StartDate, this.StartDate.AddDays(this.DaysCountInGregYear));
                    if (lst.Count > 0)
                    {
                        result            = new Result();
                        result.Entity     = null;
                        result.EnumType   = typeof(EServicesProxiesEnum);
                        result.EnumMember = EServicesProxiesEnum.RejectedBecauseThereIsVacationExist.ToString();

                        return(result);
                    }
                }

                EServicesProxies EServiceProxy = new EServicesProxies()
                {
                    EServiceTypeID        = this.EServiceType.EServiceTypeID,
                    FromEmployeeCodeID    = this.FromEmployee.EmployeeCodeID,
                    ToEmployeeCodeID      = this.ToEmployee.EmployeeCodeID,
                    StartDate             = this.StartDate,
                    EndDate               = this.EndDate,
                    EServiceProxyStatusID = (int)EServicesProxiesStatusEnum.Valid,
                    IsActive              = true,
                    Notes       = this.Notes,
                    CreatedDate = DateTime.Now,
                    CreatedBy   = this.LoginIdentity.EmployeeCodeID
                };

                this.EServiceProxyID = new EServicesProxiesDAL().Insert(EServiceProxy);

                #region Send SMS on creation
                EmployeesCodesBLL FromEmployeeCodeBLL = new EmployeesCodesBLL().GetByEmployeeCodeID(this.FromEmployee.EmployeeCodeID);
                EmployeesCodesBLL ToEmployeeCodeBLL   = new EmployeesCodesBLL().GetByEmployeeCodeID(this.ToEmployee.EmployeeCodeID);
                SMSBLL            SMSObj = new SMSBLL();
                SMSObj.SendSMS(new SMSLogsBLL()
                {
                    BusinssSubCategory = BusinessSubCategoriesEnum.EServicesProxies,
                    DetailID           = this.EServiceProxyID,
                    MobileNo           = ToEmployeeCodeBLL.Employee.EmployeeMobileNo,
                    Message            = string.Format(Globalization.SMSEServicesProxiesCreationText,
                                                       ToEmployeeCodeBLL.Employee.EmployeeNameAr, FromEmployeeCodeBLL.Employee.EmployeeNameAr),
                    CreatedBy = this.LoginIdentity,
                });
                #endregion

                result            = new Result();
                result.Entity     = this;
                result.EnumType   = typeof(EServicesProxiesEnum);
                result.EnumMember = EServicesProxiesEnum.Done.ToString();
                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 10
0
        public static Result IsNoConflictWithOtherProcess(int EmployeeCodeID, DateTime StartDate, DateTime EndDate, params BusinessSubCategoriesEnum[] ExcludeBusinessSubCategories)
        {
            Result result = null;

            if (ExcludeBusinessSubCategories.Contains(BusinessSubCategoriesEnum.InternshipScholarships) == false)
            {
                #region Validaion for conflict with InternshipScholarship
                List <BaseInternshipScholarshipsBLL> BaseInternshipScholarshipBLLList = new BaseInternshipScholarshipsBLL().GetByEmployeeCodeID(EmployeeCodeID, StartDate, EndDate);
                if (BaseInternshipScholarshipBLLList.Count() != 0)
                {
                    result            = new Result();
                    result.EnumType   = typeof(NoConflictWithOtherProcessValidationEnum);
                    result.EnumMember = NoConflictWithOtherProcessValidationEnum.RejectedBecauseOfConflictWithInternshipScholarship.ToString();
                    return(result);
                }
                #endregion
            }

            if (ExcludeBusinessSubCategories.Contains(BusinessSubCategoriesEnum.OverTimes) == false)
            {
                #region Validaion for conflict with Overtime
                List <OverTimesBLL> OverTimesBLLList = new OverTimesBLL().GetByEmployeeCodeID(EmployeeCodeID, StartDate, EndDate);
                OverTimesBLL        nn = new OverTimesBLL();
                if (OverTimesBLLList.Count() != 0)
                {
                    result            = new Result();
                    result.EnumType   = typeof(NoConflictWithOtherProcessValidationEnum);
                    result.EnumMember = NoConflictWithOtherProcessValidationEnum.RejectedBecauseOfConflictWithOverTime.ToString();
                    result.Entity     = nn;
                    return(result);
                }

                #endregion
            }

            if (ExcludeBusinessSubCategories.Contains(BusinessSubCategoriesEnum.Delegations) == false)
            {
                #region Validaion for conflict with Delegation
                List <BaseDelegationsBLL> DelegationsBLLList = new BaseDelegationsBLL().GetByEmployeeCodeID(EmployeeCodeID, StartDate, EndDate);
                if (DelegationsBLLList.Count() != 0)
                {
                    result            = new Result();
                    result.EnumType   = typeof(NoConflictWithOtherProcessValidationEnum);
                    result.EnumMember = NoConflictWithOtherProcessValidationEnum.RejectedBecauseOfConflictWithDelegation.ToString();
                    return(result);
                }

                #endregion
            }

            if (ExcludeBusinessSubCategories.Contains(BusinessSubCategoriesEnum.Vacations) == false)
            {
                #region Validaion for conflict with vacation
                List <BaseVacationsBLL> VacationsBLLList = new BaseVacationsBLL().GetByEmployeeCodeID(EmployeeCodeID, StartDate, EndDate);
                if (VacationsBLLList.Count() != 0)
                {
                    result            = new Result();
                    result.EnumType   = typeof(NoConflictWithOtherProcessValidationEnum);
                    result.EnumMember = NoConflictWithOtherProcessValidationEnum.RejectedBecauseOfConflictWithVacation.ToString();
                    return(result);
                }
                #endregion
            }

            if (ExcludeBusinessSubCategories.Contains(BusinessSubCategoriesEnum.StopWork) == false)
            {
                #region Validaion for conflict with StopWorks
                List <StopWorksBLL> StopWorksBLLList = new StopWorksBLL().GetByEmployeeCodeID(EmployeeCodeID, StartDate, EndDate);
                if (StopWorksBLLList.Count() != 0)
                {
                    result            = new Result();
                    result.EnumType   = typeof(NoConflictWithOtherProcessValidationEnum);
                    result.EnumMember = NoConflictWithOtherProcessValidationEnum.RejectedBecauseOfConflictWithStopWork.ToString();
                    return(result);
                }
                #endregion
            }

            if (ExcludeBusinessSubCategories.Contains(BusinessSubCategoriesEnum.Scholarships) == false)
            {
                #region Validaion for conflict with Scholarship
                List <BaseScholarshipsBLL> BaseScholarshipsBLLList = new BaseScholarshipsBLL().GetByEmployeeCodeID(EmployeeCodeID, StartDate, EndDate);
                if (BaseScholarshipsBLLList.Count() != 0)
                {
                    result            = new Result();
                    result.EnumType   = typeof(NoConflictWithOtherProcessValidationEnum);
                    result.EnumMember = NoConflictWithOtherProcessValidationEnum.RejectedBecauseOfConflictWithScholarship.ToString();
                    return(result);
                }
                #endregion
            }

            if (ExcludeBusinessSubCategories.Contains(BusinessSubCategoriesEnum.Lenders) == false)
            {
                #region Validaion for conflict with Lenders
                List <LendersBLL> LendersBLLList = new LendersBLL().GetByEmployeeCodeID(EmployeeCodeID, StartDate, EndDate);
                if (LendersBLLList.Count() != 0)
                {
                    result            = new Result();
                    result.EnumType   = typeof(NoConflictWithOtherProcessValidationEnum);
                    result.EnumMember = NoConflictWithOtherProcessValidationEnum.RejectedBecauseOfConflictWithLender.ToString();
                    return(result);
                }
                #endregion
            }

            if (ExcludeBusinessSubCategories.Contains(BusinessSubCategoriesEnum.Assignings) == false)
            {
                #region Validaion for conflict with External Assigning
                List <ExternalAssigningBLL> ExternalAssigningBLLList = new ExternalAssigningBLL().GetByEmployeeCodeID(EmployeeCodeID, StartDate, EndDate);
                if (ExternalAssigningBLLList.Count() != 0)
                {
                    result            = new Result();
                    result.EnumType   = typeof(NoConflictWithOtherProcessValidationEnum);
                    result.EnumMember = NoConflictWithOtherProcessValidationEnum.RejectedBecauseOfConflictWithExternalAssigning.ToString();
                    return(result);
                }
                #endregion
            }

            if (ExcludeBusinessSubCategories.Contains(BusinessSubCategoriesEnum.Teachers) == false)
            {
                #region Validaion for conflict with Teachers
                //List<TeachersBLL> TeachersBLLList = new TeachersBLL().GetByEmployeeCodeID(EmployeeCodeID, StartDate, EndDate);
                //if (TeachersBLLList.Count() != 0)
                //{
                //    result = new Result();
                //    result.EnumType = typeof(NoConflictWithOtherProcessValidationEnum);
                //    result.EnumMember = NoConflictWithOtherProcessValidationEnum.RejectedBecauseOfConflictWithTeacher.ToString();
                //    return result;
                //}
                #endregion
            }

            return(result);
        }
Esempio n. 11
0
        public ActionResult Create(VacationsViewModel VacationVM)
        {
            BaseVacationsBLL Vacation = null;

            if (!VacationVM.VacationStartDate.HasValue || !VacationVM.VacationEndDate.HasValue)
            {
                throw new CustomException(Resources.Globalization.RequiredStartDateAndEndDateText);
            }

            if (VacationVM.VacationType.VacationTypeID == (int)VacationsTypesEnum.Normal)
            {
                Vacation = GenericFactoryPattern <BaseVacationsBLL, NormalVacationsBLL> .CreateInstance();

                if (VacationVM.NormalVacationTypeID.HasValue)
                {
                    ((NormalVacationsBLL)Vacation).NormalVacationType = new NormalVacationsTypesBLL()
                    {
                        NormalVacationTypeID = VacationVM.NormalVacationTypeID.Value
                    }
                }
                ;
            }

            Vacation.EmployeeCareerHistory = new EmployeesCareersHistoryBLL().GetEmployeeCurrentJob(VacationVM.EmployeeCodeID.Value);
            Vacation.VacationType          = (VacationsTypesEnum)VacationVM.VacationType.VacationTypeID;
            Vacation.VacationStartDate     = VacationVM.VacationStartDate.Value.Date;
            Vacation.VacationEndDate       = VacationVM.VacationEndDate.Value.Date;
            Vacation.Notes = VacationVM.Notes;
            Vacation.IsApprovedFromManager = false;
            Vacation.LoginIdentity         = new EmployeesCodesBLL()
            {
                EmployeeCodeNo = this.WindowsUserIdentity,
                EmployeeCodeID = VacationVM.EmployeeCodeID.Value
            };

            Result result = Vacation.Add();

            if (result.EnumMember == VacationsValidationEnum.RejectedBecauseOfBeforeHiringDate.ToString())
            {
                throw new CustomException(string.Format(Resources.Globalization.ValidationVacationBeforeHiringText, ((EmployeesCareersHistoryBLL)result.Entity).JoinDate.ToString(Classes.Helpers.CommonHelper.DateFormat)));
            }

            else if (result.EnumMember == VacationsValidationEnum.RejectedBeacuseOfEmployeeNotHasActualOrganization.ToString())
            {
                throw new CustomException(Resources.Globalization.ValidationEmployeeNotHasActualOrganizationText);
            }

            else if (result.EnumMember == VacationsValidationEnum.RejectedBecauseOfDuringProbation.ToString())
            {
                throw new CustomException(string.Format(Resources.Globalization.ValidationVacationDuringProbationText, ((EmployeesCareersHistoryBLL)result.Entity).ProbationEndDate.ToString(Classes.Helpers.CommonHelper.DateFormat)));
            }

            else if (result.EnumMember == VacationsValidationEnum.SportsSeasonDoesNotExist.ToString())
            {
                throw new CustomException(Resources.Globalization.SportsSeasonDoesNotExistText);
            }

            else if (result.EnumMember == VacationsValidationEnum.RejectedBecauseOfInvalidDates.ToString())
            {
                throw new CustomException(Resources.Globalization.ValidationInvalidDateText);
            }

            else if (result.EnumMember == VacationsValidationEnum.RejectedBecauseOfInvalidSportsDates.ToString())
            {
                throw new CustomException(Resources.Globalization.ValidationInvalidSportsDateText);
            }

            else if (result.EnumMember == VacationsValidationEnum.RejectedBecauseOfNoBalance.ToString())
            {
                throw new CustomException(Resources.Globalization.ValidationAlreadyReachTheVacationLimitText);
            }

            else if (result.EnumMember == VacationsValidationEnum.RejectedBecauseOfInvalidStartDate.ToString())
            {
                throw new CustomException(Resources.Globalization.ValidationInvalidVacationStartDateText);
            }

            else if (result.EnumMember == VacationsValidationEnum.RejectedBecauseOfConsumedMaxLimit.ToString())
            {
                throw new CustomException(Resources.Globalization.ValidationAlreadyReachTheNormalVacationLimitText);
            }

            else if (result.EnumMember == VacationsValidationEnum.RejectedBecauseOfNormalVacationBalanceExists.ToString())
            {
                throw new CustomException(Resources.Globalization.ValidationBecauseOfNormalVacationBalanceExistsText);
            }

            else if (result.EnumMember == VacationsValidationEnum.RejectedBecauseOfNormalVacationReachedToMaxLimitOfSeparatedDays.ToString())
            {
                throw new CustomException(Resources.Globalization.ValidationBecauseOfNormalVacationReachedToMaxLimitOfSeparatedDaysText);
            }

            else if (result.EnumMember == VacationsValidationEnum.RejectedBecauseOfVacationNotAllowedBetween1437and1438.ToString())
            {
                throw new CustomException(Resources.Globalization.ValidationBecauseOfVacationNotAllowedBetween1437and1438Text);
            }

            else if (result.EnumMember == VacationsValidationEnum.RejectedBecauseOfVacationOutOfRange.ToString())
            {
                throw new CustomException(Resources.Globalization.ValidationBecauseOfVacationOutOfRangeText);
            }

            else if (result.EnumMember == VacationsValidationEnum.RejectedBecauseSickExceptionalVacationDatesOutOfRange.ToString())
            {
                throw new CustomException(Resources.Globalization.ValidationBecauseOfSickExceptionalVacationDatesOutOfRangeText);
            }

            else if (result.EnumMember == VacationsValidationEnum.RejectedBecauseOfErrorInTimeAttendanceApp.ToString())
            {
                throw new CustomException(Resources.Globalization.ErrorInTimeAttendanceAppText);
            }

            else if (result.EnumMember == VacationsValidationEnum.RejectedBecauseOfMarriageVacationAcceptedOneTime.ToString())
            {
                throw new CustomException(Resources.Globalization.ValidationBecauseOfMarriageVacationAcceptedOneTimeText);
            }

            else if (result.EnumMember == VacationsValidationEnum.RejectedBecauseOfNoActiveProxyCreatedToOtherPerson.ToString())
            {
                throw new CustomException(Resources.Globalization.ValidationBecauseOfNoActiveProxyCreatedToOtherPersonText);
            }

            else if (result.EnumMember == VacationsValidationEnum.RejectedBecauseOfEmployeeHasProxyByOtherPerson.ToString())
            {
                throw new CustomException(string.Format(Resources.Globalization.ValidationBecauseOfThereIsProxyByOtherPersonText, ((EServicesProxiesBLL)result.Entity).FromEmployee?.Employee?.EmployeeNameAr,
                                                        ((EServicesProxiesBLL)result.Entity).StartDate.Date.ToString(Classes.Helpers.CommonHelper.DateFormat)));
            }

            else if (result.EnumMember == VacationsValidationEnum.RejectedBeacuseOfNotAllowedWeekEndBetweenTwoVacations.ToString())
            {
                throw new CustomException(string.Format(Resources.Globalization.ValidationNotAllowedWeekEndBetweenTwoVacationsText, ((BaseVacationsBLL)result.Entity).VacationStartDate.Date.ToString(Classes.Helpers.CommonHelper.DateFormat),
                                                        ((BaseVacationsBLL)result.Entity).VacationPeriod,
                                                        ((BaseVacationsBLL)result.Entity).VacationEndDate.Date.ToString(Classes.Helpers.CommonHelper.DateFormat),
                                                        ((BaseVacationsBLL)result.Entity).VacationTypeName));
            }

            else if (result.EnumMember == VacationsValidationEnum.RejectedBecauseOfEVacationRequestPendingExist.ToString())
            {
                throw new CustomException(string.Format(Resources.Globalization.ValidationBecauseOfEVacationRequestPendingExistText, ((BaseVacationsBLL)result.Entity).EVacationsRequest.EVacationRequestNo));
            }

            Classes.Helpers.CommonHelper.ConflictValidationMessage(result);

            Session["EVacationRequestNo"] = Vacation.EVacationsRequest.EVacationRequestNo;
            return(Json(new { EVacationRequestNo = Vacation.EVacationsRequest.EVacationRequestNo }, JsonRequestBehavior.AllowGet));
        }