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 { [Serializable] public enum EnumCarFuelAvgPayType { NONE = 0, OT = 1, Allowance = 2, Deduction = 3 } #region CarFuelItem [Serializable] public class CarFuelItem : BasicBaseObject { #region Cache Store private static Cache _cache = new Cache(typeof(CarFuelItem)); #endregion #region Constructor public CarFuelItem() { _code = string.Empty; _name = string.Empty; _CarFuelType = EnumCarFuelType.Provision; Status = EnumStatus.Active; } #endregion #region Properties #region Code private string _code; public string Code { get { return _code; } set { base.OnPropertyChange("code", _code, value); _code = value; } } #endregion #region Name private string _name; public string Name { get { return _name; } set { base.OnPropertyChange("name", _name, value); _name = value; } } #endregion #region CarFuelType private EnumCarFuelType _CarFuelType; public EnumCarFuelType CarFuelType { get { return _CarFuelType; } set { base.OnPropertyChange("CarFueltype", (short)_CarFuelType, (short)value); _CarFuelType = value; } } #endregion #region Service Factory ICarFuelItemService : ICarFuelItemService internal static ICarFuelItemService Service { get { return Services.Factory.CreateService(typeof(ICarFuelItemService)); } } #endregion #endregion #region Functions 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; } public string GetNextCode() { return CarFuelItem.Service.GetNextCode(); } public static CarFuelItem Get(ID nCarFuelItemID) { CarFuelItem oCarFuelItem = null; #region Cache Header oCarFuelItem = (CarFuelItem)_cache["Get", nCarFuelItemID]; if (oCarFuelItem != null) return oCarFuelItem; #endregion oCarFuelItem = CarFuelItem.Service.Get(nCarFuelItemID); #region Cache Footer _cache.Add(oCarFuelItem, "Get", nCarFuelItemID); #endregion return oCarFuelItem; } internal static ObjectsTemplate Get(string CarFuelID) { #region Cache Header ObjectsTemplate CarFuelitems = _cache["Get", CarFuelID] as ObjectsTemplate; if (CarFuelitems != null) return CarFuelitems; #endregion try { CarFuelitems = Service.Get(CarFuelID); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(CarFuelitems, "Get", CarFuelID); #endregion return CarFuelitems; } public static ObjectsTemplate Get() { #region Cache Header ObjectsTemplate CarFuelItems = _cache["Get"] as ObjectsTemplate; if (CarFuelItems != null) return CarFuelItems; #endregion try { CarFuelItems = Service.Get(); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(CarFuelItems, "Get"); #endregion return CarFuelItems; } public static ObjectsTemplate Get(EnumStatus status) { #region Cache Header ObjectsTemplate CarFuelitems = _cache["Get", status] as ObjectsTemplate; if (CarFuelitems != null) return CarFuelitems; #endregion try { CarFuelitems = Service.Get(status); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(CarFuelitems, "Get", status); #endregion return CarFuelitems; } public static ObjectsTemplate Get(EnumCarFuelType CarFuelType, EnumStatus status) { #region Cache Header ObjectsTemplate CarFuelitems = _cache["Get", CarFuelType, status] as ObjectsTemplate; if (CarFuelitems != null) return CarFuelitems; #endregion try { CarFuelitems = Service.Get(CarFuelType, status); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(CarFuelitems, "Get", CarFuelType, status); #endregion return CarFuelitems; } public ID Save() { this.SetAuditTrailProperties(); return CarFuelItem.Service.Save(this); } public void Delete(ID id) { if(id.Integer!=21) CarFuelItem.Service.Delete(id); } #endregion } #endregion #region ICarFuelItem Service public interface ICarFuelItemService { CarFuelItem Get(ID id); ObjectsTemplate Get(string CarFuelID); ObjectsTemplate Get(); ObjectsTemplate Get(EnumStatus status); ObjectsTemplate Get(EnumCarFuelType CarFuelType, EnumStatus status); ID Save(CarFuelItem item); string GetNextCode(); void Delete(ID id); } #endregion }