Example #1
0
        private Result ApproveDelegation(BaseDelegationsBLL BaseDelegationBll, bool IsApprove)
        {
            try
            {
                Result result = new Result();
                // Delegations delegation = new DelegationsDAL().GetByDelegationID(BaseDelegationBll.DelegationID);
                if (BaseDelegationBll.IsApproved && IsApprove)
                {
                    result.Entity     = BaseDelegationBll;
                    result.EnumType   = typeof(DelegationsValidationEnum);
                    result.EnumMember = DelegationsValidationEnum.RejectedBecauseOfAlreadyApprove.ToString();
                    return(result);
                }
                if (!BaseDelegationBll.IsApproved && !IsApprove)
                {
                    result.Entity     = this;
                    result.EnumType   = typeof(DelegationsValidationEnum);
                    result.EnumMember = DelegationsValidationEnum.RejectedBecauseOfAlreadyApproveCancel.ToString();
                    return(result);
                }

                Delegations delegation = new Delegations();
                delegation.IsApproved          = IsApprove;
                delegation.DelegationID        = BaseDelegationBll.DelegationID;
                delegation.DelegationStartDate = BaseDelegationBll.DelegationStartDate;
                if (IsApprove)
                {
                    delegation.ApprovedBy   = BaseDelegationBll.ApprovedBy;
                    delegation.ApprovedDate = DateTime.Now;
                    BaseDelegationBll.DelegationsDetails = new DelegationsDetailsBLL().GetDelegationsDetailsByDelegationID(BaseDelegationBll.DelegationID);
                    delegation.LastUpdatedBy             = BaseDelegationBll.ApprovedBy;
                }
                else
                {
                    BaseDelegationBll.DelegationsDetails = new DelegationsDetailsBLL().GetDelegationsDetailsByDelegationID(BaseDelegationBll.DelegationID);
                    delegation.LastUpdatedBy             = BaseDelegationBll.ApprovedBy;
                    delegation.ApprovedBy   = null;
                    delegation.ApprovedDate = null;
                }
                new DelegationsDAL().Approve(delegation);
                //send SMS message.
                SendSMS(BaseDelegationBll);
                if (BaseDelegationBll.DelegationID != 0)
                {
                    result.Entity     = this;
                    result.EnumType   = typeof(DelegationsValidationEnum);
                    result.EnumMember = DelegationsValidationEnum.Done.ToString();
                }
                return(result);
            }
            catch
            {
                throw;
            }
        }
Example #2
0
        public BaseDelegationsBLL GetByDelegationID(int DelegationID)
        {
            BaseDelegationsBLL DelegationBLL = null;
            Delegations        Delegation    = new DelegationsDAL().GetByDelegationID(DelegationID);

            if (Delegation != null)
            {
                DelegationBLL = MapDelegation(Delegation);
            }
            return(DelegationBLL);
        }
Example #3
0
        private void SendSMS(ExpensesBLL Expense)
        {
            SMSLogsBLL smslog = new SMSLogsBLL()
            {
                CreatedDate = DateTime.Now,
                CreatedBy   = new EmployeesCodesBLL()
                {
                    EmployeeCodeID = Expense.ApprovedBy.Value
                }
            };


            if (this.GetType() == typeof(BaseDelegationsBLL))
            {
                BaseDelegationsBLL Delegation = (BaseDelegationsBLL)Expense;
                smslog.DetailID           = Delegation.DelegationID;
                smslog.BusinssSubCategory = BusinessSubCategoriesEnum.Delegations;
                if (!Expense.IsApproved)
                {
                    smslog.Message = string.Format(Globalization.SMSDelegationApprovalMessageText, Delegation.DelegationStartDate.ToShortDateString(), Delegation.DelegationPeriod);
                }
                else if (Expense.IsApproved)
                {
                    smslog.Message = string.Format(Globalization.SMSDelegationApprovalCancelMessageText, Delegation.DelegationStartDate.ToShortDateString(), Delegation.DelegationPeriod);
                }
                foreach (DelegationsDetailsBLL dd in Delegation.DelegationsDetails)
                {
                    smslog.MobileNo = dd.EmployeeCareerHistory.EmployeeCode.Employee.EmployeeMobileNo;
                    new SMSBLL().SendSMS(smslog);
                }
            }

            if (this.GetType() == typeof(OverTimesBLL))
            {
                OverTimesBLL OverTime = (OverTimesBLL)Expense;
                smslog.DetailID           = OverTime.OverTimeID;
                smslog.BusinssSubCategory = BusinessSubCategoriesEnum.OverTimes;
                if (!Expense.IsApproved)
                {
                    smslog.Message = string.Format(Globalization.SMSOverTimeApprovalMessageText, OverTime.OverTimeStartDate.ToShortDateString(), OverTime.OverTimePeriod);
                }
                else if (Expense.IsApproved)
                {
                    smslog.Message = string.Format(Globalization.SMSOverTimeApprovalCancelMessageText, OverTime.OverTimeStartDate.ToShortDateString(), OverTime.OverTimePeriod);
                }
                foreach (OverTimesDetailsBLL dd in OverTime.OverTimesDetails)
                {
                    smslog.MobileNo = dd.EmployeeCareerHistory.EmployeeCode.Employee.EmployeeMobileNo;
                    new SMSBLL().SendSMS(smslog);
                }
            }
        }
Example #4
0
        internal BaseDelegationsBLL MapDelegation(Delegations Delegation)
        {
            try
            {
                BaseDelegationsBLL DelegationBLL = null;
                if (Delegation != null)
                {
                    KSACitiesBLL KSACity1 = Delegation.KSACities != null ? new KSACitiesBLL().MapKSACity(Delegation.KSACities) : null;
                    CountriesBLL Country1 = Delegation.Countries != null ? new CountriesBLL().MapCountry(Delegation.Countries) : null;
                    if (Delegation.DelegationTypeID == (Int32)DelegationsTypesEnum.Internal)
                    {
                        DelegationBLL = new InternalDelegationBLL()
                        {
                            KSACity = KSACity1,
                            DelegationDestination = KSACity1.KSACityName + "-" + KSACity1.KSARegion.KSARegionName
                        };
                    }
                    else if (Delegation.DelegationTypeID == (Int32)DelegationsTypesEnum.External)
                    {
                        DelegationBLL = new ExternalDelegationBLL()
                        {
                            Country = Country1,
                            DelegationDestination = Country1.CountryName
                        };
                    }

                    DelegationBLL.DelegationID        = Delegation.DelegationID;
                    DelegationBLL.DelegationKind      = new DelegationsKindsBLL().MapDelegationKind(Delegation.DelegationsKinds);
                    DelegationBLL.DelegationType      = new DelegationsTypesBLL().MapDelegationType(Delegation.DelegationsTypes);
                    DelegationBLL.DelegationStartDate = Delegation.DelegationStartDate.Date;
                    DelegationBLL.DelegationEndDate   = Delegation.DelegationEndDate.Date;
                    DelegationBLL.DelegationReason    = Delegation.DelegationReason;
                    DelegationBLL.Notes = Delegation.Notes;
                    DelegationBLL.DelegationDistancePeriod = Delegation.DelegationDistancePeriod;
                    DelegationBLL.CreatedBy    = new EmployeesCodesBLL().MapEmployeeCode(Delegation.CreatedByNav);
                    DelegationBLL.CreatedDate  = Delegation.CreatedDate;
                    DelegationBLL.IsApproved   = Delegation.IsApproved;
                    DelegationBLL.ApprovedBy   = Delegation.ApprovedBy;
                    DelegationBLL.ApprovedDate = Delegation.ApprovedDate;
                    //DelegationBLL.LastUpdatedBy = new EmployeesCodesBLL().MapEmployeeCode(Delegation.EmployeesCodes1);
                    //DelegationBLL.LastUpdatedDate = Delegation.LastUpdatedDate;
                }
                return(DelegationBLL);
            }
            catch
            {
                throw;
            }
        }
Example #5
0
        public virtual Result ApproveCancel(int id)
        {
            Result result = null;

            if (this.GetType() == typeof(OverTimesBLL))
            {
                OverTimesBLL overTime = new OverTimesBLL().GetByOverTimeID(id);
                overTime.ApprovedBy = this.ApprovedBy;
                result = ApproveOverTime(overTime, false);
            }
            if (this.GetType() == typeof(BaseDelegationsBLL))
            {
                BaseDelegationsBLL delegation = new BaseDelegationsBLL().GetByDelegationID(id);
                delegation.ApprovedBy = this.ApprovedBy;
                result = ApproveDelegation(delegation, false);
            }
            return(result);
        }
Example #6
0
        public Result IsValid()
        {
            Result result = null;

            #region Validation for Delegation Dates
            //CultureInfo cul = Thread.CurrentThread.CurrentCulture;
            ////Thread.CurrentThread.CurrentCulture = cul;
            ////Thread.CurrentThread.CurrentUICulture = cul;
            //List<FinancialYearsBLL> FinancialYearsBLLList = new FinancialYearsBLL().GetFinancialYears();
            //if (new Globals.Calendar().IsGreg(FinancialYearsBLLList.FirstOrDefault().FinancialYearStartDate.ToString(System.Configuration.ConfigurationManager.AppSettings["DateFormat"].ToString())))
            //{
            //    FinancialYearsBLLList.ForEach(x => x.FinancialYearStartDate = Convert.ToDateTime(Globals.Calendar.GregToUmAlQura(x.FinancialYearStartDate)));
            //    FinancialYearsBLLList.ForEach(x => x.FinancialYearEndDate = Convert.ToDateTime(Globals.Calendar.GregToUmAlQura(x.FinancialYearEndDate)));
            //}

            //FinancialYearsBLL FinancialYearBLL = FinancialYearsBLLList.Where(x => this.DelegationStartDate >= x.FinancialYearStartDate && this.DelegationEndDate <= x.FinancialYearEndDate).FirstOrDefault();
            //if (FinancialYearBLL == null)
            //{
            //    FinancialYearBLL = FinancialYearsBLLList.FirstOrDefault(x => x.FinancialYearStartDate <= this.DelegationStartDate && x.FinancialYearEndDate >= this.DelegationStartDate);
            //    result.EnumType = typeof(DelegationsValidationEnum);
            //    result.EnumMember = DelegationsValidationEnum.RejectedBecauseOfDelegationDatesMustBeInSameFinancialYear.ToString();
            //    result.Entity = FinancialYearBLL;
            //    return result;
            //}

            result = ExpensesBLL.IsValidExpenseActionInSameFinancialYear(this.DelegationStartDate, this.DelegationEndDate, new BaseDelegationsBLL());
            if (result != null)
            {
                return(result);
            }
            #endregion

            #region validate for Conflict With Other Process
            result = CommonHelper.IsNoConflictWithOtherProcess(this.EmployeeCode.EmployeeCodeID, this.DelegationStartDate, this.DelegationEndDate);
            if (result != null)
            {
                return(result);
            }
            else
            {
                result = new Result();
            }
            #endregion

            #region Validation for balance
            /*  As per business no need to validate the balance if the kind is not tasks related delegation    */
            result = new Result();
            if (DelegationKindID != (int)DelegationsKindsEnum.Tasks)
            {
                result.EnumType   = typeof(DelegationsValidationEnum);
                result.EnumMember = DelegationsValidationEnum.Done.ToString();
                return(result);
            }
            else
            {
                BaseDelegationsBLL dd = new BaseDelegationsBLL()
                {
                    DelegationStartDate = this.DelegationStartDate, DelegationEndDate = this.DelegationEndDate
                };
                //bool IsValid = DelegationRemainingBalance >= DelegationEndDate.Subtract(DelegationStartDate).Days ? true : false;

                bool IsValid = DelegationRemainingBalance >= dd.DelegationPeriod ? true : false;
                if (!IsValid)
                {
                    result.EnumType   = typeof(DelegationsValidationEnum);
                    result.EnumMember = DelegationsValidationEnum.RejectedBecauseOfMaxLimit.ToString();
                }
                else
                {
                    result.EnumType   = typeof(DelegationsValidationEnum);
                    result.EnumMember = DelegationsValidationEnum.Done.ToString();
                }

                return(result);
            }
            #endregion
        }
Example #7
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);
        }