805 lines
27 KiB
C#
805 lines
27 KiB
C#
using System;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using Ease.CoreV35;
|
|
using Ease.CoreV35.Model;
|
|
using Ease.CoreV35.DataAccess;
|
|
using System.Collections.Generic;
|
|
using Payroll.BO;
|
|
using Ease.CoreV35.Caching;
|
|
|
|
namespace Payroll.Service
|
|
{
|
|
#region IncomeTax Service
|
|
[Serializable]
|
|
public class IncomeTaxService : ServiceTemplate, IIncomeTaxService
|
|
{
|
|
#region Private functions and declaration
|
|
Cache _cache = new Cache(typeof(IncomeTax));
|
|
private EnumIncomeTaxDataFrom _dataFrom;
|
|
private int _sequentialId;
|
|
#endregion
|
|
public IncomeTaxService() { _sequentialId = 0; }
|
|
|
|
private void MapObject(IncomeTax oIncomeTax, DataReader oReader)
|
|
{
|
|
_sequentialId = _sequentialId + 1;
|
|
base.SetObjectID(oIncomeTax, ID.FromInteger(_sequentialId));
|
|
oIncomeTax.EmployeeID =ID.FromInteger( oReader.GetInt32("employeeID").GetValueOrDefault());
|
|
oIncomeTax.ItemID = oReader.GetInt32("Itemid").GetValueOrDefault();//Itemid
|
|
oIncomeTax.ItemGroup = (EnumIncomeTaxItemGroup)oReader.GetInt32("itemCode").Value;
|
|
oIncomeTax.DataTo = _dataFrom;
|
|
if (_dataFrom != EnumIncomeTaxDataFrom.ProcessedData)
|
|
{
|
|
oIncomeTax.PreviousAmount = oReader.GetDouble("previousAmount").Value;
|
|
oIncomeTax.ThisMonthAmount = oReader.GetDouble("thisMonthAmount").Value;
|
|
oIncomeTax.ProjectedAmount = oReader.GetDouble("projectedAmount").Value;
|
|
oIncomeTax.ModifiedBy = ID.FromInteger(oReader.GetInt32("ModifiedBy").GetValueOrDefault());
|
|
oIncomeTax.ModifiedDate = oReader.GetDateTime("ModifiedDate").GetValueOrDefault();
|
|
}
|
|
else
|
|
{
|
|
oIncomeTax.TotalAmount = oReader.GetDouble("totalAmount").Value;
|
|
oIncomeTax.TaxParameterID = ID.FromInteger(oReader.GetInt32("taxParamID").GetValueOrDefault());
|
|
}
|
|
oIncomeTax.Position = oReader.GetInt32("position").Value;
|
|
oIncomeTax.Description = oReader.GetString("description");
|
|
oIncomeTax.Side = (EnumIncomeTaxSide)oReader.GetInt32("side").Value;
|
|
this.SetObjectState(oIncomeTax, Ease.CoreV35.ObjectState.Saved);
|
|
|
|
}
|
|
protected override T CreateObject<T>(DataReader oReader)
|
|
{
|
|
IncomeTax oIncomeTax = new IncomeTax();
|
|
MapObject(oIncomeTax, oReader);
|
|
return oIncomeTax as T;
|
|
}
|
|
protected IncomeTax CreateObject(DataReader oReader)
|
|
{
|
|
IncomeTax oIncomeTax = new IncomeTax();
|
|
MapObject(oIncomeTax, oReader);
|
|
return oIncomeTax;
|
|
}
|
|
#region Service implementation
|
|
|
|
public ObjectsTemplate<IncomeTax> Get(ID employeeid, EnumIncomeTaxDataFrom dataFrom)
|
|
{
|
|
ObjectsTemplate<IncomeTax> incomeTaxs = null;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
_dataFrom = dataFrom;
|
|
DataReader dr = new DataReader(IncomeTaxDA.GetFromRunningYear(tc, employeeid.Integer, dataFrom));
|
|
incomeTaxs = this.CreateObjects<IncomeTax>(dr);
|
|
dr.Close();
|
|
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
return incomeTaxs;
|
|
}
|
|
|
|
public IncomeTax Get(EnumIncomeTaxDataFrom dataFrom, ID nEmpID, EnumIncomeTaxItemGroup groupCode, int itemID)
|
|
{
|
|
IncomeTax oIncomeTax = null;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(IncomeTaxDA.Get(tc, dataFrom, nEmpID, groupCode, itemID));
|
|
if (oreader.Read())
|
|
{
|
|
oIncomeTax = this.CreateObject<IncomeTax>(oreader);
|
|
}
|
|
oreader.Close();
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
return oIncomeTax;
|
|
}
|
|
|
|
public DataSet GetByEmpID(EnumIncomeTaxDataFrom dataFrom,ID employeeid)
|
|
{
|
|
DataSet incomeTaxs = null;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
incomeTaxs = IncomeTaxDA.GetByEmpID(tc, dataFrom,employeeid);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
return incomeTaxs;
|
|
}
|
|
|
|
public DataSet GetEmpIDforOthTax(EnumIncomeTaxDataFrom dataFrom,ID employeeid)
|
|
{
|
|
DataSet incomeTaxs = null;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
incomeTaxs = IncomeTaxDA.GetEmpIDforOthTax(tc, dataFrom,employeeid);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
return incomeTaxs;
|
|
}
|
|
|
|
public ObjectsTemplate<IncomeTax> Get(EnumIncomeTaxDataFrom dataFrom, int payrollTypeID)
|
|
{
|
|
ObjectsTemplate<IncomeTax> incomeTaxs = null;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
_dataFrom = dataFrom;
|
|
DataReader dr = new DataReader(IncomeTaxDA.Get(tc, dataFrom, payrollTypeID));
|
|
incomeTaxs = this.CreateObjects<IncomeTax>(dr);
|
|
dr.Close();
|
|
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
return incomeTaxs;
|
|
}
|
|
|
|
public ObjectsTemplate<IncomeTax> Get(EnumIncomeTaxDataFrom dataFrom, ID nEmpID, ID nTaxParamID)
|
|
{
|
|
ObjectsTemplate<IncomeTax> incomeTaxs = null;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
_dataFrom = dataFrom;
|
|
DataReader dr = new DataReader(IncomeTaxDA.Get(tc, dataFrom, nEmpID, nTaxParamID));
|
|
incomeTaxs = this.CreateObjects<IncomeTax>(dr);
|
|
dr.Close();
|
|
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
return incomeTaxs;
|
|
}
|
|
|
|
//Income Tax From Old Table
|
|
public ObjectsTemplate<IncomeTax> GetOldIncomeTax(EnumIncomeTaxDataFrom dataFrom, ID nEmpID, ID nTaxParamID)
|
|
{
|
|
ObjectsTemplate<IncomeTax> incomeTaxs = null;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
_dataFrom = dataFrom;
|
|
DataReader dr = new DataReader(IncomeTaxDA.GetOldIncomeTax(tc, dataFrom, nEmpID, nTaxParamID));
|
|
incomeTaxs = this.CreateObjects<IncomeTax>(dr);
|
|
dr.Close();
|
|
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
return incomeTaxs;
|
|
}
|
|
|
|
public ObjectsTemplate<IncomeTax> GetPrvYear(ID Taxparameterid, int payrollTypeID)
|
|
{
|
|
ObjectsTemplate<IncomeTax> incomeTaxs = null;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
_dataFrom = EnumIncomeTaxDataFrom.ProcessedData;
|
|
DataReader dr = new DataReader(IncomeTaxDA.GetPrvYear(tc, Taxparameterid, payrollTypeID));
|
|
incomeTaxs = this.CreateObjects<IncomeTax>(dr);
|
|
dr.Close();
|
|
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
return incomeTaxs;
|
|
}
|
|
public ObjectsTemplate<IncomeTax> GetPrvYear(ID Taxparameterid, int payrollTypeID,int empID)
|
|
{
|
|
ObjectsTemplate<IncomeTax> incomeTaxs = null;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
_dataFrom = EnumIncomeTaxDataFrom.ProcessedData;
|
|
DataReader dr = new DataReader(IncomeTaxDA.GetPrvYear(tc, Taxparameterid, payrollTypeID,empID));
|
|
incomeTaxs = this.CreateObjects<IncomeTax>(dr);
|
|
dr.Close();
|
|
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
return incomeTaxs;
|
|
}
|
|
|
|
public ObjectsTemplate<IncomeTax> GetPrvYear(ID Taxparameterid,
|
|
EnumIncomeTaxItemGroup groupCode, int ItemId)
|
|
{
|
|
ObjectsTemplate<IncomeTax> incomeTaxs = null;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
_dataFrom = EnumIncomeTaxDataFrom.ProcessedData;
|
|
DataReader dr = new DataReader(IncomeTaxDA.GetPrvYear(tc, _dataFrom, Taxparameterid, groupCode, ItemId));
|
|
incomeTaxs = this.CreateObjects<IncomeTax>(dr);
|
|
dr.Close();
|
|
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
return incomeTaxs;
|
|
}
|
|
|
|
public void DoYearEndReProcess(ObjectsTemplate<IncomeTax> oIncometaxes, ID taxParameterID, int payrollTypeID)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
IncomeTaxDA.DeleteYearlyData(tc, taxParameterID, payrollTypeID);
|
|
foreach (IncomeTax oItem in oIncometaxes)
|
|
{
|
|
this.SetObjectState(oItem, ObjectState.New);
|
|
oItem.CreatedBy = User.CurrentUser.ID;
|
|
this.Save(tc, oItem, EnumIncomeTaxDataFrom.ProcessedData);
|
|
}
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
#endregion
|
|
}
|
|
}
|
|
public void DoYearEndReProcess2(ObjectsTemplate<IncomeTax> oIncometaxes, ID taxParameterID)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
IncomeTaxDA.DeleteYearlyData2(tc, taxParameterID, oIncometaxes[0].EmployeeID.Integer);
|
|
foreach (IncomeTax oItem in oIncometaxes)
|
|
{
|
|
this.SetObjectState(oItem, ObjectState.New);
|
|
oItem.CreatedBy = User.CurrentUser.ID;
|
|
this.Save(tc, oItem, EnumIncomeTaxDataFrom.ProcessedData);
|
|
}
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
public void DoTaxYearEnd(ObjectsTemplate<IncomeTax> oIncometaxes, ID PayrollTypeID)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
TaxParameter oparam = TaxParameter.Get(SystemInformation.CurrentSysInfo.TaxParamID);
|
|
tc = TransactionContext.Begin(true);
|
|
IncomeTaxDA.DeleteCurrYearData(tc, PayrollTypeID.Integer);
|
|
IncomeTaxDA.DeleteYearlyData(tc, SystemInformation.CurrentSysInfo.TaxParamID, PayrollTypeID.Integer);
|
|
foreach (IncomeTax oItem in oIncometaxes)
|
|
{
|
|
this.SetObjectState(oItem, ObjectState.New);
|
|
oItem.CreatedBy = User.CurrentUser.ID;
|
|
oItem.CreatedDate = DateTime.Today;
|
|
this.Save(tc, oItem, EnumIncomeTaxDataFrom.ProcessedData);
|
|
}
|
|
SystemInformationDA.DoTaxYearEnd(tc, oparam.FiscalyearDateTo, PayrollTypeID.Integer);
|
|
tc.End();
|
|
SystemInformation.CurrentSysInfo = SystemInformation.Get();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
public ID Save(IncomeTax oIncomeTax, EnumIncomeTaxDataFrom saveto)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
if (oIncomeTax.IsNew)
|
|
{
|
|
int id = tc.GenerateID(IncomeTaxDA.GetTableName(saveto), "IncomeTaxID");
|
|
base.SetObjectID(oIncomeTax, ID.FromInteger(id));
|
|
IncomeTaxDA.Insert(tc, oIncomeTax, saveto);
|
|
}
|
|
else
|
|
{
|
|
IncomeTaxDA.Update(tc, oIncomeTax, saveto);
|
|
}
|
|
tc.End();
|
|
return oIncomeTax.ID;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
public ID Save(TransactionContext tc, IncomeTax oIncomeTax, EnumIncomeTaxDataFrom saveto)
|
|
{
|
|
try
|
|
{
|
|
if (oIncomeTax.IsNew)
|
|
{
|
|
// int id = tc.GenerateID(IncomeTaxDA.GetTableName(saveto), "IncomeTaxID");
|
|
// base.SetObjectID(oIncomeTax, ID.FromInteger(id));
|
|
IncomeTaxDA.Insert(tc, oIncomeTax, saveto);
|
|
}
|
|
else
|
|
{
|
|
IncomeTaxDA.Update(tc, oIncomeTax, saveto);
|
|
}
|
|
return oIncomeTax.ID;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
public void UpdateOT(ObjectsTemplate<OTProcess> otProcess)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
foreach (var process in otProcess)
|
|
{
|
|
IncomeTaxDA.UpdateOT(tc, process);
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
public ID SaveForEdit(TransactionContext tc, IncomeTax oIncomeTax, EnumIncomeTaxDataFrom saveto)
|
|
{
|
|
try
|
|
{
|
|
if (oIncomeTax.IsNew)
|
|
{
|
|
// int id = tc.GenerateID(IncomeTaxDA.GetTableName(saveto), "IncomeTaxID");
|
|
// base.SetObjectID(oIncomeTax, ID.FromInteger(id));
|
|
IncomeTaxDA.InsertforEdit(tc, oIncomeTax, saveto);
|
|
}
|
|
else
|
|
{
|
|
IncomeTaxDA.Update(tc, oIncomeTax, saveto);
|
|
}
|
|
return oIncomeTax.ID;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
public void Save(ObjectsTemplate<IncomeTax> _IncomeTaxs, EnumIncomeTaxDataFrom saveto)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
if (saveto == EnumIncomeTaxDataFrom.ProcessTempData)
|
|
{
|
|
foreach (IncomeTax oIncomeTax in _IncomeTaxs)
|
|
{
|
|
if (oIncomeTax.IsNew)
|
|
{
|
|
IncomeTaxDA.Insert(tc, oIncomeTax, saveto);
|
|
}
|
|
else
|
|
{
|
|
IncomeTaxDA.Update(tc, oIncomeTax, saveto);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
ID nTaxParamid = _IncomeTaxs[0].TaxParameterID;
|
|
if (nTaxParamid == null && nTaxParamid.IsUnassigned == false) throw new ServiceException("Tax-Parameter ID is not found");
|
|
IncomeTaxDA.DeleteYearlyData(tc, _IncomeTaxs[0].TaxParameterID, EnumIncomeTaxDataFrom.ProcessedData, _IncomeTaxs[0].EmployeeID);
|
|
foreach (IncomeTax oIncomeTax in _IncomeTaxs)
|
|
{
|
|
oIncomeTax.TaxParameterID = nTaxParamid;
|
|
oIncomeTax.CreatedBy = User.CurrentUser.ID;
|
|
IncomeTaxDA.Insert(tc, oIncomeTax, EnumIncomeTaxDataFrom.ProcessedData);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
public void Save(TransactionContext tc, ObjectsTemplate<IncomeTax> _IncomeTaxs, EnumIncomeTaxDataFrom saveto)
|
|
{
|
|
try
|
|
{
|
|
if (saveto == EnumIncomeTaxDataFrom.ProcessTempData)
|
|
{
|
|
foreach (IncomeTax oIncomeTax in _IncomeTaxs)
|
|
{
|
|
if (oIncomeTax.IsNew)
|
|
{
|
|
IncomeTaxDA.Insert(tc, oIncomeTax, saveto);
|
|
}
|
|
else
|
|
{
|
|
IncomeTaxDA.Update(tc, oIncomeTax, saveto);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
IncomeTaxDA.DeleteYearlyData(tc, _IncomeTaxs[0].TaxParameterID, EnumIncomeTaxDataFrom.ProcessedData, _IncomeTaxs[0].EmployeeID);
|
|
foreach (IncomeTax oIncomeTax in _IncomeTaxs)
|
|
{
|
|
IncomeTaxDA.Insert(tc, oIncomeTax, EnumIncomeTaxDataFrom.ProcessedData);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
public void Delete(ID nEmpId, EnumIncomeTaxDataFrom deletefrom, EnumIncomeTaxItemGroup ItemGroup, int ItemID)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
IncomeTaxDA.Delete(tc, nEmpId, deletefrom, ItemGroup, ItemID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
public void DeleteYearlyData(ID TaxParamID, EnumIncomeTaxDataFrom deletefrom, ID nEmpID, EnumIncomeTaxItemGroup ItemGroup, int ItemID)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
IncomeTaxDA.DeleteYearlyData(tc, TaxParamID, deletefrom, nEmpID, ItemGroup, ItemID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
#endregion
|
|
}
|
|
}
|
|
public void DoTaxTempReProcess(ObjectsTemplate<IncomeTax> oIncometaxes, ID taxParameterID, EnumIncomeTaxDataFrom saveTo, int payrollTypeID)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
IncomeTaxDA.DeleteTaxTempData(tc, saveTo,payrollTypeID);
|
|
foreach (IncomeTax oItem in oIncometaxes)
|
|
{
|
|
this.SetObjectState(oItem, ObjectState.New);
|
|
oItem.CreatedBy = User.CurrentUser.ID;
|
|
this.Save(tc, oItem, saveTo);
|
|
}
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
#endregion
|
|
}
|
|
}
|
|
public ObjectsTemplate<IncomeTax> GetByYear(ID Taxparameterid, EnumIncomeTaxDataFrom dataFrom, int payrollTypeID)
|
|
{
|
|
ObjectsTemplate<IncomeTax> incomeTaxs = null;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
_dataFrom = dataFrom;
|
|
DataReader dr = new DataReader(IncomeTaxDA.GetByYear(tc, Taxparameterid, dataFrom, payrollTypeID));
|
|
incomeTaxs = this.CreateObjects<IncomeTax>(dr);
|
|
dr.Close();
|
|
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
return incomeTaxs;
|
|
}
|
|
#endregion
|
|
|
|
|
|
public DataSet GetTaxWithProjection(int empID)
|
|
{
|
|
DataSet allData = new DataSet();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
allData = IncomeTaxDA.GetTaxWithProjection(tc, empID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
#endregion
|
|
}
|
|
return allData;
|
|
}
|
|
public DataSet GetTaxAdj(EnumIncomeTaxItemGroup itemcode,int nItemID ,ID empID)
|
|
{
|
|
DataSet allData = new DataSet();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
allData = IncomeTaxDA.GetTaxAdj(tc, itemcode, nItemID , empID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
#endregion
|
|
}
|
|
return allData;
|
|
}
|
|
public DataSet GetTaxWithoutProjection(int empID)
|
|
{
|
|
DataSet allData = new DataSet();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
allData = IncomeTaxDA.GetTaxWithoutProjection(tc, empID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
#endregion
|
|
}
|
|
return allData;
|
|
}
|
|
public DataSet GetTaxCertificate(string empNo, int taxParamId)
|
|
{
|
|
DataSet allData = new DataSet();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
allData = IncomeTaxDA.GetTaxCertificate(tc, empNo, taxParamId);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
#endregion
|
|
}
|
|
return allData;
|
|
}
|
|
}
|
|
#endregion
|
|
}
|