CEL_Payroll/Payroll.BO/AllowDeduct/ADParameterEmployee.cs

828 lines
25 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 ADParameterEmployee
[Serializable]
public class ADParameterEmployee : AuditTrailBase
{
#region Cache Store
private static Cache _cache = new Cache(typeof(ADParameterEmployee));
#endregion
#region Constructor
public ADParameterEmployee()
{
_aDParameterID = null;
_allowDeductID = null;
_periodicity = EnumPeriodicity.RegardLess;
_employeeID = null;
_formDate = DateTime.MinValue;
_tillDate = DateTime.MinValue;
_monthlyAmount = 0;
_totalAmount = 0;
_arreartype = EnumArrearType.Regardless;
_employee = null;
_disbursAmount = 0;
_tracNo = string.Empty;
}
#endregion
#region Properties
#region ADParameterID : ID
private ID _aDParameterID;
public ID ADParameterID
{
get { return _aDParameterID; }
set
{
base.OnPropertyChange<ID>("ADParameterID", _aDParameterID, value);
_aDParameterID = value;
}
}
#endregion
#region AllowDeductID : ID
private ID _allowDeductID;
public ID AllowDeductID
{
get { return _allowDeductID; }
set
{
base.OnPropertyChange<ID>("AllowDeductID", _allowDeductID, value);
_allowDeductID = value;
}
}
#endregion
#region AllowDeductID : ID
private AllowanceDeduction _allowanceDeduct = null;
public AllowanceDeduction AllowDeduct
{
get
{
if (_allowanceDeduct == null && !_allowDeductID.IsUnassigned && _allowDeductID.Integer > 0)
{
_allowanceDeduct = AllowanceDeduction.Get(_allowDeductID);
}
return _allowanceDeduct;
}
}
#endregion
#region periodicity : EnumPeriodicity
private EnumPeriodicity _periodicity;
public EnumPeriodicity Periodicity
{
get { return _periodicity; }
set
{
base.OnPropertyChange<short>("periodicity", (short)_periodicity, (short)value);
_periodicity = value;
}
}
#endregion
#region EmployeeID : ID
private ID _employeeID;
public ID EmployeeID
{
get { return _employeeID; }
set
{
base.OnPropertyChange<ID>("EmployeeID", _employeeID, value);
_employeeID = value;
}
}
#endregion
#region formDate : DateTime
private DateTime _formDate;
public DateTime FormDate
{
get { return _formDate; }
set
{
base.OnPropertyChange<DateTime>("formDate", _formDate, value);
_formDate = value;
}
}
#endregion
#region tillDate : DateTime
private DateTime? _tillDate;
public DateTime? TillDate
{
get { return _tillDate; }
set
{
base.OnPropertyChange<DateTime>("tillDate", _tillDate, value);
_tillDate = value;
}
}
#endregion
#region DisburseAmount : double
private double _disbursAmount;
public double DisburseAmount
{
get { return _disbursAmount; }
set
{
base.OnPropertyChange<double>("DisburseAmount", _disbursAmount, value);
_disbursAmount = value;
}
}
#endregion
#region monthlyAmount : double
private double _monthlyAmount;
public double MonthlyAmount
{
get { return _monthlyAmount; }
set
{
base.OnPropertyChange<double>("monthlyAmount", _monthlyAmount, value);
_monthlyAmount = value;
}
}
#endregion
//#region EuroAmount : double
//private double _euroAmount;
//public double EuroAmount
//{
// get { return _euroAmount; }
// set
// {
// base.OnPropertyChange<double>("EuroAmount", _euroAmount, value);
// _euroAmount = value;
// }
//}
//#endregion
//#region IsEuro : bool
//private bool _isEuro;
//public bool IsEuro
//{
// get { return _isEuro; }
// set { _isEuro = value; }
//}
//#endregion
#region totalAmount : double
private double _totalAmount;
public double TotalAmount
{
get { return _totalAmount; }
set
{
base.OnPropertyChange<double>("totalAmount", _totalAmount, value);
_totalAmount = value;
}
}
#endregion
#region arreartype : EnumArrearType
private EnumArrearType _arreartype;
public EnumArrearType Arreartype
{
get { return _arreartype; }
set
{
base.OnPropertyChange<short>("arreartype",(short) _arreartype, (short)value);
_arreartype = value;
}
}
#endregion
#region employee : Employee
private Employee _employee;
public Employee Employee
{
get
{
if (_employeeID.Integer > 0 && _employee == null)
{
_employee = new Employee();
_employee = Employee.Get(_employeeID);
}
return this._employee;
}
set
{
_employee = value;
}
}
#endregion
#region EnumADEmpType : EnumADEmpType
private EnumADEmpType _ADEmpType = EnumADEmpType.AppliedToIndividual;
public EnumADEmpType ADEmpType
{
get
{
return _ADEmpType;
}
set
{
_ADEmpType = value;
}
}
#endregion
#region EnumADEmpType : EnumADEmpType
private EnumValueType _ADValueType = EnumValueType.Amount;
public EnumValueType ValueType
{
get
{
return _ADValueType;
}
set
{
_ADValueType = value;
}
}
#endregion
#region totalAmount : double
private string _tracNo;
public string TracNo
{
get { return _tracNo; }
set
{
base.OnPropertyChange<string>("TracNo", _tracNo, value);
_tracNo = value;
}
}
#endregion
#region Service Factory IADParameterEmployeeService : IADParameterEmployeeService
internal static IADParameterEmployeeService Service
{
get { return Services.Factory.CreateService<IADParameterEmployeeService>(typeof(IADParameterEmployeeService)); }
}
#endregion
#endregion
#region Functions
public static ADParameterEmployee Get(ID nID)
{
ADParameterEmployee oADParameterEmployee = null;
#region Cache Header
oADParameterEmployee = (ADParameterEmployee)_cache["Get", nID];
if (oADParameterEmployee != null)
return oADParameterEmployee;
#endregion
oADParameterEmployee = ADParameterEmployee.Service.Get(nID);
#region Cache Footer
_cache.Add(oADParameterEmployee, "Get", nID);
#endregion
return oADParameterEmployee;
}
public static ADParameterEmployee Get(ID nEmpID, ID nAllowDeductID, ID nADParamID)
{
ADParameterEmployee oADParameterEmployee = null;
#region Cache Header
oADParameterEmployee = (ADParameterEmployee)_cache["Get", nEmpID, nAllowDeductID, nADParamID];
if (oADParameterEmployee != null)
return oADParameterEmployee;
#endregion
oADParameterEmployee = ADParameterEmployee.Service.Get(nEmpID,nAllowDeductID,nADParamID);
#region Cache Footer
_cache.Add(oADParameterEmployee, "Get", nEmpID, nAllowDeductID, nADParamID);
#endregion
return oADParameterEmployee;
}
public static ADParameterEmployee Get(ID nEmpID, ID nAllowDeductID, ID nADParamID,EnumArrearType nArrearType)
{
ADParameterEmployee oADParameterEmployee = null;
#region Cache Header
oADParameterEmployee = (ADParameterEmployee)_cache["Get", nEmpID, nAllowDeductID, nADParamID,nArrearType];
if (oADParameterEmployee != null)
return oADParameterEmployee;
#endregion
oADParameterEmployee = ADParameterEmployee.Service.Get(nEmpID, nAllowDeductID, nADParamID,nArrearType);
#region Cache Footer
_cache.Add(oADParameterEmployee, "Get", nEmpID, nAllowDeductID, nADParamID,nArrearType);
#endregion
return oADParameterEmployee;
}
public static ObjectsTemplate<ADParameterEmployee> GetByEmployee(ID nEmpID, EnumAllowOrDeduct adType, EnumADEmpType adEmpType)
{
#region Cache Header
ObjectsTemplate<ADParameterEmployee> aDParameterEmployees = _cache["Get", nEmpID, adType, adEmpType] as ObjectsTemplate<ADParameterEmployee>;
if (aDParameterEmployees != null)
return aDParameterEmployees;
#endregion
try
{
aDParameterEmployees = Service.GetByEmployee(nEmpID, adType, adEmpType, SystemInformation.CurrentSysInfo.NextPayProcessDate, SystemInformation.CurrentSysInfo.PayrollTypeID);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(aDParameterEmployees, "Get", nEmpID, adType, adEmpType);
#endregion
return aDParameterEmployees;
}
public static ObjectsTemplate<ADParameterEmployee> GetByEmployee(ID nEmpID, EnumAllowOrDeduct adType, EnumADEmpType adEmpType, DateTime lastDate)
{
#region Cache Header
ObjectsTemplate<ADParameterEmployee> aDParameterEmployees = _cache["Get", nEmpID, adType, adEmpType] as ObjectsTemplate<ADParameterEmployee>;
if (aDParameterEmployees != null)
return aDParameterEmployees;
#endregion
try
{
aDParameterEmployees = Service.GetByEmployee(nEmpID, adType, adEmpType, lastDate, SystemInformation.CurrentSysInfo.PayrollTypeID);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(aDParameterEmployees, "Get", nEmpID, adType, adEmpType);
#endregion
return aDParameterEmployees;
}
public static ObjectsTemplate<ADParameterEmployee> GetByEmployee(ID nEmpID, ID nAllowDeductID)
{
#region Cache Header
ObjectsTemplate<ADParameterEmployee> aDParameterEmployees = _cache["Get", nEmpID, nAllowDeductID] as ObjectsTemplate<ADParameterEmployee>;
if (aDParameterEmployees != null)
return aDParameterEmployees;
#endregion
try
{
aDParameterEmployees = Service.GetByEmployee(nEmpID, nAllowDeductID, SystemInformation.CurrentSysInfo.PayrollTypeID);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(aDParameterEmployees, "Get", nEmpID, nAllowDeductID);
#endregion
return aDParameterEmployees;
}
//public static bool IsMonthlyAllowDeduct(ID employeeID, ID allowDeductID, DateTime AllowDeductMonth)
//{
// bool IsPermanent = false;
// IsPermanent = Service.IsMonthlyAllowDeduct(employeeID, allowDeductID,AllowDeductMonth);
// return IsPermanent;
//}
public static ObjectsTemplate<ADParameterEmployee> Get(ID nEmpID,ID nAlloDeductID,DateTime dFromDate, DateTime dToDate)
{
#region Cache Header
ObjectsTemplate<ADParameterEmployee> aDParameterEmployees = _cache["Get", nEmpID,dFromDate, dToDate] as ObjectsTemplate<ADParameterEmployee>;
if (aDParameterEmployees != null)
return aDParameterEmployees;
#endregion
try
{
aDParameterEmployees = Service.Get(nEmpID,nAlloDeductID,dFromDate,dToDate);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(aDParameterEmployees, "Get", nEmpID, dFromDate,dToDate);
#endregion
return aDParameterEmployees;
}
public static ObjectsTemplate<ADParameterEmployee> Get(ID nAlloDeductID, DateTime dFromDate, DateTime dToDate)
{
#region Cache Header
ObjectsTemplate<ADParameterEmployee> aDParameterEmployees = _cache["Get",dFromDate, dToDate] as ObjectsTemplate<ADParameterEmployee>;
if (aDParameterEmployees != null)
return aDParameterEmployees;
#endregion
try
{
aDParameterEmployees = Service.Get(nAlloDeductID, dFromDate, dToDate, SystemInformation.CurrentSysInfo.PayrollTypeID);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(aDParameterEmployees, "Get", dFromDate, dToDate);
#endregion
return aDParameterEmployees;
}
public static ObjectsTemplate<ADParameterEmployee> GetForApproval(ID nAlloDeductID, DateTime dFromDate, DateTime dToDate)
{
#region Cache Header
ObjectsTemplate<ADParameterEmployee> aDParameterEmployees = _cache["GetForApproval", dFromDate, dToDate] as ObjectsTemplate<ADParameterEmployee>;
if (aDParameterEmployees != null)
return aDParameterEmployees;
#endregion
try
{
aDParameterEmployees = Service.GetForApproval(nAlloDeductID, dFromDate, dToDate, SystemInformation.CurrentSysInfo.PayrollTypeID);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(aDParameterEmployees, "GetForApproval", dFromDate, dToDate);
#endregion
return aDParameterEmployees;
}
public static ObjectsTemplate<ADParameterEmployee> Get(DateTime dFromDate, DateTime dToDate)
{
#region Cache Header
ObjectsTemplate<ADParameterEmployee> aDParameterEmployees = _cache["Get", dFromDate, dToDate] as ObjectsTemplate<ADParameterEmployee>;
if (aDParameterEmployees != null)
return aDParameterEmployees;
#endregion
try
{
aDParameterEmployees = Service.Get(dFromDate, dToDate, SystemInformation.CurrentSysInfo.PayrollTypeID);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(aDParameterEmployees, "Get",dFromDate, dToDate);
#endregion
return aDParameterEmployees;
}
public static ObjectsTemplate<ADParameterEmployee> Get(EnumStatus status)
{
#region Cache Header
ObjectsTemplate<ADParameterEmployee> aDParameterEmployees = _cache["Get"] as ObjectsTemplate<ADParameterEmployee>;
if (aDParameterEmployees != null)
return aDParameterEmployees;
#endregion
try
{
aDParameterEmployees = Service.Get(status);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(aDParameterEmployees, "Get",status);
#endregion
return aDParameterEmployees;
}
public double GetAmount(double basicSalary, double grossSalary)
{
if (this.ValueType == EnumValueType.Amount) return this.MonthlyAmount;
else
{
return ((basicSalary + grossSalary) * this.MonthlyAmount) / 100;
}
}
public static ObjectsTemplate<ADParameterEmployee> GetbyParameter(ID nADPAramID)
{
#region Cache Header
ObjectsTemplate<ADParameterEmployee> aDParameterEmployees = _cache["Get", nADPAramID] as ObjectsTemplate<ADParameterEmployee>;
if (aDParameterEmployees != null)
{
return aDParameterEmployees;
}
#endregion
try
{
aDParameterEmployees = Service.GetbyParameter(nADPAramID, SystemInformation.CurrentSysInfo.NextPayProcessDate);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(aDParameterEmployees, "Get", nADPAramID);
#endregion
return aDParameterEmployees;
}
public static ObjectsTemplate<ADParameterEmployee> GetByAllow(ID nAllowDeducID)
{
#region Cache Header
ObjectsTemplate<ADParameterEmployee> aDParameterEmployees = _cache["Get", nAllowDeducID] as ObjectsTemplate<ADParameterEmployee>;
if (aDParameterEmployees != null)
{
return aDParameterEmployees;
}
#endregion
try
{
aDParameterEmployees = Service.GetByAllow(nAllowDeducID);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(aDParameterEmployees, "Get", nAllowDeducID);
#endregion
return aDParameterEmployees;
}
public static ObjectsTemplate<ADParameterEmployee> GetByAllowForApproval(ID nAllowDeducID)
{
#region Cache Header
ObjectsTemplate<ADParameterEmployee> aDParameterEmployees = _cache["GetByAllowForApproval", nAllowDeducID] as ObjectsTemplate<ADParameterEmployee>;
if (aDParameterEmployees != null)
{
return aDParameterEmployees;
}
#endregion
try
{
aDParameterEmployees = Service.GetByAllowForApproval(nAllowDeducID, SystemInformation.CurrentSysInfo.PayrollTypeID);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(aDParameterEmployees, "GetByAllowForApproval", nAllowDeducID);
#endregion
return aDParameterEmployees;
}
public static ObjectsTemplate<ADParameterEmployee> GetbyParameter(ID nADPAramID, EnumADEmpType type)
{
#region Cache Header
ObjectsTemplate<ADParameterEmployee> aDParameterEmployees = _cache["Get", nADPAramID, type] as ObjectsTemplate<ADParameterEmployee>;
if (aDParameterEmployees != null)
{
return aDParameterEmployees;
}
#endregion
try
{
aDParameterEmployees = Service.GetbyParameter(nADPAramID, type);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(aDParameterEmployees, "Get", nADPAramID, type);
#endregion
return aDParameterEmployees;
}
public static ObjectsTemplate<ADParameterEmployee> GetByCreatedBy(ID createdByID)
{
ObjectsTemplate<ADParameterEmployee> oADParameterEmployee = null;
oADParameterEmployee = ADParameterEmployee.Service.GetByCreatedBy(createdByID, SystemInformation.CurrentSysInfo.NextPayProcessDate);
return oADParameterEmployee;
}
public void SetArrearType()
{
if (this.FormDate <= SystemInformation.CurrentSysInfo.LastPayProcessDate)
{
this.Arreartype = EnumArrearType.ToCalculate;
}
else
{
this.Arreartype = EnumArrearType.NotPresent;
}
}
public ID Save()
{
this.SetAuditTrailProperties();
return ADParameterEmployee.Service.Save(this);
}
public static void Save(ObjectsTemplate<ADParameterEmployee> ADParameterEmployees, ID allowDeducID)
{
ADParameterEmployee.Service.Save(ADParameterEmployees, allowDeducID);
}
public static void Save(ObjectsTemplate<ADParameterEmployee> ADParameterEmployees, ID allowDeducID, ID createdBy)
{
ADParameterEmployee.Service.Save(ADParameterEmployees, allowDeducID, createdBy);
}
public void Delete()
{
ADParameterEmployee.Service.Delete(ID);
}
public void Delete(ADParameterEmployee adparamEmp)
{
ADParameterEmployee.Service.Delete(adparamEmp);
}
public void DeleteByAllowDeductMonth(ID nEmpID, ID nAllowDeductID, DateTime dAllowDeductMonht)
{
ADParameterEmployee.Service.DeleteByAllowDeductMonth(nEmpID, nAllowDeductID, dAllowDeductMonht);
}
public ADParameterEmployee Clone()
{
ADParameterEmployee adEmp = new ADParameterEmployee();
adEmp.ADEmpType = this.ADEmpType;
adEmp.ADParameterID = this.ADParameterID;
adEmp.AllowDeductID = this.AllowDeductID;
adEmp.Arreartype = this.Arreartype;
adEmp.DisburseAmount = this.DisburseAmount;
adEmp.EmployeeID = this.EmployeeID;
adEmp.FormDate = this.FormDate;
adEmp.MonthlyAmount = this.MonthlyAmount;
adEmp.Periodicity = this.Periodicity;
adEmp.SortOrder = this.SortOrder;
adEmp.TillDate = this.TillDate;
adEmp.TotalAmount = this.TotalAmount;
adEmp.ValueType = this.ValueType;
return adEmp;
}
#endregion
}
#endregion
#region IADParameterEmployee Service
public interface IADParameterEmployeeService
{
ADParameterEmployee Get(ID id);
ObjectsTemplate<ADParameterEmployee> Get(EnumStatus status);
ObjectsTemplate<ADParameterEmployee> GetbyParameter(ID ADParamID, DateTime nextPayProcessDate);
ObjectsTemplate<ADParameterEmployee> GetbyParameter(ID nADPAramID, EnumADEmpType type);
ObjectsTemplate<ADParameterEmployee> GetByAllow(ID AllDeductID);
ObjectsTemplate<ADParameterEmployee> GetByAllowForApproval(ID AllDeductID, ID PayrolltypeID);
ObjectsTemplate<ADParameterEmployee> GetByCreatedBy(ID createdByID, DateTime nextPayProcessDate);
ID Save(ADParameterEmployee item);
void Save(ObjectsTemplate<ADParameterEmployee> items,ID allowDeducID);
void Save(ObjectsTemplate<ADParameterEmployee> items, ID allowDeducID, ID createdBy);
void Delete(ID id);
void DeleteByAllowDeductMonth(ID nEmpID,ID nAllowDeductID,DateTime dAllowDeductMonht);
//void DeleteByAllo(ID allowDeductID);
//void DeleteByEmpID(ID nEmpID,ID nADParameterID);
//bool IsMonthlyAllowDeduct(ID employeeID, ID allowDeductID,DateTime AllowDeductMonth);
ADParameterEmployee Get(ID nEmpID, ID nAllowDeductID, ID nADParamID);
ADParameterEmployee Get(ID nEmpID, ID nAllowDeductID, ID nADParamID,EnumArrearType nArrearType);
ObjectsTemplate<ADParameterEmployee> GetByEmployee(ID nEmpID, EnumAllowOrDeduct adType, EnumADEmpType adEmpType, DateTime nextPayProcessDate, ID PayrolltypeID);
ObjectsTemplate<ADParameterEmployee> GetByEmployee(ID nEmpID, ID nAllowDeductID, ID PayrolltypeID);
ObjectsTemplate<ADParameterEmployee> Get(DateTime fromdate, DateTime todate, ID PayrolltypeID);
ObjectsTemplate<ADParameterEmployee> Get(ID nAllowDeductID, DateTime fromdate, DateTime todate, ID PayrolltypeID);
ObjectsTemplate<ADParameterEmployee> GetForApproval(ID nAllowDeductID, DateTime fromdate, DateTime todate, ID PayrolltypeID);
ObjectsTemplate<ADParameterEmployee> Get(ID nEmpID, ID nAllowDeductID,DateTime fromdate, DateTime todate);
void Delete(ADParameterEmployee adparamEmp);
}
#endregion
}