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; using System.Data; using Ease.CoreV35.Utility; namespace Payroll.BO { #region CarFuelProcess [Serializable] public class CarFuelProcess : BasicBaseObject { #region Cache Store private static Cache _cache = new Cache(typeof(CarFuelProcess)); #endregion CarFuelProcessDetailItem oProcessDetailItem = null; #region Constructor public CarFuelProcess() { _CarFuelMonth = DateTime.Today; _processDate = DateTime.Today; _CarFuelProcessDetails = null; } #endregion #region Properties #region CarFuelMonth : DateTime private DateTime _CarFuelMonth; public DateTime CarFuelMonth { get { return _CarFuelMonth; } set { base.OnPropertyChange("CarFuelmonth", _CarFuelMonth, value); _CarFuelMonth = value; } } #endregion #region ProcessDate : DateTime private DateTime _processDate; public DateTime ProcessDate { get { return _processDate; } set { base.OnPropertyChange("processdate", _processDate, value); _processDate = value; } } #endregion #region IsApproved : bool private bool _isApproved; public bool IsApproved { get { return _isApproved; } set { _isApproved = value; } } #endregion #region CarFuelProcessDetail : ObjectsTemplate private ObjectsTemplate _CarFuelProcessDetails; public ObjectsTemplate CarFuelProcessDetails { get { if (_CarFuelProcessDetails == null && !this.ID.IsUnassigned && this.ID.Integer > 0) { _CarFuelProcessDetails = GetProcessDetails(this.ID); } return this._CarFuelProcessDetails; } set { _CarFuelProcessDetails = value; } } #endregion #region Service Factory ICarFuelProcessService : ICarFuelProcessService internal static ICarFuelProcessService Service { get { return Services.Factory.CreateService(typeof(ICarFuelProcessService)); } } #endregion #endregion #region Functions public static CarFuelProcess Get(ID nCarFuelProcessID) { CarFuelProcess oCarFuelProcess = null; #region Cache Header oCarFuelProcess = (CarFuelProcess)_cache["Get", nCarFuelProcessID]; if (oCarFuelProcess != null) return oCarFuelProcess; #endregion oCarFuelProcess = CarFuelProcess.Service.Get(nCarFuelProcessID,Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); #region Cache Footer _cache.Add(oCarFuelProcess, "Get", nCarFuelProcessID); #endregion return oCarFuelProcess; } public static ObjectsTemplate Get() { #region Cache Header ObjectsTemplate oCarFuelProcesss = _cache["Get"] as ObjectsTemplate; if (oCarFuelProcesss != null) return oCarFuelProcesss; #endregion try { oCarFuelProcesss = Service.Get(Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(oCarFuelProcesss, "Get"); #endregion return oCarFuelProcesss; } public static ObjectsTemplate Get(DateTime dCarFuelMonth) { #region Cache Header ObjectsTemplate oProcesss = _cache["Get", dCarFuelMonth] as ObjectsTemplate; if (oProcesss != null) return oProcesss; #endregion try { oProcesss = Service.Get(dCarFuelMonth,Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(oProcesss, "Get", dCarFuelMonth); #endregion return oProcesss; } public static ObjectsTemplate GetProcessDetails(ID CarFuelProcessID) { #region Cache Header ObjectsTemplate oProcessDetails = _cache["GetProcessDetails", CarFuelProcessID] as ObjectsTemplate; if (oProcessDetails != null) return oProcessDetails; #endregion try { oProcessDetails = Service.GetProcessDetails(CarFuelProcessID,Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(oProcessDetails, "GetProcessDetails", CarFuelProcessID); #endregion return oProcessDetails; } public static ObjectsTemplate GetProcessDetailWithItems(ID CarFuelProcessID) { #region Cache Header ObjectsTemplate oProcessDetails = _cache["GetProcessDetailWithItems", CarFuelProcessID] as ObjectsTemplate; if (oProcessDetails != null) return oProcessDetails; #endregion try { oProcessDetails = Service.GetProcessDetailWithItems(CarFuelProcessID,Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(oProcessDetails, "GetProcessDetailWithItems", CarFuelProcessID); #endregion return oProcessDetails; } public static ObjectsTemplate GetProcessDetailItems(ID nProcessDetailID) { #region Cache Header ObjectsTemplate oProcessDetailItems = _cache["GetProcessDetailItems", nProcessDetailID] as ObjectsTemplate; if (oProcessDetailItems != null) return oProcessDetailItems; #endregion try { oProcessDetailItems = Service.GetProcessDetailItems(nProcessDetailID,Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(oProcessDetailItems, "GetProcessDetailItems", nProcessDetailID); #endregion return oProcessDetailItems; } public static ObjectsTemplate GetProcessDetails(DateTime processMonth) { ObjectsTemplate oProcessDetailItems = null; try { oProcessDetailItems = Service.GetProcessDetails(processMonth,Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); } catch (ServiceException e) { throw new Exception(e.Message, e); } return oProcessDetailItems; } public static CarFuelProcessDetail GetDetail(ID employeeID, DateTime processMonth) { CarFuelProcessDetail oProcessDetail = null; try { oProcessDetail = Service.GetDetail(employeeID, processMonth,Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); } catch (ServiceException e) { throw new Exception(e.Message, e); } return oProcessDetail; } public static double GetProvisionAmountByEmpID(ID nEmpID) { return CarFuelProcess.Service.GetProvisionAmountByEmpID(nEmpID); } public static double GetPrevMonthAmount(ID nEmpID, ID nCarFuelItemID, DateTime dFromCarFuelMonth, DateTime dToCarFuelMonth) { return CarFuelProcess.Service.GetPrevMonthAmount(nEmpID, nCarFuelItemID, dFromCarFuelMonth, dToCarFuelMonth); } public static DataSet GetCarFuelRegister(string sCarFuelItemID, DateTime dCarFuelMonth, string sEmpID) { DataSet ds = null; try { ds = Service.GetCarFuelRegister(sCarFuelItemID, dCarFuelMonth, sEmpID); } catch (Exception e) { throw new Exception(e.Message, e); } return ds; } public static DataSet GetDetailOtherPayrollItems(string sCarFuelItemID, DateTime dCarFuelMonth, string sEmpID) { DataSet ds = null; try { ds = Service.GetDetailOtherPayrollItems(sCarFuelItemID, dCarFuelMonth, sEmpID); } catch (Exception e) { throw new Exception(e.Message, e); } return ds; } public static DataSet GetCarFuelTotalValueRegister(DateTime dFromCarFuelMonth, DateTime dToCarFuelMonth, int nCarFuelItemID, string sEmpID) { DataSet ds = null; try { ds = Service.GetCarFuelTotalValueRegister(dFromCarFuelMonth, dToCarFuelMonth, nCarFuelItemID, sEmpID); } catch (Exception e) { throw new Exception(e.Message, e); } return ds; } public static DataSet GetDataSetOfCarFuelRegister(string sSearch) { DataSet dsCarFuelRegister = null; dsCarFuelRegister = CarFuelProcess.Service.GetDataSetOfCarFuelRegister(sSearch); return dsCarFuelRegister; } public ID Save() { this.SetAuditTrailProperties(); return CarFuelProcess.Service.Save(this); } public static ID UpdateOnlyProcess(CarFuelProcess oProcess) { oProcess.SetAuditTrailProperties(); return CarFuelProcess.Service.UpdateOnlyProcess(oProcess); } public static void Save(CarFuelProcess oProcess, ObjectsTemplate oPDetails) { oProcess.SetAuditTrailProperties(); CarFuelProcess.Service.Save(oProcess, oPDetails,Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); } public void Delete() { CarFuelProcess.Service.Delete(this.ID,Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); } public static void Undo(DateTime CarFuelMonth) { CarFuelProcess.Service.Undo(CarFuelMonth,Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); } public void UpdateCarFuelDetail(ObjectsTemplate oItems) { CarFuelProcess.Service.UpdateDetail(oItems); } #endregion public static ObjectsTemplate GetCarFuelProcessItems(DateTime dateTime) { #region Cache Header ObjectsTemplate oProcessDetailItems = _cache["GetCarFuelProcessItems", dateTime] as ObjectsTemplate; if (oProcessDetailItems != null) return oProcessDetailItems; #endregion try { oProcessDetailItems = Service.GetCarFuelProcessItems(dateTime,Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(oProcessDetailItems, "GetCarFuelProcessItems", dateTime); #endregion return oProcessDetailItems; } public static ObjectsTemplate GetLastMonthItems(int nEmployeeID) { #region Cache Header ObjectsTemplate oCarFuelProcessDetailItems = _cache["GetLastMonthItems", nEmployeeID] as ObjectsTemplate; if (oCarFuelProcessDetailItems != null) return oCarFuelProcessDetailItems; #endregion try { oCarFuelProcessDetailItems = Service.GetLastMonthItems(nEmployeeID,Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); } catch (ServiceException e) { throw new Exception(e.Message, e); } #region Cache Footer _cache.Add(oCarFuelProcessDetailItems, "GetLastMonthItems", nEmployeeID); #endregion return oCarFuelProcessDetailItems; } public static DataSet GetEmpCarFuelPaySlip(DateTime _SalaryMonth, string sEmpID) { DataSet ds = null; try { ds = Service.GetEmpCarFuelPaySlip(_SalaryMonth, sEmpID); } catch (Exception e) { throw new Exception(e.Message, e); } return ds; } public static double GetAmountOnRange(Employee employee, DateTime fromDate, DateTime toDate, int CarFuelID, int parameterid) { double fractionMonthAmount = 0; double amount = 0; if (Ease.CoreV35.Utility.Global.DateFunctions.DateDiff("m", GlobalFunctions.FirstDateOfMonth(fromDate), GlobalFunctions.LastDateOfMonth(toDate)) > 2) { amount = CarFuelProcess.Service.GetPrevMonthAmount(employee.ID, ID.FromInteger(CarFuelID), GlobalFunctions.FirstDateOfMonth(fromDate.AddMonths(1)), GlobalFunctions.LastDateOfMonth(toDate.AddMonths(-1))); } bool dataNotFound = false; if (fromDate != Global.DateFunctions.FirstDateOfMonth(fromDate)) { EmployeeGradeSalary oge = EmployeeGradeSalary.Get(employee.ID, fromDate, EnumArrearType.NotPresent); if (oge != null) { CarFuelParameter op = CarFuelParameter.Service.Get(ID.FromInteger(parameterid),Payroll.BO.SystemInformation.CurrentSysInfo.PayrollTypeID.Integer); if (op != null) { oge.FractionofFromTo = GlobalFunctions.GetFraction(oge.EffectDate, (DateTime)oge.TillDate); fractionMonthAmount = op.GetGradeDefinedAmount(employee, oge.BasicSalary, oge.GrossSalary, oge.FractionofFromTo); fractionMonthAmount = fractionMonthAmount * GlobalFunctions.GetFractinalOfMonth(fromDate); dataNotFound = true; } } } if (dataNotFound == false) { fractionMonthAmount = CarFuelProcess.Service.GetPrevMonthAmount(employee.ID, ID.FromInteger(CarFuelID), GlobalFunctions.FirstDateOfMonth(fromDate), GlobalFunctions.LastDateOfMonth(fromDate)); } if (Global.DateFunctions.FirstDateOfMonth(fromDate) != GlobalFunctions.FirstDateOfMonth(toDate)) // if cross two month { fractionMonthAmount = fractionMonthAmount + CarFuelProcess.Service.GetPrevMonthAmount(employee.ID, ID.FromInteger(CarFuelID), GlobalFunctions.FirstDateOfMonth(toDate), GlobalFunctions.LastDateOfMonth(toDate)) * GlobalFunctions.GetFractinalOfTillDate(toDate); } return amount = amount + fractionMonthAmount; } public static DataSet GetIDLCCarFuelRegister(DateTime dCarFuelMonth, string sEmpID) { DataSet ds = null; try { ds = Service.GetIDLCCarFuelRegister( dCarFuelMonth, sEmpID); } catch (Exception e) { throw new Exception(e.Message, e); } return ds; } public static DataSet GetItemWiseCarFuel(DateTime dFromCarFuelMonth, int CarFuelItemID, string sEmpID) { DataSet ds = null; try { ds = Service.GetItemWiseCarFuel(dFromCarFuelMonth,CarFuelItemID,sEmpID); } catch (Exception e) { throw new Exception(e.Message, e); } return ds; } public static DataSet GetManagersCarFuel(DateTime dtFromCarFuel, DateTime dtToCarFuel, int CarFuelItemID, string sEmpID) { DataSet ds = null; try { ds = Service.GetManagersCarFuel(dtFromCarFuel,dtToCarFuel, CarFuelItemID, sEmpID); } catch (Exception e) { throw new Exception(e.Message, e); } return ds; } public static DataSet GetCarFuelRegister(string sCarFuelItemID, DateTime dCarFuelMonth, DateTime dCarFuelMonth2, string sEmpID) { DataSet ds = null; try { ds = Service.GetCarFuelRegister(sCarFuelItemID, dCarFuelMonth, dCarFuelMonth2, sEmpID); } catch (Exception e) { throw new Exception(e.Message, e); } return ds; } public static CarFuelProcess Get(DateTime fromdate, ID empiD) { CarFuelProcess oCarFuelProcess = null; #region Cache Header oCarFuelProcess = (CarFuelProcess)_cache["Get", fromdate, empiD]; if (oCarFuelProcess != null) return oCarFuelProcess; #endregion oCarFuelProcess = CarFuelProcess.Service.Get(fromdate, empiD); #region Cache Footer _cache.Add(oCarFuelProcess, "Get", fromdate, empiD); #endregion return oCarFuelProcess; } public static DateTime? GetLastPaidCarFuelMonth(int empID) { return CarFuelProcess.Service.GetLastPaidCarFuelMonth(empID); } } #endregion #region ICarFuelProcess Service public interface ICarFuelProcessService { CarFuelProcess Get(ID id, int payrollTypeID); ObjectsTemplate Get(int payrollTypeID); ObjectsTemplate Get(DateTime dCarFuelMonth, int payrollTypeID); ObjectsTemplate GetProcessDetailWithItems(ID CarFuelProcessID, int payrollTypeID); ObjectsTemplate GetProcessDetails(ID CarFuelProcessID, int payrollTypeID); ObjectsTemplate GetProcessDetails(DateTime processMonth, int payrollTypeID); ObjectsTemplate GetProcessDetailItems(ID nProcessDetailID, int payrollTypeID); CarFuelProcessDetail GetDetail(ID employeeID, DateTime CarFuelMonth, int payrollTypeID); double GetProvisionAmountByEmpID(ID nEmpID); double GetPrevMonthAmount(ID nEmpID, ID nCarFuelItemID, DateTime dFromCarFuelMonth, DateTime dToCarFuelMonth); DataSet GetDataSetOfCarFuelRegister(string sSearch); DataSet GetCarFuelRegister(string sCarFuelItemID, DateTime dCarFuelMonth, string sEmpID); DataSet GetCarFuelTotalValueRegister(DateTime dFromCarFuelMonth, DateTime dToCarFuelMonth, int nCarFuelItemID, string sEmpID); ID Save(CarFuelProcess item); ID UpdateOnlyProcess(CarFuelProcess oProcess); void Save(CarFuelProcess oProcess, ObjectsTemplate oPDetails, int payrollTypeID); void Delete(ID id, int payrollTypeID); void Undo(DateTime CarFuelMonth, int payrollTypeID); void UpdateDetail(ObjectsTemplate oCarFuelDetails); DataSet GetDetailOtherPayrollItems(string sCarFuelItemID, DateTime dCarFuelMonth, string sEmpID); ObjectsTemplate GetCarFuelProcessItems(DateTime dateTime, int payrollTypeID); ObjectsTemplate GetLastMonthItems(int nEmployeeID, int payrollTypeID); DataSet GetEmpCarFuelPaySlip(DateTime _SalaryMonth, string sEmpID); DataSet GetIDLCCarFuelRegister(DateTime dCarFuelMonth, string sEmpID); DataSet GetItemWiseCarFuel(DateTime dFromCarFuelMonth, int CarFuelItemID, string sEmpID); DataSet GetManagersCarFuel(DateTime dtFromCarFuel, DateTime dtToCarFuel, int CarFuelItemID, string sEmpID); CarFuelProcess Get(DateTime fromdate, ID empiD); DateTime? GetLastPaidCarFuelMonth(int empID); DataSet GetCarFuelRegister(string sCarFuelItemID, DateTime dCarFuelMonth, DateTime dCarFuelMonth2, string sEmpID); } #endregion }