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("Description", _description, value); _description = value; } } #endregion #region FromDate : DateTime private DateTime _fromDate; public DateTime FromDate { get { return _fromDate; } set { //base.OnPropertyChange("FromDate", _fromDate, value); _fromDate = value; } } #endregion #region ToDate : DateTime private DateTime _toDate; public DateTime ToDate { get { return _toDate; } set { //base.OnPropertyChange("ToDate", _toDate, value); _toDate = value; } } #endregion #region FromTime : DateTime private DateTime _fromTime; public DateTime FromTime { get { return _fromTime; } set { //base.OnPropertyChange("FromTime", _fromTime, value); _fromTime = value; } } #endregion #region ToTime : DateTime private DateTime _toTime; public DateTime ToTime { get { return _toTime; } set { //base.OnPropertyChange("ToTime", _toTime, value); _toTime = value; } } #endregion #region type : HolidayType private HolidayType _holidayType; public HolidayType HolidayType { get { return _holidayType; } set { //base.OnPropertyChange("HolidayType", (short)_holidayType, (short)value); _holidayType = value; } } #endregion #region HolidayHour : double private double _holidayHour; public double HolidayHour { get { return _holidayHour; } set { //base.OnPropertyChange("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("payrollTypeID", _payrollTypeID, value); _payrollTypeID = value; } } #endregion #region AttnNationalHolidayLocations : ObjectsTemplate private List _attnNationalHolidayLocations; public List AttnNationalHolidayLocations { get { //if (this.ID != null && _attnNationalHolidayLocations == null) //{ // _attnNationalHolidayLocations = AttnNationalHoliday.Service.GetAttnNationalHolidayLocation(this.ID); //} return _attnNationalHolidayLocations; } set { _attnNationalHolidayLocations = value; } } #endregion #region AttnShiftWiseNationalHolidays : ObjectsTemplate private List _attnShiftWiseNationalHolidays; public List 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(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 GetByMonthAndPayrollType(DateTime fromDate, DateTime todate, int payrollTypeID) //{ // ObjectsTemplate 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 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 GetByMonth(DateTime fromDate, DateTime todate) //{ // ObjectsTemplate 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 Get(EnumStatus status) //{ // #region Cache Header // ObjectsTemplate attnNationalHolidays = _cache["Get", status] as ObjectsTemplate; // 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("AttnNationalHoliday", _attnNationalHolidayID, value); _attnNationalHolidayID = value; } } #endregion #region LocationID : ID private int _locationID; public int LocationID { get { return _locationID; } set { //base.OnPropertyChange("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("AttnNationalHolidayID", _aNationalHolidayID, value); _aNationalHolidayID = value; } } #endregion #region ShiftID : ID private int _shiftID; public int ShiftID { get { return _shiftID; } set { //base.OnPropertyChange("ShiftID", _shiftID, value); _shiftID = value; } } #endregion #region WorkPlanGroupID : ID private int _workPlanGroupID; public int WorkPlanGroupID { get { return _workPlanGroupID; } set { //base.OnPropertyChange("WorkPlanGroupID", _workPlanGroupID, value); _workPlanGroupID = value; } } #endregion #endregion } #endregion #region IAttnNationalHoliday Service public interface IAttnNationalHolidayService { AttnNationalHoliday Get(int id); List Get(DateTime fromdate, DateTime toDate, int payrollTypeID); List Get(EnumStatus status, int payrollTypeID); List GetAttnNationalHolidayLocation(int iD); List GetAttnNationalHolidayShift(int iD); int Save(AttnNationalHoliday item, int payrollTypeID); void Delete(int id); List GetByMonthAndPayrollType(DateTime fromDate, DateTime todate, int payrollTypeID); List GetupcommintHoliday(DateTime fromDate, int payrollTypeID); List GetupcommintHolidayByUserId(DateTime fromDate, int userId); AttnNationalHoliday GetHoliday(List attNHolidays, DateTime dDate, int locationID, int workPlanGroupID); List GetByMonthAndPayrollTypeWithDetails(DateTime fromDate, DateTime todate, int payrollTypeID); List GetByMonth(DateTime fromDate, DateTime todate); } #endregion }