Esempio n. 1
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. 2
0
        public override Result Add()
        {
            try
            {
                Result result = base.Add();
                if (result != null)
                {
                    return(result);
                }

                int      EmployeeCodeID = this.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID;
                DateTime StartDate      = this.AssigningStartDate;
                DateTime EndDate        = this.AssigningEndDate ?? DateTime.Now.Date;

                #region Validaion for conflict with lender
                EmployeesCareersHistoryBLL EmployeesCareersHistory = new EmployeesCareersHistoryBLL().GetActiveByEmployeeCareerHistoryID(this.EmployeeCareerHistory.EmployeeCareerHistoryID);
                //if (EmployeesCareersHistory != null && EmployeesCareersHistory.EmployeeCareerHistoryID > 0)
                //    EmployeeCodeID = EmployeesCareersHistory.EmployeeCode.EmployeeCodeID;

                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

                #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

                #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

                #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

                result = new Result();
                Assignings assigning = DALInstance;
                assigning.JobID          = this.Job.JobID;
                assigning.ManagerCodeID  = this.Manager != null ? this.Manager.EmployeeCodeID : (int?)null;
                assigning.OrganizationID = this.Organization.OrganizationID;
                assigning.CreatedBy      = this.LoginIdentity.EmployeeCodeID;
                this.AssigningID         = new AssigningsDAL().Insert(assigning);
                if (this.AssigningID != 0)
                {
                    result.Entity     = this;
                    result.EnumType   = typeof(AssigningsValidationEnum);
                    result.EnumMember = AssigningsValidationEnum.Done.ToString();
                }
                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }