using System; using System.Collections.Generic; using System.Linq; using System.Text; using Ease.CoreV35.Caching; using Ease.CoreV35.Model; namespace Payroll.BO { #region BuyerSetup [Serializable] public class BuyerSetup : BasicBaseObject { #region Cache Store private static Cache _cache = new Cache(typeof(BuyerSetup)); #endregion #region Constructor public BuyerSetup() { _name = string.Empty; _IsCurrent = false; _acceptHour = 0; _isHolidayOTAllowed = false; _maxHolidayOTHour = 0; _maxHDInMonth = 0; } #endregion #region Properties #region Name : string private string _name; public string Name { get { return _name; } set { base.OnPropertyChange("Name", _name, value); _name = value; } } #endregion #region AcceptHour : double private double _acceptHour; public double AcceptHour { get { return _acceptHour; } set { base.OnPropertyChange("AcceptHour", _acceptHour, value); _acceptHour = value; } } #endregion #region IsCurrent : bool private bool _IsCurrent; public bool IsCurrent { get { return _IsCurrent; } set { base.OnPropertyChange("IsCurrent", _IsCurrent, value); _IsCurrent = value; } } #endregion #region IsHolidayOTAllowed : bool private bool _isHolidayOTAllowed; public bool IsHolidayOTAllowed { get { return _isHolidayOTAllowed; } set { base.OnPropertyChange("IsHolidayOTAllowed", _isHolidayOTAllowed, value); _isHolidayOTAllowed = value; } } #endregion #region MaxHolidayOTHour : double private double _maxHolidayOTHour; public double MaxHolidayOTHour { get { return _maxHolidayOTHour; } set { base.OnPropertyChange("MaxHolidayOTHour", _maxHolidayOTHour, value); _maxHolidayOTHour = value; } } #endregion #region MaxHDInMonth : int private double _maxHDInMonth; public double MaxHDInMonth { get { return _maxHDInMonth; } set { base.OnPropertyChange("MaxHDInMonth", _maxHDInMonth, value); _maxHDInMonth = value; } } #endregion #region Service Factory IBuyerSetupService : IBuyerSetupService internal static IBuyerSetupService Service { get { return Services.Factory.CreateService(typeof(IBuyerSetupService)); } } #endregion #endregion #region Functions public static BuyerSetup Get(ID nID) { BuyerSetup oBuyerSetup = null; #region Cache Header oBuyerSetup = (BuyerSetup)_cache["Get", nID]; if (oBuyerSetup != null) return oBuyerSetup; #endregion oBuyerSetup = BuyerSetup.Service.Get(nID); #region Cache Footer _cache.Add(oBuyerSetup, "Get", nID); #endregion return oBuyerSetup; } public static BuyerSetup GetCurrentBuyer() { BuyerSetup oBuyerSetup = null; #region Cache Header oBuyerSetup = (BuyerSetup)_cache["Get"]; if (oBuyerSetup != null) return oBuyerSetup; #endregion oBuyerSetup = BuyerSetup.Service.GetCurrentBuyer(); #region Cache Footer _cache.Add(oBuyerSetup, "Get"); #endregion return oBuyerSetup; } public ID Save() { if (this.IsNew) { this.Status = EnumStatus.Active; } this.SetAuditTrailProperties(); return BuyerSetup.Service.Save(this); } public void Delete() { BuyerSetup.Service.Delete(ID); } public static ObjectsTemplate Get() { #region Cache Header ObjectsTemplate buyerSetups = _cache["Get"] as ObjectsTemplate; if (buyerSetups != null) return buyerSetups; #endregion try { buyerSetups = Service.Get(); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(buyerSetups, "Get"); #endregion return buyerSetups; } #endregion } #endregion #region IBuyerSetup Service public interface IBuyerSetupService { BuyerSetup Get(ID id); ObjectsTemplate Get(); ID Save(BuyerSetup item); void Delete(ID id); BuyerSetup GetCurrentBuyer(); } #endregion }