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

508 lines
13 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Ease.CoreV35;
using Ease.CoreV35.Model;
using Ease.CoreV35.Caching;
using System.Data.Linq.Mapping;
using System.Collections;
namespace Payroll.BO
{
#region OTProcess
[Serializable]
public class OTProcess : AuditTrailBase
{
#region Cache Store
private static Cache _cache = new Cache(typeof(OTProcess));
#endregion
#region Constructor
public OTProcess()
{
_monthDate = DateTime.MinValue;
_employeeID = null;
_amount = 0;
_termID = null;
_termParameterID = null;
_empOverTimeID = null;
_totalHour = 0;
_arrearAmount = 0;
_oTMonth = DateTime.MinValue;
_empOverTime = null;
_PayrollTypeID = null;
}
#endregion
#region Properties
#region monthDate : DateTime
private DateTime _monthDate;
public DateTime MonthDate
{
get { return _monthDate; }
set
{
base.OnPropertyChange<DateTime>("monthDate", _monthDate, value);
_monthDate = 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 amount : double
private double _amount;
public double Amount
{
get { return _amount; }
set
{
base.OnPropertyChange<double>("amount", _amount, value);
_amount = value;
}
}
#endregion
#region termID : ID
private ID _termID;
public ID TermID
{
get { return _termID; }
set
{
base.OnPropertyChange<ID>("termID", _termID, value);
_termID = value;
}
}
#endregion
#region Term : ID
private Term _term;
public Term TermObj
{
get
{
if (_term == null && !this.TermID.IsUnassigned && this.TermID.Integer > 0)
{
_term = Term.Get(this.TermID);
}
return _term;
}
}
#endregion
#region TermParameter : ID
private TermParameter _termParameter;
public TermParameter TermParam
{
get
{
if (_termParameter == null && !this.TermParameterID.IsUnassigned && this.ID.Integer > 0)
{
_termParameter = TermParameter.Get(this.TermParameterID);
}
return _termParameter;
}
}
#endregion
#region TermParameterID : ID
private ID _termParameterID;
public ID TermParameterID
{
get { return _termParameterID; }
set
{
base.OnPropertyChange<ID>("TermParameterID", _termParameterID, value);
_termParameterID = value;
}
}
#endregion
#region EmpOverTimeID : ID
private ID _empOverTimeID;
public ID EmpOverTimeID
{
get { return _empOverTimeID; }
set
{
base.OnPropertyChange<ID>("EmpOverTimeID", _empOverTimeID, value);
_empOverTimeID = value;
}
}
#endregion
#region totalHour : double
private double _totalHour;
public double TotalHour
{
get { return _totalHour; }
set
{
base.OnPropertyChange<double>("totalHour", _totalHour, value);
_totalHour = value;
}
}
#endregion
#region EmpOverTime : EmpOverTime
private EmployeeOverTime _empOverTime;
public EmployeeOverTime EmpOverTime
{
get
{
if (_empOverTime == null && !_empOverTimeID.IsUnassigned && _empOverTimeID.Integer>0)
{
_empOverTime = EmployeeOverTime.Get(_empOverTimeID);
}
return _empOverTime;
}
set
{
_empOverTime = value;
}
}
#endregion
#region ArrearAmount : double
private double _arrearAmount;
public double ArrearAmount
{
get { return _arrearAmount; }
set
{
base.OnPropertyChange<double>("ArrearAmount", _arrearAmount, value);
_arrearAmount = value;
}
}
#endregion
#region OTMonth : DateTime
private DateTime _oTMonth;
public DateTime OTMonth
{
get { return _oTMonth; }
set
{
base.OnPropertyChange<DateTime>("OTMonth", _oTMonth, value);
_oTMonth = value;
}
}
#endregion
#region PayrollTypeID : ID
private ID _PayrollTypeID;
public ID PayrollTypeID
{
get { return _PayrollTypeID; }
set
{
base.OnPropertyChange<ID>("PayrollTypeID", _PayrollTypeID, value);
_PayrollTypeID = value;
}
}
#endregion
#endregion
#region Service Factory IOTProcessService : IOTProcessService
internal static IOTProcessService Service
{
get { return Services.Factory.CreateService<IOTProcessService>(typeof(IOTProcessService)); }
}
#endregion
#region Functions
public static OTProcess Get(ID nID)
{
OTProcess oOTProcess = null;
#region Cache Header
oOTProcess = (OTProcess)_cache["Get", nID];
if (oOTProcess != null)
return oOTProcess;
#endregion
oOTProcess = OTProcess.Service.Get(nID);
#region Cache Footer
_cache.Add(oOTProcess, "Get", nID);
#endregion
return oOTProcess;
}
public static ObjectsTemplate<OTProcess> Get()
{
#region Cache Header
ObjectsTemplate<OTProcess> oTProcess = _cache["Get"] as ObjectsTemplate<OTProcess>;
if (oTProcess != null)
return oTProcess;
#endregion
try
{
oTProcess = Service.Get();
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(oTProcess, "Get");
#endregion
return oTProcess;
}
public static DataSet GetOTProcessData(DateTime Month,string sEmpID)
{
DataSet oTProcess = null;
try
{
oTProcess = Service.GetOTProcessData(Month,sEmpID);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
return oTProcess;
}
public static DataSet GetOTMonthRangeData(DateTime FDate,DateTime TDate)
{
DataSet oTProcess = null;
try
{
oTProcess = Service.GetOTMonthRangeData(FDate,TDate);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
return oTProcess;
}
public static DataSet GetBranchWiseOT(DateTime Month)
{
DataSet oTProcess = null;
try
{
oTProcess = Service.GetBranchWiseOT(Month);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
return oTProcess;
}
public static DataSet GetLocationWiseOT(DateTime FDate, DateTime TDate)
{
DataSet oTProcess = null;
try
{
oTProcess = Service.GetLocationWiseOT(FDate, TDate);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
return oTProcess;
}
public static ObjectsTemplate<OTProcess> Get(DateTime dMonthDate)
{
#region Cache Header
ObjectsTemplate<OTProcess> oTProcess = _cache["Get", dMonthDate] as ObjectsTemplate<OTProcess>;
if (oTProcess != null)
return oTProcess;
#endregion
try
{
oTProcess = Service.Get(dMonthDate);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(oTProcess, "Get", dMonthDate);
#endregion
return oTProcess;
}
public static ObjectsTemplate<OTProcess> GetbyOtMonth(Hashtable empList,Hashtable monthDate )
{
ObjectsTemplate<OTProcess> oTProcess = null;
string sEmpIDs = string.Empty, sDates = string.Empty;
foreach (int nKey in empList.Keys)
{
sEmpIDs = sEmpIDs + empList[nKey].ToString() + ",";
}
if (sEmpIDs.Length > 0)
{
sEmpIDs = sEmpIDs.Substring(0, sEmpIDs.Length - 1);
}
foreach (DateTime dKey in monthDate.Keys)
{
sDates = sDates + "'" + Convert.ToDateTime(monthDate[dKey].ToString()).ToString("dd MMM yyyy") + "'" + ",";
}
if (sDates.Length > 0)
{
sDates = sDates.Substring(0, sDates.Length - 1);
}
try
{
if (sEmpIDs.Length > 0 && sDates.Length > 0)
{
oTProcess = Service.GetbyOtMonth(sEmpIDs, sDates);
}
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
return oTProcess;
}
public ID Save()
{
return OTProcess.Service.Save(this);
}
public static void Save(ObjectsTemplate<OTProcess> otProcesses)
{
foreach (OTProcess process in otProcesses)
{
process.SetAuditTrailProperties();
}
OTProcess.Service.Save(otProcesses);
}
public void Delete()
{
OTProcess.Service.Delete(ID);
}
public static bool IsProcessed(DateTime dMonthDate)
{
return OTProcess.Service.IsProcessed(dMonthDate, SystemInformation.CurrentSysInfo.PayrollTypeID);
}
public static void UndoProcess(DateTime dMonthDate,ID nPayrollTypeID)
{
OTProcess.Service.Delete(dMonthDate,nPayrollTypeID);
}
public static DataSet GetCostCenterWiseOT(DateTime dateTime, string sEmpID)
{
DataSet oTProcess = null;
try
{
oTProcess = Service.GetCostCenterWiseOT(dateTime, sEmpID);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
return oTProcess;
}
#endregion
}
#endregion
#region IOTProcess Service
public interface IOTProcessService
{
OTProcess Get(ID id);
ObjectsTemplate<OTProcess> Get();
ID Save(OTProcess item);
void Delete(ID id);
void Save(ObjectsTemplate<OTProcess> otProcesses);
bool IsProcessed(DateTime dMonthDate, ID PayrollTypeID);
void Delete(DateTime dMonthDate,ID nPayrollTypeID);
ObjectsTemplate<OTProcess> Get(DateTime dMonthDate);
ObjectsTemplate<OTProcess> GetbyOtMonth(string sEmpIDs, string sMonths);
DataSet GetOTProcessData(DateTime Month,string sEmpID);
DataSet GetOTMonthRangeData(DateTime FDate,DateTime TDate);
DataSet GetBranchWiseOT(DateTime Month);
DataSet GetLocationWiseOT(DateTime FDate, DateTime TDate);
DataSet GetCostCenterWiseOT(DateTime dateTime, string sEmpID);
}
#endregion
}