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 Designation [Serializable] public class Designation : BasicBaseObject { #region Cache Store private static Cache _cache = new Cache(typeof(Designation)); #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 Designation() { _gradeID = null; _code = string.Empty; _name = string.Empty; _status = EnumStatus.Active; } #endregion #region Properties #region GradeID : ID private ID _gradeID; public ID GradeID { get { return _gradeID; } set { base.OnPropertyChange("GradeID", _gradeID, value); _gradeID = value; } } #endregion #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 SapDesCodes : ObjectsTemplate private ObjectsTemplate _sapDesCodes; public ObjectsTemplate SapDesCodes { get { return _sapDesCodes; } set { _sapDesCodes = value; } } #endregion #region Service Factory IDesignationService : IDesignationService internal static IDesignationService Service { get { return Services.Factory.CreateService(typeof(IDesignationService)); } } #endregion #endregion #region Functions public string GetNextCode() { return Designation.Service.GetNextCode(); } public static Designation Get(ID nID) { Designation oDesignation = null; #region Cache Header oDesignation = (Designation)_cache["Get", nID]; if (oDesignation != null) return oDesignation; #endregion oDesignation = Designation.Service.Get(nID); #region Cache Footer _cache.Add(oDesignation, "Get", nID); #endregion return oDesignation; } public static Designation Get(string sCode) { Designation oDesignation = null; #region Cache Header oDesignation = (Designation)_cache["Get", sCode]; if (oDesignation != null) return oDesignation; #endregion oDesignation = Designation.Service.Get(sCode); #region Cache Footer _cache.Add(oDesignation, "Get", sCode); #endregion return oDesignation; } public static ObjectsTemplate Get(EnumStatus status) { #region Cache Header ObjectsTemplate designations = _cache["Get",status] as ObjectsTemplate; if (designations != null) return designations; #endregion try { designations = Service.Get(status); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(designations, "Get",status); #endregion return designations; } public static ObjectsTemplate GetWithSapCode(EnumStatus status) { #region Cache Header ObjectsTemplate designations = _cache["Get", status] as ObjectsTemplate; if (designations != null) return designations; #endregion try { designations = Service.GetWithSapCodes(status); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(designations, "Get", status); #endregion return designations; } public ID Save() { this.SetAuditTrailProperties(); return Designation.Service.Save(this); } public void Delete(ID id) { Designation.Service.Delete(id); } #endregion } #endregion #region IDesignation Service public interface IDesignationService { Designation Get(ID id); ObjectsTemplate Get(EnumStatus status); ObjectsTemplate GetWithSapCodes(EnumStatus status); ID Save(Designation item); void Delete(ID id); Designation Get(string sCode); string GetNextCode(); } #endregion }