using System; using System.Collections.Generic; using System.Linq; using System.Text; using Ease.CoreV35; using Ease.CoreV35.Model; using Ease.CoreV35.Caching; using System.Data.Linq.Mapping; using System.Data; namespace Payroll.BO { #region AllowanceDeduction [Serializable] public class AllowanceDeduction : BasicBaseObject { #region Cache Store private static Cache _cache = new Cache(typeof(AllowanceDeduction)); #endregion #region Constructor public AllowanceDeduction() { _code = string.Empty; _name = string.Empty; _allowOrDeductType = EnumAllowOrDeduct.Allowance; _status = EnumStatus.Active; } #endregion #region Input validator public string[] InputValidator() { string[] sErrorString = new string[2]; if (this.Code == "") { sErrorString[0] = "Code can not be empty"; sErrorString[1] = "Code"; return sErrorString; } if (this.Name == "") { sErrorString[0] = "Description can not be empty"; sErrorString[1] = "Description"; return sErrorString; } sErrorString = null; return sErrorString; } #endregion #region Properties #region code : string private string _code; public string Code { get { return _code; } set { base.OnPropertyChange("code", _code, value); _code = value; } } #endregion #region name : string private string _name; public string Name { get { return _name; } set { base.OnPropertyChange("name", _name, value); _name = value; } } #endregion #region allowOrDeductType : EnumAllowanceOrDeduction private EnumAllowOrDeduct _allowOrDeductType; public EnumAllowOrDeduct AllowOrDeductType { get { return _allowOrDeductType; } set { base.OnPropertyChange("allowOrDeductType", (short)_allowOrDeductType, (short)value); _allowOrDeductType = value; } } #region Property Error List: DataUpload private ObjectsTemplate _errorList; public ObjectsTemplate ErrorList { get { return _errorList; } set { _errorList = value; } } #endregion #endregion #region Service Factory IAllowanceDeductionService : IAllowanceDeductionService internal static IAllowanceDeductionService Service { get { return Services.Factory.CreateService(typeof(IAllowanceDeductionService)); } } #endregion #endregion #region Functions public static AllowanceDeduction Get(ID nID) { AllowanceDeduction oAllowanceDeduction = null; #region Cache Header oAllowanceDeduction = (AllowanceDeduction)_cache["Get", nID]; if (oAllowanceDeduction != null) return oAllowanceDeduction; #endregion oAllowanceDeduction = AllowanceDeduction.Service.Get(nID); #region Cache Footer _cache.Add(oAllowanceDeduction, "Get", nID); #endregion return oAllowanceDeduction; } public static ObjectsTemplate Get(EnumStatus status) { #region Cache Header ObjectsTemplate allowanceDeductions = _cache["Get"] as ObjectsTemplate; if (allowanceDeductions != null) return allowanceDeductions; #endregion try { allowanceDeductions = Service.Get(status); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(allowanceDeductions, "Get",status); #endregion return allowanceDeductions; } public static ObjectsTemplate GetByGradeID(EnumStatus status, ID gradeID, EnumAllowOrDeduct type) { #region Cache Header ObjectsTemplate allowanceDeductions = _cache["GetByGradeID", status, gradeID, type] as ObjectsTemplate; if (allowanceDeductions != null) return allowanceDeductions; #endregion try { allowanceDeductions = Service.GetByGradeID(status, gradeID, type); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(allowanceDeductions, "GetByGradeID", status, gradeID, type); #endregion return allowanceDeductions; } public static ObjectsTemplate GetAllowance(EnumStatus status) { #region Cache Header ObjectsTemplate allowanceDeductions = _cache["Get",status] as ObjectsTemplate; if (allowanceDeductions != null) return allowanceDeductions; #endregion try { allowanceDeductions = Service.GetAllowance(status); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(allowanceDeductions, "Get",status); #endregion return allowanceDeductions; } public static ObjectsTemplate GetAllowance(EnumPeriodicity periodicity, EnumAllowOrDeduct allowOrdeduct) { #region Cache Header ObjectsTemplate allowanceDeductions = _cache["Get", periodicity, allowOrdeduct] as ObjectsTemplate; if (allowanceDeductions != null) return allowanceDeductions; #endregion try { allowanceDeductions = Service.GetAllowance(periodicity, allowOrdeduct); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(allowanceDeductions, "Get", periodicity, allowOrdeduct); #endregion return allowanceDeductions; } public static ObjectsTemplate GetAllowance(EnumPeriodicity enumPeriodicity, EnumEntitleType enumEntitleType, EnumAllowOrDeduct enumAllowOrDeduct) { #region Cache Header ObjectsTemplate allowanceDeductions = _cache["GetAllowance", enumPeriodicity, enumEntitleType, enumAllowOrDeduct] as ObjectsTemplate; if (allowanceDeductions != null) return allowanceDeductions; #endregion try { allowanceDeductions = Service.GetAllowance(enumPeriodicity, enumEntitleType, enumAllowOrDeduct); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(allowanceDeductions, "GetAllowance", enumPeriodicity, enumEntitleType, enumAllowOrDeduct); #endregion return allowanceDeductions; } public static ObjectsTemplate GetDeduction(EnumStatus status) { #region Cache Header ObjectsTemplate allowanceDeductions = _cache["Get",status] as ObjectsTemplate; if (allowanceDeductions != null) return allowanceDeductions; #endregion try { allowanceDeductions = Service.GetDeduction(status); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(allowanceDeductions, "Get", status); #endregion return allowanceDeductions; } public static ObjectsTemplate Get(EnumStatus status, EnumAllowOrDeduct nType, EnumPeriodicity nPeriodcity) { #region Cache Header ObjectsTemplate allowanceDeductions = _cache["Get", status,nType,nPeriodcity] as ObjectsTemplate; if (allowanceDeductions != null) return allowanceDeductions; #endregion try { allowanceDeductions = Service.Get(status,nType,nPeriodcity); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(allowanceDeductions, "Get", status,nType,nPeriodcity); #endregion return allowanceDeductions; } public static ObjectsTemplate Get(EnumStatus status, EnumAllowOrDeduct nType) { #region Cache Header ObjectsTemplate allowanceDeductions = _cache["Get", status, nType] as ObjectsTemplate; if (allowanceDeductions != null) return allowanceDeductions; #endregion try { allowanceDeductions = Service.Get(status, nType); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(allowanceDeductions, "Get", status, nType); #endregion return allowanceDeductions; } public ID Save() { this.SetAuditTrailProperties(); return AllowanceDeduction.Service.Save(this); } public void Delete(ID id) { AllowanceDeduction.Service.Delete(id); } public string GetNextCode() { return AllowanceDeduction.Service.GetNextCode(); } public static DataSet GetEmpAllowDeduc(DateTime dEffectDate, ID AllowDeducID) { DataSet ds = null; try { ds = Service.GetEmpAllowDeduc(dEffectDate, AllowDeducID, SystemInformation.CurrentSysInfo.PayrollTypeID); } catch (Exception e) { throw new Exception(e.Message, e); } return ds; } public static DataSet GetEmpAllowDeduc2(DateTime dEffectDate, DateTime dEffectDate2, ID AllowDeducID) { DataSet ds = null; try { ds = Service.GetEmpAllowDeduc2(dEffectDate, dEffectDate2, AllowDeducID, SystemInformation.CurrentSysInfo.PayrollTypeID); } catch (Exception e) { throw new Exception(e.Message, e); } return ds; } #endregion } #endregion #region IAllowanceDeduction Service public interface IAllowanceDeductionService { AllowanceDeduction Get(ID id); ObjectsTemplate Get(EnumStatus status); ObjectsTemplate GetAllowance(EnumStatus status); ObjectsTemplate GetAllowance(EnumPeriodicity periodicity,EnumAllowOrDeduct allowOrdeduct); ObjectsTemplate GetDeduction(EnumStatus status); ObjectsTemplate Get(EnumStatus status, EnumAllowOrDeduct nType, EnumPeriodicity nPeriodcity); string GetNextCode(); ID Save(AllowanceDeduction item); ObjectsTemplate GetByGradeID(EnumStatus status, ID gradeID, EnumAllowOrDeduct type); void Delete(ID id); DataSet GetEmpAllowDeduc(DateTime dEffectDate, ID AllowDeducID, ID PayrolltypeID); DataSet GetEmpAllowDeduc2(DateTime dEffectDate, DateTime dEffectDate2, ID AllowDeducID, ID PayrolltypeID); ObjectsTemplate Get(EnumStatus status, EnumAllowOrDeduct nType); ObjectsTemplate GetAllowance(EnumPeriodicity enumPeriodicity, EnumEntitleType enumEntitleType, EnumAllowOrDeduct enumAllowOrDeduct); } #endregion }