CEL_Payroll/Payroll.BO/Attendence/DailyAttnProcess.cs

905 lines
27 KiB
C#
Raw 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.Caching;
using Ease.CoreV35.Model;
using System.Data;
namespace Payroll.BO
{
#region DailyAttnProcess
[Serializable]
public class DailyAttnProcess : AuditTrailBase
{
#region Cache Store
private static Cache _cache = new Cache(typeof(DailyAttnProcess));
#endregion
#region Constructor
public DailyAttnProcess()
{
_employeeID = ID.FromInteger(0);
_attnDate = DateTime.MinValue;
_shiftID = ID.FromInteger(0);
_inTime = DateTime.MinValue;
_outTime = DateTime.MinValue;
_workDayType = EnumWorkPlanDayType.WorkingDay;
_attenType = 0;
_comments = string.Empty;
_isManualEntry = false;
_isLate = false;
_referenceID = ID.FromInteger(0);
_employee = null;
_lateHour = 0;
_earlyHour = 0;
_oTHour = 0;
_reason = string.Empty;
}
#endregion
#region Properties
#region employeeID : ID
private ID _employeeID;
public ID EmployeeID
{
get { return _employeeID; }
set
{
base.OnPropertyChange<ID>("employeeID", _employeeID, value);
_employeeID = value;
}
}
#endregion
#region attnDate : DateTime
private DateTime _attnDate;
public DateTime AttnDate
{
get { return _attnDate; }
set
{
base.OnPropertyChange<DateTime>("attnDate", _attnDate, value);
_attnDate = value;
}
}
#endregion
#region shiftID : ID
private ID _shiftID;
public ID ShiftID
{
get { return _shiftID; }
set
{
base.OnPropertyChange<ID>("shiftID", _shiftID, value);
_shiftID = value;
}
}
#endregion
#region inTime : DateTime
private DateTime _inTime;
public DateTime InTime
{
get { return _inTime; }
set
{
base.OnPropertyChange<DateTime>("inTime", _inTime, value);
_inTime = value;
}
}
#endregion
#region outTime : DateTime
private DateTime _outTime;
public DateTime OutTime
{
get { return _outTime; }
set
{
base.OnPropertyChange<DateTime>("outTime", _outTime, value);
_outTime = value;
}
}
#endregion
#region WorkDayType : EnumWorkPlanDayType
private EnumWorkPlanDayType _workDayType;
public EnumWorkPlanDayType WorkDayType
{
get { return _workDayType; }
set
{
base.OnPropertyChange<short>("workDayType", (short)_workDayType, (short)value);
_workDayType = value;
}
}
#endregion
#region attenType : EnumAttendanceType
private EnumAttendanceType _attenType;
public EnumAttendanceType AttenType
{
get { return _attenType; }
set
{
base.OnPropertyChange<short>("attenType", (short)_attenType, (short)value);
_attenType = value;
}
}
#endregion
#region comments : string
private string _comments;
public string Comments
{
get { return _comments; }
set
{
base.OnPropertyChange<string>("comments", _comments, value);
_comments = value;
}
}
#endregion
#region Reason : string
private string _reason;
public string Reason
{
get { return _reason; }
set
{
_reason = value;
}
}
#endregion
#region isManualEntry : bool
private bool _isManualEntry;
public bool IsManualEntry
{
get { return _isManualEntry; }
set
{
base.OnPropertyChange<bool>("isManualEntry", _isManualEntry, value);
_isManualEntry = value;
}
}
#endregion
#region IsLate : bool
private bool _isLate;
public bool IsLate
{
get { return _isLate; }
set
{
base.OnPropertyChange<bool>("isLate", _isLate, value);
_isLate = value;
}
}
#endregion
#region LateHour : double
private double _lateHour;
public double LateHour
{
get { return _lateHour; }
set
{
base.OnPropertyChange<double>("LateHour", _lateHour, value);
_lateHour = value;
}
}
#endregion
#region EarlyHour : double
private double _earlyHour;
public double EarlyHour
{
get { return _earlyHour; }
set
{
base.OnPropertyChange<double>("EarlyHour", _earlyHour, value);
_earlyHour = value;
}
}
#endregion
#region OTHour : double
private double _oTHour;
public double OTHour
{
get { return _oTHour; }
set
{
base.OnPropertyChange<double>("OTHour", _oTHour, value);
_oTHour = value;
}
}
#endregion
#region referenceID : ID
private ID _referenceID;
public ID ReferenceID
{
get { return _referenceID; }
set
{
base.OnPropertyChange<ID>("referenceID", _referenceID, value);
_referenceID = 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 Shift : Shift
private Shift _shift;
public Shift Shift
{
get
{
if (_shiftID.Integer > 0 && _shift == null)
{
_shift = new Shift();
_shift = Shift.Get(_shiftID);
}
return this._shift;
}
set
{
_shift = value;
}
}
#endregion
#region Service Factory IDailyAttnProcessService : IDailyAttnProcessService
internal static IDailyAttnProcessService Service
{
get { return Services.Factory.CreateService<IDailyAttnProcessService>(typeof(IDailyAttnProcessService)); }
}
#endregion
#endregion
#region Functions
public static DailyAttnProcess Get(ID nID)
{
DailyAttnProcess oDailyAttnProcess = null;
#region Cache Header
oDailyAttnProcess = (DailyAttnProcess)_cache["Get", nID];
if (oDailyAttnProcess != null)
return oDailyAttnProcess;
#endregion
oDailyAttnProcess = DailyAttnProcess.Service.Get(nID);
#region Cache Footer
_cache.Add(oDailyAttnProcess, "Get", nID);
#endregion
return oDailyAttnProcess;
}
public static ObjectsTemplate<DailyAttnProcess> Get()
{
#region Cache Header
ObjectsTemplate<DailyAttnProcess> dailyAttnProcesses = _cache["Get"] as ObjectsTemplate<DailyAttnProcess>;
if (dailyAttnProcesses != null)
return dailyAttnProcesses;
#endregion
try
{
dailyAttnProcesses = DailyAttnProcess.Service.Get();
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(dailyAttnProcesses, "Get");
#endregion
return dailyAttnProcesses;
}
public static ObjectsTemplate<DailyAttnProcess> GetProcessByWPG(EnumWorkPlanGroup wpg, DateTime attnDate)
{
#region Cache Header
ObjectsTemplate<DailyAttnProcess> dailyAttnProcesses = _cache["GetProcessByWPG", wpg, attnDate] as ObjectsTemplate<DailyAttnProcess>;
if (dailyAttnProcesses != null)
return dailyAttnProcesses;
#endregion
try
{
dailyAttnProcesses = Service.GetProcessByWPG(wpg, attnDate);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(dailyAttnProcesses, "GetProcessByWPG", wpg, attnDate);
#endregion
return dailyAttnProcesses;
}
public static ObjectsTemplate<DailyAttnProcess> Get(DateTime attnDate)
{
#region Cache Header
ObjectsTemplate<DailyAttnProcess> dailyAttnProcesses = _cache["Get", attnDate] as ObjectsTemplate<DailyAttnProcess>;
if (dailyAttnProcesses != null)
return dailyAttnProcesses;
#endregion
try
{
dailyAttnProcesses = Service.Get(attnDate);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(dailyAttnProcesses, "Get", attnDate);
#endregion
return dailyAttnProcesses;
}
public static ObjectsTemplate<DailyAttnProcess> GetManualProcess(DateTime attnDate)
{
#region Cache Header
ObjectsTemplate<DailyAttnProcess> dailyAttnProcesses = _cache["GetManualProcess", attnDate] as ObjectsTemplate<DailyAttnProcess>;
if (dailyAttnProcesses != null)
return dailyAttnProcesses;
#endregion
try
{
dailyAttnProcesses = Service.GetManualProcess(attnDate);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(dailyAttnProcesses, "GetManualProcess", attnDate);
#endregion
return dailyAttnProcesses;
}
public static ObjectsTemplate<DailyAttnProcess> Get(ID empID, DateTime fromDate, DateTime toDate)
{
#region Cache Header
ObjectsTemplate<DailyAttnProcess> dailyAttnProcesses = _cache["Get", empID, fromDate, toDate] as ObjectsTemplate<DailyAttnProcess>;
if (dailyAttnProcesses != null)
return dailyAttnProcesses;
#endregion
try
{
dailyAttnProcesses = Service.Get(empID, fromDate, toDate);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(dailyAttnProcesses, "Get", empID, fromDate, toDate);
#endregion
return dailyAttnProcesses;
}
public static ObjectsTemplate<DailyAttnProcess> Get(string empID, DateTime fromDate, DateTime toDate)
{
#region Cache Header
ObjectsTemplate<DailyAttnProcess> dailyAttnProcesses = _cache["Get", empID, fromDate, toDate] as ObjectsTemplate<DailyAttnProcess>;
if (dailyAttnProcesses != null)
return dailyAttnProcesses;
#endregion
try
{
dailyAttnProcesses = Service.Get(empID, fromDate, toDate);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(dailyAttnProcesses, "Get", empID, fromDate, toDate);
#endregion
return dailyAttnProcesses;
}
public static ObjectsTemplate<DailyAttnProcess> Get(DateTime fromDate, DateTime toDate)
{
#region Cache Header
ObjectsTemplate<DailyAttnProcess> dailyAttnProcesses = _cache["Get", fromDate, toDate] as ObjectsTemplate<DailyAttnProcess>;
if (dailyAttnProcesses != null)
return dailyAttnProcesses;
#endregion
try
{
dailyAttnProcesses = Service.Get(fromDate, toDate);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(dailyAttnProcesses, "Get",fromDate, toDate);
#endregion
return dailyAttnProcesses;
}
public static ObjectsTemplate<DailyAttnProcess> Get(DateTime attnDate, ID shiftID, EnumAttendanceType attnType)
{
#region Cache Header
ObjectsTemplate<DailyAttnProcess> dailyAttnProcesses = _cache["Get", attnDate, shiftID, attnType] as ObjectsTemplate<DailyAttnProcess>;
if (dailyAttnProcesses != null)
return dailyAttnProcesses;
#endregion
try
{
dailyAttnProcesses = Service.Get(attnDate, shiftID, attnType);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(dailyAttnProcesses, "Get", attnDate, shiftID, attnType);
#endregion
return dailyAttnProcesses;
}
public ID Save()
{
this.SetAuditTrailProperties();
return DailyAttnProcess.Service.Save(this);
}
public static void Save(ObjectsTemplate<DailyAttnProcess> dAttnProcessess, bool IscounterClock)
{
foreach (DailyAttnProcess dAttnProcess in dAttnProcessess)
{
dAttnProcess.SetAuditTrailProperties();
}
DailyAttnProcess.Service.Save(dAttnProcessess, IscounterClock);
}
public static void SaveAuto(ObjectsTemplate<DailyAttnProcess> dailyattProcesses, AttnProcessRunSummary oAttnRunSummary)
{
foreach (DailyAttnProcess dAttnProcess in dailyattProcesses)
{
dAttnProcess.SetAuditTrailProperties();
}
DailyAttnProcess.Service.SaveAuto(dailyattProcesses, oAttnRunSummary);
}
//new
public static ObjectsTemplate<DailyAttnProcess> GetWhrOutTimeIsNull(DateTime attnDate, ID shiftID)
{
#region Cache Header
ObjectsTemplate<DailyAttnProcess> dailyAttnProcesses = _cache["GetWhrOutTimeIsNull", attnDate, shiftID] as ObjectsTemplate<DailyAttnProcess>;
if (dailyAttnProcesses != null)
return dailyAttnProcesses;
#endregion
try
{
dailyAttnProcesses = Service.GetWhrOutTimeIsNull(attnDate, shiftID);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(dailyAttnProcesses, "GetWhrOutTimeIsNull", attnDate, shiftID);
#endregion
return dailyAttnProcesses;
}
//
public void Delete()
{
DailyAttnProcess.Service.Delete(ID);
}
public static DateTime GetLastProcessDate()
{
DateTime lastProcessDate = DateTime.MinValue;
try
{
lastProcessDate = DailyAttnProcess.Service.GetLastProcessDate();
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
return lastProcessDate;
}
public static DateTime GetLastProcessDateByPayrollType()
{
DateTime lastProcessDate = DateTime.MinValue;
try
{
lastProcessDate = DailyAttnProcess.Service.GetLastProcessDateByPayrollType(SystemInformation.CurrentSysInfo.PayrollTypeID);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
return lastProcessDate;
}
public void UpdateLeave(ID employeeID, ID leaveID, DateTime leavaDate, int n)
{
DailyAttnProcess.Service.UpdateLeave(employeeID, leaveID, leavaDate, n);
}
public static DataSet GetMonthlyAttn(DateTime dFromDate, DateTime dToDate, string sEmpID)
{
DataSet monthlyAttn = null;
try
{
monthlyAttn = Service.GetMonthlyAttn(dFromDate, dToDate, sEmpID);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
return monthlyAttn;
}
public static DataSet GetDailyInOut(DateTime attndate, string sEmpID)
{
DataSet dailyInOut = null;
try
{
dailyInOut = Service.GetDailyInOut(attndate, sEmpID);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
return dailyInOut;
}
public static DataSet GetDailyDataByStatus(DateTime attnDate, string sEmpID, params EnumAttendanceType[] eStatus)
{
DataSet dailyInOut = null;
string sStatus = string.Empty;
sStatus = eStatus.Aggregate(new StringBuilder(),
(sb, el) => sb.Append(((int)el).ToString() + ","),
sb => sb.ToString().Trim(','));
try
{
dailyInOut = Service.GetDailyDataByStatus(attnDate,sStatus,sEmpID);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
return dailyInOut;
}
public static DataSet GetDateRangeDataByStatus(DateTime attnFromDate, DateTime attnToDate, string sEmpID, params EnumAttendanceType[] eStatus)
{
DataSet dailyInOut = null;
string sStatus = string.Empty;
sStatus = eStatus.Aggregate(new StringBuilder(),
(sb, el) => sb.Append(((int)el).ToString() + ","),
sb => sb.ToString().Trim(','));
try
{
dailyInOut = Service.GetDateRangeDataByStatus(attnFromDate,attnToDate, sStatus, sEmpID);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
return dailyInOut;
}
public static DataSet GetDailyAbsent(DateTime attndate, string sEmpID)
{
DataSet dailyAbsent = null;
try
{
dailyAbsent = Service.GetDailyAbsent(attndate, sEmpID);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
return dailyAbsent;
}
public static DataSet GetDailyInOutAndAbsent(DateTime attnDate, string sEmpID)
{
DataSet dailyInOutAndAbsent = null;
try
{
dailyInOutAndAbsent = Service.GetDailyInOutAndAbsent(attnDate, sEmpID);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
return dailyInOutAndAbsent;
}
public static DataSet GetMonthlyDetail(DateTime dFromDate, DateTime dToDate, string sEmpID)
{
DataSet monthlyDetail = null;
try
{
monthlyDetail = Service.GetMonthlyDetail(dFromDate, dToDate, sEmpID);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
return monthlyDetail;
}
public static DataSet GetMonthlyLongAbsent(DateTime dFromDate, DateTime dToDate, int totalAbsentDays)
{
DataSet monthlyDetail = null;
try
{
monthlyDetail = Service.GetMonthlyLongAbsent(dFromDate, dToDate, totalAbsentDays);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
return monthlyDetail;
}
public static DataSet GetEmpAttenInfo(string sEmpID)
{
DataSet empAttenInfo = null;
try
{
empAttenInfo = Service.GetEmpAttenInfo(sEmpID);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
return empAttenInfo;
}
//for creating AccessCard
public static DataSet GetEmpCardInfo(string sEmpID)
{
DataSet empAttenInfo = null;
try
{
empAttenInfo = Service.GetEmpCardInfo(sEmpID);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
return empAttenInfo;
}
public static DataSet GetEmpCardInfoPerPage(string sEmpID)
{
DataSet empAttenInfo = null;
try
{
empAttenInfo = Service.GetEmpCardInfoPerPage(sEmpID);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
return empAttenInfo;
}
//return no. of holidays by month range
public static DataSet GetHolidays(DateTime attndate, ID empID)
{
DataSet holidays = null;
try
{
holidays = Service.GetHolidays(attndate, empID);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
return holidays;
}
public static DataSet GetPresentDays(DateTime attndate, ID empID)
{
DataSet presentDays = null;
try
{
presentDays = Service.GetPresentDays(attndate, empID);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
return presentDays;
}
public static ObjectsTemplate<DailyAttnProcess> GetEmployeesFirstAttendances(string employeeIDs)
{
ObjectsTemplate<DailyAttnProcess> oFirstAttendances = null;
try
{
oFirstAttendances = Service.GetEmployeesFirstAttendances(employeeIDs);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
return oFirstAttendances;
}
public static DailyAttnProcess GetDailyEmployeeAbsent(ID nID, DateTime dateTime)
{
DailyAttnProcess oEmployeeAbsent = null;
try
{
oEmployeeAbsent = Service.GetDailyEmployeeAbsent(nID, dateTime);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
return oEmployeeAbsent;
}
public static ObjectsTemplate<DailyAttnProcess> Get(ID empID, ID shiftID, DateTime fromdate, DateTime todate,EnumAttendanceType enumAttendanceType)
{
ObjectsTemplate<DailyAttnProcess> odAttnProcesses = null;
try
{
odAttnProcesses = Service.Get(empID, shiftID, fromdate, todate, enumAttendanceType);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
return odAttnProcesses;
}
#endregion
}
#endregion
#region IDailyAttnProcess Service
public interface IDailyAttnProcessService
{
DailyAttnProcess Get(ID id);
ObjectsTemplate<DailyAttnProcess> Get();
ObjectsTemplate<DailyAttnProcess> GetProcessByWPG(EnumWorkPlanGroup wpg, DateTime attnDate);
ObjectsTemplate<DailyAttnProcess> Get(DateTime attnDate);
ObjectsTemplate<DailyAttnProcess> GetManualProcess(DateTime attnDate);
ObjectsTemplate<DailyAttnProcess> Get(ID empID, DateTime fromDate, DateTime toDate);
ObjectsTemplate<DailyAttnProcess> Get(string empID, DateTime fromDate, DateTime toDate);
ObjectsTemplate<DailyAttnProcess> Get(DateTime fromDate, DateTime toDate);
ObjectsTemplate<DailyAttnProcess> Get(DateTime attnDate, ID shiftID, EnumAttendanceType attnType);
ID Save(DailyAttnProcess item);
void Save(ObjectsTemplate<DailyAttnProcess> _dAttnProcessess, bool IscounterClock);
void Delete(ID id);
void UpdateLeave(ID employeeID, ID leaveID, DateTime leavaDate, int n);
DataSet GetMonthlyAttn(DateTime dFromDate, DateTime dToDate, string sEmpID);
DataSet GetDailyInOut(DateTime attndate, string sEmpID);
DataSet GetDailyDataByStatus(DateTime attnDate, string sStatus, string sEmpID);
DataSet GetDateRangeDataByStatus(DateTime attnFromDate, DateTime attnToDate, string sStatus, string sEmpID);
DataSet GetDailyAbsent(DateTime attndate, string sEmpID);
DataSet GetDailyInOutAndAbsent(DateTime attnDate, string sEmpID);
DataSet GetMonthlyDetail(DateTime dFromDate, DateTime dToDate, string sEmpID);
DataSet GetEmpAttenInfo(string sEmpID);
DataSet GetEmpCardInfo(string sEmpID);
DataSet GetEmpCardInfoPerPage(string sEmpID);
DataSet GetHolidays(DateTime attndate, ID empID);
DataSet GetPresentDays(DateTime attndate, ID empID);
DataSet GetMonthlyLongAbsent(DateTime dFromDate, DateTime dToDate, int totalAbsentDays);
//new
DailyAttnProcess GetDailyEmployeeAbsent(ID nID, DateTime dateTime);
ObjectsTemplate<DailyAttnProcess> GetWhrOutTimeIsNull(DateTime attnDate, ID shiftID);
ObjectsTemplate<DailyAttnProcess> GetEmployeesFirstAttendances(string employeeIDs);
DateTime GetLastProcessDate();
DateTime GetLastProcessDateByPayrollType(ID PayrolltypeID);
//
void SaveAuto(ObjectsTemplate<DailyAttnProcess> dailyattProcesses, AttnProcessRunSummary oAttnRunSummary);
ObjectsTemplate<DailyAttnProcess> Get(ID empID, ID shiftID, DateTime fromdate, DateTime todate,EnumAttendanceType enumAttendanceType);
}
#endregion
}