Пример #1
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);
                }
            }
        }
Пример #2
0
        public Result IsValid()
        {
            Result result;

            //#region Validation for OverTime Dates
            //FinancialYearsBLL FinancialYearBLL = new FinancialYearsBLL().GetByFinancialYear(this.OverTimes.OverTimeFiscalYear);
            //if (FinancialYearBLL != null)
            //{
            //    if (this.OverTimes.OverTimeStartDate < FinancialYearBLL.FinancialYearStartDate && this.OverTimes.OverTimeEndDate < FinancialYearBLL.FinancialYearStartDate)
            //    {
            //        FinancialYearBLL = new FinancialYearsBLL().GetByFinancialYear(this.OverTimes.OverTimeFiscalYear - 1);
            //    }
            //    if (this.OverTimes.OverTimeStartDate < FinancialYearBLL.FinancialYearStartDate || this.OverTimes.OverTimeEndDate > FinancialYearBLL.FinancialYearEndDate)
            //    {
            //        result.EnumType = typeof(OverTimeValidationEnum);
            //        result.EnumMember = OverTimeValidationEnum.RejectedBecauseOfOverTimeDatesMustBeInSameFinancialYear.ToString();
            //        result.Entity = FinancialYearBLL;
            //        return result;
            //    }
            //}
            //#endregion


            #region Validation for OverTimes Dates
            //CultureInfo cul = Thread.CurrentThread.CurrentCulture;
            //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.OverTime.OverTimeStartDate >= x.FinancialYearStartDate && this.OverTime.OverTimeEndDate <= x.FinancialYearEndDate).FirstOrDefault();
            //if (FinancialYearBLL == null)
            //{
            //    FinancialYearBLL = FinancialYearsBLLList.FirstOrDefault(x => x.FinancialYearStartDate <= this.OverTime.OverTimeStartDate && x.FinancialYearEndDate >= this.OverTime.OverTimeEndDate);
            //    result.EnumType = typeof(OverTimeValidationEnum);
            //    result.EnumMember = OverTimeValidationEnum.RejectedBecauseOfOverTimeDatesMustBeInSameFinancialYear.ToString();
            //    result.Entity = FinancialYearBLL;
            //    return result;
            //}
            result = ExpensesBLL.IsValidExpenseActionInSameFinancialYear(this.OverTime.OverTimeStartDate, this.OverTime.OverTimeEndDate, new OverTimesBLL());
            if (result != null)
            {
                return(result);
            }
            #endregion

            /*  As per business no need to validate Trainings related delegation    */
            #region Validaion for employee Exist
            OverTimesDetails employee = new OverTimesDetailsDAL().GetOverTimesDetailsByOverTimeID(this.OverTime.OverTimeID).Where(d => d.EmployeeCareerHistoryID == this.EmployeeCareerHistory.EmployeeCareerHistoryID).FirstOrDefault();
            if (employee != null)
            {
                result.Entity     = null;
                result.EnumType   = typeof(OverTimeValidationEnum);
                result.EnumMember = OverTimeValidationEnum.RejectedBecauseAlreadyExist.ToString();

                return(result);
            }
            #endregion

            #region validate for Conflict With Other Process
            if (this.OverTime.OverTimesDays == null || this.OverTime.OverTimesDays.Count == 0)
            {
                result = CommonHelper.IsNoConflictWithOtherProcess(this.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID,
                                                                   this.OverTime.OverTimeStartDate, this.OverTime.OverTimeEndDate, BusinessSubCategoriesEnum.Vacations);
                if (result != null)
                {
                    return(result);
                }
            }
            else
            {
                foreach (var item in this.OverTime.OverTimesDays)
                {
                    result = CommonHelper.IsNoConflictWithOtherProcess(this.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID,
                                                                       item.OverTimeDay, item.OverTimeDay, BusinessSubCategoriesEnum.Vacations);
                    if (result != null)
                    {
                        return(result);
                    }
                }
            }
            #endregion

            result            = new Result();
            result.EnumType   = typeof(OverTimeValidationEnum);
            result.EnumMember = OverTimeValidationEnum.Done.ToString();

            return(result);
        }
Пример #3
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
        }
Пример #4
0
        public static Result IsValidExpenseActionInSameFinancialYear(DateTime StartDate, DateTime EndDate, ExpensesBLL Expense)
        {
            Result result = null;

            ///// this validation was stoped on 20/02/2020 with task no #93

            //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 => StartDate >= x.FinancialYearStartDate && EndDate <= x.FinancialYearEndDate).FirstOrDefault();
            //if (FinancialYearBLL == null)
            //{
            //    result = new Result();
            //    FinancialYearBLL = FinancialYearsBLLList.FirstOrDefault(x => x.FinancialYearStartDate <= StartDate && x.FinancialYearEndDate >= StartDate); // to get the start date and end date of the fainancial year
            //    result.Entity = FinancialYearBLL;
            //    if (Expense is OverTimesBLL)
            //    {
            //        result.EnumType = typeof(OverTimeValidationEnum);
            //        result.EnumMember = OverTimeValidationEnum.RejectedBecauseOfOverTimeDatesMustBeInSameFinancialYear.ToString();
            //    }
            //    else if (Expense is BaseDelegationsBLL)
            //    {
            //        result.EnumType = typeof(DelegationsValidationEnum);
            //        result.EnumMember = DelegationsValidationEnum.RejectedBecauseOfDelegationDatesMustBeInSameFinancialYear.ToString();
            //    }

            //    return result;
            //}

            return(result);
        }