EchoTex_Payroll/HRM.DA/Service/Fund/GF/ESBSlabService.cs

195 lines
5.4 KiB
C#
Raw Normal View History

2024-10-14 10:01:49 +06:00
using System;
using System.Data;
using Ease.Core.Model;
using Ease.Core.DataAccess;
using Ease.Core;
using System.Collections.Generic;
using Ease.Core.Utility;
using HRM.BO;
using HRM.DA;
namespace HRM.DA.Fund
{
[Serializable]
public class ESBSlabService : ServiceTemplate //, IESBSlabService
{
#region Private Function And Declaration
public ESBSlabService()
{
}
private void MapObject(ESBSlab slab, DataReader dr)
{
base.SetObjectID(slab, dr.GetInt32("SlabID").Value);
slab.CalculateNo = dr.GetDouble("CalCulNo").Value;
slab.DaysToConsider = dr.GetDouble("DaysToConsider").Value;
slab.ESBID = dr.GetInt32("ESBID").Value;
//slab.ServiceDay = dr.GetInt32("ServiceDay").Value;
//slab.ServiceMonth = dr.GetInt32("ServiceMonth").Value;
slab.ServiceYear = dr.GetInt32("ServiceYear").Value;
slab.UptoServiceYear = dr.GetInt32("UptoServiceYear").Value;
slab.CreatedBy = dr.GetInt32("CreatedBy").Value;
slab.CreatedDate = dr.GetDateTime("CreatedDate").Value;
slab.ModifiedBy = dr.GetInt32("ModifiedBy");
slab.ModifiedDate = dr.GetDateTime("ModifiedDate");
// slab.ProjectID = dr.GetInt32("ProjectID");
base.SetObjectState(slab, ObjectState.Saved);
}
protected override T CreateObject<T>(DataReader dr)
{
ESBSlab item = new ESBSlab();
MapObject(item, dr);
return item as T;
}
private ESBSlab CreateObject(DataReader dr)
{
ESBSlab oESBSlab = new ESBSlab();
MapObject(oESBSlab, dr);
return oESBSlab;
}
private List<ESBSlab> CreateObjects(IDataReader dr)
{
List<ESBSlab> oESBSlabs = new List<ESBSlab>();
DataReader oreader = new DataReader(dr);
while (dr.Read())
{
ESBSlab Item = CreateObject(oreader);
oESBSlabs.Add(Item);
}
return oESBSlabs;
}
#endregion
#region Service Implementation
public ESBSlab Get(int id)
{
ESBSlab oESBSlab = new ESBSlab();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
IDataReader oreader = ESBSlabDA.Get(tc, id);
DataReader dr = new DataReader(oreader);
if (oreader.Read())
{
oESBSlab = CreateObject<ESBSlab>(dr);
}
oreader.Close();
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException("Failed to Get ESBSlab", e);
#endregion
}
return oESBSlab;
}
public List<ESBSlab> Get()
{
List<ESBSlab> eSBSlabs = new List<ESBSlab>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
IDataReader dr = ESBSlabDA.Get(tc);
eSBSlabs = CreateObjects(dr);
dr.Close();
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException("Failed to Get ESBSlab ", e);
#endregion
}
return eSBSlabs;
}
#region Insert
public void Save(ESBSlab eSBSlab)
{
ESBSlab oESBSlab = new ESBSlab();
oESBSlab = eSBSlab;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
if (oESBSlab.IsNew)
{
int id = tc.GenerateID("ESBSlab", "SlabID");
base.SetObjectID(oESBSlab, id);
ESBSlabDA.Insert(tc, oESBSlab);
}
else
{
ESBSlabDA.Update(tc, oESBSlab);
}
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
}
#endregion
public void Delete(int id)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
ESBSlabDA.Delete(tc, id);
tc.End();
// CacheInfo.ClearCache(typeof(BankService).FullName);
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException("Failed to Delete ESBSlab", e);
#endregion
}
}
#endregion
}
}