EchoTex_Payroll/HRM.BO/Attendance/EmployeeWorkPlanSetup.cs

829 lines
24 KiB
C#
Raw Permalink Normal View History

2024-10-14 10:01:49 +06:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ease.Core;
using System.Data;
namespace HRM.BO
{
#region EmployeeWorkPlanSetup
[Serializable]
public class EmployeeWorkPlanSetup : AuditTrailBase
{
#region Constructor
public EmployeeWorkPlanSetup()
{
_employeeID = 0;
_shiftID = 0;
_startDate = DateTime.MinValue;
_workPanGroupId = 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 int _employeeID;
public int EmployeeID
{
get { return _employeeID; }
set
{
//base.OnPropertyChange<ID>("employeeID", _employeeID, value);
_employeeID = 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 StartDate : DateTime
private DateTime _startDate;
public DateTime StartDate
{
get { return _startDate; }
set
{
//base.OnPropertyChange<DateTime>("StartDate", _startDate, value);
_startDate = value;
}
}
#endregion
#region WorkPlanGroupID : ID
private int _workPanGroupId;
public int WorkPlanGroupID
{
get { return _workPanGroupId; }
set
{
//base.OnPropertyChange<ID>("WorkPlanGroupID", _workPanGroupId, value);
_workPanGroupId = value;
}
}
#endregion
#region WorkPlanGroupType : EnumWorkPlanGroup
public EnumWorkPlanGroup WorkPlanGroupType { get; set; }
#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
public int PayrolltypeID { get; set; }
#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");
}
}
public string EmployeeNoView { get; set; }
public string EmployeeNameView { get; set; }
public string WorkPlanGroupNameView { get; set; }
//#region Service Factory IEmployeeWorkPlanSetupService : IEmployeeWorkPlanSetupService
//internal static IEmployeeWorkPlanSetupService Service
//{
// get { return Services.Factory.CreateService<IEmployeeWorkPlanSetupService>(typeof(IEmployeeWorkPlanSetupService)); }
//}
//#endregion
#endregion
//#region Functions
//public static ObjectsTemplate<EmployeeWorkPlanSetup> GetAll()
//{
// #region Cache Header
// ObjectsTemplate<EmployeeWorkPlanSetup> autoWorkPlans = _cache["Get"] as ObjectsTemplate<EmployeeWorkPlanSetup>;
// if (autoWorkPlans != null)
// return autoWorkPlans;
// #endregion
// try
// {
// autoWorkPlans = Service.GetAll();
// }
// catch (ServiceException e)
// {
// throw new Exception(e.Message, e);
// }
// #region Cache Footer
// _cache.Add(autoWorkPlans, "Get");
// #endregion
// return autoWorkPlans;
//}
//public static ObjectsTemplate<EmployeeWorkPlanSetup> Get(int payrollTypeId)
//{
// #region Cache Header
// ObjectsTemplate<EmployeeWorkPlanSetup> autoWorkPlans = _cache["Get"] as ObjectsTemplate<EmployeeWorkPlanSetup>;
// if (autoWorkPlans != null)
// return autoWorkPlans;
// #endregion
// try
// {
// autoWorkPlans = Service.Get(payrollTypeId);
// }
// catch (ServiceException e)
// {
// throw new Exception(e.Message, e);
// }
// #region Cache Footer
// _cache.Add(autoWorkPlans, "Get");
// #endregion
// return autoWorkPlans;
//}
//public static ObjectsTemplate<EmployeeWorkPlanSetup> LoaData(DataTable dtEMPWPS)
//{
// ObjectsTemplate<EmployeeWorkPlanSetup> _oEmployeeWorkPlanSetups = new ObjectsTemplate<EmployeeWorkPlanSetup>();
// EmployeeWorkPlanSetup oEmployeeWorkPlanSetup = null;
// if (dtEMPWPS != null && dtEMPWPS.Rows.Count > 0)
// {
// foreach (DataRow drItem in dtEMPWPS.Rows)
// {
// oEmployeeWorkPlanSetup = new EmployeeWorkPlanSetup();
// oEmployeeWorkPlanSetup.SetID(Ease.CoreV35.Model.ID.FromInteger(Convert.ToInt32(drItem["EMPLOYEEWORKPLANSETUPID"])));
// oEmployeeWorkPlanSetup.PayrolltypeID = Ease.CoreV35.Model.ID.FromInteger(Convert.ToInt32(drItem["PayrollTypeID"]));
// oEmployeeWorkPlanSetup.WorkPlanGroupID = Ease.CoreV35.Model.ID.FromInteger(Convert.ToInt32(drItem["WorkPlanGroupID"]));
// oEmployeeWorkPlanSetup.EmployeeID = Ease.CoreV35.Model.ID.FromInteger(Convert.ToInt32(drItem["EmployeeID"]));
// _oEmployeeWorkPlanSetups.Add(oEmployeeWorkPlanSetup);
// }
// }
// return _oEmployeeWorkPlanSetups;
//}
//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<EmployeeWorkPlanSetup> Get()
//{
// #region Cache Header
// ObjectsTemplate<EmployeeWorkPlanSetup> autoWorkPlans = _cache["Get"] as ObjectsTemplate<EmployeeWorkPlanSetup>;
// 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();
// }
// catch (ServiceException e)
// {
// throw new Exception(e.Message, e);
// }
// return empInfo;
//}
//public ID GetFixedShiftID(DayOfWeek dWeek)
//{
// int? ShiftID = null;
// switch (dWeek)
// {
// case DayOfWeek.Friday:
// ShiftID = this.FridayShiftID;
// break;
// case DayOfWeek.Monday:
// ShiftID = this.MondayShiftID;
// break;
// case DayOfWeek.Saturday:
// ShiftID = this.SaturdayShiftID;
// break;
// case DayOfWeek.Sunday:
// ShiftID = this.SundayShiftID;
// break;
// case DayOfWeek.Thursday:
// ShiftID = this.ThursdayShiftID;
// break;
// case DayOfWeek.Tuesday:
// ShiftID = this.TuesdayShiftID;
// break;
// case DayOfWeek.Wednesday:
// ShiftID = this.WednesdayShiftID;
// break;
// default:
// break;
// }
// return ID.FromInteger((int)ShiftID);
//}
//public static ObjectsTemplate<EmployeeWorkPlanSetup> GetForFixedWP(ID groupID, DayOfWeek holiday)
//{
// #region Cache Header
// ObjectsTemplate<EmployeeWorkPlanSetup> employeeWorkPlanSetups = _cache["GetForFixedWP", groupID, holiday] as ObjectsTemplate<EmployeeWorkPlanSetup>;
// 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<EmployeeWorkPlanSetup> Get(EnumWorkPlanGroup type)
//{
// #region Cache Header
// ObjectsTemplate<EmployeeWorkPlanSetup> employeeWorkPlanSetups = _cache["Get", type] as ObjectsTemplate<EmployeeWorkPlanSetup>;
// 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<EmployeeWorkPlanSetup> GetByWPGroupID(ID wpGroupID)
//{
// #region Cache Header
// ObjectsTemplate<EmployeeWorkPlanSetup> employeeWorkPlanSetups = _cache["GetByWPGroupID", wpGroupID] as ObjectsTemplate<EmployeeWorkPlanSetup>;
// 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<EmployeeWorkPlanSetup> GetMissingEmps(ID wpGroupID, DateTime assignDate)
//{
// #region Cache Header
// ObjectsTemplate<EmployeeWorkPlanSetup> employeeWorkPlanSetups = _cache["GetMissingEmps", wpGroupID, assignDate] as ObjectsTemplate<EmployeeWorkPlanSetup>;
// 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<EmployeeWorkPlanSetup> oEMpWPSetups)
//{
// foreach (EmployeeWorkPlanSetup oEMpSetUp in oEMpWPSetups)
// {
// oEMpSetUp.SetAuditTrailProperties();
// }
// EmployeeWorkPlanSetup.Service.Save(oEMpWPSetups);
//}
//public void SaveFixedWPlans(ObjectsTemplate<EmployeeWorkPlanSetup> oEMpWPSetups)
//{
// foreach (EmployeeWorkPlanSetup oEMpSetUp in oEMpWPSetups)
// {
// oEMpSetUp.SetAuditTrailProperties();
// }
// EmployeeWorkPlanSetup.Service.SaveFixedWPlans(oEMpWPSetups);
//}
//public bool IsExist(ID groupID, DayOfWeek weekEndOn)
//{
// return EmployeeWorkPlanSetup.Service.IsExist(groupID, weekEndOn);
//}
//public bool IsEmployeeExistInWorkplan(ID empID)
//{
// return EmployeeWorkPlanSetup.Service.IsEmployeeExistInWorkplan(empID);
//}
//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(int id);
//EmployeeWorkPlanSetup Get(ID empID, DateTime attnDate);
EmployeeWorkPlanSetup GetByEmpID(int empID);
List<EmployeeWorkPlanSetup> Get();
List<EmployeeWorkPlanSetup> Get(EnumWorkPlanGroup type);
List<EmployeeWorkPlanSetup> GetForFixedWP(int groupID, DayOfWeek holiDay);
List<EmployeeWorkPlanSetup> GetMissingEmps(int wpGroupID, DateTime assignDate);
List<EmployeeWorkPlanSetup> NotYetAssigned(int payrollTypeID);
// List<EmployeeWorkPlanSetup> GetEmployeeWorkPlan(int wpGroupID, DateTime assignDate);
List<EmployeeWorkPlanSetup> getEmployeeWorkPlan(string empID);
int Save(EmployeeWorkPlanSetup item, int payrollID);
void Save(List<EmployeeWorkPlanSetup> oEMpSetUps, int payrollID);
void SaveFixedWPlans(List<EmployeeWorkPlanSetup> oEMpSetUps, int payrollID);
bool IsExist(int groupID, DayOfWeek weekEndOn);
void Delete(int id);
void Delete(int groupID, DayOfWeek weekEndOn);
List<EmployeeWorkPlanSetup> GetByWPGroupID(int wpGroupID);
bool IsEmployeeExistInWorkplan(int empID);
List<EmployeeWorkPlanSetup> IsEmpExistInWorkplan(List<SearchEmployee> emps, int payrollTypeID);
List<EmployeeWorkPlanSetup> GetByPayrollTypeID(int payrollTypeId);
List<EmployeeWorkPlanSetup> GetAll();
}
#endregion
}