EchoTex_Payroll/HRM.BO/Attendance/MonthlyWorkPlan.cs

415 lines
15 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 MonthlyWorkPlan
public class MonthlyWorkPlan : AuditTrailBase
{
#region Constructor
public MonthlyWorkPlan()
{
WorkDate = DateTime.MinValue;
ShiftID = 0;
HolidayID = 0;
WorkPlanGroupID = 0;
Type = EnumWorkPlanDayType.WorkingDay;
}
#endregion
#region Properties
#region ItemID
private int? _employeeID;
public int? EmployeeID
{
get { return _employeeID; }
set { _employeeID = value; }
}
#endregion
public int payrollTypeID { get; set; }
public DateTime WorkDate { get; set; }
public int ShiftID { get; set; }
public int HolidayID { get; set; }
public EnumWorkPlanDayType Type { get; set; }
public int WorkPlanGroupID { get; set; }
public int DaySerial { get; set; }
public int NextDaySerial
{
get {
if (this.WorkPlanGroup ==null)
return 0;
else if (this.WorkPlanGroup.Type == EnumWorkPlanGroup.Two_Days_Shift_1 ||
this.WorkPlanGroup.Type == EnumWorkPlanGroup.Two_Days_Shift_2)
return DaySerial == 0 ? 0 : (DaySerial == 2 ? 1 : (DaySerial + 1));
else if (this.WorkPlanGroup.Type == EnumWorkPlanGroup.Three_Days_Shift_1 ||
this.WorkPlanGroup.Type == EnumWorkPlanGroup.Three_Days_Shift_2)
return DaySerial == 0 ? 0 : (DaySerial == 3 ? 1 : (DaySerial + 1));
else return DaySerial == 0 ? 0 : (DaySerial == 7 ? 1 : (DaySerial + 1));
}
}
private Shift _shift;
public Shift Shift
{
get
{
return _shift;
}
}
private WorkPlanGroup _workPlanGroup;
public WorkPlanGroup WorkPlanGroup
{
set
{
_workPlanGroup = value;
}
get
{
//if (_workPlanGroup == null && WorkPlanGroupID != null && !WorkPlanGroupID.IsUnassigned)
//{
// _workPlanGroup = WorkPlanGroup.Get(WorkPlanGroupID);
//}
return _workPlanGroup;
}
}
//#region Service Factory IMonthlyWorkPlanService : IMonthlyWorkPlanService
//internal static IMonthlyWorkPlanService Service
//{
// get { return Services.Factory.CreateService<IMonthlyWorkPlanService>(typeof(IMonthlyWorkPlanService)); }
//}
//#endregion
#endregion
//#region Functions
//public static ObjectsTemplate<MonthlyWorkPlan> Get()
//{
// #region Cache Header
// ObjectsTemplate<MonthlyWorkPlan> monthlyWorkPlans = _cache["Get"] as ObjectsTemplate<MonthlyWorkPlan>;
// if (monthlyWorkPlans != null)
// return monthlyWorkPlans;
// #endregion
// try
// {
// monthlyWorkPlans = Service.Get();
// }
// catch (ServiceException e)
// {
// throw new Exception(e.Message, e);
// }
// #region Cache Footer
// _cache.Add(monthlyWorkPlans, "Get");
// #endregion
// return monthlyWorkPlans;
//}
//public static ObjectsTemplate<MonthlyWorkPlan> GetByPayrollTypeID(DateTime fromDate, DateTime toDate, int payrollTypeID)
//{
// #region Cache Header
// ObjectsTemplate<MonthlyWorkPlan> monthlyWorkPlans = _cache["Get", fromDate, toDate] as ObjectsTemplate<MonthlyWorkPlan>;
// if (monthlyWorkPlans != null)
// return monthlyWorkPlans;
// #endregion
// try
// {
// monthlyWorkPlans = Service.GetByPayrollTypeID(fromDate, toDate, payrollTypeID);
// }
// catch (ServiceException e)
// {
// throw new Exception(e.Message, e);
// }
// #region Cache Footer
// _cache.Add(monthlyWorkPlans, "Get", fromDate, toDate);
// #endregion
// return monthlyWorkPlans;
//}
//public static MonthlyWorkPlan GetByEmpID(ID nEmpID, DateTime assDate, EnumWorkPlanGroup type)
//{
// MonthlyWorkPlan oMonthlyWorkPlan = null;
// #region Cache Header
// oMonthlyWorkPlan = (MonthlyWorkPlan)_cache["GetByEmpID", nEmpID, assDate, type];
// if (oMonthlyWorkPlan != null)
// return oMonthlyWorkPlan;
// #endregion
// oMonthlyWorkPlan = MonthlyWorkPlan.Service.GetByEmpID(nEmpID, assDate, type);
// #region Cache Footer
// _cache.Add(oMonthlyWorkPlan, "GetByEmpID", nEmpID, assDate, type);
// #endregion
// return oMonthlyWorkPlan;
//}
//public static ObjectsTemplate<MonthlyWorkPlan> GetByDateAndPayrollType(DateTime attnDate, int payrollTypeID)
//{
// #region Cache Header
// ObjectsTemplate<MonthlyWorkPlan> monthlyWorkPlans = _cache["Get", attnDate] as ObjectsTemplate<MonthlyWorkPlan>;
// if (monthlyWorkPlans != null)
// return monthlyWorkPlans;
// #endregion
// try
// {
// monthlyWorkPlans = Service.GetByDateAndPayrollType(attnDate, payrollTypeID);
// }
// catch (ServiceException e)
// {
// throw new Exception(e.Message, e);
// }
// #region Cache Footer
// _cache.Add(monthlyWorkPlans, "Get", attnDate);
// #endregion
// return monthlyWorkPlans;
//}
//public static MonthlyWorkPlan GetByEmpID(ID nEmpID, DateTime workDate)
//{
// MonthlyWorkPlan oMonthlyWorkPlan = null;
// #region Cache Header
// oMonthlyWorkPlan = (MonthlyWorkPlan)_cache["GetByEmpID", nEmpID, workDate];
// if (oMonthlyWorkPlan != null)
// return oMonthlyWorkPlan;
// #endregion
// oMonthlyWorkPlan = MonthlyWorkPlan.Service.GetByEmpID(nEmpID, workDate);
// #region Cache Footer
// _cache.Add(oMonthlyWorkPlan, "GetByEmpID", nEmpID, workDate);
// #endregion
// return oMonthlyWorkPlan;
//}
//public static ObjectsTemplate<MonthlyWorkPlan> Get(DateTime fromDate, DateTime toDate)
//{
// #region Cache Header
// ObjectsTemplate<MonthlyWorkPlan> monthlyWorkPlans = _cache["Get", fromDate, toDate] as ObjectsTemplate<MonthlyWorkPlan>;
// if (monthlyWorkPlans != null)
// return monthlyWorkPlans;
// #endregion
// try
// {
// monthlyWorkPlans = Service.Get(fromDate, toDate);
// }
// catch (ServiceException e)
// {
// throw new Exception(e.Message, e);
// }
// #region Cache Footer
// _cache.Add(monthlyWorkPlans, "Get", fromDate, toDate);
// #endregion
// return monthlyWorkPlans;
//}
//public static ObjectsTemplate<MonthlyWorkPlan> GetMonthlyDataByEmp(DateTime fromDate, DateTime toDate, EnumWorkPlanGroup type, ID nEmpID, int workPlanGroupID)
//{
// #region Cache Header
// ObjectsTemplate<MonthlyWorkPlan> monthlyWorkPlans = _cache["GetMonthlyDataByEmp", fromDate, toDate, type, nEmpID, workPlanGroupID] as ObjectsTemplate<MonthlyWorkPlan>;
// if (monthlyWorkPlans != null)
// return monthlyWorkPlans;
// #endregion
// try
// {
// monthlyWorkPlans = Service.GetMonthlyDataByEmp(fromDate, toDate, type, nEmpID, workPlanGroupID);
// }
// catch (ServiceException e)
// {
// throw new Exception(e.Message, e);
// }
// #region Cache Footer
// _cache.Add(monthlyWorkPlans, "GetMonthlyDataByEmp");
// #endregion
// return monthlyWorkPlans;
//}
//public static ObjectsTemplate<MonthlyWorkPlan> GetMonthlyDataByEmp(DateTime dAssDate, EnumWorkPlanGroup type, ID nEmpID)
//{
// #region Cache Header
// ObjectsTemplate<MonthlyWorkPlan> monthlyWorkPlans = _cache["GetMonthlyDataByEmp", dAssDate, type, nEmpID] as ObjectsTemplate<MonthlyWorkPlan>;
// if (monthlyWorkPlans != null)
// return monthlyWorkPlans;
// #endregion
// try
// {
// monthlyWorkPlans = Service.GetMonthlyDataByEmp(dAssDate, type, nEmpID);
// }
// catch (ServiceException e)
// {
// throw new Exception(e.Message, e);
// }
// #region Cache Footer
// _cache.Add(monthlyWorkPlans, "GetMonthlyDataByEmp");
// #endregion
// return monthlyWorkPlans;
//}
//public static ObjectsTemplate<MonthlyWorkPlan> GetByDate(DateTime attnDate)
//{
// try
// {
// return Service.GetByDate(attnDate);
// }
// catch (ServiceException e)
// {
// throw new Exception(e.Message, e);
// }
//}
//public static ObjectsTemplate<MonthlyWorkPlan> Get(DateTime attnMonth)
//{
// try
// {
// return Service.Get(attnMonth);
// }
// catch (ServiceException e)
// {
// throw new Exception(e.Message, e);
// }
//}
//public static ObjectsTemplate<MonthlyWorkPlan> GetByDateAndGroupID(DateTime assignDate, ID groupID)
//{
// #region Cache Header
// ObjectsTemplate<MonthlyWorkPlan> monthlyWorkPlans = _cache["GetByDateAndGroupID", assignDate, groupID] as ObjectsTemplate<MonthlyWorkPlan>;
// if (monthlyWorkPlans != null)
// return monthlyWorkPlans;
// #endregion
// try
// {
// monthlyWorkPlans = Service.GetByDateAndGroupID(assignDate, groupID);
// }
// catch (ServiceException e)
// {
// throw new Exception(e.Message, e);
// }
// #region Cache Footer
// _cache.Add(monthlyWorkPlans, "GetByDateAndGroupID");
// #endregion
// return monthlyWorkPlans;
//}
//public static DateTime GetLastSavedWorkDate()
//{
// return Service.GetLastSavedWorkDate();
//}
//public void Save(ObjectsTemplate<MonthlyWorkPlan> oMWPlans)
//{
// foreach (MonthlyWorkPlan oMWPlan in oMWPlans)
// {
// oMWPlan.SetAuditTrailProperties();
// }
// MonthlyWorkPlan.Service.Save(oMWPlans);
//}
//public void Delete(DateTime fromDate)
//{
// MonthlyWorkPlan.Service.Delete(fromDate);
//}
//public void Delete(DateTime assignDate, string empIds)
//{
// MonthlyWorkPlan.Service.Delete(assignDate, empIds);
//}
//public void Delete(DateTime dFromDate, DateTime dToDate)
//{
// MonthlyWorkPlan.Service.Delete(dFromDate, dToDate);
//}
//public static bool IsExist(DateTime dAssDate, ID groupID)
//{
// return MonthlyWorkPlan.Service.IsExist(dAssDate, groupID);
//}
//public static MonthlyWorkPlan GetPlanwithEmployee(DateTime EffectDate, ID employeeid, ObjectsTemplate<EmployeeWorkPlanSetup> plans, ObjectsTemplate<MonthlyWorkPlan> MworkPlans, ObjectsTemplate<ActingResponsibilitySetup> temporaryShiftEmps)
//{
// MonthlyWorkPlan dPlan = null;
// if (temporaryShiftEmps == null)
// {
// EmployeeWorkPlanSetup workGroup = plans.FirstOrDefault(x => x.EmployeeID.Integer == employeeid.Integer);
// if (workGroup != null)
// {
// dPlan = MworkPlans.FirstOrDefault(x => x.WorkPlanGroupID.Integer == workGroup.WorkPlanGroupID.Integer && x.WorkDate == EffectDate);
// if (dPlan != null)
// dPlan.EmployeeID = employeeid.Integer;
// }
// }
// else
// {
// ActingResponsibilitySetup tempShift = temporaryShiftEmps.FirstOrDefault(x => x.EmployeeID.Integer == employeeid.Integer && x.GradeID == null);
// if (tempShift != null)
// {
// dPlan = MworkPlans.FirstOrDefault(x => x.WorkPlanGroupID.Integer == tempShift.WorkPlanGroupID.Integer && x.WorkDate == EffectDate);
// dPlan.EmployeeID = employeeid.Integer;
// }
// }
// return dPlan;
//}
//#endregion
}
#endregion
//#region IMonthlyWorkPlan Service
public interface IMonthlyWorkPlanService
{
List<MonthlyWorkPlan> Get(DateTime attnMonth, int payrollTypeID);
List<MonthlyWorkPlan> Get(DateTime fromDate, DateTime toDate, int payrollTypeID);
List<MonthlyWorkPlan> GetByDateAndGroupID(DateTime dAssDate, int groupID);
List<MonthlyWorkPlan> GetByDate(DateTime attnDate,int payrollTypeID);
DateTime GetLastSavedWorkDate(int payrollTypeID);
void Save(List<MonthlyWorkPlan> oMonthlyWPlans);
void UpdateShiftAndRoster(MonthlyWorkPlan mplan);
void Delete(DateTime fromDate, DateTime toDate, int payrollTypeID);
void DeleteOnward(DateTime fromMonth, int payrollTypeID);
bool IsExist(DateTime dAssDate, int groupID);
List<MonthlyWorkPlan> RefreshMonthlyWorkplan(DateTime monthFromDate, DateTime monthToDate, int payrollTypeID);
List<MonthlyWorkPlan> updateWorkPlan(MonthlyWorkPlan mplan);
//List<MonthlyWorkPlan> GetMonthlyDataByEmp(DateTime fromDate, DateTime toDate, EnumWorkPlanGroup type, ID nEmpID, int workPlanGroupID);
//List<MonthlyWorkPlan> GetMonthlyDataByEmp(DateTime dAssDate, EnumWorkPlanGroup type, int nEmpID);
//void Delete(DateTime assignDate, string empIds);
//void Delete(DateTime fromDate, DateTime toDate);
//MonthlyWorkPlan GetByEmpID(int nEmpID, DateTime assDate, EnumWorkPlanGroup type);
//MonthlyWorkPlan GetByEmpID(int nEmpID, DateTime workDate);
//List<MonthlyWorkPlan> GetByDateAndPayrollType(DateTime attnDate, int payrollTypeID);
//List<MonthlyWorkPlan> GetByPayrollTypeID(DateTime fromDate, DateTime toDate, int payrollTypeID);
}
//#endregion
}