CEL_Payroll/Payroll.BO/UnAuthLeave/EmployeeUnAuthorizeLeave.cs

664 lines
19 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;
using Ease.CoreV35.Model;
using Ease.CoreV35.Caching;
using System.Data.Linq.Mapping;
using System.Data;
namespace Payroll.BO
{
#region EmployeeUnAuthorizeLeave
[Serializable]
public enum EnumLeaveEntryType
{
Normal = 1,
PaidLeave = 2
}
[Serializable]
public class EmployeeUnAuthorizeLeave : AuditTrailBase
{
#region Cache Store
private static Cache _cache = new Cache(typeof(EmployeeUnAuthorizeLeave));
#endregion
#region Constructor
public EmployeeUnAuthorizeLeave()
{
_employeeID = null;
_unAuthorizeleaveID = null;
_monthDate = DateTime.MinValue;
_leaveMonth = DateTime.MinValue;
_toDate = DateTime.MinValue;
_fromDate = DateTime.MinValue;
_referenceID = null;
_Type = EnumLeaveEntryType.Normal;
_leaveDays = 0;
_ParamID = null;
_adjustedDays = 0;
}
#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 Employee : Employee
private Employee _Employee = null;
public Employee EmployeeObj
{
get
{
if(_Employee ==null && !_employeeID.IsUnassigned && _employeeID.Integer>0)
{
_Employee = Employee.Get(_employeeID);
}
return _Employee;
}
}
#endregion
#region Param : UnAuthorizeLeaveParameter
private UnAuthorizeLeaveParam _Param;
public UnAuthorizeLeaveParam Param
{
get
{
if (_Param == null && !this.ParamID.IsUnassigned && this.ParamID.Integer > 0)
{
_Param = UnAuthorizeLeaveParam.Get(this.ParamID);
}
return _Param;
}
set
{
_Param = value;
}
}
#endregion
#region ParamID : ID
private ID _ParamID;
public ID ParamID
{
get { return _ParamID; }
set
{
base.OnPropertyChange<ID>("ParamID", _ParamID, value);
_ParamID = 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 UnAuthorizeleaveID : ID
private ID _unAuthorizeleaveID;
public ID UnAuthorizeleaveID
{
get { return _unAuthorizeleaveID; }
set
{
base.OnPropertyChange<ID>("UnAuthorizeleaveID", _unAuthorizeleaveID, value);
_unAuthorizeleaveID = value;
}
}
#endregion
#region UnAuthorizeleave : UnAuthorizeleave
private UnAuthorizeLeave _unAuthorizeleave = null;
public UnAuthorizeLeave UALeave
{
get
{
if (_unAuthorizeleave == null && !_unAuthorizeleaveID.IsUnassigned && _unAuthorizeleaveID.Integer > 0)
{
_unAuthorizeleave = UnAuthorizeLeave.Get(_unAuthorizeleaveID);
}
return _unAuthorizeleave;
}
}
#endregion
#region monthDate : DateTime
private DateTime _monthDate;
public DateTime MonthDate
{
get { return _monthDate; }
set
{
base.OnPropertyChange<DateTime>("monthDate", _monthDate, value);
_monthDate = value;
}
}
#endregion
#region leaveDays : int
private int _leaveDays;
public int LeaveDays
{
get { return _leaveDays; }
set
{
base.OnPropertyChange<int>("leaveDaysThis", _leaveDays, value);
_leaveDays = value;
}
}
#endregion
#region RemainingDays : int
private int _remainingDays;
public int RemainingDays
{
get { return _remainingDays; }
set
{
base.OnPropertyChange<int>("RemainingDays", _remainingDays, value);
_remainingDays = value;
}
}
#endregion
#region AdjustedDays : int
private int _adjustedDays;
public int AdjustedDays
{
get
{
if (_adjustedDays == 0 && !this.ReferenceID.IsUnassigned && this.ReferenceID.Integer > 0)
{
_adjustedDays = GetAdjestedDays(this.ReferenceID);
}
return _adjustedDays;
}
}
#endregion
#region leaveMonth : DateTime
private DateTime _leaveMonth;
public DateTime LeaveMonth
{
get { return _leaveMonth; }
set
{
base.OnPropertyChange<DateTime>("leaveMonth", _leaveMonth, value);
_leaveMonth = value;
}
}
#endregion
#region FromDate : DateTime
private DateTime _fromDate;
public DateTime FromDate
{
get { return _fromDate; }
set
{
base.OnPropertyChange<DateTime>("fromDate", _fromDate, value);
_fromDate = value;
}
}
#endregion
#region ToMonth : DateTime
private DateTime _toDate;
public DateTime ToDate
{
get { return _toDate; }
set
{
base.OnPropertyChange<DateTime>("toDate", _toDate, value);
_toDate = value;
}
}
#endregion
#region EnumLeaveEntryType : int
private EnumLeaveEntryType _Type;
public EnumLeaveEntryType Type
{
get { return _Type; }
set
{
base.OnPropertyChange<short>("type",(short) _Type,(short) value);
_Type = value;
}
}
#endregion
#region Service Factory IEmployeeUnAuthorizeLeaveService : IEmployeeUnAuthorizeLeaveService
internal static IEmployeeUnAuthorizeLeaveService Service
{
get { return Services.Factory.CreateService<IEmployeeUnAuthorizeLeaveService>(typeof(IEmployeeUnAuthorizeLeaveService)); }
}
#endregion
#endregion
#region Functions
public static EmployeeUnAuthorizeLeave Get(ID nID)
{
EmployeeUnAuthorizeLeave oEmployeeUnAuthorizeLeave = null;
#region Cache Header
oEmployeeUnAuthorizeLeave = (EmployeeUnAuthorizeLeave)_cache["Get", nID];
if (oEmployeeUnAuthorizeLeave != null)
return oEmployeeUnAuthorizeLeave;
#endregion
oEmployeeUnAuthorizeLeave = EmployeeUnAuthorizeLeave.Service.Get(nID);
#region Cache Footer
_cache.Add(oEmployeeUnAuthorizeLeave, "Get", nID);
#endregion
return oEmployeeUnAuthorizeLeave;
}
public static ObjectsTemplate<EmployeeUnAuthorizeLeave> Get(EnumLeaveEntryType type, DateTime month)
{
#region Cache Header
ObjectsTemplate<EmployeeUnAuthorizeLeave> employeeUnAuthorizeLeaves = _cache["Get", type] as ObjectsTemplate<EmployeeUnAuthorizeLeave>;
if (employeeUnAuthorizeLeaves != null)
return employeeUnAuthorizeLeaves;
#endregion
try
{
employeeUnAuthorizeLeaves = Service.Get(type,month );
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(employeeUnAuthorizeLeaves, "Get", type);
#endregion
return employeeUnAuthorizeLeaves;
}
public static ObjectsTemplate<EmployeeUnAuthorizeLeave> Get()
{
#region Cache Header
ObjectsTemplate<EmployeeUnAuthorizeLeave> employeeUnAuthorizeLeaves = _cache["Get"] as ObjectsTemplate<EmployeeUnAuthorizeLeave>;
if (employeeUnAuthorizeLeaves != null)
return employeeUnAuthorizeLeaves;
#endregion
try
{
employeeUnAuthorizeLeaves = Service.Get();
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(employeeUnAuthorizeLeaves, "Get");
#endregion
return employeeUnAuthorizeLeaves;
}
public static ObjectsTemplate<EmployeeUnAuthorizeLeave> GetByEmployee(ID nEmpID,EnumLeaveEntryType type)
{
#region Cache Header
ObjectsTemplate<EmployeeUnAuthorizeLeave> employeeUnAuthorizeLeaves = _cache["GetByEmployee", nEmpID, type] as ObjectsTemplate<EmployeeUnAuthorizeLeave>;
if (employeeUnAuthorizeLeaves != null)
return employeeUnAuthorizeLeaves;
#endregion
try
{
employeeUnAuthorizeLeaves = Service.GetByEmployee(nEmpID, type);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(employeeUnAuthorizeLeaves, "GetByEmployee", nEmpID, type);
#endregion
return employeeUnAuthorizeLeaves;
}
public static ObjectsTemplate<EmployeeUnAuthorizeLeave> GetByEmployee(ID nEmpID,ID nUALeaveID, EnumLeaveEntryType type)
{
#region Cache Header
ObjectsTemplate<EmployeeUnAuthorizeLeave> employeeUnAuthorizeLeaves = _cache["GetByEmployee", nEmpID,nUALeaveID, type] as ObjectsTemplate<EmployeeUnAuthorizeLeave>;
if (employeeUnAuthorizeLeaves != null)
return employeeUnAuthorizeLeaves;
#endregion
try
{
employeeUnAuthorizeLeaves = Service.GetByEmployee(nEmpID, nUALeaveID, type);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(employeeUnAuthorizeLeaves, "GetByEmployee", nEmpID,nUALeaveID, type);
#endregion
return employeeUnAuthorizeLeaves;
}
public static ObjectsTemplate<EmployeeUnAuthorizeLeave> GetDeductedLeaves(ID nEmpID, ID nLeaveID, EnumLeaveEntryType type)
{
#region Cache Header
ObjectsTemplate<EmployeeUnAuthorizeLeave> employeeUnAuthorizeLeaves = _cache["GetDeductedLeaves", nEmpID, nLeaveID, type] as ObjectsTemplate<EmployeeUnAuthorizeLeave>;
if (employeeUnAuthorizeLeaves != null)
return employeeUnAuthorizeLeaves;
#endregion
try
{
employeeUnAuthorizeLeaves = Service.GetDeductedLeaves(nEmpID, nLeaveID, type, SystemInformation.CurrentSysInfo.NextPayProcessDate);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(employeeUnAuthorizeLeaves, "GetDeductedLeaves", nEmpID, nLeaveID, type);
#endregion
return employeeUnAuthorizeLeaves;
}
public static ObjectsTemplate<EmployeeUnAuthorizeLeave> GetByEmployee(ID nEmpID, DateTime dMonth, EnumLeaveEntryType type)
{
#region Cache Header
ObjectsTemplate<EmployeeUnAuthorizeLeave> employeeUnAuthorizeLeaves = _cache["GetByEmployee", nEmpID, dMonth, type] as ObjectsTemplate<EmployeeUnAuthorizeLeave>;
if (employeeUnAuthorizeLeaves != null)
return employeeUnAuthorizeLeaves;
#endregion
try
{
employeeUnAuthorizeLeaves = Service.GetByEmployee(nEmpID, dMonth, type);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(employeeUnAuthorizeLeaves, "GetByEmployee", nEmpID, dMonth, type);
#endregion
return employeeUnAuthorizeLeaves;
}
public static EmployeeUnAuthorizeLeave GetLeaveTypeByEmployee(ID nEmpID, DateTime dMonth, EnumLeaveEntryType type)
{
#region Cache Header
EmployeeUnAuthorizeLeave employeeUnAuthorizeLeave = null;
if (employeeUnAuthorizeLeave != null)
return employeeUnAuthorizeLeave;
#endregion
try
{
employeeUnAuthorizeLeave = Service.GetLeaveTypeByEmployee(nEmpID, dMonth, type);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(employeeUnAuthorizeLeave, "GetByEmployee", nEmpID, dMonth, type);
#endregion
return employeeUnAuthorizeLeave;
}
public int AuthorizedDays(DateTime dMonth)
{
int authorizedday = 0;
try
{
authorizedday = Service.AdjustedDays(this.ID, dMonth);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
return authorizedday;
}
private int GetAdjestedDays(ID nID)
{
return Service.AdjustedDays(nID);
}
public EmployeeUnAuthorizeLeave GetClone()
{
EmployeeUnAuthorizeLeave item = new EmployeeUnAuthorizeLeave();
item.EmployeeID = this.EmployeeID ;
item.UnAuthorizeleaveID = this.UnAuthorizeleaveID;
item.MonthDate = this.MonthDate ;
item.LeaveMonth=this.LeaveMonth;
item.ToDate = this.ToDate;
item.FromDate = this.FromDate;
item.ReferenceID = this.ReferenceID;
item.Type = this.Type;
item.LeaveDays = this.LeaveDays;
item.ParamID = this.ParamID ;
return item;
}
public ID Save()
{
this.SetAuditTrailProperties();
return EmployeeUnAuthorizeLeave.Service.Save(this);
}
public void Delete()
{
EmployeeUnAuthorizeLeave.Service.Delete(this.ID);
}
public static void Save(ObjectsTemplate<EmployeeUnAuthorizeLeave> empLeaves)
{
foreach (EmployeeUnAuthorizeLeave leave in empLeaves)
{
leave.SetAuditTrailProperties();
}
EmployeeUnAuthorizeLeave.Service.Save(empLeaves);
}
public static void SaveAuthrizedLeave(ID employeeID, DateTime month, ObjectsTemplate<EmployeeUnAuthorizeLeave> empLeaves)
{
foreach (EmployeeUnAuthorizeLeave leave in empLeaves)
{
leave.SetAuditTrailProperties();
}
EmployeeUnAuthorizeLeave.Service.Save(empLeaves);
}
//By A MonthRange
public static DataSet GetUnAuthorizeLeave(DateTime date)
{
DataSet UnAuthoLeaves = null;
try
{
UnAuthoLeaves = Service.GetUnAuthorizeLeave(date);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
return UnAuthoLeaves;
}
public static DataSet GetAllUnAuthorizeLeave(DateTime date)
{
DataSet UnAuthoLeaves = null;
try
{
UnAuthoLeaves = Service.GetCurrentUnAuthorizeLeave(date);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
return UnAuthoLeaves;
}
public static DataSet GetThisMonthUnAuthorizeLeave(DateTime date)
{
DataSet UnAuthoLeaves = null;
try
{
UnAuthoLeaves = Service.GetPreviousUnAuthorizeLeave(date);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
return UnAuthoLeaves;
}
public static DataSet GetUnPaidLeave(int nYear)
{
DataSet UnAuthoLeaves = null;
try
{
UnAuthoLeaves = Service.GetUnPaidLeave(nYear);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
return UnAuthoLeaves;
}
#endregion
}
#endregion
#region IEmployeeUnAuthorizeLeave Service
public interface IEmployeeUnAuthorizeLeaveService
{
EmployeeUnAuthorizeLeave Get(ID id);
ObjectsTemplate<EmployeeUnAuthorizeLeave> Get();
ID Save(EmployeeUnAuthorizeLeave item);
void Delete(ID id);
void Save(ObjectsTemplate<EmployeeUnAuthorizeLeave> empLeaves);
void SaveAuthorizeLeave(ID employeeId, DateTime month, ObjectsTemplate<EmployeeUnAuthorizeLeave> empLeaves);
ObjectsTemplate<EmployeeUnAuthorizeLeave> GetByEmployee(ID nEmpID, EnumLeaveEntryType type);
ObjectsTemplate<EmployeeUnAuthorizeLeave> GetByEmployee(ID nEmpID, ID nLeaveID, EnumLeaveEntryType type);
ObjectsTemplate<EmployeeUnAuthorizeLeave> GetDeductedLeaves(ID nEmpID, ID nLeaveID, EnumLeaveEntryType type, DateTime nextPayProcessDate);
ObjectsTemplate<EmployeeUnAuthorizeLeave> GetByEmployee(ID nEmpID, DateTime dMonth, EnumLeaveEntryType type);
EmployeeUnAuthorizeLeave GetLeaveTypeByEmployee(ID nEmpID, DateTime dMonth, EnumLeaveEntryType type);
int AdjustedDays(ID nID);
int AdjustedDays(ID nID, DateTime month);
ObjectsTemplate<EmployeeUnAuthorizeLeave> Get(EnumLeaveEntryType type, DateTime month);
DataSet GetUnAuthorizeLeave(DateTime date);
DataSet GetCurrentUnAuthorizeLeave(DateTime date);
DataSet GetPreviousUnAuthorizeLeave(DateTime date);
DataSet GetUnPaidLeave(int nYear);
}
#endregion
}