159 lines
4.7 KiB
C#
159 lines
4.7 KiB
C#
using System;
|
|
using Ease.Core.Model;
|
|
using Ease.Core.DataAccess;
|
|
using HRM.BO;
|
|
using Ease.Core.Utility;
|
|
using System.Collections.Generic;
|
|
|
|
namespace HRM.DA
|
|
{
|
|
public class AdvanceIncomeTaxService : ServiceTemplate, IAdvanceIncomeTaxService
|
|
{
|
|
#region MapObjects
|
|
|
|
private void MapObject(AdvanceIncomeTax oAdvanceIncomeTax, DataReader oReader)
|
|
{
|
|
base.SetObjectID(oAdvanceIncomeTax, oReader.GetInt32("AdvanceIncomeTaxID").Value);
|
|
oAdvanceIncomeTax.EmployeeID = oReader.GetInt32("EmployeeID", 0);
|
|
oAdvanceIncomeTax.TaxParameterID = oReader.GetInt32("TaxParameterID", 0);
|
|
oAdvanceIncomeTax.Amount = oReader.GetDouble("Amount").Value;
|
|
oAdvanceIncomeTax.Remarks = oReader.GetString("Remarks");
|
|
oAdvanceIncomeTax.CreatedBy = oReader.GetInt32("CreatedBy", 0);
|
|
oAdvanceIncomeTax.CreatedDate = oReader.GetDateTime("CreationDate").Value;
|
|
oAdvanceIncomeTax.ModifiedBy = oReader.GetInt32("ModifiedBy", 0);
|
|
oAdvanceIncomeTax.ModifiedDate = oReader.GetDateTime("ModifiedDate");
|
|
|
|
this.SetObjectState(oAdvanceIncomeTax, Ease.Core.ObjectState.Saved);
|
|
}
|
|
|
|
protected override T CreateObject<T>(DataReader oReader)
|
|
{
|
|
AdvanceIncomeTax oAdvanceIncomeTax = new AdvanceIncomeTax();
|
|
MapObject(oAdvanceIncomeTax, oReader);
|
|
return oAdvanceIncomeTax as T;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Service Methods
|
|
|
|
public AdvanceIncomeTax Get(int id)
|
|
{
|
|
AdvanceIncomeTax oAdvanceIncomeTax = null;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(AdvanceIncomeTaxDA.Get(tc, id));
|
|
if (oreader.Read())
|
|
{
|
|
oAdvanceIncomeTax = this.CreateObject<AdvanceIncomeTax>(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 oAdvanceIncomeTax;
|
|
}
|
|
|
|
public List<AdvanceIncomeTax> Get()
|
|
{
|
|
List<AdvanceIncomeTax> oAdvanceIncomeTaxs = new List<AdvanceIncomeTax>();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(AdvanceIncomeTaxDA.Get(tc));
|
|
oAdvanceIncomeTaxs = this.CreateObjects<AdvanceIncomeTax>(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 oAdvanceIncomeTaxs;
|
|
}
|
|
|
|
public int Save(AdvanceIncomeTax oAdvanceIncomeTax)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
if (oAdvanceIncomeTax.IsNew)
|
|
{
|
|
int id = tc.GenerateID("AdvanceIncomeTax", "AdvanceIncomeTaxID");
|
|
base.SetObjectID(oAdvanceIncomeTax, id);
|
|
|
|
AdvanceIncomeTaxDA.Insert(tc, oAdvanceIncomeTax);
|
|
}
|
|
else
|
|
{
|
|
AdvanceIncomeTaxDA.Update(tc, oAdvanceIncomeTax);
|
|
}
|
|
|
|
tc.End();
|
|
return oAdvanceIncomeTax.ID;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
public void Delete(int id)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
AdvanceIncomeTaxDA.Delete(tc, id);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
} |