HRM-10/HRM.DA/Service/Fund/VoucherSetup/ActivityVoucherSetupService.cs

291 lines
8.7 KiB
C#
Raw Normal View History

2026-11-03 13:06:00 +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;
namespace HRM.DA
{
public class ActivityVoucherSetupService : ServiceTemplate, IActivityVoucherSetupService
{
public ActivityVoucherSetupService()
{
}
private void MapObject(ActivityVoucherSetup ActivityVoucherSetup, DataReader dr)
{
base.SetObjectID(ActivityVoucherSetup, dr.GetInt32("SetupID").Value);
ActivityVoucherSetup.FundTypeID = dr.GetInt32("FundTypeID").Value;
ActivityVoucherSetup.ProcessID = (EnumFundProcessType) dr.GetInt32("ProcessID").Value;
ActivityVoucherSetup.CreatedBy = dr.GetInt32("CreatedBy").Value;
ActivityVoucherSetup.CreatedDate = dr.GetDateTime("CreatedDate").Value;
ActivityVoucherSetup.ModifiedBy =
dr.GetInt32("ModifiedBy") != null ? dr.GetInt32("ModifiedBy").Value : (0);
ActivityVoucherSetup.ModifiedDate = dr.GetDateTime("ModifiedDate") != null
? dr.GetDateTime("ModifiedDate")
: DateTime.MinValue;
ActivityVoucherSetup.ReferenceID = dr.GetInt32("ReferenceID");
ActivityVoucherSetup.ReferenceType = dr.GetInt32("ReferenceType")==null?0:(EnumProcessReferenceType)dr.GetInt32("ReferenceType");
ActivityVoucherSetup.GLSide =(EnumTranSide) dr.GetInt32("GLSide").Value;
ActivityVoucherSetup.GLID = dr.GetInt32("GLID").Value;
ActivityVoucherSetup.VouhcerSetupItemType = (EnumVouhcerSetupItemType)dr.GetInt32("VoucherSetupItemType");
ActivityVoucherSetup.FundProcessType = (EnumFundProcessType)dr.GetInt32("FundProcessType");
base.SetObjectState(ActivityVoucherSetup, ObjectState.Saved);
}
protected override T CreateObject<T>(DataReader dr)
{
ActivityVoucherSetup ActivityVoucherSetup = new ActivityVoucherSetup();
MapObject(ActivityVoucherSetup, dr);
return ActivityVoucherSetup as T;
}
#region Service Implementation
#region Insert
public void Save(ActivityVoucherSetup activityVoucherSetup)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
if (!activityVoucherSetup.IsNew)
{
ActivityVoucherSetupDA.Update(tc, activityVoucherSetup);
}
else
{
int id = tc.GenerateID("FM_ActivityVoucherSetup", "SetupID");
base.SetObjectID(activityVoucherSetup, (id));
ActivityVoucherSetupDA.Insert(tc, activityVoucherSetup);
}
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
}
#region Delete
public void Delete(int id)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
ActivityVoucherSetupDA.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
#region Delete
public void DeleteByProcessID(int id)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
ActivityVoucherSetupDA.DeleteByProcessID(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
#region GetbyProcessid(By ID)
public List<ActivityVoucherSetup> GetByProcessID(int ID)
{
List<ActivityVoucherSetup> ActivityVoucherSetup = new List<ActivityVoucherSetup>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(ActivityVoucherSetupDA.GetByProcessID(tc, ID));
ActivityVoucherSetup = this.CreateObjects<ActivityVoucherSetup>(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 ActivityVoucherSetup;
}
#endregion
public List<ActivityVoucherSetup> GetByProcessType(int fundtypeid, EnumFundProcessType processType)
{
List<ActivityVoucherSetup> ActivityVoucherSetups = new List<ActivityVoucherSetup>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(ActivityVoucherSetupDA.GetByProcessType(tc, fundtypeid, processType));
ActivityVoucherSetups = this.CreateObjects<ActivityVoucherSetup>(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 ActivityVoucherSetups;
}
public List<ActivityVoucherSetup> GetByProcessType(TransactionContext tc, int fundtypeid, EnumFundProcessType processType)
{
List<ActivityVoucherSetup> ActivityVoucherSetups = new List<ActivityVoucherSetup>();
try
{
DataReader dr = new DataReader(ActivityVoucherSetupDA.GetByProcessType(tc, fundtypeid, processType));
ActivityVoucherSetups = this.CreateObjects<ActivityVoucherSetup>(dr);
dr.Close();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return ActivityVoucherSetups;
}
public List<ActivityVoucherSetup> GetByFundType(int fundtypeid)
{
List<ActivityVoucherSetup> ActivityVoucherSetups = new List<ActivityVoucherSetup>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(ActivityVoucherSetupDA.GetByFundType(tc, fundtypeid));
ActivityVoucherSetups = this.CreateObjects<ActivityVoucherSetup>(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 ActivityVoucherSetups;
}
public DataTable GetProcessIDsByFundType(int fundtypeid)
{
DataTable dt = new DataTable();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
dt = ActivityVoucherSetupDA.GetProcessIDsByFundType(tc, fundtypeid);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return dt;
}
//#endregion
#endregion
#endregion
}
}