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 Division [Serializable] public class Division : BasicBaseObject { #region Cache Store private static Cache _cache = new Cache(typeof(Division)); #endregion #region constructor public Division() { _code = string.Empty; _name = string.Empty; _status = EnumStatus.Active; } #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] = "Name can not be empty"; sErrorString[1] = "Name"; return sErrorString; } sErrorString = null; return sErrorString; } #endregion #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", _code, value); _name = value; } } #endregion #region Service Factory IDivisionService : IDivisionService internal static IDivisionService Service { get { return Services.Factory.CreateService(typeof(IDivisionService)); } } #endregion #endregion #region Function public static Division Get(ID nID) { Division oDivision = null; #region Cache Header oDivision = (Division)_cache["Get", nID]; if (oDivision != null) return oDivision; #endregion oDivision = Division.Service.Get(nID); #region Cache Footer _cache.Add(oDivision, "Get", nID); #endregion return oDivision; } public static Division Get(string sCode) { Division oDivision = null; #region Cache Header oDivision = (Division)_cache["Get", sCode]; if (oDivision != null) return oDivision; #endregion oDivision = Division.Service.Get(sCode); #region Cache Footer _cache.Add(oDivision, "Get", sCode); #endregion return oDivision; } public static ObjectsTemplate Get() { #region cache header ObjectsTemplate countries = _cache["Get"] as ObjectsTemplate; if (countries != null) return countries; #endregion try { countries = Service.Get(); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region cache footer _cache.Add(countries, "Get"); #endregion return countries; } public static ObjectsTemplate Get(EnumStatus status) { #region Cache Header ObjectsTemplate countries = _cache["Get", status] as ObjectsTemplate; if (countries != null) return countries; #endregion try { countries = Service.Get(status); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(countries, "Get", status); #endregion return countries; } public ID Save() { this.SetAuditTrailProperties(); return Division.Service.Save(this); } public void Delete(ID id) { Division.Service.Delete(id); } #endregion } #endregion #region IDivision Service public interface IDivisionService { Division Get(ID id); Division Get(string sCode); ObjectsTemplate Get(); ObjectsTemplate Get(EnumStatus status); ID Save(Division item); void Delete(ID id); } #endregion }