379 lines
12 KiB
C#
379 lines
12 KiB
C#
using Ease.CoreV35.Model;
|
|
using Payroll.BO;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Data;
|
|
using System.Text;
|
|
using Ease.CoreV35.Caching;
|
|
using Ease.CoreV35.DataAccess;
|
|
using Payroll.Service.Basic.DA;
|
|
|
|
namespace Payroll.Service.Basic.Service
|
|
{
|
|
[Serializable]
|
|
class ChildrenEducationService : ServiceTemplate, IChildrenEducationService
|
|
{
|
|
#region Private functions and declaration
|
|
Cache _cache = new Cache(typeof(ChildrenEducation));
|
|
|
|
#endregion
|
|
|
|
public ChildrenEducationService()
|
|
{
|
|
|
|
}
|
|
|
|
private void MapObject(ChildrenEducation oChildrenEducation, DataReader dr)
|
|
{
|
|
base.SetObjectID(oChildrenEducation, dr.GetID("ChildrenEducationID"));
|
|
oChildrenEducation.FromMonth = dr.GetDateTime("FromMonth").Value;
|
|
oChildrenEducation.NoOfChildren = dr.GetInt32("NoofChildren").Value;
|
|
oChildrenEducation.Amount = dr.GetDouble("Amount").Value;
|
|
oChildrenEducation.CreatedBy = dr.GetID("CreatedBy");
|
|
oChildrenEducation.CreatedDate = dr.GetDateTime("CreatedDate").Value;
|
|
oChildrenEducation.EmployeeID = dr.GetID("EmployeeID");
|
|
this.SetObjectState(oChildrenEducation, Ease.CoreV35.ObjectState.Saved);
|
|
}
|
|
protected override T CreateObject<T>(DataReader oReader)
|
|
{
|
|
ChildrenEducation ochildrenEducation = new ChildrenEducation();
|
|
MapObject(ochildrenEducation, oReader);
|
|
return ochildrenEducation as T;
|
|
|
|
}
|
|
|
|
protected ChildrenEducation CreateObject(DataReader oReader)
|
|
{
|
|
ChildrenEducation oChildrenEducation = new ChildrenEducation();
|
|
MapObject(oChildrenEducation, oReader);
|
|
return oChildrenEducation;
|
|
}
|
|
|
|
|
|
#region Service Implementation
|
|
|
|
public ID Save(ChildrenEducation oChildrenEducation)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
if (oChildrenEducation.IsNew)
|
|
{
|
|
|
|
int id = tc.GenerateID("ChildrenEducation", "ChildrenEducationID");
|
|
base.SetObjectID(oChildrenEducation, ID.FromInteger(id));
|
|
if (ChildrenEducationDA.IsExist(tc, oChildrenEducation.EmployeeID, oChildrenEducation.FromMonth))
|
|
{
|
|
ChildrenEducationDA.Delete(tc, oChildrenEducation);
|
|
}
|
|
ChildrenEducationDA.Insert(tc, oChildrenEducation);
|
|
}
|
|
else
|
|
{
|
|
ChildrenEducationDA.Update(tc, oChildrenEducation);
|
|
}
|
|
tc.End();
|
|
return oChildrenEducation.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<ChildrenEducation> oChildrenEducations, ObjectsTemplate<ADParameterEmployee> _adParamEmployees)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
|
|
ADParameterEmployeeService adeService = new ADParameterEmployeeService();
|
|
foreach (ADParameterEmployee item in _adParamEmployees)
|
|
{
|
|
if (ADParameterEmployeeDA.IsExist(tc, item.EmployeeID.Integer, item.AllowDeductID.Integer, item.ADParameterID.Integer, item.TillDate, item.Periodicity))
|
|
{
|
|
adeService.Delete(item);
|
|
}
|
|
adeService.Save(item);
|
|
}
|
|
|
|
foreach (ChildrenEducation oCEAllow in oChildrenEducations)
|
|
{
|
|
if (ChildrenEducationDA.IsExist(tc, oCEAllow.EmployeeID))
|
|
{
|
|
|
|
ChildrenEducationDA.UpdateByEmpID(tc, oCEAllow);
|
|
}
|
|
else
|
|
{
|
|
int id = tc.GenerateID("ChildrenEducation", "ChildrenEducationID");
|
|
base.SetObjectID(oCEAllow, ID.FromInteger(id));
|
|
ChildrenEducationDA.Insert(tc, oCEAllow);
|
|
}
|
|
|
|
}
|
|
|
|
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(ChildrenEducation oChildrenEducation, ADParameterEmployee _adParamEmployee)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
|
|
ADParameterEmployeeService adeService = new ADParameterEmployeeService();
|
|
adeService.Save2(_adParamEmployee, tc);
|
|
|
|
if (oChildrenEducation.IsNew)
|
|
{
|
|
|
|
int id = tc.GenerateID("ChildrenEducation", "ChildrenEducationID");
|
|
base.SetObjectID(oChildrenEducation, ID.FromInteger(id));
|
|
if (ChildrenEducationDA.IsExist(tc, oChildrenEducation.EmployeeID))
|
|
{
|
|
ChildrenEducationDA.DeleteByEmpID(tc, oChildrenEducation.EmployeeID);
|
|
}
|
|
ChildrenEducationDA.Insert(tc, oChildrenEducation);
|
|
}
|
|
else
|
|
{
|
|
ChildrenEducationDA.Update(tc, oChildrenEducation);
|
|
}
|
|
|
|
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(ObjectsTemplate<ChildrenEducation> oChildrenEducations)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
foreach (ChildrenEducation oCEAllow in oChildrenEducations)
|
|
{
|
|
if (ChildrenEducationDA.IsExist(tc, oCEAllow.EmployeeID))
|
|
{
|
|
|
|
ChildrenEducationDA.UpdateByEmpID(tc, oCEAllow);
|
|
}
|
|
else
|
|
{
|
|
int id = tc.GenerateID("ChildrenEducation", "ChildrenEducationID");
|
|
base.SetObjectID(oCEAllow, ID.FromInteger(id));
|
|
ChildrenEducationDA.Insert(tc, oCEAllow);
|
|
}
|
|
|
|
}
|
|
|
|
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 Delete(ID id)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
ChildrenEducationDA.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 ChildrenEducation Get(ID id)
|
|
{
|
|
ChildrenEducation oChildrenEducation = new ChildrenEducation();
|
|
#region Cache Header
|
|
oChildrenEducation = _cache["Get", id] as ChildrenEducation;
|
|
if (oChildrenEducation != null)
|
|
return oChildrenEducation;
|
|
#endregion
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(ChildrenEducationDA.Get(tc, id));
|
|
if (oreader.Read())
|
|
{
|
|
oChildrenEducation = this.CreateObject<ChildrenEducation>(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
|
|
}
|
|
#region Cache Footer
|
|
_cache.Add(oChildrenEducation, "Get", id);
|
|
#endregion
|
|
return oChildrenEducation;
|
|
}
|
|
|
|
public ObjectsTemplate<ChildrenEducation> Get()
|
|
{
|
|
|
|
ObjectsTemplate<ChildrenEducation> aChildrenEducation = new ObjectsTemplate<ChildrenEducation>();
|
|
#region Cache Header
|
|
aChildrenEducation = _cache["Get"] as ObjectsTemplate<ChildrenEducation>;
|
|
if (aChildrenEducation != null)
|
|
return aChildrenEducation;
|
|
#endregion
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr = new DataReader(ChildrenEducationDA.Get(tc));
|
|
aChildrenEducation = this.CreateObjects<ChildrenEducation>(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
|
|
}
|
|
|
|
#region Cache Footer
|
|
_cache.Add(aChildrenEducation, "Get");
|
|
#endregion
|
|
return aChildrenEducation;
|
|
}
|
|
public ObjectsTemplate<ChildrenEducation> Get(DateTime date)
|
|
{
|
|
#region Cache Header
|
|
|
|
ObjectsTemplate<ChildrenEducation> aChildrenEducation = _cache["Get"] as ObjectsTemplate<ChildrenEducation>;
|
|
#endregion
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader dr = new DataReader(ChildrenEducationDA.Get(tc, date));
|
|
aChildrenEducation = this.CreateObjects<ChildrenEducation>(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
|
|
}
|
|
#region Cache Footer
|
|
|
|
_cache.Add(aChildrenEducation, "Get");
|
|
|
|
#endregion
|
|
|
|
return aChildrenEducation;
|
|
|
|
}
|
|
|
|
public bool IsExist(ChildrenEducation childrenEducation)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
bool result = true;
|
|
result = ChildrenEducationDA.IsExist(tc, childrenEducation);
|
|
return result;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
finally
|
|
{
|
|
if (tc != null)
|
|
{
|
|
tc.End();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
}
|
|
}
|