EchoTex_Payroll/HRM.BO/Attendance/AttnNationalHoliday.cs
2024-10-14 10:01:49 +06:00

501 lines
14 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ease.Core;
using Ease.Core.Model;
namespace HRM.BO
{
#region AttnNationalHoliday
[Serializable]
public class AttnNationalHoliday : BasicBaseObject
{
#region Constructor
public AttnNationalHoliday()
{
_description = string.Empty;
_fromDate = DateTime.MinValue;
_toDate = DateTime.MinValue;
_status = EnumStatus.Active;
_holidayHour = 0.0;
_holidayType = HolidayType.General;
_payrollTypeID = 0;
_attnShiftWiseNationalHolidays = null;
_attnNationalHolidayLocations = null;
}
#endregion
#region Input validator
public string[] InputValidator()
{
string[] sErrorString = new string[2];
if (this.Description == "")
{
sErrorString[0] = "Description can not be empty";
sErrorString[1] = "Description";
return sErrorString;
}
sErrorString = null;
return sErrorString;
}
#endregion
#region Properties
#region Description : string
private string _description;
public string Description
{
get { return _description; }
set
{
//base.OnPropertyChange<string>("Description", _description, value);
_description = 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 ToDate : DateTime
private DateTime _toDate;
public DateTime ToDate
{
get { return _toDate; }
set
{
//base.OnPropertyChange<DateTime>("ToDate", _toDate, value);
_toDate = value;
}
}
#endregion
#region FromTime : DateTime
private DateTime _fromTime;
public DateTime FromTime
{
get { return _fromTime; }
set
{
//base.OnPropertyChange<DateTime>("FromTime", _fromTime, value);
_fromTime = value;
}
}
#endregion
#region ToTime : DateTime
private DateTime _toTime;
public DateTime ToTime
{
get { return _toTime; }
set
{
//base.OnPropertyChange<DateTime>("ToTime", _toTime, value);
_toTime = value;
}
}
#endregion
#region type : HolidayType
private HolidayType _holidayType;
public HolidayType HolidayType
{
get { return _holidayType; }
set
{
//base.OnPropertyChange<short>("HolidayType", (short)_holidayType, (short)value);
_holidayType = value;
}
}
#endregion
#region HolidayHour : double
private double _holidayHour;
public double HolidayHour
{
get { return _holidayHour; }
set
{
//base.OnPropertyChange<double>("HolidayHour", _holidayHour, value);
_holidayHour = value;
}
}
#endregion
#region LocationID : ID
private int? _locID;
public int? LocationID
{
get { return _locID; }
set
{
_locID = value;
}
}
#endregion
#region payrollTypeID : ID
private int _payrollTypeID;
public int PayrollTypeID
{
get { return _payrollTypeID; }
set
{
//base.OnPropertyChange<ID>("payrollTypeID", _payrollTypeID, value);
_payrollTypeID = value;
}
}
#endregion
#region AttnNationalHolidayLocations : ObjectsTemplate<AttnNationalHolidayLocation>
private List<AttnNationalHolidayLocation> _attnNationalHolidayLocations;
public List<AttnNationalHolidayLocation> AttnNationalHolidayLocations
{
get
{
//if (this.ID != null && _attnNationalHolidayLocations == null)
//{
// _attnNationalHolidayLocations = AttnNationalHoliday.Service.GetAttnNationalHolidayLocation(this.ID);
//}
return _attnNationalHolidayLocations;
}
set { _attnNationalHolidayLocations = value; }
}
#endregion
#region AttnShiftWiseNationalHolidays : ObjectsTemplate<AttnShiftWiseNationalHoliday>
private List<AttnShiftWiseNationalHoliday> _attnShiftWiseNationalHolidays;
public List<AttnShiftWiseNationalHoliday> AttnShiftWiseNationalHolidays
{
get
{
//if (this.ID != null && _attnShiftWiseNationalHolidays == null)
//{
// _attnShiftWiseNationalHolidays = AttnNationalHoliday.Service.GetAttnNationalHolidayShift(this.ID);
//}
return _attnShiftWiseNationalHolidays;
}
set { _attnShiftWiseNationalHolidays = value; }
}
#endregion
//#region Service Factory IAttnNationalHolidayService : IAttnNationalHolidayService
//internal static IAttnNationalHolidayService Service
//{
// get { return Services.Factory.CreateService<IAttnNationalHolidayService>(typeof(IAttnNationalHolidayService)); }
//}
//#endregion
#endregion
//#region Functions
//public static AttnNationalHoliday Get(ID nID)
//{
// AttnNationalHoliday oAttnNationalHoliday = null;
// #region Cache Header
// oAttnNationalHoliday = (AttnNationalHoliday)_cache["Get", nID];
// if (oAttnNationalHoliday != null)
// return oAttnNationalHoliday;
// #endregion
// oAttnNationalHoliday = AttnNationalHoliday.Service.Get(nID);
// #region Cache Footer
// _cache.Add(oAttnNationalHoliday, "Get", nID);
// #endregion
// return oAttnNationalHoliday;
//}
//public static ObjectsTemplate<AttnNationalHoliday> GetByMonthAndPayrollType(DateTime fromDate, DateTime todate, int payrollTypeID)
//{
// ObjectsTemplate<AttnNationalHoliday> attnNationalHolidays = null;
// try
// {
// attnNationalHolidays = Service.GetByMonthAndPayrollType(fromDate, todate, payrollTypeID);
// }
// catch (ServiceException e)
// {
// throw new Exception(e.Message, e);
// }
// return attnNationalHolidays;
//}
//public static AttnNationalHoliday GetHoliday(ObjectsTemplate<AttnNationalHoliday> attNHolidays, DateTime dDate, ID locationID, ID workPlanGroupID)
//{
// AttnNationalHoliday oAttNHoliday = null;
// if (attNHolidays.Count > 0)
// oAttNHoliday = attNHolidays.Where(o => dDate.Date >= o.FromDate.Date && dDate.Date <= o.ToDate.Date).FirstOrDefault();
// if (oAttNHoliday != null && oAttNHoliday.AttnNationalHolidayLocations.Count == 0 && oAttNHoliday.AttnShiftWiseNationalHolidays.Count == 0)
// return oAttNHoliday;
// else if (oAttNHoliday != null && oAttNHoliday.AttnNationalHolidayLocations.Count > 0 && oAttNHoliday.AttnShiftWiseNationalHolidays.Count > 0)
// {
// if (oAttNHoliday.AttnNationalHolidayLocations.Exists(x => x.LocationID.Integer == locationID.Integer) == true
// && oAttNHoliday.AttnShiftWiseNationalHolidays.Exists(x => x.WorkPlanGroupID.Integer == workPlanGroupID.Integer) == true)
// return oAttNHoliday;
// }
// else if (oAttNHoliday != null && oAttNHoliday.AttnNationalHolidayLocations.Count > 0 && oAttNHoliday.AttnShiftWiseNationalHolidays.Count == 0)
// {
// if (oAttNHoliday.AttnNationalHolidayLocations.Exists(x => x.LocationID.Integer == locationID.Integer) == true) return oAttNHoliday;
// }
// else if (oAttNHoliday != null && oAttNHoliday.AttnNationalHolidayLocations.Count == 0 && oAttNHoliday.AttnShiftWiseNationalHolidays.Count > 0)
// if (oAttNHoliday.AttnShiftWiseNationalHolidays.Exists(x => x.WorkPlanGroupID.Integer == workPlanGroupID.Integer) == true) return oAttNHoliday;
// return null;
//}
//public static ObjectsTemplate<AttnNationalHoliday> GetByMonth(DateTime fromDate, DateTime todate)
//{
// ObjectsTemplate<AttnNationalHoliday> attnNationalHolidays = null;
// try
// {
// attnNationalHolidays = Service.Get(fromDate, todate, SystemInformation.CurrentSysInfo.PayrollTypeID.Integer);
// }
// catch (ServiceException e)
// {
// throw new Exception(e.Message, e);
// }
// return attnNationalHolidays;
//}
//public static ObjectsTemplate<AttnNationalHoliday> Get(EnumStatus status)
//{
// #region Cache Header
// ObjectsTemplate<AttnNationalHoliday> attnNationalHolidays = _cache["Get", status] as ObjectsTemplate<AttnNationalHoliday>;
// if (attnNationalHolidays != null)
// return attnNationalHolidays;
// #endregion
// try
// {
// attnNationalHolidays = Service.Get(status, SystemInformation.CurrentSysInfo.PayrollTypeID.Integer);
// }
// catch (ServiceException e)
// {
// throw new Exception(e.Message, e);
// }
// #region Cache Footer
// _cache.Add(attnNationalHolidays, "Get", status);
// #endregion
// return attnNationalHolidays;
//}
//public ID Save()
//{
// this.SetAuditTrailProperties();
// return AttnNationalHoliday.Service.Save(this);
//}
//public void Delete(ID id)
//{
// AttnNationalHoliday.Service.Delete(ID);
//}
//#endregion
}
#endregion
#region AttnNationalHolidayLocation
[Serializable]
public class AttnNationalHolidayLocation : BasicBaseObject
{
#region Constructor
public AttnNationalHolidayLocation()
{
_attnNationalHolidayID = 0;
_locationID = 0;
}
#endregion
#region Properties
#region AttnNationalHolidayID : ID
private int _attnNationalHolidayID;
public int AttnNationalHolidayID
{
get { return _attnNationalHolidayID; }
set
{
//base.OnPropertyChange<ID>("AttnNationalHoliday", _attnNationalHolidayID, value);
_attnNationalHolidayID = value;
}
}
#endregion
#region LocationID : ID
private int _locationID;
public int LocationID
{
get { return _locationID; }
set
{
//base.OnPropertyChange<ID>("LocationID", _locationID, value);
_locationID = value;
}
}
#endregion
#endregion
}
#endregion
#region AttnNationalHolidayLocation
[Serializable]
public class AttnShiftWiseNationalHoliday : BasicBaseObject
{
#region Constructor
public AttnShiftWiseNationalHoliday()
{
_aNationalHolidayID = 0;
_shiftID = 0;
_workPlanGroupID = 0;
}
#endregion
#region Properties
#region ANationalHolidayID : ID
private int _aNationalHolidayID;
public int ANationalHolidayID
{
get { return _aNationalHolidayID; }
set
{
//base.OnPropertyChange<ID>("AttnNationalHolidayID", _aNationalHolidayID, value);
_aNationalHolidayID = value;
}
}
#endregion
#region ShiftID : ID
private int _shiftID;
public int ShiftID
{
get { return _shiftID; }
set
{
//base.OnPropertyChange<ID>("ShiftID", _shiftID, value);
_shiftID = value;
}
}
#endregion
#region WorkPlanGroupID : ID
private int _workPlanGroupID;
public int WorkPlanGroupID
{
get { return _workPlanGroupID; }
set
{
//base.OnPropertyChange<ID>("WorkPlanGroupID", _workPlanGroupID, value);
_workPlanGroupID = value;
}
}
#endregion
#endregion
}
#endregion
#region IAttnNationalHoliday Service
public interface IAttnNationalHolidayService
{
AttnNationalHoliday Get(int id);
List<AttnNationalHoliday> Get(DateTime fromdate, DateTime toDate, int payrollTypeID);
List<AttnNationalHoliday> Get(EnumStatus status, int payrollTypeID);
List<AttnNationalHolidayLocation> GetAttnNationalHolidayLocation(int iD);
List<AttnShiftWiseNationalHoliday> GetAttnNationalHolidayShift(int iD);
int Save(AttnNationalHoliday item, int payrollTypeID);
void Delete(int id);
List<AttnNationalHoliday> GetByMonthAndPayrollType(DateTime fromDate, DateTime todate, int payrollTypeID);
List<AttnNationalHoliday> GetupcommintHoliday(DateTime fromDate, int payrollTypeID);
List<AttnNationalHoliday> GetupcommintHolidayByUserId(DateTime fromDate, int userId);
AttnNationalHoliday GetHoliday(List<AttnNationalHoliday> attNHolidays, DateTime dDate, int locationID, int workPlanGroupID);
List<AttnNationalHoliday> GetByMonthAndPayrollTypeWithDetails(DateTime fromDate, DateTime todate, int payrollTypeID);
List<AttnNationalHoliday> GetByMonth(DateTime fromDate, DateTime todate);
}
#endregion
}