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

443 lines
13 KiB
C#

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 AllowanceDeduction
[Serializable]
public class AllowanceDeduction : BasicBaseObject
{
#region Cache Store
private static Cache _cache = new Cache(typeof(AllowanceDeduction));
#endregion
#region Constructor
public AllowanceDeduction()
{
_code = string.Empty;
_name = string.Empty;
_allowOrDeductType = EnumAllowOrDeduct.Allowance;
_status = EnumStatus.Active;
}
#endregion
#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
#region Properties
#region code : string
private string _code;
public string Code
{
get { return _code; }
set
{
base.OnPropertyChange<string>("code", _code, value);
_code = value;
}
}
#endregion
#region name : string
private string _name;
public string Name
{
get { return _name; }
set
{
base.OnPropertyChange<string>("name", _name, value);
_name = value;
}
}
#endregion
#region allowOrDeductType : EnumAllowanceOrDeduction
private EnumAllowOrDeduct _allowOrDeductType;
public EnumAllowOrDeduct AllowOrDeductType
{
get { return _allowOrDeductType; }
set
{
base.OnPropertyChange<short>("allowOrDeductType", (short)_allowOrDeductType, (short)value);
_allowOrDeductType = value;
}
}
#region Property Error List: DataUpload
private ObjectsTemplate<RegularDataUpload> _errorList;
public ObjectsTemplate<RegularDataUpload> ErrorList
{
get { return _errorList; }
set { _errorList = value; }
}
#endregion
#endregion
#region Service Factory IAllowanceDeductionService : IAllowanceDeductionService
internal static IAllowanceDeductionService Service
{
get { return Services.Factory.CreateService<IAllowanceDeductionService>(typeof(IAllowanceDeductionService)); }
}
#endregion
#endregion
#region Functions
public static AllowanceDeduction Get(ID nID)
{
AllowanceDeduction oAllowanceDeduction = null;
#region Cache Header
oAllowanceDeduction = (AllowanceDeduction)_cache["Get", nID];
if (oAllowanceDeduction != null)
return oAllowanceDeduction;
#endregion
oAllowanceDeduction = AllowanceDeduction.Service.Get(nID);
#region Cache Footer
_cache.Add(oAllowanceDeduction, "Get", nID);
#endregion
return oAllowanceDeduction;
}
public static ObjectsTemplate<AllowanceDeduction> Get(EnumStatus status)
{
#region Cache Header
ObjectsTemplate<AllowanceDeduction> allowanceDeductions = _cache["Get"] as ObjectsTemplate<AllowanceDeduction>;
if (allowanceDeductions != null)
return allowanceDeductions;
#endregion
try
{
allowanceDeductions = Service.Get(status);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(allowanceDeductions, "Get",status);
#endregion
return allowanceDeductions;
}
public static ObjectsTemplate<AllowanceDeduction> GetByGradeID(EnumStatus status, ID gradeID, EnumAllowOrDeduct type)
{
#region Cache Header
ObjectsTemplate<AllowanceDeduction> allowanceDeductions = _cache["GetByGradeID", status, gradeID, type] as ObjectsTemplate<AllowanceDeduction>;
if (allowanceDeductions != null)
return allowanceDeductions;
#endregion
try
{
allowanceDeductions = Service.GetByGradeID(status, gradeID, type);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(allowanceDeductions, "GetByGradeID", status, gradeID, type);
#endregion
return allowanceDeductions;
}
public static ObjectsTemplate<AllowanceDeduction> GetAllowance(EnumStatus status)
{
#region Cache Header
ObjectsTemplate<AllowanceDeduction> allowanceDeductions = _cache["Get",status] as ObjectsTemplate<AllowanceDeduction>;
if (allowanceDeductions != null)
return allowanceDeductions;
#endregion
try
{
allowanceDeductions = Service.GetAllowance(status);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(allowanceDeductions, "Get",status);
#endregion
return allowanceDeductions;
}
public static ObjectsTemplate<AllowanceDeduction> GetAllowance(EnumPeriodicity periodicity, EnumAllowOrDeduct allowOrdeduct)
{
#region Cache Header
ObjectsTemplate<AllowanceDeduction> allowanceDeductions = _cache["Get", periodicity, allowOrdeduct] as ObjectsTemplate<AllowanceDeduction>;
if (allowanceDeductions != null)
return allowanceDeductions;
#endregion
try
{
allowanceDeductions = Service.GetAllowance(periodicity, allowOrdeduct);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(allowanceDeductions, "Get", periodicity, allowOrdeduct);
#endregion
return allowanceDeductions;
}
public static ObjectsTemplate<AllowanceDeduction> GetAllowance(EnumPeriodicity enumPeriodicity, EnumEntitleType enumEntitleType, EnumAllowOrDeduct enumAllowOrDeduct)
{
#region Cache Header
ObjectsTemplate<AllowanceDeduction> allowanceDeductions = _cache["GetAllowance", enumPeriodicity, enumEntitleType, enumAllowOrDeduct] as ObjectsTemplate<AllowanceDeduction>;
if (allowanceDeductions != null)
return allowanceDeductions;
#endregion
try
{
allowanceDeductions = Service.GetAllowance(enumPeriodicity, enumEntitleType, enumAllowOrDeduct);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(allowanceDeductions, "GetAllowance", enumPeriodicity, enumEntitleType, enumAllowOrDeduct);
#endregion
return allowanceDeductions;
}
public static ObjectsTemplate<AllowanceDeduction> GetDeduction(EnumStatus status)
{
#region Cache Header
ObjectsTemplate<AllowanceDeduction> allowanceDeductions = _cache["Get",status] as ObjectsTemplate<AllowanceDeduction>;
if (allowanceDeductions != null)
return allowanceDeductions;
#endregion
try
{
allowanceDeductions = Service.GetDeduction(status);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(allowanceDeductions, "Get", status);
#endregion
return allowanceDeductions;
}
public static ObjectsTemplate<AllowanceDeduction> Get(EnumStatus status, EnumAllowOrDeduct nType, EnumPeriodicity nPeriodcity)
{
#region Cache Header
ObjectsTemplate<AllowanceDeduction> allowanceDeductions = _cache["Get", status,nType,nPeriodcity] as ObjectsTemplate<AllowanceDeduction>;
if (allowanceDeductions != null)
return allowanceDeductions;
#endregion
try
{
allowanceDeductions = Service.Get(status,nType,nPeriodcity);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(allowanceDeductions, "Get", status,nType,nPeriodcity);
#endregion
return allowanceDeductions;
}
public static ObjectsTemplate<AllowanceDeduction> Get(EnumStatus status, EnumAllowOrDeduct nType)
{
#region Cache Header
ObjectsTemplate<AllowanceDeduction> allowanceDeductions = _cache["Get", status, nType] as ObjectsTemplate<AllowanceDeduction>;
if (allowanceDeductions != null)
return allowanceDeductions;
#endregion
try
{
allowanceDeductions = Service.Get(status, nType);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(allowanceDeductions, "Get", status, nType);
#endregion
return allowanceDeductions;
}
public ID Save()
{
this.SetAuditTrailProperties();
return AllowanceDeduction.Service.Save(this);
}
public void Delete(ID id)
{
AllowanceDeduction.Service.Delete(id);
}
public string GetNextCode()
{
return AllowanceDeduction.Service.GetNextCode();
}
public static DataSet GetEmpAllowDeduc(DateTime dEffectDate, ID AllowDeducID)
{
DataSet ds = null;
try
{
ds = Service.GetEmpAllowDeduc(dEffectDate, AllowDeducID, SystemInformation.CurrentSysInfo.PayrollTypeID);
}
catch (Exception e)
{
throw new Exception(e.Message, e);
}
return ds;
}
public static DataSet GetEmpAllowDeduc2(DateTime dEffectDate, DateTime dEffectDate2, ID AllowDeducID)
{
DataSet ds = null;
try
{
ds = Service.GetEmpAllowDeduc2(dEffectDate, dEffectDate2, AllowDeducID, SystemInformation.CurrentSysInfo.PayrollTypeID);
}
catch (Exception e)
{
throw new Exception(e.Message, e);
}
return ds;
}
#endregion
}
#endregion
#region IAllowanceDeduction Service
public interface IAllowanceDeductionService
{
AllowanceDeduction Get(ID id);
ObjectsTemplate<AllowanceDeduction> Get(EnumStatus status);
ObjectsTemplate<AllowanceDeduction> GetAllowance(EnumStatus status);
ObjectsTemplate<AllowanceDeduction> GetAllowance(EnumPeriodicity periodicity,EnumAllowOrDeduct allowOrdeduct);
ObjectsTemplate<AllowanceDeduction> GetDeduction(EnumStatus status);
ObjectsTemplate<AllowanceDeduction> Get(EnumStatus status, EnumAllowOrDeduct nType, EnumPeriodicity nPeriodcity);
string GetNextCode();
ID Save(AllowanceDeduction item);
ObjectsTemplate<AllowanceDeduction> GetByGradeID(EnumStatus status, ID gradeID, EnumAllowOrDeduct type);
void Delete(ID id);
DataSet GetEmpAllowDeduc(DateTime dEffectDate, ID AllowDeducID, ID PayrolltypeID);
DataSet GetEmpAllowDeduc2(DateTime dEffectDate, DateTime dEffectDate2, ID AllowDeducID, ID PayrolltypeID);
ObjectsTemplate<AllowanceDeduction> Get(EnumStatus status, EnumAllowOrDeduct nType);
ObjectsTemplate<AllowanceDeduction> GetAllowance(EnumPeriodicity enumPeriodicity, EnumEntitleType enumEntitleType, EnumAllowOrDeduct enumAllowOrDeduct);
}
#endregion
}