240 lines
6.6 KiB
C#
240 lines
6.6 KiB
C#
|
using HRM.BO;
|
|||
|
using Ease.Core.DataAccess;
|
|||
|
using Ease.Core.Model;
|
|||
|
using Ease.Core.Utility;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
|
|||
|
namespace HRM.DA
|
|||
|
{
|
|||
|
#region Term Service
|
|||
|
|
|||
|
public class TermService : ServiceTemplate, ITermService
|
|||
|
{
|
|||
|
#region Private functions and declaration
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
public TermService()
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
private void MapObject(Term oTerm, DataReader oReader)
|
|||
|
{
|
|||
|
base.SetObjectID(oTerm, oReader.GetInt32("termID").Value);
|
|||
|
oTerm.Code = oReader.GetString("code");
|
|||
|
oTerm.Name = oReader.GetString("name");
|
|||
|
oTerm.NameInBangla = oReader.GetString("nameinbangla", true, null);
|
|||
|
oTerm.TermType = (EnumTermType)oReader.GetInt32("TermType").Value;
|
|||
|
oTerm.Sequence = oReader.GetInt32("SequenceNo").Value;
|
|||
|
oTerm.Status = (EnumStatus)oReader.GetInt32("Status").Value;
|
|||
|
oTerm.payrolltypeid = oReader.GetInt32("payrolltypeid").Value;
|
|||
|
oTerm.CreatedBy = oReader.GetString("CreatedBy") == null ? 0 : oReader.GetInt32("CreatedBy").Value;
|
|||
|
oTerm.CreatedDate = oReader.GetDateTime("CreationDate").Value;
|
|||
|
oTerm.ModifiedBy = oReader.GetString("ModifiedBy") == null ? 0 : oReader.GetInt32("ModifiedBy").Value;
|
|||
|
oTerm.ModifiedDate = oReader.GetDateTime("ModifiedDate");
|
|||
|
this.SetObjectState(oTerm, Ease.Core.ObjectState.Saved);
|
|||
|
}
|
|||
|
|
|||
|
protected override T CreateObject<T>(DataReader oReader)
|
|||
|
{
|
|||
|
Term oTerm = new Term();
|
|||
|
MapObject(oTerm, oReader);
|
|||
|
return oTerm as T;
|
|||
|
}
|
|||
|
|
|||
|
protected Term CreateObject(DataReader oReader)
|
|||
|
{
|
|||
|
Term oTerm = new Term();
|
|||
|
MapObject(oTerm, oReader);
|
|||
|
return oTerm;
|
|||
|
}
|
|||
|
|
|||
|
#region Service implementation
|
|||
|
|
|||
|
public Term Get(int id)
|
|||
|
{
|
|||
|
Term oTerm = new Term();
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(TermDA.Get(tc, id));
|
|||
|
if (oreader.Read())
|
|||
|
{
|
|||
|
oTerm = this.CreateObject<Term>(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 oTerm;
|
|||
|
}
|
|||
|
|
|||
|
public List<Term> Get(EnumStatus status, int payrolltypeid)
|
|||
|
{
|
|||
|
List<Term> terms = new List<Term>();
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader dr = new DataReader(TermDA.Get(tc, status, payrolltypeid));
|
|||
|
terms = this.CreateObjects<Term>(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 terms;
|
|||
|
}
|
|||
|
|
|||
|
public List<Term> GetBySlabTerm(EnumTermType slabType, int payrolltypeid)
|
|||
|
{
|
|||
|
List<Term> terms = new List<Term>();
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader dr = new DataReader(TermDA.GetBySlabTerm(tc, slabType, payrolltypeid));
|
|||
|
terms = this.CreateObjects<Term>(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 terms;
|
|||
|
}
|
|||
|
|
|||
|
public int Save(Term oTerm)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
if (oTerm.IsNew)
|
|||
|
{
|
|||
|
int id = tc.GenerateID("Term", "TermID");
|
|||
|
base.SetObjectID(oTerm, id);
|
|||
|
int seqNo = tc.GenerateID("Term", "SequenceNO");
|
|||
|
oTerm.Sequence = seqNo;
|
|||
|
TermDA.Insert(tc, oTerm);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
TermDA.Update(tc, oTerm);
|
|||
|
}
|
|||
|
|
|||
|
tc.End();
|
|||
|
return oTerm.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);
|
|||
|
TermDA.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
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public List<Term> GetAllTerm(int payrollTypeID, EnumStatus status, string code, string name)
|
|||
|
{
|
|||
|
List<Term> terms = new List<Term>();
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader dr = new DataReader(TermDA.GetAllTerm(tc, payrollTypeID, status, code, name));
|
|||
|
terms = this.CreateObjects<Term>(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 terms;
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|