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 EmployeeWorkPlanSetup [Serializable] public class EmployeeWorkPlanSetup : AuditTrailBase { #region Cache Store private static Cache _cache = new Cache(typeof(EmployeeWorkPlanSetup)); #endregion #region Constructor public EmployeeWorkPlanSetup() { _employeeID = ID.FromInteger(0); _shiftID = null; _startDate = DateTime.MinValue; _workPanGroupId = ID.FromInteger(0); _weekEndOn = null; _weekEndOn2 = null; _saturdayShiftID = null; _sundayShiftID = null; _mondayShiftID = null; _tuesdayShiftID = null; _wednesdayShiftID = null; _thursdayShiftID = null; _fridayShiftID = null; } #endregion #region Properties #region employeeID : ID private ID _employeeID; public ID EmployeeID { get { return _employeeID; } set { base.OnPropertyChange("employeeID", _employeeID, value); _employeeID = value; } } #endregion #region shiftID : ID private ID _shiftID; public ID ShiftID { get { return _shiftID; } set { base.OnPropertyChange("shiftID", _shiftID, value); _shiftID = value; } } #endregion #region StartDate : DateTime private DateTime _startDate; public DateTime StartDate { get { return _startDate; } set { base.OnPropertyChange("StartDate", _startDate, value); _startDate = value; } } #endregion #region WorkPlanGroupID : ID private ID _workPanGroupId; public ID WorkPlanGroupID { get { return _workPanGroupId; } set { base.OnPropertyChange("WorkPlanGroupID", _workPanGroupId, value); _workPanGroupId = value; } } #endregion #region WeekEndOn : Enum DayOfWeek private DayOfWeek? _weekEndOn; public DayOfWeek? WeekEndOn { get { return _weekEndOn; } set { _weekEndOn = value; } } #endregion #region WeekEndOn2 : Enum DayOfWeek private DayOfWeek? _weekEndOn2; public DayOfWeek? WeekEndOn2 { get { return _weekEndOn2; } set { _weekEndOn2 = value; } } #endregion #region Employee : Employee private Employee _Employee = null; 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 = null; 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 SaturdayShiftID : int? private int? _saturdayShiftID; public int? SaturdayShiftID { get { return _saturdayShiftID; } set { _saturdayShiftID = value; _saturdayShift = null; } } #endregion #region SaturdayShift : Shift private Shift _saturdayShift = null; public Shift SaturdayShift { get { if (_saturdayShiftID!=null && _saturdayShift == null) { _saturdayShift = new Shift(); _saturdayShift = Shift.Get(ID.FromInteger(_saturdayShiftID.Value)); } return _saturdayShift; } set { _saturdayShift = value; } } #endregion #region SundayShiftID : int private int? _sundayShiftID; public int? SundayShiftID { get { return _sundayShiftID; } set { _sundayShiftID = value; _sundayShift = null; } } #endregion #region SundayShift : Shift private Shift _sundayShift = null; public Shift SundayShift { get { if (_sundayShiftID != null && _sundayShift == null) { _sundayShift = new Shift(); _sundayShift = Shift.Get(ID.FromInteger(_sundayShiftID.Value)); } return _sundayShift; } set { _sundayShift = value; } } #endregion #region MondayShiftID : int private int? _mondayShiftID; public int? MondayShiftID { get { return _mondayShiftID; } set { _mondayShiftID = value; _mondayShift = null; } } #endregion #region MondayShift : Shift private Shift _mondayShift = null; public Shift MondayShift { get { if (_mondayShiftID != null && _mondayShift == null) { _mondayShift = new Shift(); _mondayShift = Shift.Get(ID.FromInteger(_mondayShiftID.Value)); } return _mondayShift; } set { _mondayShift = value; } } #endregion #region TuesdayShiftID : int private int? _tuesdayShiftID; public int? TuesdayShiftID { get { return _tuesdayShiftID; } set { _tuesdayShiftID = value; _tuesdayShift = null; } } #endregion #region TuesdayShift : Shift private Shift _tuesdayShift = null; public Shift TuesdayShift { get { if (_tuesdayShiftID != null && _tuesdayShift == null) { _tuesdayShift = new Shift(); _tuesdayShift = Shift.Get(ID.FromInteger(_tuesdayShiftID.Value)); } return _tuesdayShift; } set { _tuesdayShift = value; } } #endregion #region WednesdayShiftID : int private int? _wednesdayShiftID; public int? WednesdayShiftID { get { return _wednesdayShiftID; } set { _wednesdayShiftID = value; _wednesdayShift = null; } } #endregion #region WednesdayShift : Shift private Shift _wednesdayShift = null; public Shift WednesdayShift { get { if (_wednesdayShiftID != null && _wednesdayShift == null) { _wednesdayShift = new Shift(); _wednesdayShift = Shift.Get(ID.FromInteger(_wednesdayShiftID.Value)); } return _wednesdayShift; } set { _wednesdayShift = value; } } #endregion #region ThursdayShiftID : int private int? _thursdayShiftID; public int? ThursdayShiftID { get { return _thursdayShiftID; } set { _thursdayShiftID = value; _thursdayShift = null; } } #endregion #region ThursdayShift : Shift private Shift _thursdayShift = null; public Shift ThursdayShift { get { if (_thursdayShiftID != null && _thursdayShift == null) { _thursdayShift = new Shift(); _thursdayShift = Shift.Get(ID.FromInteger(_thursdayShiftID.Value)); } return _thursdayShift; } set { _thursdayShift = value; } } #endregion #region FridayShiftID : int private int? _fridayShiftID; public int? FridayShiftID { get { return _fridayShiftID; } set { _fridayShiftID = value; _fridayShift = null; } } #endregion #region FridayShift : Shift private Shift _fridayShift = null; public Shift FridayShift { get { if (_fridayShiftID != null && _fridayShift == null) { _fridayShift = new Shift(); _fridayShift = Shift.Get(ID.FromInteger(_fridayShiftID.Value)); } return _fridayShift; } set { _fridayShift = value; } } #endregion public string ShiftsName { get { return (SaturdayShift != null ? SaturdayShift.ShortName : "Empty") + "," + (SundayShift != null ? SundayShift.ShortName : "Empty") + "," + (MondayShift != null ? MondayShift.ShortName : "Empty") + "," + (TuesdayShift != null ? TuesdayShift.ShortName : "Empty") + "," + (WednesdayShift != null ? WednesdayShift.ShortName : "Empty") + "," + (ThursdayShift != null ? ThursdayShift.ShortName : "Empty") + "," + (FridayShift != null ? FridayShift.ShortName : "Empty"); } } #region Service Factory IEmployeeWorkPlanSetupService : IEmployeeWorkPlanSetupService internal static IEmployeeWorkPlanSetupService Service { get { return Services.Factory.CreateService(typeof(IEmployeeWorkPlanSetupService)); } } #endregion #endregion #region Functions public static EmployeeWorkPlanSetup Get(ID nID) { EmployeeWorkPlanSetup oEmployeeWorkPlanSetup = null; #region Cache Header oEmployeeWorkPlanSetup = (EmployeeWorkPlanSetup)_cache["Get", nID]; if (oEmployeeWorkPlanSetup != null) return oEmployeeWorkPlanSetup; #endregion oEmployeeWorkPlanSetup = EmployeeWorkPlanSetup.Service.Get(nID); #region Cache Footer _cache.Add(oEmployeeWorkPlanSetup, "Get", nID); #endregion return oEmployeeWorkPlanSetup; } //public static EmployeeWorkPlanSetup Get(ID empID, DateTime attnDate) //{ // EmployeeWorkPlanSetup oEmployeeWorkPlanSetup = null; // #region Cache Header // oEmployeeWorkPlanSetup = (EmployeeWorkPlanSetup)_cache["Get", empID, attnDate]; // if (oEmployeeWorkPlanSetup != null) // return oEmployeeWorkPlanSetup; // #endregion // oEmployeeWorkPlanSetup = EmployeeWorkPlanSetup.Service.Get(empID, attnDate); // #region Cache Footer // _cache.Add(oEmployeeWorkPlanSetup, "Get", empID, attnDate); // #endregion // return oEmployeeWorkPlanSetup; //} public static EmployeeWorkPlanSetup GetByEmpID(ID nempID) { EmployeeWorkPlanSetup oEmployeeWorkPlanSetup = null; #region Cache Header oEmployeeWorkPlanSetup = (EmployeeWorkPlanSetup)_cache["GetByEmpID", nempID]; if (oEmployeeWorkPlanSetup != null) return oEmployeeWorkPlanSetup; #endregion oEmployeeWorkPlanSetup = EmployeeWorkPlanSetup.Service.GetByEmpID(nempID); #region Cache Footer _cache.Add(oEmployeeWorkPlanSetup, "GetByEmpID", nempID); #endregion return oEmployeeWorkPlanSetup; } public static ObjectsTemplate Get() { #region Cache Header ObjectsTemplate autoWorkPlans = _cache["Get"] as ObjectsTemplate; if (autoWorkPlans != null) return autoWorkPlans; #endregion try { autoWorkPlans = Service.Get(); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(autoWorkPlans, "Get"); #endregion return autoWorkPlans; } public static DataSet GetEmpNotInWorkPlan() { DataSet empInfo = null; try { empInfo = Service.GetEmpNotInWorkPlan(Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); } catch (ServiceException e) { throw new Exception(e.Message, e); } return empInfo; } public static ObjectsTemplate GetForFixedWP(ID groupID, DayOfWeek holiday) { #region Cache Header ObjectsTemplate employeeWorkPlanSetups = _cache["GetForFixedWP", groupID, holiday] as ObjectsTemplate; if (employeeWorkPlanSetups != null) return employeeWorkPlanSetups; #endregion try { employeeWorkPlanSetups = Service.GetForFixedWP(groupID, holiday); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(employeeWorkPlanSetups, "GetForFixedWP", groupID, holiday); #endregion return employeeWorkPlanSetups; } public static ObjectsTemplate Get(EnumWorkPlanGroup type) { #region Cache Header ObjectsTemplate employeeWorkPlanSetups = _cache["Get", type] as ObjectsTemplate; if (employeeWorkPlanSetups != null) return employeeWorkPlanSetups; #endregion try { employeeWorkPlanSetups = Service.Get(type); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(employeeWorkPlanSetups, "Get", type); #endregion return employeeWorkPlanSetups; } public static ObjectsTemplate GetByWPGroupID(ID wpGroupID) { #region Cache Header ObjectsTemplate employeeWorkPlanSetups = _cache["GetByWPGroupID", wpGroupID] as ObjectsTemplate; if (employeeWorkPlanSetups != null) return employeeWorkPlanSetups; #endregion try { employeeWorkPlanSetups = Service.GetByWPGroupID(wpGroupID); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(employeeWorkPlanSetups, "GetByWPGroupID", wpGroupID); #endregion return employeeWorkPlanSetups; } //Get Employees whoes monthlyworkPlan is not set public static ObjectsTemplate GetMissingEmps(ID wpGroupID, DateTime assignDate) { #region Cache Header ObjectsTemplate employeeWorkPlanSetups = _cache["GetMissingEmps", wpGroupID, assignDate] as ObjectsTemplate; if (employeeWorkPlanSetups != null) return employeeWorkPlanSetups; #endregion try { employeeWorkPlanSetups = Service.GetMissingEmps(wpGroupID, assignDate); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(employeeWorkPlanSetups, "GetMissingEmps", wpGroupID, assignDate); #endregion return employeeWorkPlanSetups; } public ID Save() { this.SetAuditTrailProperties(); return EmployeeWorkPlanSetup.Service.Save(this); } public void Save(ObjectsTemplate oEMpWPSetups) { foreach (EmployeeWorkPlanSetup oEMpSetUp in oEMpWPSetups) { oEMpSetUp.SetAuditTrailProperties(); } EmployeeWorkPlanSetup.Service.Save(oEMpWPSetups); } public bool IsExist(ID groupID, DayOfWeek weekEndOn) { return EmployeeWorkPlanSetup.Service.IsExist(groupID, weekEndOn); } public void Delete() { EmployeeWorkPlanSetup.Service.Delete(ID); } public void Delete(ID groupID, DayOfWeek weekEndOn) { EmployeeWorkPlanSetup.Service.Delete(groupID, weekEndOn); } #endregion } #endregion #region IEmployeeWorkPlanSetup Service public interface IEmployeeWorkPlanSetupService { EmployeeWorkPlanSetup Get(ID id); //EmployeeWorkPlanSetup Get(ID empID, DateTime attnDate); EmployeeWorkPlanSetup GetByEmpID(ID empID); ObjectsTemplate Get(); ObjectsTemplate Get(EnumWorkPlanGroup type); ObjectsTemplate GetForFixedWP(ID groupID, DayOfWeek holiDay); ObjectsTemplate GetMissingEmps(ID wpGroupID, DateTime assignDate); ID Save(EmployeeWorkPlanSetup item); void Save(ObjectsTemplate oEMpSetUps); bool IsExist(ID groupID, DayOfWeek weekEndOn); void Delete(ID id); void Delete(ID groupID, DayOfWeek weekEndOn); ObjectsTemplate GetByWPGroupID(ID wpGroupID); DataSet GetEmpNotInWorkPlan(int payrollTypeID); } #endregion }