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 Company [Serializable] public class Company : BasicBaseObject { #region Cache Store private static Cache _cache = new Cache(typeof(Company)); #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 Company() { _code = string.Empty; _name = string.Empty; _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 Service Factory ICompanyService : ICompanyService internal static ICompanyService Service { get { return Services.Factory.CreateService(typeof(ICompanyService)); } } #endregion #endregion #region Functions public static Company Get(ID nID) { Company oCompany = null; #region Cache Header oCompany = (Company)_cache["Get", nID]; if (oCompany != null) return oCompany; #endregion oCompany = Company.Service.Get(nID); #region Cache Footer _cache.Add(oCompany, "Get", nID); #endregion return oCompany; } public static ObjectsTemplate Get(EnumStatus status) { #region Cache Header ObjectsTemplate Companys = _cache["Get", status] as ObjectsTemplate; if (Companys != null) return Companys; #endregion try { Companys = Service.Get(status); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(Companys, "Get", status); #endregion return Companys; } //#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 ID Save() { base.SetAuditTrailProperties(); return Company.Service.Save(this); } public void Delete(ID id) { Company.Service.Delete(id); } #endregion } #endregion #region ICompany Service public interface ICompanyService { Company Get(ID id); ObjectsTemplate Get(EnumStatus status); ID Save(Company item); void Delete(ID id); } #endregion }