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; namespace Payroll.BO { [Serializable] public class DolarRate:AuditTrailBase { #region Cache Store private static Cache _cache = new Cache(typeof(DolarRate)); #endregion #region Constructor #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 public DolarRate() { _monthDate = DateTime.MinValue; _rate = 0; _amount = 0; _dAPACode = string.Empty; _dDescription = string.Empty; _dAccountNo = string.Empty; _cAPACode = string.Empty; _cDescription = string.Empty; _cAccountNo = string.Empty; _HBInterestRate = 0; _PersonalInterestRate = 0; _VehicleInterestRate = 0; } #endregion #region Properties #region HBInterestRate : double private double _HBInterestRate; public double HBInterestRate { get { return _HBInterestRate; } set { base.OnPropertyChange("HBInterestRate", _HBInterestRate, value); _HBInterestRate = value; } } #endregion #region PersonalInterestRate : double private double _PersonalInterestRate; public double PersonalInterestRate { get { return _PersonalInterestRate; } set { base.OnPropertyChange("PersonalInterestRate", _PersonalInterestRate, value); _PersonalInterestRate = value; } } #endregion #region VehicleInterestRate : double private double _VehicleInterestRate; public double VehicleInterestRate { get { return _VehicleInterestRate; } set { base.OnPropertyChange("VehicleInterestRate", _VehicleInterestRate, value); _VehicleInterestRate = value; } } #endregion #region MonthDate : DateTime private DateTime _monthDate; public DateTime MonthDate { get { return _monthDate; } set { base.OnPropertyChange("monthDate", _monthDate, value); _monthDate = value; } } #endregion #region Rate : double private double _rate; public double Rate { get { return _rate; } set { base.OnPropertyChange("Rate", _rate, value); _rate = value; } } #endregion #region Amount : double private double _amount; public double Amount { get { return _amount; } set { base.OnPropertyChange("Amount", _amount, value); _amount = value; } } #endregion #region DAPACode : string private string _dAPACode; public string DAPACode { get { return _dAPACode; } set { base.OnPropertyChange("DAPACode", _dAPACode, value); _dAPACode = value; } } #endregion #region DDescription : string private string _dDescription; public string DDescription { get { return _dDescription; } set { base.OnPropertyChange("DDescription", _dDescription, value); _dDescription = value; } } #endregion #region DAccountNo : string private string _dAccountNo; public string DAccountNo { get { return _dAccountNo; } set { base.OnPropertyChange("DAccountNo", _dAccountNo, value); _dAccountNo = value; } } #endregion #region CAPACode : string private string _cAPACode; public string CAPACode { get { return _cAPACode; } set { base.OnPropertyChange("CAPACode", _cAPACode, value); _cAPACode = value; } } #endregion #region CDescription : string private string _cDescription; public string CDescription { get { return _cDescription; } set { base.OnPropertyChange("CDescription", _cDescription, value); _cDescription = value; } } #endregion #region CAccountNo : string private string _cAccountNo; public string CAccountNo { get { return _cAccountNo; } set { base.OnPropertyChange("CAccountNo", _cAccountNo, value); _cAccountNo = value; } } #endregion #region Service Factory IPFTransactionService : IPFTransactionService internal static IDolarRateService Service { get { return Services.Factory.CreateService(typeof(IDolarRateService)); } } #endregion #endregion #region Functions public DolarRate Get(DateTime dMonthDate) { DolarRate oDolarRate = null; #region Cache Header oDolarRate = (DolarRate)_cache["Get", dMonthDate]; if (oDolarRate != null) return oDolarRate; #endregion oDolarRate = DolarRate.Service.Get(dMonthDate); #region Cache Footer _cache.Add(oDolarRate, "Get", dMonthDate); #endregion return oDolarRate; } public static ObjectsTemplate Get() { #region cache header ObjectsTemplate DolarRates = _cache["Get"] as ObjectsTemplate; if (DolarRates != null) return DolarRates; #endregion try { DolarRates = Service.Get(); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region cache footer _cache.Add(DolarRates, "Get"); #endregion return DolarRates; } public static ObjectsTemplate GetLastSixMonth() { #region cache header ObjectsTemplate DolarRates = _cache["GetLastSixMonth"] as ObjectsTemplate; if (DolarRates != null) return DolarRates; #endregion try { DolarRates = Service.GetLastSixMonth(); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region cache footer _cache.Add(DolarRates, "GetLastSixMonth"); #endregion return DolarRates; } //public static ObjectsTemplate GetByCategory(ID categoryID) // { // #region Cache Header // ObjectsTemplate DolarRates = _cache["Get", categoryID] as ObjectsTemplate; // if (DolarRates != null) // return DolarRates; // #endregion // try // { // DolarRates = Service.GetByCategory(categoryID); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // #region Cache Footer // _cache.Add(DolarRates, "Get", categoryID); // #endregion // return DolarRates; // } //public bool IsTagged() //{ // if (this.IsNew || this.ID.IsUnassigned) // return false; // return Service.IsTagged(this.ID); //} public void Save() { base.SetAuditTrailProperties(); DolarRate.Service.Save(this); } public void Delete(DateTime dMonthDate) { DolarRate.Service.Delete(dMonthDate); } public void Delete() { DolarRate.Service.Delete(ID); } #endregion } #region IDolarRate Service public interface IDolarRateService { DolarRate Get(DateTime dMonthDate); ObjectsTemplate Get(); ObjectsTemplate GetLastSixMonth(); //ObjectsTemplate GetByCategory(ID categoryID); void Save(DolarRate item); void Delete(DateTime dMonthDate); void Delete(ID ID); } #endregion }