CEL_Payroll/Payroll.BO/Attendence/BuyerSetup.cs
2024-09-17 14:30:13 +06:00

224 lines
5.3 KiB
C#

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<string>("Name", _name, value);
_name = value;
}
}
#endregion
#region AcceptHour : double
private double _acceptHour;
public double AcceptHour
{
get { return _acceptHour; }
set
{
base.OnPropertyChange<double>("AcceptHour", _acceptHour, value);
_acceptHour = value;
}
}
#endregion
#region IsCurrent : bool
private bool _IsCurrent;
public bool IsCurrent
{
get { return _IsCurrent; }
set
{
base.OnPropertyChange<bool>("IsCurrent", _IsCurrent, value);
_IsCurrent = value;
}
}
#endregion
#region IsHolidayOTAllowed : bool
private bool _isHolidayOTAllowed;
public bool IsHolidayOTAllowed
{
get { return _isHolidayOTAllowed; }
set
{
base.OnPropertyChange<bool>("IsHolidayOTAllowed", _isHolidayOTAllowed, value);
_isHolidayOTAllowed = value;
}
}
#endregion
#region MaxHolidayOTHour : double
private double _maxHolidayOTHour;
public double MaxHolidayOTHour
{
get { return _maxHolidayOTHour; }
set
{
base.OnPropertyChange<double>("MaxHolidayOTHour", _maxHolidayOTHour, value);
_maxHolidayOTHour = value;
}
}
#endregion
#region MaxHDInMonth : int
private double _maxHDInMonth;
public double MaxHDInMonth
{
get { return _maxHDInMonth; }
set
{
base.OnPropertyChange<double>("MaxHDInMonth", _maxHDInMonth, value);
_maxHDInMonth = value;
}
}
#endregion
#region Service Factory IBuyerSetupService : IBuyerSetupService
internal static IBuyerSetupService Service
{
get { return Services.Factory.CreateService<IBuyerSetupService>(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<BuyerSetup> Get()
{
#region Cache Header
ObjectsTemplate<BuyerSetup> buyerSetups = _cache["Get"] as ObjectsTemplate<BuyerSetup>;
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<BuyerSetup> Get();
ID Save(BuyerSetup item);
void Delete(ID id);
BuyerSetup GetCurrentBuyer();
}
#endregion
}