485 lines
15 KiB
C#
485 lines
15 KiB
C#
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 MonthlyWorkPlan
|
|
|
|
[Serializable]
|
|
public class MonthlyWorkPlan : AuditTrailBase
|
|
{
|
|
#region Cache Store
|
|
|
|
private static Cache _cache = new Cache(typeof(MonthlyWorkPlan));
|
|
|
|
#endregion
|
|
|
|
#region Constructor
|
|
|
|
public MonthlyWorkPlan()
|
|
{
|
|
_employeeID = null;
|
|
_workDate = DateTime.MinValue;
|
|
_shiftID = null;
|
|
_holidayID = null;
|
|
_employee = null;
|
|
_workPlanGroupID = null;
|
|
_type = EnumWorkPlanDayType.WorkingDay;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Properties
|
|
|
|
#region employeeID : ID
|
|
|
|
private ID _employeeID;
|
|
public ID EmployeeID
|
|
{
|
|
get { return _employeeID; }
|
|
set
|
|
{
|
|
base.OnPropertyChange<ID>("employeeID", _employeeID, value);
|
|
_employeeID = value;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region workDate : DateTime
|
|
|
|
private DateTime _workDate;
|
|
public DateTime WorkDate
|
|
{
|
|
get { return _workDate; }
|
|
set
|
|
{
|
|
base.OnPropertyChange<DateTime>("workDate", _workDate, value);
|
|
_workDate = value;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region shiftID : ID
|
|
|
|
private ID _shiftID;
|
|
public ID ShiftID
|
|
{
|
|
get { return _shiftID; }
|
|
set
|
|
{
|
|
base.OnPropertyChange<ID>("shiftID", _shiftID, value);
|
|
_shiftID = value;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region holidayID : ID
|
|
|
|
private ID _holidayID;
|
|
public ID HolidayID
|
|
{
|
|
get { return _holidayID; }
|
|
set
|
|
{
|
|
base.OnPropertyChange<ID>("holidayID", _holidayID, value);
|
|
_holidayID = value;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Type : EnumWorkPlanDayType
|
|
private EnumWorkPlanDayType _type;
|
|
public EnumWorkPlanDayType Type
|
|
{
|
|
get { return _type; }
|
|
set
|
|
{
|
|
base.OnPropertyChange<short>("Type", (short)_type, (short)value);
|
|
_type = value;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region employee : Employee
|
|
|
|
private Employee _employee;
|
|
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;
|
|
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 WorkPlanGroupID : ID
|
|
|
|
private ID _workPlanGroupID;
|
|
public ID WorkPlanGroupID
|
|
{
|
|
get { return _workPlanGroupID; }
|
|
set
|
|
{
|
|
base.OnPropertyChange<ID>("WorkPlanGroupID", _workPlanGroupID, value);
|
|
_workPlanGroupID = value;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region WorkPlanGroup : WorkPlanGroup
|
|
|
|
private WorkPlanGroup _workPlanGroup;
|
|
public WorkPlanGroup WorkPlanGroup
|
|
{
|
|
get
|
|
{
|
|
if (_workPlanGroupID.Integer > 0 && _workPlanGroup == null)
|
|
{
|
|
_workPlanGroup = new WorkPlanGroup();
|
|
_workPlanGroup = WorkPlanGroup.Get(_workPlanGroupID);
|
|
}
|
|
return this._workPlanGroup;
|
|
}
|
|
set
|
|
{
|
|
_workPlanGroup = value;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Service Factory IMonthlyWorkPlanService : IMonthlyWorkPlanService
|
|
|
|
internal static IMonthlyWorkPlanService Service
|
|
{
|
|
get { return Services.Factory.CreateService<IMonthlyWorkPlanService>(typeof(IMonthlyWorkPlanService)); }
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
#region Functions
|
|
|
|
public static MonthlyWorkPlan Get(ID nID)
|
|
{
|
|
MonthlyWorkPlan oMonthlyWorkPlan = null;
|
|
#region Cache Header
|
|
oMonthlyWorkPlan = (MonthlyWorkPlan)_cache["Get", nID];
|
|
if (oMonthlyWorkPlan != null)
|
|
return oMonthlyWorkPlan;
|
|
#endregion
|
|
oMonthlyWorkPlan = MonthlyWorkPlan.Service.Get(nID);
|
|
#region Cache Footer
|
|
_cache.Add(oMonthlyWorkPlan, "Get", nID);
|
|
#endregion
|
|
return oMonthlyWorkPlan;
|
|
}
|
|
|
|
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 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()
|
|
{
|
|
#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> Get(DateTime attnDate)
|
|
{
|
|
#region Cache Header
|
|
ObjectsTemplate<MonthlyWorkPlan> monthlyWorkPlans = _cache["Get", attnDate] as ObjectsTemplate<MonthlyWorkPlan>;
|
|
if (monthlyWorkPlans != null)
|
|
return monthlyWorkPlans;
|
|
#endregion
|
|
try
|
|
{
|
|
monthlyWorkPlans = Service.Get(attnDate);
|
|
}
|
|
catch (ServiceException e)
|
|
{
|
|
throw new Exception(e.Message, e);
|
|
}
|
|
#region Cache Footer
|
|
_cache.Add(monthlyWorkPlans, "Get", attnDate);
|
|
#endregion
|
|
return monthlyWorkPlans;
|
|
}
|
|
|
|
|
|
public static ObjectsTemplate<MonthlyWorkPlan> GetByType(EnumWorkPlanGroup type)
|
|
{
|
|
#region Cache Header
|
|
ObjectsTemplate<MonthlyWorkPlan> monthlyWorkPlans = _cache["GetByType", type] as ObjectsTemplate<MonthlyWorkPlan>;
|
|
if (monthlyWorkPlans != null)
|
|
return monthlyWorkPlans;
|
|
#endregion
|
|
try
|
|
{
|
|
monthlyWorkPlans = Service.GetByType(type);
|
|
}
|
|
catch (ServiceException e)
|
|
{
|
|
throw new Exception(e.Message, e);
|
|
}
|
|
#region Cache Footer
|
|
_cache.Add(monthlyWorkPlans, "GetByType");
|
|
#endregion
|
|
return monthlyWorkPlans;
|
|
}
|
|
|
|
public static ObjectsTemplate<MonthlyWorkPlan> GetByDateAndWPGType(DateTime dAssDate, EnumWorkPlanGroup type)
|
|
{
|
|
#region Cache Header
|
|
ObjectsTemplate<MonthlyWorkPlan> monthlyWorkPlans = _cache["GetByDateAndWPGType", dAssDate, type] as ObjectsTemplate<MonthlyWorkPlan>;
|
|
if (monthlyWorkPlans != null)
|
|
return monthlyWorkPlans;
|
|
#endregion
|
|
try
|
|
{
|
|
monthlyWorkPlans = Service.GetByDateAndWPGType(dAssDate, type);
|
|
}
|
|
catch (ServiceException e)
|
|
{
|
|
throw new Exception(e.Message, e);
|
|
}
|
|
#region Cache Footer
|
|
_cache.Add(monthlyWorkPlans, "GetByDateAndWPGType");
|
|
#endregion
|
|
return monthlyWorkPlans;
|
|
}
|
|
|
|
public static ObjectsTemplate<MonthlyWorkPlan> GetByDateAndGroupID(DateTime dAssDate, ID groupID)
|
|
{
|
|
#region Cache Header
|
|
ObjectsTemplate<MonthlyWorkPlan> monthlyWorkPlans = _cache["GetByDateAndGroupID", dAssDate, groupID] as ObjectsTemplate<MonthlyWorkPlan>;
|
|
if (monthlyWorkPlans != null)
|
|
return monthlyWorkPlans;
|
|
#endregion
|
|
try
|
|
{
|
|
monthlyWorkPlans = Service.GetByDateAndGroupID(dAssDate, groupID);
|
|
}
|
|
catch (ServiceException e)
|
|
{
|
|
throw new Exception(e.Message, e);
|
|
}
|
|
#region Cache Footer
|
|
_cache.Add(monthlyWorkPlans, "GetByDateAndGroupID");
|
|
#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 ID Save()
|
|
{
|
|
return MonthlyWorkPlan.Service.Save(this);
|
|
}
|
|
public void Save(ObjectsTemplate<MonthlyWorkPlan> oMWPlans)
|
|
{
|
|
foreach (MonthlyWorkPlan oMWPlan in oMWPlans)
|
|
{
|
|
oMWPlan.SetAuditTrailProperties();
|
|
}
|
|
MonthlyWorkPlan.Service.Save(oMWPlans);
|
|
}
|
|
public void Delete()
|
|
{
|
|
MonthlyWorkPlan.Service.Delete(ID);
|
|
}
|
|
public void Delete(DateTime dFromDate, DateTime dToDate, EnumWorkPlanGroup type)
|
|
{
|
|
MonthlyWorkPlan.Service.Delete(dFromDate, dToDate, type);
|
|
}
|
|
public void Delete(DateTime assignDate, string empIds)
|
|
{
|
|
MonthlyWorkPlan.Service.Delete(assignDate, empIds);
|
|
}
|
|
public void Delete(DateTime dFromDate, DateTime dToDate, ID wpGroupID)
|
|
{
|
|
MonthlyWorkPlan.Service.Delete(dFromDate, dToDate, wpGroupID);
|
|
}
|
|
|
|
public void Delete(DateTime dFromDate, DateTime dToDate)
|
|
{
|
|
MonthlyWorkPlan.Service.Delete(dFromDate, dToDate);
|
|
}
|
|
|
|
public static int DayCount(EnumWorkPlanGroup type)
|
|
{
|
|
return MonthlyWorkPlan.Service.DayCount(type);
|
|
}
|
|
|
|
public static DataSet GetMissingEmp(ID groupID, DateTime assignDate)
|
|
{
|
|
DataSet missingEmp = null;
|
|
|
|
try
|
|
{
|
|
missingEmp = Service.GetMissingEmp(groupID, assignDate);
|
|
}
|
|
catch (ServiceException e)
|
|
{
|
|
throw new Exception(e.Message, e);
|
|
}
|
|
|
|
return missingEmp;
|
|
}
|
|
|
|
public static DataSet GetEmpNotInMonthlyWorkPlan(DateTime assignDate)
|
|
{
|
|
DataSet empInfo = null;
|
|
|
|
try
|
|
{
|
|
empInfo = Service.GetEmpNotInMonthlyWorkPlan(assignDate);
|
|
}
|
|
catch (ServiceException e)
|
|
{
|
|
throw new Exception(e.Message, e);
|
|
}
|
|
|
|
return empInfo;
|
|
}
|
|
|
|
public static bool IsExist(DateTime dAssDate, ID groupID)
|
|
{
|
|
return MonthlyWorkPlan.Service.IsExist(dAssDate, groupID);
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region IMonthlyWorkPlan Service
|
|
|
|
public interface IMonthlyWorkPlanService
|
|
{
|
|
MonthlyWorkPlan Get(ID id);
|
|
ObjectsTemplate<MonthlyWorkPlan> Get();
|
|
ObjectsTemplate<MonthlyWorkPlan> Get(DateTime attnDate);
|
|
ObjectsTemplate<MonthlyWorkPlan> GetByType(EnumWorkPlanGroup type);
|
|
ObjectsTemplate<MonthlyWorkPlan> GetByDateAndWPGType(DateTime dAssDate, EnumWorkPlanGroup type);
|
|
ObjectsTemplate<MonthlyWorkPlan> GetByDateAndGroupID(DateTime dAssDate, ID groupID);
|
|
MonthlyWorkPlan GetByEmpID(ID empID, DateTime assDate, EnumWorkPlanGroup type);
|
|
MonthlyWorkPlan GetByEmpID(ID empID, DateTime workDate);
|
|
ObjectsTemplate<MonthlyWorkPlan> GetMonthlyDataByEmp(DateTime dAssDate, EnumWorkPlanGroup type, ID nEmpID);
|
|
ID Save(MonthlyWorkPlan item);
|
|
void Save(ObjectsTemplate<MonthlyWorkPlan> oMonthlyWPlans);
|
|
void Delete(ID id);
|
|
void Delete(DateTime dFromDate, DateTime dToDate, EnumWorkPlanGroup type);
|
|
void Delete(DateTime dFromDate, DateTime dToDate, ID wpGroupID);
|
|
void Delete(DateTime dFromDate, DateTime dToDate);
|
|
void Delete(DateTime assignDate, string empIds);
|
|
int DayCount(EnumWorkPlanGroup type);
|
|
bool IsExist(DateTime dAssDate, ID groupID);
|
|
DataSet GetMissingEmp(ID groupID, DateTime assignDate);
|
|
DataSet GetEmpNotInMonthlyWorkPlan(DateTime assignDate);
|
|
}
|
|
|
|
#endregion
|
|
}
|