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; using System.Data; namespace Payroll.BO { #region Category [Serializable] public class Category : BasicBaseObject { #region Cache Store private static Cache _cache = new Cache(typeof(Category)); #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 Category() { _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 WageType : Enum private EnumWagesType _wagesType; public EnumWagesType WagesType { get { return _wagesType; } set { base.OnPropertyChange("WagesType", (short)_wagesType, (short)value); _wagesType = value; } } #endregion #region Service Factory ICategoryService : ICategoryService internal static ICategoryService Service { get { return Services.Factory.CreateService(typeof(ICategoryService)); } } #endregion #endregion #region Functions public string GetNextCode() { return Category.Service.GetNextCode(); } public Category Get(ID nID) { Category oCategory = null; #region Cache Header oCategory = (Category)_cache["Get", ID]; if (oCategory != null) return oCategory; #endregion oCategory = Category.Service.Get(nID); #region Cache Footer _cache.Add(oCategory, "Get", ID); #endregion return oCategory; } public static ObjectsTemplate Get() { #region cache header ObjectsTemplate categorys = _cache["Get"] as ObjectsTemplate; if (categorys != null) return categorys; #endregion try { categorys = Service.Get(); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region cache footer _cache.Add(categorys, "Get"); #endregion return categorys; } public static ObjectsTemplate Get(EnumStatus status) { #region Cache Header ObjectsTemplate categorys = _cache["Get",status] as ObjectsTemplate; if (categorys != null) return categorys; #endregion try { categorys = Service.Get(status); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(categorys, "Get",status); #endregion return categorys; } //#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 Category.Service.Save(this); } public void Delete(ID id) { Category.Service.Delete(id); } public static DataSet GetAgeRange(int fromyear,int toyear) { DataSet ds = null; try { ds = Service.GetAgeRange(fromyear, toyear); } catch (Exception e) { throw new Exception(e.Message, e); } return ds; } #endregion } #endregion #region ICategory Service public interface ICategoryService { Category Get(ID id); ObjectsTemplate Get(); ObjectsTemplate Get(EnumStatus status); ID Save(Category item); void Delete(ID id); string GetNextCode(); DataSet GetAgeRange(int fromyear,int toyear); } #endregion }