CEL_Payroll/Payroll.BO/CarFuel/CarFuelProcess.cs

600 lines
22 KiB
C#
Raw Permalink Normal View History

2024-09-17 14:30:13 +06:00
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<DateTime>("CarFuelmonth", _CarFuelMonth, value);
_CarFuelMonth = value;
}
}
#endregion
#region ProcessDate : DateTime
private DateTime _processDate;
public DateTime ProcessDate
{
get
{
return _processDate;
}
set
{
base.OnPropertyChange<DateTime>("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<CarFuelProcessDetail>
private ObjectsTemplate<CarFuelProcessDetail> _CarFuelProcessDetails;
public ObjectsTemplate<CarFuelProcessDetail> 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<ICarFuelProcessService>(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<CarFuelProcess> Get()
{
#region Cache Header
ObjectsTemplate<CarFuelProcess> oCarFuelProcesss = _cache["Get"] as ObjectsTemplate<CarFuelProcess>;
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<CarFuelProcess> Get(DateTime dCarFuelMonth)
{
#region Cache Header
ObjectsTemplate<CarFuelProcess> oProcesss = _cache["Get", dCarFuelMonth] as ObjectsTemplate<CarFuelProcess>;
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<CarFuelProcessDetail> GetProcessDetails(ID CarFuelProcessID)
{
#region Cache Header
ObjectsTemplate<CarFuelProcessDetail> oProcessDetails = _cache["GetProcessDetails", CarFuelProcessID] as ObjectsTemplate<CarFuelProcessDetail>;
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<CarFuelProcessDetail> GetProcessDetailWithItems(ID CarFuelProcessID)
{
#region Cache Header
ObjectsTemplate<CarFuelProcessDetail> oProcessDetails = _cache["GetProcessDetailWithItems", CarFuelProcessID] as ObjectsTemplate<CarFuelProcessDetail>;
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<CarFuelProcessDetailItem> GetProcessDetailItems(ID nProcessDetailID)
{
#region Cache Header
ObjectsTemplate<CarFuelProcessDetailItem> oProcessDetailItems = _cache["GetProcessDetailItems", nProcessDetailID] as ObjectsTemplate<CarFuelProcessDetailItem>;
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<CarFuelProcessDetail> GetProcessDetails(DateTime processMonth)
{
ObjectsTemplate<CarFuelProcessDetail> 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<CarFuelProcessDetail> 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<CarFuelProcessDetailItem> oItems)
{
CarFuelProcess.Service.UpdateDetail(oItems);
}
#endregion
public static ObjectsTemplate<CarFuelProcessDetailItem> GetCarFuelProcessItems(DateTime dateTime)
{
#region Cache Header
ObjectsTemplate<CarFuelProcessDetailItem> oProcessDetailItems = _cache["GetCarFuelProcessItems", dateTime] as ObjectsTemplate<CarFuelProcessDetailItem>;
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<CarFuelProcessDetailItem> GetLastMonthItems(int nEmployeeID)
{
#region Cache Header
ObjectsTemplate<CarFuelProcessDetailItem> oCarFuelProcessDetailItems = _cache["GetLastMonthItems", nEmployeeID] as ObjectsTemplate<CarFuelProcessDetailItem>;
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<CarFuelProcess> Get(int payrollTypeID);
ObjectsTemplate<CarFuelProcess> Get(DateTime dCarFuelMonth, int payrollTypeID);
ObjectsTemplate<CarFuelProcessDetail> GetProcessDetailWithItems(ID CarFuelProcessID, int payrollTypeID);
ObjectsTemplate<CarFuelProcessDetail> GetProcessDetails(ID CarFuelProcessID, int payrollTypeID);
ObjectsTemplate<CarFuelProcessDetail> GetProcessDetails(DateTime processMonth, int payrollTypeID);
ObjectsTemplate<CarFuelProcessDetailItem> 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<CarFuelProcessDetail> oPDetails, int payrollTypeID);
void Delete(ID id, int payrollTypeID);
void Undo(DateTime CarFuelMonth, int payrollTypeID);
void UpdateDetail(ObjectsTemplate<CarFuelProcessDetailItem> oCarFuelDetails);
DataSet GetDetailOtherPayrollItems(string sCarFuelItemID, DateTime dCarFuelMonth, string sEmpID);
ObjectsTemplate<CarFuelProcessDetailItem> GetCarFuelProcessItems(DateTime dateTime, int payrollTypeID);
ObjectsTemplate<CarFuelProcessDetailItem> 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
}