using System; using System.Collections.Generic; using System.Linq; using System.Text; using Ease.CoreV35; using Ease.CoreV35.Model; using Ease.CoreV35.Caching; using System.Data.Linq.Mapping; namespace Payroll.BO { #region LeavePlan [Serializable] public class LeavePlan : BasicBaseObject { #region Cache Store private static Cache _cache = new Cache(typeof(LeavePlan)); #endregion #region Constructor public LeavePlan() { _empID = 0; _leaveID = ID.FromInteger(0); _leaveYear = 0; _planFromDate = DateTime.Now.Date; _planToDate = DateTime.Now.Date; _appTotalDays = 0; _entryDate = DateTime.Now.Date; _bIsApproved = false; _bIsSubmitted = false; } #endregion #region Properties #region EmployeeID private int _empID; public int EmpID { get { return _empID; } set { _empID = value; } } #endregion #region LeaveID private ID _leaveID; public ID LeaveID { get { return _leaveID; } set { _leaveID = value; } } #endregion #region Leave Year private int _leaveYear; public int LeaveYear { get { return _leaveYear; } set { _leaveYear = value; } } #endregion #region Plan From Date private DateTime _planFromDate; public DateTime PlanFromDate { get { return _planFromDate; } set { _planFromDate = value; } } #endregion #region Plan To Date private DateTime _planToDate; public DateTime PlanToDate { get { return _planToDate; } set { _planToDate = value; } } #endregion #region PlanTotalDays private double _appTotalDays; public double PlanTotalDays { get { return _appTotalDays; } set { _appTotalDays = value; } } #endregion #region Entry Date private DateTime _entryDate; public DateTime EntryDate { get { return _entryDate; } set { _entryDate = value; } } #endregion #region IsApproved private bool _bIsApproved; public bool IsApproved { get { return _bIsApproved; } set { _bIsApproved = value; } } #endregion #region IsSubmitted private bool _bIsSubmitted; public bool IsSubmitted { get { return _bIsSubmitted; } set { _bIsSubmitted = value; } } #endregion #endregion #region Functions public static LeavePlan GetID(int id) { LeavePlan leavePlan = null; leavePlan = LeavePlan.Service.GetID(id); return leavePlan; } public static bool IsEmpIDExist(int empID, int leaveYear) { return LeavePlan.Service.IsEmpIDExist(empID, leaveYear); } public static bool IsEmpApproved(int empID, int leaveYear, DateTime FormDate, DateTime ToDate, bool isApprove) { return LeavePlan.Service.IsEmpApproved(empID, leaveYear, FormDate, ToDate, isApprove); } public static void Save(ObjectsTemplate leavePlans) { try { LeavePlan.Service.Save(leavePlans); } catch (ServiceException e) { throw new ServiceException(e.Message, e); } } public static void UpDateLeavePlan(LeavePlan oLeaveItem, int PlanID) { try { LeavePlan.Service.UpDateLeavePlan(oLeaveItem, PlanID); } catch (ServiceException e) { throw new ServiceException(e.Message, e); } } public static void UpdateApprove(int empID, int leaveYear, DateTime FormDate, DateTime ToDate, bool isApproved) { try { LeavePlan.Service.UpdateApprove(empID, leaveYear, FormDate, ToDate, isApproved); } catch (ServiceException e) { throw new ServiceException(e.Message, e); } } public static void UpdateLeavePlanSubmit(ObjectsTemplate oLeaveItems) { try { LeavePlan.Service.UpdateLeavePlanSubmit(oLeaveItems); } catch (ServiceException e) { throw new ServiceException(e.Message, e); } } public static void Delete(ID id) { LeavePlan.Service.Delete(id); } #endregion #region Collection Functions public static ObjectsTemplate Get(int empID) { ObjectsTemplate LeavePlans = null; LeavePlans = LeavePlan.Service.Get(empID); return LeavePlans; } public static ObjectsTemplate GetAllData() { ObjectsTemplate LeavePlans = null; LeavePlans = LeavePlan.Service.GetAllData(); return LeavePlans; } public static ObjectsTemplate GetPlanData(int empID, int leaveYear) { ObjectsTemplate LeavePlans = null; LeavePlans = LeavePlan.Service.GetPlanData(empID, leaveYear); return LeavePlans; } public static ObjectsTemplate GetByMonthRange(int empID, DateTime dFromDate, DateTime dToDate) { ObjectsTemplate LeavePlans = null; LeavePlans = LeavePlan.Service.GetByMonthRange(empID, dFromDate, dToDate); return LeavePlans; } #endregion #region Service Factory internal static ILeavePlanService Service { get { return Services.Factory.CreateService(typeof(ILeavePlanService)); } } #endregion } #endregion #region ILeave Service public interface ILeavePlanService { ObjectsTemplate Get(int empID); ObjectsTemplate GetPlanData(int empID, int leaveYear); ObjectsTemplate GetAllData(); LeavePlan GetID(int id); ObjectsTemplate GetByMonthRange(int nEmpID, DateTime dFromDate, DateTime dToDate); bool IsEmpIDExist(int empID, int leaveYear); bool IsEmpApproved(int empID, int leaveYear, DateTime FormDate, DateTime ToDate, bool isApprove); void Save(ObjectsTemplate leavePlans); void Delete(ID id); void UpdateApprove(int empID, int leaveYear, DateTime FormDate, DateTime ToDate, bool isApproved); void UpDateLeavePlan(LeavePlan oLeaveItem, int PlanID); void UpdateLeavePlanSubmit(ObjectsTemplate oLPlans); } #endregion }