EchoTex_Payroll/HRM.DA/Service/Fund/Transaction/GLTranUserRecordService.cs

676 lines
23 KiB
C#
Raw Normal View History

2024-10-14 10:01:49 +06:00
using Ease.Core.DataAccess;
using Ease.Core.Model;
using Ease.Core.Utility;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using HRM.BO;
namespace HRM.DA
{
#region GLTranUserRecord Service
[Serializable]
public class GLTranUserRecordService : ServiceTemplate //, IGLTranUserRecordService
{
#region Private functions and declaration
public GLTranUserRecordService()
{
}
#region Map Objects
private void MapObject(GLTranUserRecord gLTranUserRecord, DataReader oReader)
{
this.SetObjectID(gLTranUserRecord, oReader.GetInt32("GLTranUserRecordID").Value);
gLTranUserRecord.GLID = oReader.GetInt32("GLID").Value;
gLTranUserRecord.GLTranID = oReader.GetInt32("GLTranID").Value;
gLTranUserRecord.GLTranDetailID = oReader.GetInt32("GLTranDetailID").Value;
gLTranUserRecord.UserObject1ID = oReader.GetInt32("UserObject1ID").Value;
gLTranUserRecord.UserRecord1ID = oReader.GetInt32("UserRecord1ID").Value;
gLTranUserRecord.UserObject2ID = oReader.GetInt32("UserObject2ID").Value;
gLTranUserRecord.UserRecord2ID = oReader.GetInt32("UserRecord2ID").Value;
gLTranUserRecord.Amount = oReader.GetDecimal("Amount").Value;
gLTranUserRecord.Description = oReader.GetString("Description");
gLTranUserRecord.Modifiedby = oReader.GetInt32("Modifiedby").Value;
gLTranUserRecord.ModifiedDate = oReader.GetDateTime("ModifiedDate").Value;
gLTranUserRecord.OperationalStatus = (EnumOperationalStatus)oReader.GetInt32("OperationalStatus");
this.SetObjectState(gLTranUserRecord, Ease.Core.ObjectState.Saved);
}
protected override T CreateObject<T>(DataReader oReader)
{
GLTranUserRecord oGLTranUserRecord = new GLTranUserRecord();
MapObject(oGLTranUserRecord, oReader);
return oGLTranUserRecord as T;
}
protected GLTranUserRecord CreateObject(DataReader oReader)
{
GLTranUserRecord oGLTranUserRecord = new GLTranUserRecord();
MapObject(oGLTranUserRecord, oReader);
return oGLTranUserRecord;
}
//private GLTranUserRecords CreateObjects(IDataReader oReader)
//{
// GLTranUserRecords oGLTranUserRecords = new GLTranUserRecords();
// NullHandler oreader = new NullHandler(oReader);
// while (oReader.Read())
// {
// GLTranUserRecord oItem = CreateObject(oreader);
// oGLTranUserRecords.Add(oItem);
// }
// return oGLTranUserRecords;
//}
#endregion
#region Map Open
private void OpenMapObject(GLTranUserRecord gLTranUserRecord, DataReader oReader)
{
this.SetObjectID(gLTranUserRecord, oReader.GetInt32("GLTranUserRecordID").Value);
gLTranUserRecord.GLID = oReader.GetInt32("GLID").Value;
gLTranUserRecord.GLTranID = oReader.GetInt32("GLTranID").Value;
gLTranUserRecord.GLTranDetailID = oReader.GetInt32("GLTranDetailID").Value;
gLTranUserRecord.UserObject1ID = oReader.GetInt32("UserObject1ID").Value;
gLTranUserRecord.UserRecord1ID = oReader.GetInt32("UserRecord1ID").Value;
gLTranUserRecord.UserObject2ID = oReader.GetInt32("UserObject2ID").Value;
gLTranUserRecord.UserRecord2ID = oReader.GetInt32("UserRecord2ID").Value;
gLTranUserRecord.Amount = oReader.GetDecimal("Amount").Value;
gLTranUserRecord.Description = oReader.GetString("Description");
gLTranUserRecord.Modifiedby = oReader.GetInt32("Modifiedby").Value;
gLTranUserRecord.ModifiedDate = oReader.GetDateTime("ModifiedDate").Value;
gLTranUserRecord.OperationalStatus = (EnumOperationalStatus)oReader.GetInt32("OperationalStatus");
this.SetObjectState(gLTranUserRecord, Ease.Core.ObjectState.Saved);
}
protected GLTranUserRecord OpenCreateObject(DataReader oReader)
{
GLTranUserRecord oGLTranUserRecord = new GLTranUserRecord();
MapObject(oGLTranUserRecord, oReader);
return oGLTranUserRecord;
}
//private GLTranUserRecords OpenCreateObjects(IDataReader oReader)
//{
// GLTranUserRecords oGLTranUserRecords = new GLTranUserRecords();
// NullHandler oreader = new NullHandler(oReader);
// while (oReader.Read())
// {
// GLTranUserRecord oItem = OpenCreateObject(oreader);
// oGLTranUserRecords.Add(oItem);
// }
// return oGLTranUserRecords;
//}
#endregion
#region Map Open
private void YearEndMapObject(GLTranUserRecord gLTranUserRecord, DataReader oReader)
{
this.SetObjectID(gLTranUserRecord, oReader.GetInt32("GLTranUserRecordID").Value);
gLTranUserRecord.GLID = oReader.GetInt32("GLID").Value;
gLTranUserRecord.GLTranID = oReader.GetInt32("GLTranID").Value;
gLTranUserRecord.GLTranDetailID = oReader.GetInt32("GLTranDetailID").Value;
gLTranUserRecord.UserObject1ID = oReader.GetInt32("UserObject1ID").Value;
gLTranUserRecord.UserRecord1ID = oReader.GetInt32("UserRecord1ID").Value;
gLTranUserRecord.UserObject2ID = oReader.GetInt32("UserObject2ID").Value;
gLTranUserRecord.UserRecord2ID = oReader.GetInt32("UserRecord2ID").Value;
gLTranUserRecord.Amount = oReader.GetDecimal("Amount").Value;
gLTranUserRecord.Description = oReader.GetString("Description");
gLTranUserRecord.Modifiedby = oReader.GetInt32("Modifiedby").Value;
gLTranUserRecord.ModifiedDate = oReader.GetDateTime("ModifiedDate").Value;
gLTranUserRecord.OperationalStatus = (EnumOperationalStatus)oReader.GetInt32("OperationalStatus");
this.SetObjectState(gLTranUserRecord, Ease.Core.ObjectState.Saved);
}
protected GLTranUserRecord YearEndCreateObject(DataReader oReader)
{
GLTranUserRecord oGLTranUserRecord = new GLTranUserRecord();
MapObject(oGLTranUserRecord, oReader);
return oGLTranUserRecord;
}
//private GLTranUserRecords YearEndCreateObjects(IDataReader oReader)
//{
// GLTranUserRecords oGLTranUserRecords = new GLTranUserRecords();
// NullHandler oreader = new NullHandler(oReader);
// while (oReader.Read())
// {
// GLTranUserRecord oItem = YearEndCreateObject(oreader);
// oGLTranUserRecords.Add(oItem);
// }
// return oGLTranUserRecords;
//}
#endregion
#endregion
#region Service implementation
public GLTranUserRecord Get(int id)
{
GLTranUserRecord oGLTranDetail = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(GLTranUserRecordDA.Get(tc, id));
if (oreader.Read())
{
oGLTranDetail = this.CreateObject<GLTranUserRecord>(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 oGLTranDetail;
}
public List<GLTranUserRecord> Get()
{
List<GLTranUserRecord> oGLTranUserRecord = new List<GLTranUserRecord>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(GLTranUserRecordDA.Get(tc));
oGLTranUserRecord = this.CreateObjects<GLTranUserRecord>(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 oGLTranUserRecord;
}
public List<GLTranUserRecord> GetByGLID(int gLID)
{
List<GLTranUserRecord> oGLTranUserRecord = new List<GLTranUserRecord>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(GLTranUserRecordDA.GetByGLID(tc, gLID));
oGLTranUserRecord = this.CreateObjects<GLTranUserRecord>(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 oGLTranUserRecord;
}
public List<GLTranUserRecord> GetByGLTranID(int gLTranID)
{
List<GLTranUserRecord> oGLTranUserRecord = new List<GLTranUserRecord>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(GLTranUserRecordDA.GetByGLTranID(tc, gLTranID));
oGLTranUserRecord = this.CreateObjects<GLTranUserRecord>(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 oGLTranUserRecord;
}
internal List<GLTranUserRecord> GetByGLTranID(TransactionContext tc, int gLTranID)
{
List<GLTranUserRecord> oGLTranUserRecord = new List<GLTranUserRecord>();
//TransactionContext tc = null;
try
{
// tc = TransactionContext.Begin();
DataReader dr = new DataReader(GLTranUserRecordDA.GetByGLTranID(tc, gLTranID));
oGLTranUserRecord = this.CreateObjects<GLTranUserRecord>(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 oGLTranUserRecord;
}
internal List<GLTranUserRecord> GetByGLTranIDOpen(TransactionContext tc, int gLTranID)
{
List<GLTranUserRecord> oGLTranDetails = new List<GLTranUserRecord>();
// TransactionContext tc = null;
try
{
// tc = TransactionContext.Begin();
DataReader dr = new DataReader(GLTranUserRecordDA.GetByGLTranIDOpen(tc, gLTranID));
oGLTranDetails = this.CreateObjects<GLTranUserRecord>(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 oGLTranDetails;
}
public List<GLTranUserRecord> GetByGLTranDetailID(int gLTranDetailID)
{
List<GLTranUserRecord> oGLTranDetails = new List<GLTranUserRecord>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(GLTranUserRecordDA.GetByGLTranDetailID(tc, gLTranDetailID));
oGLTranDetails = this.CreateObjects<GLTranUserRecord>(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 oGLTranDetails;
}
internal List<GLTranUserRecord> GetByGLTranDetailID(TransactionContext tc, int gLTranDetailID)
{
List<GLTranUserRecord> oGLTranDetails = new List<GLTranUserRecord>();
// TransactionContext tc = null;
try
{
// tc = TransactionContext.Begin();
DataReader dr = new DataReader(GLTranUserRecordDA.GetByGLTranDetailID(tc, gLTranDetailID));
oGLTranDetails = this.CreateObjects<GLTranUserRecord>(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 oGLTranDetails;
}
internal List<GLTranUserRecord> GetByGLTranDetailIDOpen(TransactionContext tc, int gLTranDetailID)
{
List<GLTranUserRecord> oGLTranDetails = new List<GLTranUserRecord>();
// TransactionContext tc = null;
try
{
//tc = TransactionContext.Begin();
DataReader dr = new DataReader(GLTranUserRecordDA.GetByGLTranDetailIDOpen(tc, gLTranDetailID));
oGLTranDetails = this.CreateObjects<GLTranUserRecord>(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 oGLTranDetails;
}
//internal List<GLTranUserRecord> GetByVoucherDate(TransactionContext tc, DateTime firstDate, DateTime lastDate)
//{
// List<GLTranUserRecord> glTranUserRecords = new List<GLTranUserRecord>();
// //TransactionContext tc = null;
// try
// {
// //tc = TransactionContext.Begin(true);
// /* DataReader oReader = new DataReader(GLTranUserRecordDA.GetByVoucherDate(tc, firstDate, lastDate));
// glTranUserRecords = this.CreateObjects<GLTranUserRecord>(oReader);
// oReader.Close(); */
// IDataReader oReader = GLTranUserRecordDA.GetByVoucherDate(tc, firstDate, lastDate);
// glTranUserRecords = CreateObjects(oReader);
// oReader.Close();
// IDataReader oOpenReader = GLTranUserRecordDA.GetByOpenVoucherDate(tc, firstDate, lastDate);
// MapOpen(glTranUserRecords, oOpenReader);
// oOpenReader.Close();
// IDataReader oYearEndReader = GLTranUserRecordDA.GetByYearEndVoucherDate(tc, firstDate, lastDate);
// MapYearEnd(glTranUserRecords, oYearEndReader);
// oYearEndReader.Close();
// //tc.End();
// }
// catch (Exception e)
// {
// #region Handle Exception
// if (tc != null)
// tc.HandleError();
// ExceptionLog.Write(e);
// throw new ServiceException("Failed to Get GLTranUserRecords", e);
// #endregion
// }
// return glTranUserRecords;
//}
//private void MapOpen(GLTranUserRecords glTranUserRecords, IDataReader oReader)
//{
// NullHandler oreader = new NullHandler(oReader);
// while (oReader.Read())
// {
// GLTranUserRecord oItem = OpenCreateObject(oreader);
// glTranUserRecords.Add(oItem);
// }
//}
//private void MapYearEnd(GLTranUserRecords glTranUserRecords, IDataReader oReader)
//{
// NullHandler oreader = new NullHandler(oReader);
// while (oReader.Read())
// {
// GLTranUserRecord oItem = YearEndCreateObject(oreader);
// glTranUserRecords.Add(oItem);
// }
//}
public int Save(GLTranUserRecord gLTranUserRecord)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
if (gLTranUserRecord.IsNew)
{
int id = tc.GenerateID("GLTranUserRecord", "GLTranUserRecordID");
base.SetObjectID(gLTranUserRecord, id);
GLTranUserRecordDA.Insert(tc, gLTranUserRecord);
}
else
{
GLTranUserRecordDA.Update(tc, gLTranUserRecord);
}
tc.End();
return gLTranUserRecord.ID;
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
}
internal int Save(TransactionContext tc, GLTranUserRecord gLTranUserRecord)
{
try
{
//tc = TransactionContext.Begin(true);
if (gLTranUserRecord.IsNew)
{
int id = tc.GenerateID("GLTranUserRecord", "GLTranUserRecordID");
base.SetObjectID(gLTranUserRecord, id);
GLTranUserRecordDA.Insert(tc, gLTranUserRecord);
}
else
{
GLTranUserRecordDA.Update(tc, gLTranUserRecord);
}
tc.End();
return gLTranUserRecord.ID;
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
}
//internal int SaveOpen(TransactionContext tc, GLTranUserRecord gLTranUserRecord)
//{
// try
// {
// if (gLTranUserRecord.IsNew)
// {
// #region Creator
// //gLTranUserRecord.CreatedBy = User.CurrentUser.ID;
// //gLTranUserRecord.CreateDate = DateTime.Now;
// #endregion
// this.SetObjectID(gLTranUserRecord, ID.FromInteger(GLTranUserRecordDA.GetNewIDOpen(tc)));
// GLTranUserRecordDA.InsertOpen(tc, gLTranUserRecord);
// }
// else
// {
// #region Modifier
// gLTranUserRecord.Modifiedby = User.CurrentUser.ID;
// gLTranUserRecord.ModifiedDate = DateTime.Now;
// #endregion
// GLTranUserRecordDA.UpdateOpen(tc, gLTranUserRecord);
// }
// }
// catch (Exception e)
// {
// #region Handle Exception
// if (tc != null)
// tc.HandleError();
// ExceptionLog.Write(e);
// throw new ServiceException("Failed to Get GLTranUserRecord", e);
// #endregion
// }
// return gLTranUserRecord.ID;
//}
//internal int SaveYearEnd(TransactionContext tc, GLTranUserRecord gLTranUserRecord)
//{
// try
// {
// if (gLTranUserRecord.IsNew)
// {
// #region Creator
// //gLTranUserRecord.CreatedBy = User.CurrentUser.ID;
// //gLTranUserRecord.CreateDate = DateTime.Now;
// #endregion
// this.SetObjectID(gLTranUserRecord, ID.FromInteger(GLTranUserRecordDA.GetNewIDYearEnd(tc)));
// GLTranUserRecordDA.InsertYearEnd(tc, gLTranUserRecord);
// }
// else
// {
// #region Modifier
// gLTranUserRecord.Modifiedby = User.CurrentUser.ID;
// gLTranUserRecord.ModifiedDate = DateTime.Now;
// #endregion
// GLTranUserRecordDA.UpdateYearEnd(tc, gLTranUserRecord);
// }
// }
// catch (Exception e)
// {
// #region Handle Exception
// if (tc != null)
// tc.HandleError();
// ExceptionLog.Write(e);
// throw new ServiceException("Failed to Get GLTranUserRecord", e);
// #endregion
// }
// return gLTranUserRecord.ID;
//}
public void Delete(int id)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
GLTranUserRecordDA.Delete(tc, id);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException("Failed to Delete " + e.Message);
#endregion
}
}
//public void DeleteOpen(ID id)
//{
// TransactionContext tc = null;
// try
// {
// tc = TransactionContext.Begin(true);
// GLTranUserRecordDA.DeleteOpen(tc, id);
// tc.End();
// }
// catch (Exception e)
// {
// #region Handle Exception
// if (tc != null)
// tc.HandleError();
// ExceptionLog.Write(e);
// throw new ServiceException("Failed to GetGLTranUserRecord", e);
// #endregion
// }
//}
#endregion
}
#endregion
}