CEL_Payroll/Payroll.BO/Basic/PayScale.cs

414 lines
10 KiB
C#
Raw Permalink Normal View History

2024-09-17 14:30:13 +06:00
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 PayScale
[Serializable]
public class PayScale:AuditTrailBase
{
#region Cache Store
private static Cache _cache = new Cache(typeof(PayScale));
#endregion
#region Constructor
public PayScale()
{
_gradeID = null;
_itemID = 0;
_initialAmount = 0;
_noOfStep = 0;
_effectDate = DateTime.MinValue;
_itemType = EnumPayScaleItemType.None;
}
#endregion
#region Properties
#region gradeID : ID
private ID _gradeID;
public ID GradeID
{
get { return _gradeID; }
set
{
base.OnPropertyChange<ID>("gradeID", _gradeID, value);
_gradeID = value;
}
}
#endregion
#region gradeID : ID
private Grade _grade = null;
public Grade GradeObj
{
get
{
if (_grade == null && !_gradeID.IsUnassigned && _gradeID.Integer > 0)
{
_grade = Grade.Get(_gradeID);
}
return _grade;
}
}
#endregion
#region itemID : int
private int _itemID;
public int ItemID
{
get { return _itemID; }
set
{
base.OnPropertyChange<int>("itemID", _itemID, value);
_itemID = value;
}
}
#endregion
#region initialAmount : double
private double _initialAmount;
public double InitialAmount
{
get { return _initialAmount; }
set
{
base.OnPropertyChange<double>("initialAmount", _initialAmount, value);
_initialAmount = value;
}
}
#endregion
#region initialAmount : double
private double _percentageInc;
public double IncPercentage
{
get { return _percentageInc; }
set
{
base.OnPropertyChange<double>("IncPercentage", _percentageInc, value);
_percentageInc = value;
}
}
#endregion
#region noOfStep : int
private int _noOfStep;
public int NoOfStep
{
get { return _noOfStep; }
set
{
base.OnPropertyChange<int>("noOfStep", _noOfStep, value);
_noOfStep = value;
}
}
#endregion
#region effectDate : DateTime
private DateTime _effectDate;
public DateTime EffectDate
{
get { return _effectDate; }
set
{
base.OnPropertyChange<DateTime>("effectDate", _effectDate, value);
_effectDate = value;
}
}
#endregion
#region itemType : EnumPayScaleItemType
private EnumPayScaleItemType _itemType;
public EnumPayScaleItemType ItemType
{
get { return _itemType; }
set
{
base.OnPropertyChange<short>("itemType", (short)_itemType, (short)value);
_itemType = value;
}
}
#endregion
#region itemType : EnumPayScaleItemType
private string _Description;
public string Description
{
get
{
if (this.ItemType == EnumPayScaleItemType.Basic)
{
return "Basic";
}
else if (this.ItemType == EnumPayScaleItemType.Allowance)
{
AllowanceDeduction allowance = AllowanceDeduction.Get(ID.FromInteger(this.ItemID));
if (allowance != null)
{
return allowance.Name;
}
else
{
return "Invalid Allawance.";
}
}
else
{
return "Unknown";
}
}
}
#endregion
#region PayScaleDetails : PayScaleDetails
private ObjectsTemplate<PayScaleDetail> _details;
public ObjectsTemplate<PayScaleDetail> PayscaleDetails
{
get
{
if (_details == null && !this.ID.IsUnassigned && this.ID.Integer > 0)
{
_details = PayScaleDetail.GetByPayScale(this.ID);
}
return _details;
}
set
{
_details = value;
}
}
#endregion
#region Service Factory IPayScaleService : IPayScaleService
internal static IPayScaleService Service
{
get { return Services.Factory.CreateService<IPayScaleService>(typeof(IPayScaleService)); }
}
#endregion
#endregion
#region Functions
public static PayScale Get(ID nID)
{
PayScale oPayScale = null;
#region Cache Header
oPayScale = (PayScale)_cache["Get", nID];
if (oPayScale != null)
return oPayScale;
#endregion
oPayScale = PayScale.Service.Get(nID);
#region Cache Footer
_cache.Add(oPayScale, "Get", nID);
#endregion
return oPayScale;
}
public static PayScale Get(ID nGradeID, ID nAllowID)
{
PayScale oPayScale = null;
#region Cache Header
oPayScale = (PayScale)_cache["Get", nGradeID, nAllowID];
if (oPayScale != null)
return oPayScale;
#endregion
oPayScale = PayScale.Service.Get(nGradeID, nAllowID, SystemInformation.CurrentSysInfo.NextPayProcessDate);
#region Cache Footer
_cache.Add(oPayScale, "Get", nGradeID, nAllowID);
#endregion
return oPayScale;
}
public static PayScale GetByGrade(ID nGradeID)
{
PayScale oPayScale = null;
#region Cache Header
oPayScale = (PayScale)_cache["GetByGrade", nGradeID];
if (oPayScale != null)
return oPayScale;
#endregion
oPayScale = PayScale.Service.GetByGrade(nGradeID);
#region Cache Footer
_cache.Add(oPayScale, "GetByGrade", nGradeID);
#endregion
return oPayScale;
}
public static ObjectsTemplate<PayScale> Get()
{
#region Cache Header
ObjectsTemplate<PayScale> payScales = _cache["Get"] as ObjectsTemplate<PayScale>;
if (payScales != null)
return payScales;
#endregion
try
{
payScales = Service.Get();
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(payScales, "Get");
#endregion
return payScales;
}
public static DateTime? GetMaxEffectDate()
{
DateTime? dEffectDate = DateTime.MinValue;
try
{
dEffectDate = Service.GetMaxEffectDate(SystemInformation.CurrentSysInfo.PayrollTypeID);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
return dEffectDate;
}
public static ObjectsTemplate<PayScale> GetLatest()
{
#region Cache Header
ObjectsTemplate<PayScale> payScales = _cache["Get"] as ObjectsTemplate<PayScale>;
if (payScales != null)
return payScales;
#endregion
try
{
payScales = Service.GetLatest(SystemInformation.CurrentSysInfo.PayrollTypeID);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(payScales, "Get");
#endregion
return payScales;
}
public static ObjectsTemplate<PayScale> GetByAllowance(ID allowID)
{
#region Cache Header
ObjectsTemplate<PayScale> payScales = _cache["GetByAllowance", allowID] as ObjectsTemplate<PayScale>;
if (payScales != null)
return payScales;
#endregion
try
{
payScales = Service.GetByAllowance(allowID);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(payScales, "GetByAllowance", allowID);
#endregion
return payScales;
}
public ID Save()
{
return PayScale.Service.Save(this);
}
public void Delete()
{
PayScale.Service.Delete(ID);
}
public static void Delete(ID gradeID)
{
PayScale.Service.DeleteByGradeID(gradeID);
}
public static void Save(ObjectsTemplate<PayScale> _NewPayscale)
{
PayScale.Service.Save(_NewPayscale);
}
#endregion
}
#endregion
#region IPayScale Service
public interface IPayScaleService
{
PayScale Get(ID id);
ObjectsTemplate<PayScale> Get();
ID Save(PayScale item);
void Delete(ID id);
void DeleteByGradeID(ID id);
PayScale Get(ID nGradeID, ID nAllowID, DateTime nextPayProcessDate);
ObjectsTemplate<PayScale> GetByAllowance(ID allowID);
ObjectsTemplate<PayScale> GetLatest(ID PayrollTypeID);
PayScale GetByGrade(ID nID);
DateTime? GetMaxEffectDate(ID PayrollTypeID);
void Save(ObjectsTemplate<PayScale> _NewPayscale);
}
#endregion
}