352 lines
9.3 KiB
C#
352 lines
9.3 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;
|
|||
|
|
|||
|
namespace Payroll.BO
|
|||
|
{
|
|||
|
#region Loan Parameter
|
|||
|
|
|||
|
[Serializable]
|
|||
|
public class LoanParameter : AuditTrailBase
|
|||
|
{
|
|||
|
public delegate void ItemChanged();
|
|||
|
|
|||
|
#region Cache Store
|
|||
|
|
|||
|
private static Cache _cache = new Cache(typeof(LoanParameter));
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Constructor
|
|||
|
public LoanParameter()
|
|||
|
{
|
|||
|
_loanID = null;
|
|||
|
_noOfGross = 0;
|
|||
|
_noOfBasic = 0;
|
|||
|
_minInstallmentMonth = 0;
|
|||
|
_maxInstallmentMonth = 0;
|
|||
|
_minReconcileMonth = 0;
|
|||
|
_minFlatAmount = 0.0;
|
|||
|
_maxFlatAmount = 0.0;
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Properties
|
|||
|
#region MinFlatAmount : double
|
|||
|
|
|||
|
private double _minFlatAmount;
|
|||
|
public double MinFlatAmount
|
|||
|
{
|
|||
|
get { return _minFlatAmount; }
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<double>("MinFlatAmount", _minFlatAmount, value);
|
|||
|
_minFlatAmount = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
#region MaxFlatAmount : double
|
|||
|
|
|||
|
private double _maxFlatAmount;
|
|||
|
public double MaxFlatAmount
|
|||
|
{
|
|||
|
get { return _maxFlatAmount; }
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<double>("MaxFlatAmount", _maxFlatAmount, value);
|
|||
|
_maxFlatAmount = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
#region LoanID : ID
|
|||
|
|
|||
|
private ID _loanID;
|
|||
|
public ID LoanID
|
|||
|
{
|
|||
|
get { return _loanID; }
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<ID>("loanID", _loanID, value);
|
|||
|
_loanID = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region NoOfGross : double
|
|||
|
|
|||
|
private double _noOfGross;
|
|||
|
public double NoOfGross
|
|||
|
{
|
|||
|
get { return _noOfGross; }
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<double>("noOfGross", _noOfGross, value);
|
|||
|
_noOfGross = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region NoOfBasic : double
|
|||
|
|
|||
|
private double _noOfBasic;
|
|||
|
public double NoOfBasic
|
|||
|
{
|
|||
|
get { return _noOfBasic; }
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<double>("noOfBasic", _noOfBasic, value);
|
|||
|
_noOfBasic = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region MinInstallmentMonth : int
|
|||
|
|
|||
|
private int _minInstallmentMonth;
|
|||
|
public int MinInstallmentMonth
|
|||
|
{
|
|||
|
get { return _minInstallmentMonth; }
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<int>("minInstallmentMonth", _minInstallmentMonth, value);
|
|||
|
_minInstallmentMonth = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region MaxInstallmentMonth : int
|
|||
|
|
|||
|
private int _maxInstallmentMonth;
|
|||
|
public int MaxInstallmentMonth
|
|||
|
{
|
|||
|
get { return _maxInstallmentMonth; }
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<int>("maxInstallmentMonth", _maxInstallmentMonth, value);
|
|||
|
_maxInstallmentMonth = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region MinReconcileMonth : int
|
|||
|
|
|||
|
private int _minReconcileMonth;
|
|||
|
public int MinReconcileMonth
|
|||
|
{
|
|||
|
get { return _minReconcileMonth; }
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<int>("minReconcileMonth", _minReconcileMonth, value);
|
|||
|
_minReconcileMonth = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region LoanGrades
|
|||
|
private ObjectsTemplate<LoanGrades> _loanGrades;
|
|||
|
public ObjectsTemplate<LoanGrades> LoadGradesTemp
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
if (_loanGrades == null)
|
|||
|
{
|
|||
|
_loanGrades = LoanGrades.Service.GetLoanGrades(this.ID.Integer);
|
|||
|
//_salaryEmpCostCenters = new ObjectsTemplate<SalaryEmpCostCenter>();
|
|||
|
}
|
|||
|
return _loanGrades;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
_loanGrades = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region LoanDoc
|
|||
|
private ObjectsTemplate<LoanDoc> _loanDocs;
|
|||
|
public ObjectsTemplate<LoanDoc> LoadDocsTemp
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
if (_loanDocs == null)
|
|||
|
{
|
|||
|
_loanDocs = LoanDoc.Service.GetLoanDoc(this.ID.Integer);
|
|||
|
}
|
|||
|
return _loanDocs;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
_loanDocs = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Service Factory ILoanParameterService : ILoanParameterService
|
|||
|
|
|||
|
internal static ILoanParameterService Service
|
|||
|
{
|
|||
|
get { return Services.Factory.CreateService<ILoanParameterService>(typeof(ILoanParameterService)); }
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Functions
|
|||
|
public static LoanParameter GetApplicableParameter(Employee oemployee, ID loanid)
|
|||
|
{
|
|||
|
ObjectsTemplate<LoanParameter> opss = LoanParameter.Get();
|
|||
|
LoanParameter oparamter = GetApplicableParameter(oemployee, oemployee.GradeID, opss, loanid);
|
|||
|
|
|||
|
return oparamter;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
public static List<LoanParameter> GetApplicableParameters(Employee employee,
|
|||
|
ID graId, ObjectsTemplate<LoanParameter> parameters)
|
|||
|
{
|
|||
|
List<LoanParameter> applicableParams = parameters.FindAll(delegate(LoanParameter param) { return IsApplicable(param, graId, employee); });
|
|||
|
|
|||
|
return applicableParams;
|
|||
|
}
|
|||
|
|
|||
|
public static LoanParameter GetApplicableParameter(Employee employee,
|
|||
|
ID graId, ObjectsTemplate<LoanParameter> parameters)
|
|||
|
{
|
|||
|
foreach (LoanParameter item in parameters)
|
|||
|
{
|
|||
|
if (IsApplicable(item, graId, employee) == true)
|
|||
|
return item;
|
|||
|
}
|
|||
|
return null;
|
|||
|
}
|
|||
|
|
|||
|
public static LoanParameter GetApplicableParameter(Employee employee,
|
|||
|
ID graId, ObjectsTemplate<LoanParameter> parameters, ID loanid)
|
|||
|
{
|
|||
|
foreach (LoanParameter item in parameters)
|
|||
|
{
|
|||
|
if (item.LoanID == loanid)
|
|||
|
{
|
|||
|
if (IsApplicable(item, graId, employee) == true)
|
|||
|
return item;
|
|||
|
}
|
|||
|
}
|
|||
|
return null;
|
|||
|
}
|
|||
|
|
|||
|
private static bool IsApplicable(LoanParameter param, ID graid, Employee employee)
|
|||
|
{
|
|||
|
bool isApplicable = false;
|
|||
|
|
|||
|
foreach (LoanGrades adgrade in param.LoadGradesTemp)
|
|||
|
{
|
|||
|
if (adgrade.GradeID.Integer == graid.Integer)
|
|||
|
{
|
|||
|
isApplicable = true;
|
|||
|
}
|
|||
|
}
|
|||
|
if (!isApplicable) return false;
|
|||
|
|
|||
|
return true;
|
|||
|
}
|
|||
|
|
|||
|
public static LoanParameter Get(ID nID)
|
|||
|
{
|
|||
|
LoanParameter oLoanParameter = null;
|
|||
|
#region Cache Header
|
|||
|
oLoanParameter = (LoanParameter)_cache["Get", nID];
|
|||
|
if (oLoanParameter != null)
|
|||
|
return oLoanParameter;
|
|||
|
#endregion
|
|||
|
oLoanParameter = LoanParameter.Service.Get(nID);
|
|||
|
#region Cache Footer
|
|||
|
_cache.Add(oLoanParameter, "Get", nID);
|
|||
|
#endregion
|
|||
|
return oLoanParameter;
|
|||
|
}
|
|||
|
|
|||
|
public static ObjectsTemplate<LoanParameter> Get()
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
|
|||
|
ObjectsTemplate<LoanParameter> loanParameters = _cache["Get"] as ObjectsTemplate<LoanParameter>;
|
|||
|
if (loanParameters != null)
|
|||
|
return loanParameters;
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
try
|
|||
|
{
|
|||
|
loanParameters = Service.Get();
|
|||
|
}
|
|||
|
catch (ServiceException e)
|
|||
|
{
|
|||
|
throw new Exception(e.Message, e);
|
|||
|
}
|
|||
|
|
|||
|
#region Cache Footer
|
|||
|
|
|||
|
_cache.Add(loanParameters, "Get");
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
return loanParameters;
|
|||
|
}
|
|||
|
|
|||
|
public ID Save()
|
|||
|
{
|
|||
|
base.SetAuditTrailProperties();
|
|||
|
return LoanParameter.Service.Save(this);
|
|||
|
}
|
|||
|
|
|||
|
public void Delete()
|
|||
|
{
|
|||
|
LoanParameter.Service.Delete(ID);
|
|||
|
}
|
|||
|
|
|||
|
public static ObjectsTemplate<LoanGrades> GetLoanGrades(int loanParameterID)
|
|||
|
{
|
|||
|
ObjectsTemplate<LoanGrades> oLoanGrades = null;
|
|||
|
oLoanGrades = Service.GetLoanGrades(loanParameterID);
|
|||
|
return oLoanGrades;
|
|||
|
}
|
|||
|
|
|||
|
public static ObjectsTemplate<LoanDoc> GetLoanDoc(int loanParameterID)
|
|||
|
{
|
|||
|
ObjectsTemplate<LoanDoc> oLoanDoc = null;
|
|||
|
oLoanDoc = Service.GetLoanDoc(loanParameterID);
|
|||
|
return oLoanDoc;
|
|||
|
}
|
|||
|
#endregion
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region ILoanParameterService Service
|
|||
|
|
|||
|
public interface ILoanParameterService
|
|||
|
{
|
|||
|
LoanParameter Get(ID id);
|
|||
|
ObjectsTemplate<LoanParameter> Get();
|
|||
|
ID Save(LoanParameter item);
|
|||
|
void Delete(ID id);
|
|||
|
|
|||
|
ObjectsTemplate<LoanGrades> GetLoanGrades(int loanParameterID);
|
|||
|
ObjectsTemplate<LoanDoc> GetLoanDoc(int loanParameterID);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|