EchoTex_Payroll/HRM.DA/Service/SearchTools/QTColumnService.cs
2024-10-14 10:01:49 +06:00

76 lines
2.2 KiB
C#

using System;
using System.Collections.Generic;
using System.Text;
using Ease.Core.DataAccess;
using Ease.Core.Model;
using Ease.Core.Utility;
using HRM.BO;
using HRM.BO.SearchTools;
using HRM.DA.DA.SearchTools;
namespace HRM.DA.Service.SearchTools
{
public class QTColumnService : ServiceTemplate, IQTColumnService
{
public QTColumnService()
{
}
private void MapObject(QTColumn item, DataReader dataReader)
{
base.SetObjectID(item, dataReader.GetInt32("QTColumnID").Value);
item.QueryToolID = dataReader.GetInt32("QueryToolID").Value;
item.ColumnID = dataReader.GetInt32("ColumnID").Value;
item.Alignment = (ColumnAlignmentEnum)dataReader.GetInt32("Alignment").Value;
item.Aggregate = dataReader.GetString("Aggregate");
item.Format = dataReader.GetString("Format");
item.Caption = dataReader.GetString("Caption");
this.SetObjectState(item, Ease.Core.ObjectState.Saved);
}
protected override T CreateObject<T>(DataReader dataReader)
{
QTColumn item = new QTColumn();
MapObject(item, dataReader);
return item as T;
}
protected QTColumn CreateObject(DataReader dataReader)
{
QTColumn item = new QTColumn();
MapObject(item, dataReader);
return item;
}
public void SaveQTColumn(QTColumn item)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
if (item.IsNew)
{
int id = tc.GenerateID("QTColumn", "QTColumnID");
base.SetObjectID(item, id);
QTColumnDA.Insert(tc, item);
}
else
{
QTColumnDA.Update(tc, item);
}
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
}
}
}