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 { #region BonusAdjustItem [Serializable] public class BonusAdjustItem : BasicBaseObject { #region Cache Store private static Cache _cache = new Cache(typeof(BonusAdjustItem)); #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 BonusAdjustItem() { _code = string.Empty; _name = string.Empty; _side = EnumSide.Deduct; _amount = 0; _status = EnumStatus.Active; } #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 Side : EnumSide private EnumSide _side; public EnumSide Side { get { return _side; } set { base.OnPropertyChange("Side", (short)_side, (short)value); _side = value; } } #endregion #region Amount : Double private double _amount; public double Amount { get { return _amount; } set { base.OnPropertyChange("Amount", _amount, value); _amount = value; } } #endregion #region Service Factory IBonusAdjustItemService : IBonusAdjustItemService internal static IBonusAdjustItemService Service { get { return Services.Factory.CreateService(typeof(IBonusAdjustItemService)); } } #endregion #endregion #region Functions public static BonusAdjustItem Get(ID nID) { BonusAdjustItem oBonusAdjustItem = null; #region Cache Header oBonusAdjustItem = (BonusAdjustItem)_cache["Get", nID]; if (oBonusAdjustItem != null) return oBonusAdjustItem; #endregion oBonusAdjustItem = BonusAdjustItem.Service.Get(nID); #region Cache Footer _cache.Add(oBonusAdjustItem, "Get", nID); #endregion return oBonusAdjustItem; } public static ObjectsTemplate Get(EnumStatus status) { #region Cache Header ObjectsTemplate bonusAdjustItems = _cache["Get",status] as ObjectsTemplate; if (bonusAdjustItems != null) return bonusAdjustItems; #endregion try { bonusAdjustItems = Service.Get(status); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(bonusAdjustItems, "Get",status); #endregion return bonusAdjustItems; } public ID Save() { this.SetAuditTrailProperties(); return BonusAdjustItem.Service.Save(this); } public void Delete(ID ID) { BonusAdjustItem.Service.Delete(ID); } #endregion } #endregion #region IBonusAdjustItem Service public interface IBonusAdjustItemService { BonusAdjustItem Get(ID id); ObjectsTemplate Get(EnumStatus status); ID Save(BonusAdjustItem item); void Delete(ID id); } #endregion }