public virtual Result Deactivate() { try { Result result = null; #region Validation Deactivation this.IsActive = new GovernmentFundsBLL().GetByGovernmentFundID(this.GovernmentFundID).IsActive; if (this.IsActive == false) { result = new Result(); result.EnumType = typeof(GovernmentFundsValidationEnum); result.EnumMember = GovernmentFundsValidationEnum.RejectedBecauseOfAlreadyDeactivated.ToString(); return(result); } #endregion #region DeactiveDate Validation if (this.DeactiveDate < this.DeductionStartDate) { result = new Result(); result.EnumType = typeof(GovernmentFundsValidationEnum); result.EnumMember = GovernmentFundsValidationEnum.RejectedBecauseOfDeactivationDateShouldNotBeLessThanDeductionStartDate.ToString(); return(result); } #endregion GovernmentFunds GovernmentFund = new GovernmentFunds(); GovernmentFund.GovernmentFundID = this.GovernmentFundID; GovernmentFund.LetterDate = this.LetterDate; GovernmentFund.LetterNo = this.LetterNo; GovernmentFund.Notes = this.Notes; GovernmentFund.DeactiveDate = this.DeactiveDate; GovernmentFund.IsActive = false; GovernmentFund.LastUpdatedDate = DateTime.Now; GovernmentFund.LastUpdatedBy = this.LoginIdentity.EmployeeCodeID; GovernmentFund.GovernmentFundDeactiveReasonID = this.GovernmentFundDeactiveReason.GovernmentFundDeactiveReasonID; int UpdateResult = new GovernmentFundsDAL().Deactivate(GovernmentFund); if (UpdateResult != 0) { result = new Result(); result.Entity = this; result.EnumType = typeof(GovernmentFundsValidationEnum); result.EnumMember = GovernmentFundsValidationEnum.Done.ToString(); } return(result); } catch { throw; } }
internal GovernmentFundsBLL MapGovernmentFund(GovernmentFunds GovernmentFund) { try { GovernmentFundsBLL GovernmentFundBLL = null; if (GovernmentFund != null) { GovernmentFundBLL = new GovernmentFundsBLL() { GovernmentFundID = GovernmentFund.GovernmentFundID, EmployeeCode = new EmployeesCodesBLL().MapEmployeeCode(GovernmentFund.EmployeesCodes), GovernmentFundType = new GovernmentFundsTypesBLL().MapGovernmentFundsTypes(GovernmentFund.GovernmentFundsTypes), GovernmentDeductionType = new GovernmentDeductionsTypesBLL().MapGovernmentDeductionsTypesBLL(GovernmentFund.GovernmentDeductionsTypes), LoanNo = GovernmentFund.LoanNo, LoanDate = GovernmentFund.LoanDate.Value, MonthlyDeductionAmount = GovernmentFund.MonthlyDeductionAmount, TotalDeductionAmount = GovernmentFund.TotalDeductionAmount, DeductionStartDate = GovernmentFund.DeductionStartDate, IsActive = GovernmentFund.IsActive, LetterDate = GovernmentFund.LetterDate, DeactiveDate = GovernmentFund.DeactiveDate, GovernmentFundDeactiveReason = new GovernmentFundsDeactiveReasonsBLL().MapGovernmentFundsDeactiveReasonsBLL(GovernmentFund.GovernmentFundsDeactiveReasons), LetterNo = GovernmentFund.LetterNo, Notes = GovernmentFund.Notes, ContractNo = GovernmentFund.ContractNo, BankIPAN = GovernmentFund.BankIPAN, KSACity = new KSACitiesBLL().MapKSACity(GovernmentFund.KSACities), SponserToIDNo = GovernmentFund.SponserToIDNo, SponserToName = GovernmentFund.SponserToName, CreatedDate = GovernmentFund.CreatedDate, CreatedBy = new EmployeesCodesBLL().MapEmployeeCode(GovernmentFund.CreatedByNav) }; } return(GovernmentFundBLL); } catch { throw; } }
public virtual Result Update() { try { Result result = null; #region Validation for vacation creation during probation period EmployeesCareersHistoryBLL HiringRecord = new EmployeesCareersHistoryBLL().GetHiringRecordByEmployeeCodeID(this.EmployeeCode.EmployeeCodeID); if (HiringRecord != null) { // probation period = hiring date + 1 year DateTime ProbationEndDate = HiringRecord.ProbationEndDate;//.JoinDate.AddYears(1).AddDays(-10); if (ProbationEndDate > this.DeductionStartDate) { result = new Result(); result.Entity = HiringRecord; result.EnumType = typeof(GovernmentFundsValidationEnum); result.EnumMember = GovernmentFundsValidationEnum.RejectedBecauseOfBeforeHiringDate.ToString(); return(result); } } #endregion #region Validation Loan Ammount if (this.MonthlyDeductionAmount > this.TotalDeductionAmount) { result = new Result(); result.Entity = HiringRecord; result.EnumType = typeof(GovernmentFundsValidationEnum); result.EnumMember = GovernmentFundsValidationEnum.RejectedBecauseOfMonthlyDeductionAmountShouldNotGreaterThanTotalDeductionAmount.ToString(); return(result); } #endregion #region Validation Deactivation this.IsActive = new GovernmentFundsBLL().GetByGovernmentFundID(this.GovernmentFundID).IsActive; if (this.IsActive == false) { result = new Result(); result.EnumType = typeof(GovernmentFundsValidationEnum); result.EnumMember = GovernmentFundsValidationEnum.RejectedBecauseOfAlreadyDeactivated.ToString(); return(result); } #endregion GovernmentFunds GovernmentFund = new GovernmentFunds(); GovernmentFund.GovernmentFundID = this.GovernmentFundID; GovernmentFund.EmployeeCodeID = this.EmployeeCode.EmployeeCodeID; GovernmentFund.GovernmentDeductionTypeID = this.GovernmentDeductionType.GovernmentDeductionTypeID; GovernmentFund.GovernmentFundTypeID = this.GovernmentFundType.GovernmentFundTypeID; GovernmentFund.LoanNo = this.LoanNo; GovernmentFund.LoanDate = this.LoanDate; GovernmentFund.DeductionStartDate = this.DeductionStartDate; GovernmentFund.MonthlyDeductionAmount = this.MonthlyDeductionAmount; GovernmentFund.TotalDeductionAmount = this.TotalDeductionAmount; GovernmentFund.SponserToIDNo = this.GovernmentDeductionType.GovernmentDeductionTypeID == Convert.ToInt16(GovernmentDeductionsTypesEnum.Sponser) ? this.SponserToIDNo : null; GovernmentFund.SponserToName = this.GovernmentDeductionType.GovernmentDeductionTypeID == Convert.ToInt16(GovernmentDeductionsTypesEnum.Sponser) ? this.SponserToName : null; GovernmentFund.ContractNo = this.ContractNo; GovernmentFund.BankIPAN = this.BankIPAN; GovernmentFund.KSACityID = this.KSACity.KSACityID; GovernmentFund.LastUpdatedDate = DateTime.Now; GovernmentFund.LastUpdatedBy = this.LoginIdentity.EmployeeCodeID; int UpdateResult = new GovernmentFundsDAL().Update(GovernmentFund); if (UpdateResult != 0) { result = new Result(); result.Entity = this; result.EnumType = typeof(GovernmentFundsValidationEnum); result.EnumMember = GovernmentFundsValidationEnum.Done.ToString(); } return(result); } catch { throw; } }