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 Class Discipline [Serializable] public class Discipline : BasicBaseObject { #region cache store private static Cache _cache = new Cache(typeof(Discipline)); #endregion #region constructor public Discipline() { _code = string.Empty; _description = string.Empty; _educationLevelID = null; _status = EnumStatus.Active; } #region input validator #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.Description == "") { sErrorString[0] = "Description can not be empty"; sErrorString[1] = "Description"; return sErrorString; } sErrorString = null; return sErrorString; } #endregion #endregion #endregion #region Internal Class public class DisciplineLevel : AuditTrailBase { #region Cache Store private static Cache _cache = new Cache(typeof(DisciplineLevel)); #endregion #region Constructor public DisciplineLevel() { _discilineID = null; _levelID = null; } #endregion #region Properties #region DiscilineID : ID private ID _discilineID; public ID DiscilineID { get { return _discilineID; } set { base.OnPropertyChange("DisciplineID", _discilineID, value); _discilineID = value; } } #endregion #region LevelID : ID private ID _levelID; public ID LevelID { get { return _levelID; } set { base.OnPropertyChange("LevelID", _levelID, value); _levelID = value; } } #endregion #endregion } #endregion #region properties #region DisciplineID : ID private ID _DisciplineID; public ID DisciplineID { get { return _DisciplineID; } set { _DisciplineID = value; } } #endregion #region code : String private string _code; public string Code { get { return _code; } set { base.OnPropertyChange("CODE", _code, value); _code = value; } } #endregion #region description : string private string _description; public string Description { get { return _description; } set { base.OnPropertyChange("DESCRIPTION", _description, value); _description = value; } } #endregion #region EducationLevelID: ID private ID _educationLevelID; public ID EducationLevelID { get { return _educationLevelID; } set { _educationLevelID = value; } } #endregion #region DisciplineLevels : DisciplineLevel private ObjectsTemplate _disciplineLevels = null; public ObjectsTemplate DisciplineLevels { get { if (_disciplineLevels == null && !this.ID.IsUnassigned && this.ID.Integer > 0) { _disciplineLevels = Discipline.GetDisplineByDID(this.ID); } return this._disciplineLevels; } set { _disciplineLevels = value; } } #endregion #region Service Factory IDisciplineService : IDisciplineService internal static IDisciplineService Service { get { return Services.Factory.CreateService(typeof(IDisciplineService)); } } #endregion #endregion #region functions public static Discipline Get(ID nID) { Discipline oDiscipline = null; #region Cache Header oDiscipline = (Discipline)_cache["Get", nID]; if (oDiscipline != null) return oDiscipline; #endregion oDiscipline = Discipline.Service.Get(nID); #region Cache Footer _cache.Add(oDiscipline, "Get", nID); #endregion return oDiscipline; } public static Discipline Get(string sCode) { Discipline oDiscipline = null; #region cache header oDiscipline = (Discipline)_cache["Get", sCode]; if (oDiscipline != null) return oDiscipline; #endregion oDiscipline = Discipline.Service.Get(sCode); #region cache footer _cache.Add(oDiscipline, "Get", sCode); #endregion return oDiscipline; } public static ObjectsTemplate Get() { #region cache header ObjectsTemplate disciplines = _cache["Get"] as ObjectsTemplate; if (disciplines != null) return disciplines; #endregion try { disciplines = Service.Get(); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region cache footer _cache.Add(disciplines, "Get"); #endregion return disciplines; } public static ObjectsTemplate Get(EnumStatus status) { #region Cache Header ObjectsTemplate disciplines = _cache["Get", status] as ObjectsTemplate; if (disciplines != null) return disciplines; #endregion try { disciplines = Service.Get(status); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(disciplines, "Get", status); #endregion return disciplines; } public static ObjectsTemplate GetDisplineByDID(ID DisID) { #region Cache Header ObjectsTemplate disciplines = _cache["GetDisplineByDID", DisID] as ObjectsTemplate; if (disciplines != null) return disciplines; #endregion try { disciplines = Service.GetDisplineByDID(DisID); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(disciplines, "GetDisplineByDID", DisID); #endregion return disciplines; } public static ObjectsTemplate GetByEducationLevel(ID levelID) { #region Cache Header ObjectsTemplate disciplines = _cache["GetByEducationLevel", levelID] as ObjectsTemplate; if (disciplines != null) return disciplines; #endregion try { disciplines = Service.GetByEducationLevel(levelID); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(disciplines, "GetByEducationLevel", levelID); #endregion return disciplines; } public static ObjectsTemplate GetDisByEducationLevel(ID levelID) { #region Cache Header ObjectsTemplate disciplines = _cache["GetDisByEducationLevel", levelID] as ObjectsTemplate; if (disciplines != null) return disciplines; #endregion try { disciplines = Service.GetDisByEducationLevel(levelID); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(disciplines, "GetDisByEducationLevel", levelID); #endregion return disciplines; } public ID Save() { this.SetAuditTrailProperties(); return Discipline.Service.Save(this); } public void Delete(ID id) { Discipline.Service.Delete(id); } #endregion } #endregion #region IDiscipline Service public interface IDisciplineService { Discipline Get(ID id); Discipline Get(string sCode); ObjectsTemplate Get(); ObjectsTemplate Get(EnumStatus status); ObjectsTemplate GetByEducationLevel(ID levelID); ID Save(Discipline item); void Delete(ID id); ObjectsTemplate GetDisplineByDID(ID DisID); ObjectsTemplate GetDisByEducationLevel(ID levelID); } #endregion }