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 Term [Serializable] public class Term : BasicBaseObject { #region Cache Store private static Cache _cache = new Cache(typeof(Term)); #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 Term() { _code = string.Empty; _name = string.Empty; _termType = EnumTermType.Normal; _entityMode = EnumEntityMode.OverTime; _status = EnumStatus.Active; _maxValue = 0; _itemCode = string.Empty; _isFestival = false; } #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 TermType : EnumTermType private EnumTermType _termType; public EnumTermType TermType { get { return _termType; } set { base.OnPropertyChange("TermType", (short)_termType, (short)value); _termType = value; } } #endregion #region EntityMode : EnumEntityMode private EnumEntityMode _entityMode; public EnumEntityMode EntityMode { get { return _entityMode; } set { base.OnPropertyChange("EntityMode", (short)_entityMode, (short)value); _entityMode = value; } } #endregion #region MaxValue : double private double _maxValue; public double MaxValue { get { return _maxValue; } set { base.OnPropertyChange("MaxValue", _maxValue, value); _maxValue = value; } } #endregion #region ItemCode : string private string _itemCode; public string ItemCode { get { return _itemCode; } set { base.OnPropertyChange("ItemCode", _itemCode, value); _itemCode = value; } } #endregion #region IsFestival : bool private bool _isFestival; public bool IsFestival { get { return _isFestival; } set { base.OnPropertyChange("IsFestival", _isFestival, value); _isFestival = value; } } #endregion #region Service Factory ITermService : ITermService internal static ITermService Service { get { return Services.Factory.CreateService(typeof(ITermService)); } } #endregion #endregion #region Functions public static Term Get(ID nID) { Term oTerm = null; #region Cache Header oTerm = (Term)_cache["Get", nID]; if (oTerm != null) return oTerm; #endregion oTerm = Term.Service.Get(nID); #region Cache Footer _cache.Add(oTerm, "Get", nID); #endregion return oTerm; } public string GetNextCode() { return Term.Service.GetNextCode(); } public static ObjectsTemplate Get(EnumStatus status) { #region Cache Header ObjectsTemplate terms = _cache["Get",status] as ObjectsTemplate; if (terms != null) return terms; #endregion try { terms = Service.Get(status); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(terms, "Get",status); #endregion return terms; } public static ObjectsTemplate GetBySlabTerm(EnumTermType slabType) { #region Cache Header ObjectsTemplate terms = _cache["Get",slabType] as ObjectsTemplate; if (terms != null) return terms; #endregion try { terms = Service.GetBySlabTerm(slabType); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(terms, "Get",slabType); #endregion return terms; } public ID Save() { this.SetAuditTrailProperties(); return Term.Service.Save(this); } public void Delete(ID id) { Term.Service.Delete(id); } #endregion } #endregion #region ITerm Service public interface ITermService { Term Get(ID id); ObjectsTemplate Get(EnumStatus status); ObjectsTemplate GetBySlabTerm(EnumTermType slabType); ID Save(Term item); void Delete(ID id); string GetNextCode(); } #endregion }