CEL_Payroll/Payroll.BO/Attendence/EmployeeOutsideDuty.cs

305 lines
8.3 KiB
C#
Raw Permalink 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;
namespace Payroll.BO
{
#region EmployeeOutsideDuty
[Serializable]
public class EmployeeOutsideDuty : AuditTrailBase
{
#region Cache Store
private static Cache _cache = new Cache(typeof(EmployeeOutsideDuty));
#endregion
#region Constructor
public EmployeeOutsideDuty()
{
_employeeID = null;
_entryDate = DateTime.MinValue;
_startDate = DateTime.MinValue;
_endDate = DateTime.MinValue;
_comments = string.Empty;
//_shiftID = null;
_outsideDutyID = null;
}
#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;
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 EntryDate : DateTime
private DateTime _entryDate;
public DateTime EntryDate
{
get { return _entryDate; }
set
{
base.OnPropertyChange<DateTime>("EntryDate", _entryDate, value);
_entryDate = value;
}
}
#endregion
#region startDate : DateTime
private DateTime _startDate;
public DateTime StartDate
{
get { return _startDate; }
set
{
base.OnPropertyChange<DateTime>("startDate", _startDate, value);
_startDate = value;
}
}
#endregion
#region endDate : DateTime
private DateTime _endDate;
public DateTime EndDate
{
get { return _endDate; }
set
{
base.OnPropertyChange<DateTime>("endDate", _endDate, value);
_endDate = 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 shiftID : ID
//private ID _shiftID;
//public ID ShiftID
//{
// get { return _shiftID; }
// set
// {
// base.OnPropertyChange<ID>("shiftID", _shiftID, value);
// _shiftID = value;
// }
//}
//#endregion
#region OutsideDutyID : ID
private ID _outsideDutyID;
public ID OutsideDutyID
{
get { return _outsideDutyID; }
set
{
base.OnPropertyChange<ID>("OutsideDutyID", _outsideDutyID, value);
_outsideDutyID = value;
}
}
#endregion
#region OutsideDuty : OutsideDuty
private OutsideDuty _outsideDuty;
public OutsideDuty OutsideDuty
{
get
{
if (_outsideDutyID.Integer > 0 && _outsideDuty == null)
{
_outsideDuty = new OutsideDuty();
_outsideDuty = OutsideDuty.Get(_outsideDutyID);
}
return this._outsideDuty;
}
set
{
_outsideDuty = value;
}
}
#endregion
#region Service Factory IEmployeeOutsideDutyService : IEmployeeOutsideDutyService
internal static IEmployeeOutsideDutyService Service
{
get { return Services.Factory.CreateService<IEmployeeOutsideDutyService>(typeof(IEmployeeOutsideDutyService)); }
}
#endregion
#endregion
#region Functions
public static EmployeeOutsideDuty Get(ID nID)
{
EmployeeOutsideDuty oEmployeeOutsideDuty = null;
#region Cache Header
oEmployeeOutsideDuty = (EmployeeOutsideDuty)_cache["Get", nID];
if (oEmployeeOutsideDuty != null)
return oEmployeeOutsideDuty;
#endregion
oEmployeeOutsideDuty = EmployeeOutsideDuty.Service.Get(nID);
#region Cache Footer
_cache.Add(oEmployeeOutsideDuty, "Get", nID);
#endregion
return oEmployeeOutsideDuty;
}
public static ObjectsTemplate<EmployeeOutsideDuty> Get()
{
#region Cache Header
ObjectsTemplate<EmployeeOutsideDuty> employeeOutsideDutys = _cache["Get"] as ObjectsTemplate<EmployeeOutsideDuty>;
if (employeeOutsideDutys != null)
return employeeOutsideDutys;
#endregion
try
{
employeeOutsideDutys = Service.Get();
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(employeeOutsideDutys, "Get");
#endregion
return employeeOutsideDutys;
}
public static ObjectsTemplate<EmployeeOutsideDuty> GetByEmpID(ID empID)
{
#region Cache Header
ObjectsTemplate<EmployeeOutsideDuty> employeeOutsideDutys = _cache["Get", empID] as ObjectsTemplate<EmployeeOutsideDuty>;
if (employeeOutsideDutys != null)
return employeeOutsideDutys;
#endregion
try
{
employeeOutsideDutys = Service.GetByEmpID(empID);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(employeeOutsideDutys, "Get", empID);
#endregion
return employeeOutsideDutys;
}
public static ObjectsTemplate<EmployeeOutsideDuty> Get(DateTime attnDate)
{
#region Cache Header
ObjectsTemplate<EmployeeOutsideDuty> employeeOutsideDutys = _cache["Get", attnDate] as ObjectsTemplate<EmployeeOutsideDuty>;
if (employeeOutsideDutys != null)
return employeeOutsideDutys;
#endregion
try
{
employeeOutsideDutys = Service.Get(attnDate);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(employeeOutsideDutys, "Get", attnDate);
#endregion
return employeeOutsideDutys;
}
public bool IsOutsideDutyAvailable(DateTime startDate, DateTime endDate, ID empID)
{
return EmployeeOutsideDuty.Service.IsOutsideDutyAvailable(startDate, endDate, empID);
}
public ID Save()
{
this.SetAuditTrailProperties();
return EmployeeOutsideDuty.Service.Save(this);
}
public void Delete()
{
EmployeeOutsideDuty.Service.Delete(ID);
}
#endregion
}
#endregion
#region IEmployeeOutsideDuty Service
public interface IEmployeeOutsideDutyService
{
EmployeeOutsideDuty Get(ID id);
ObjectsTemplate<EmployeeOutsideDuty> Get();
ObjectsTemplate<EmployeeOutsideDuty> GetByEmpID(ID empID);
ObjectsTemplate<EmployeeOutsideDuty> Get(DateTime attnDate);
ID Save(EmployeeOutsideDuty item);
void Delete(ID id);
bool IsOutsideDutyAvailable(DateTime startDate, DateTime endDate, ID empID);
}
#endregion
}