445 lines
14 KiB
C#
445 lines
14 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.Windows.Forms;
|
|||
|
|
|||
|
namespace Payroll.BO
|
|||
|
{
|
|||
|
#region class BudgetMaster
|
|||
|
[Serializable]
|
|||
|
public class BudgetMaster : AuditTrailBase
|
|||
|
{
|
|||
|
#region Cache Store
|
|||
|
private static Cache _cache = new Cache(typeof(BudgetMaster));
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Constructor
|
|||
|
public BudgetMaster()
|
|||
|
{
|
|||
|
_basedOn = EnumBasedOnPercent.None;
|
|||
|
_effectMonth = DateTime.MinValue;
|
|||
|
_name = string.Empty;
|
|||
|
_overAllPercentage = 0.0;
|
|||
|
_toDate = DateTime.MinValue;
|
|||
|
_individualchanges=null;
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Properties
|
|||
|
|
|||
|
#region BasedOn : EnumBasedOnPercent
|
|||
|
private EnumBasedOnPercent _basedOn;
|
|||
|
public EnumBasedOnPercent BasedOn
|
|||
|
{
|
|||
|
get { return _basedOn; }
|
|||
|
set { _basedOn = value; }
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region EffectMonth : DateTime
|
|||
|
private DateTime _effectMonth;
|
|||
|
public DateTime EffectMonth
|
|||
|
{
|
|||
|
get { return _effectMonth; }
|
|||
|
set { _effectMonth = value; }
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region FromDate : DateTime
|
|||
|
private DateTime _fromDate;
|
|||
|
public DateTime FromDate
|
|||
|
{
|
|||
|
get { return _fromDate; }
|
|||
|
set { _fromDate = value; }
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Name : string
|
|||
|
private string _name;
|
|||
|
public string Name
|
|||
|
{
|
|||
|
get { return _name; }
|
|||
|
set { _name = value; }
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region OverAllPercentage : double
|
|||
|
private double _overAllPercentage;
|
|||
|
public double OverAllPercentage
|
|||
|
{
|
|||
|
get { return _overAllPercentage; }
|
|||
|
set { _overAllPercentage = value; }
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region ToDate : DateTime
|
|||
|
private DateTime _toDate;
|
|||
|
public DateTime ToDate
|
|||
|
{
|
|||
|
get { return _toDate; }
|
|||
|
set { _toDate = value; }
|
|||
|
}
|
|||
|
#endregion
|
|||
|
private ObjectsTemplate<BudgetGrade> _budgetGrades;
|
|||
|
public ObjectsTemplate<BudgetGrade> BudgetGrades
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
if (_budgetGrades == null)
|
|||
|
{
|
|||
|
_budgetGrades = new ObjectsTemplate<BudgetGrade>();
|
|||
|
if (!this.ID.IsUnassigned)
|
|||
|
{
|
|||
|
_budgetGrades = BudgetGrade.Get(this.ID.Integer); // # get by budget master id
|
|||
|
}
|
|||
|
}
|
|||
|
return this._budgetGrades;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
_budgetGrades = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private ObjectsTemplate<BudgetIndivisualChange> _individualchanges;
|
|||
|
public ObjectsTemplate<BudgetIndivisualChange> Individualchanges
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
if (_individualchanges == null)
|
|||
|
{
|
|||
|
_individualchanges = new ObjectsTemplate<BudgetIndivisualChange>();
|
|||
|
if (!this.ID.IsUnassigned)
|
|||
|
{
|
|||
|
_individualchanges = BudgetIndivisualChange.Get(this.ID.Integer); // # get by budget master id
|
|||
|
}
|
|||
|
}
|
|||
|
return this._individualchanges;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
_individualchanges = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
private ObjectsTemplate<BudgetCostCenter> _budgetCCs;
|
|||
|
public ObjectsTemplate<BudgetCostCenter> BudgetCCs
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
if (_budgetCCs == null)
|
|||
|
{
|
|||
|
_budgetCCs = new ObjectsTemplate<BudgetCostCenter>();
|
|||
|
if (!this.ID.IsUnassigned)
|
|||
|
{
|
|||
|
_budgetCCs = BudgetCostCenter.Get(this.ID.Integer); // # get by budget master id
|
|||
|
}
|
|||
|
}
|
|||
|
return _budgetCCs;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
_budgetCCs = value;
|
|||
|
}
|
|||
|
}
|
|||
|
private ObjectsTemplate<BudgetDepartment> _budgetDepts;
|
|||
|
public ObjectsTemplate<BudgetDepartment> BudgetDepartments
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
if (_budgetDepts == null)
|
|||
|
{
|
|||
|
_budgetDepts = new ObjectsTemplate<BudgetDepartment>();
|
|||
|
if (!this.ID.IsUnassigned)
|
|||
|
{
|
|||
|
_budgetDepts = BudgetDepartment.Get(this.ID.Integer); // # get by budget master id
|
|||
|
}
|
|||
|
}
|
|||
|
return _budgetDepts;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
_budgetDepts = value;
|
|||
|
}
|
|||
|
}
|
|||
|
//private ObjectsTemplate<BudgetNewJoinerCrG> _budgetNewJoinerCCs;
|
|||
|
//public ObjectsTemplate<BudgetNewJoinerCrG> BudgetNewJoinerCCs
|
|||
|
//{
|
|||
|
// get
|
|||
|
// {
|
|||
|
// if (_budgetNewJoinerCCs == null && this.ID == null && this.ID.Integer > 0)
|
|||
|
// {
|
|||
|
// BudgetNewJoiner b = new BudgetNewJoiner();
|
|||
|
// _budgetNewJoinerCCs = b.OBudgetNewJoinerCrGs; //BudgetNewJoinerCrG.Get(); // # get by budget master id
|
|||
|
// }
|
|||
|
// return _budgetNewJoinerCCs;
|
|||
|
// }
|
|||
|
// set
|
|||
|
// {
|
|||
|
// _budgetNewJoinerCCs = value;
|
|||
|
// }
|
|||
|
//}
|
|||
|
|
|||
|
|
|||
|
private ObjectsTemplate<BudgetComponent> _components;
|
|||
|
public ObjectsTemplate<BudgetComponent> Components
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
if (_components == null)
|
|||
|
{
|
|||
|
_components = new ObjectsTemplate<BudgetComponent>();
|
|||
|
if (!this.ID.IsUnassigned)
|
|||
|
{
|
|||
|
_components = BudgetComponent.Get(this.ID.Integer); // # get by budget master id
|
|||
|
}
|
|||
|
}
|
|||
|
return _components;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
_components = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
private ObjectsTemplate<BudgetNewJoiner> _newJoiners;
|
|||
|
public ObjectsTemplate<BudgetNewJoiner> NewJoiners
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
if (_newJoiners == null)
|
|||
|
{
|
|||
|
_newJoiners = new ObjectsTemplate<BudgetNewJoiner>();
|
|||
|
if (!this.ID.IsUnassigned)
|
|||
|
{
|
|||
|
_newJoiners = BudgetNewJoiner.Get(this.ID.Integer); // # get by budget master id
|
|||
|
}
|
|||
|
}
|
|||
|
return _newJoiners;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
_newJoiners = value;
|
|||
|
}
|
|||
|
}
|
|||
|
private ObjectsTemplate<BudgetProcessMonthly> _processMonthly;
|
|||
|
public ObjectsTemplate<BudgetProcessMonthly> BudgetProcessMonthlys
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
if (_processMonthly == null)
|
|||
|
{
|
|||
|
_processMonthly = new ObjectsTemplate<BudgetProcessMonthly>();
|
|||
|
if (!this.ID.IsUnassigned)
|
|||
|
{
|
|||
|
_processMonthly = BudgetProcessMonthly.Get(); // # get by budget master id
|
|||
|
}
|
|||
|
}
|
|||
|
return _processMonthly;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
_processMonthly = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
|
|||
|
#region Service Factory IBudgetMasterService : IBudgetMasterService
|
|||
|
|
|||
|
|
|||
|
public List<BudgetIndivisualChange> getException(DateTime onmonth, Employee oEmployee)
|
|||
|
{
|
|||
|
onmonth = Ease.CoreV35.Utility.Global.DateFunctions.LastDateOfMonth(onmonth);
|
|||
|
List<BudgetIndivisualChange> exceptions = new List<BudgetIndivisualChange>();
|
|||
|
if (this.Individualchanges != null && this.Individualchanges.Count > 0)
|
|||
|
exceptions = this.Individualchanges.FindAll(delegate(BudgetIndivisualChange oItem) { return oItem.EmployeeID == oEmployee.ID && onmonth >= Ease.CoreV35.Utility.Global.DateFunctions.LastDateOfMonth(oItem.EffectDate); });
|
|||
|
return exceptions;
|
|||
|
}
|
|||
|
|
|||
|
public List<BudgetNewJoiner> GetNewJoiner(DateTime onmonth)
|
|||
|
{
|
|||
|
onmonth = Ease.CoreV35.Utility.Global.DateFunctions.LastDateOfMonth(onmonth);
|
|||
|
List<BudgetNewJoiner> newJoiners = new List<BudgetNewJoiner>();
|
|||
|
if (this.NewJoiners != null && this.NewJoiners.Count > 0)
|
|||
|
newJoiners = this.NewJoiners.FindAll(delegate(BudgetNewJoiner oItem) { return onmonth >= Ease.CoreV35.Utility.Global.DateFunctions.LastDateOfMonth(oItem.FromDate); });
|
|||
|
return newJoiners;
|
|||
|
}
|
|||
|
public List<BudgetCostCenter> GetCC(DateTime onmonth)
|
|||
|
{
|
|||
|
List<BudgetCostCenter> CCs = new List<BudgetCostCenter>();
|
|||
|
onmonth = Ease.CoreV35.Utility.Global.DateFunctions.LastDateOfMonth(onmonth);
|
|||
|
if (this.BudgetCCs != null && this.BudgetCCs.Count > 0)
|
|||
|
CCs = this.BudgetCCs.FindAll(delegate(BudgetCostCenter oItem) { return onmonth >= Ease.CoreV35.Utility.Global.DateFunctions.LastDateOfMonth(oItem.FromMonth) ; });
|
|||
|
return CCs;
|
|||
|
}
|
|||
|
public List<BudgetNewJoinerCrG> GetNewJoinerCC(DateTime onmonth)
|
|||
|
{
|
|||
|
List<BudgetNewJoinerCrG> newJoinerCCs = new List<BudgetNewJoinerCrG>();
|
|||
|
onmonth = Ease.CoreV35.Utility.Global.DateFunctions.LastDateOfMonth(onmonth);
|
|||
|
List<BudgetNewJoiner> newJoiners = new List<BudgetNewJoiner>();
|
|||
|
if (this.NewJoiners != null && this.NewJoiners.Count > 0)
|
|||
|
{
|
|||
|
newJoiners = this.NewJoiners.FindAll(delegate(BudgetNewJoiner oItem) { return onmonth >= Ease.CoreV35.Utility.Global.DateFunctions.LastDateOfMonth(oItem.FromDate); });
|
|||
|
foreach(BudgetNewJoiner bnj in newJoiners)
|
|||
|
{
|
|||
|
foreach (BudgetNewJoinerCrG bncc in bnj.OBudgetNewJoinerCrGs)
|
|||
|
{
|
|||
|
newJoinerCCs.Add(bncc);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
return newJoinerCCs;
|
|||
|
}
|
|||
|
public List<BudgetComponent> GetApplicableParameters(Employee employee, ID graId)
|
|||
|
{
|
|||
|
List<BudgetComponent> applicableParams = this.Components.FindAll(delegate(BudgetComponent param) { return IsApplicable(param, graId, employee) ;});
|
|||
|
|
|||
|
return applicableParams;
|
|||
|
}
|
|||
|
|
|||
|
private static bool IsApplicable(BudgetComponent param, ID graid, Employee employee)
|
|||
|
{
|
|||
|
bool isApplicable = false;
|
|||
|
|
|||
|
foreach (BudgetComponentGrade adgrade in param.OBudgetComponentGrades)
|
|||
|
{
|
|||
|
if (adgrade.GradeID.Integer == graid.Integer)
|
|||
|
{
|
|||
|
isApplicable = true;
|
|||
|
}
|
|||
|
}
|
|||
|
if (!isApplicable) return false;
|
|||
|
return true;
|
|||
|
}
|
|||
|
|
|||
|
internal static IBudgetMasterService Service
|
|||
|
{
|
|||
|
get { return Services.Factory.CreateService<IBudgetMasterService>(typeof(IBudgetMasterService)); }
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Function(s)
|
|||
|
|
|||
|
#region Get
|
|||
|
|
|||
|
public static BudgetMaster Get(ID nID)
|
|||
|
{
|
|||
|
BudgetMaster oBudgetMaster = null;
|
|||
|
#region Cache Header
|
|||
|
oBudgetMaster = (BudgetMaster)_cache["Get", nID];
|
|||
|
if (oBudgetMaster != null)
|
|||
|
return oBudgetMaster;
|
|||
|
#endregion
|
|||
|
|
|||
|
try
|
|||
|
{
|
|||
|
oBudgetMaster = Service.Get(nID, SystemInformation.CurrentSysInfo.PayrollTypeID);
|
|||
|
}
|
|||
|
catch (ServiceException e)
|
|||
|
{
|
|||
|
throw new Exception(e.Message, e);
|
|||
|
}
|
|||
|
|
|||
|
#region Cache Footer
|
|||
|
_cache.Add(oBudgetMaster, "Get", nID);
|
|||
|
#endregion
|
|||
|
return oBudgetMaster;
|
|||
|
}
|
|||
|
|
|||
|
public static ObjectsTemplate<BudgetMaster> Get()
|
|||
|
{
|
|||
|
|
|||
|
#region Cache Header
|
|||
|
ObjectsTemplate<BudgetMaster> oBudgetMasters = _cache["Get"] as ObjectsTemplate<BudgetMaster>;
|
|||
|
if (oBudgetMasters != null)
|
|||
|
return oBudgetMasters;
|
|||
|
#endregion
|
|||
|
|
|||
|
try
|
|||
|
{
|
|||
|
oBudgetMasters = Service.Get(SystemInformation.CurrentSysInfo.PayrollTypeID);
|
|||
|
|
|||
|
}
|
|||
|
catch (ServiceException e)
|
|||
|
{
|
|||
|
|
|||
|
throw new Exception(e.Message, e);
|
|||
|
}
|
|||
|
#region Cache Footer
|
|||
|
_cache.Add(oBudgetMasters, "Get");
|
|||
|
#endregion
|
|||
|
|
|||
|
return oBudgetMasters;
|
|||
|
}
|
|||
|
public static ObjectsTemplate<BudgetMaster> Get(DateTime dtFromDate, DateTime dtToDate)
|
|||
|
{
|
|||
|
|
|||
|
#region Cache Header
|
|||
|
ObjectsTemplate<BudgetMaster> oBudgetMasters = _cache["Get"] as ObjectsTemplate<BudgetMaster>;
|
|||
|
if (oBudgetMasters != null)
|
|||
|
return oBudgetMasters;
|
|||
|
#endregion
|
|||
|
|
|||
|
try
|
|||
|
{
|
|||
|
oBudgetMasters = Service.Get(dtFromDate, dtToDate, SystemInformation.CurrentSysInfo.PayrollTypeID);
|
|||
|
|
|||
|
}
|
|||
|
catch (ServiceException e)
|
|||
|
{
|
|||
|
|
|||
|
throw new Exception(e.Message, e);
|
|||
|
}
|
|||
|
#region Cache Footer
|
|||
|
_cache.Add(oBudgetMasters, "Get");
|
|||
|
#endregion
|
|||
|
|
|||
|
return oBudgetMasters;
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Save
|
|||
|
public ID Save(ProgressBar pbar)
|
|||
|
{
|
|||
|
//SetAuditTrailProperties();
|
|||
|
return Service.Save(this, pbar, SystemInformation.CurrentSysInfo.PayrollTypeID);
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Delete
|
|||
|
public static void Delete(ID id)
|
|||
|
{
|
|||
|
Service.Delete(id, SystemInformation.CurrentSysInfo.PayrollTypeID);
|
|||
|
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region IBudgetMasterService
|
|||
|
public interface IBudgetMasterService
|
|||
|
{
|
|||
|
BudgetMaster Get(ID nID,ID PayrollTypeID);
|
|||
|
ObjectsTemplate<BudgetMaster> Get(ID PayrollTypeID);
|
|||
|
ObjectsTemplate<BudgetMaster> Get(DateTime dtFromDate, DateTime dtToDate, ID PayrollTypeID);
|
|||
|
ID Save(BudgetMaster oBudgetMaster, ProgressBar pbar, ID PayrollTypeID);
|
|||
|
void Delete(ID nID, ID PayrollTypeID);
|
|||
|
}
|
|||
|
#endregion
|
|||
|
}
|