private Result ApproveOverTime(OverTimesBLL OverTimeBll, bool IsApprove) { try { Result result = new Result(); //OverTimes overTime = new OverTimesDAL().GetByOverTimeID(OverTimeBll.OverTimeID); // if (OverTimeBll.IsApproved && IsApprove) { result.Entity = OverTimeBll; result.EnumType = typeof(OverTimeValidationEnum); result.EnumMember = OverTimeValidationEnum.RejectedBecauseOfAlreadyApprove.ToString(); return(result); } // if (!OverTimeBll.IsApproved && !IsApprove) { result.Entity = this; result.EnumType = typeof(OverTimeValidationEnum); result.EnumMember = OverTimeValidationEnum.RejectedBecauseOfAlreadyApproveCancel.ToString(); return(result); } OverTimes overTime = new OverTimes(); overTime.IsApproved = IsApprove; overTime.OverTimeID = OverTimeBll.OverTimeID; overTime.OverTimeStartDate = OverTimeBll.OverTimeStartDate; if (IsApprove) { overTime.ApprovedBy = OverTimeBll.ApprovedBy; overTime.ApprovedDate = DateTime.Now; overTime.LastUpdatedBy = OverTimeBll.ApprovedBy; OverTimeBll.OverTimesDetails = new OverTimesDetailsBLL().GetOverTimeDetailsByOverTimeID(OverTimeBll.OverTimeID); //overTime.OverTimesDetails.Select(x => new OverTimesDetailsBLL().MapOverTimeDetail(x)).ToList();// new DelegationsDetailsBLL().MapDelegationDetail(Delegation.DelegationsDetails); } else { OverTimeBll.OverTimesDetails = new OverTimesDetailsBLL().GetOverTimeDetailsByOverTimeID(OverTimeBll.OverTimeID);// new DelegationsDetailsBLL().MapDelegationDetail(Delegation.DelegationsDetails); overTime.LastUpdatedBy = OverTimeBll.ApprovedBy; overTime.ApprovedBy = null; overTime.ApprovedDate = null; } new OverTimesDAL().Approve(overTime); //send SMS message. SendSMS(OverTimeBll); if (OverTimeBll.OverTimeID != 0) { result.Entity = this; result.EnumType = typeof(OverTimeValidationEnum); result.EnumMember = OverTimeValidationEnum.Done.ToString(); } return(result); } catch { throw; } }
public OverTimesBLL GetByOverTimeID(int OverTimeID) { OverTimesBLL OverTimesBLL = null; OverTimes OverTime = new OverTimesDAL().GetByOverTimeID(OverTimeID); if (OverTime != null) { OverTimesBLL = new OverTimesBLL().MapOverTime(OverTime); } return(OverTimesBLL); }
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); } } }
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); }
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); }
internal OverTimesBLL MapOverTime(OverTimes OverTime) { try { OverTimesBLL OverTimeBLL = null; if (OverTime != null) { OverTimeBLL = new OverTimesBLL() { OverTimeID = OverTime.OverTimeID, OverTimeStartDate = OverTime.OverTimeStartDate, OverTimeEndDate = OverTime.OverTimeEndDate, Tasks = OverTime.Tasks, WeekWorkHoursAvg = OverTime.WeekWorkHoursAvg, FridayHoursAvg = OverTime.FridayHoursAvg.HasValue ? OverTime.FridayHoursAvg.Value : 0, SaturdayHoursAvg = OverTime.SaturdayHoursAvg.HasValue ? OverTime.SaturdayHoursAvg.Value : 0, Requester = OverTime.Requester, CreatedBy = new EmployeesCodesBLL().MapEmployeeCode(OverTime.CreatedByNav), CreatedDate = OverTime.CreatedDate, IsApproved = OverTime.IsApproved, ApprovedBy = OverTime.ApprovedBy, ApprovedDate = OverTime.ApprovedDate }; OverTimeBLL.OverTimesDays = new List <OverTimesDaysBLL>(); OverTime.OverTimesDays.ToList().ForEach(c => OverTimeBLL.OverTimesDays.Add(new OverTimesDaysBLL() { OverTimeDay = c.OverTimeDay, OverTimeDayID = c.OverTimeDayID })); } return(OverTimeBLL); } catch { throw; } }
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); }