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

73 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.SearchTools;
using HRM.DA.DA.SearchTools;
namespace HRM.DA.Service.SearchTools
{
public class QTAuthorizationService : ServiceTemplate, IQTAuthorizationService
{
public QTAuthorizationService()
{
}
private void MapObject(QTAuthorization item, DataReader dataReader)
{
base.SetObjectID(item, dataReader.GetInt32("QTAuthorizationID").Value);
item.QueryToolID = dataReader.GetInt32("QueryToolID").Value;
item.EmployeeID = dataReader.GetInt32("EmployeeID").Value;
item.AuthorizeDate = dataReader.GetDateTime("AuthorizeDate").Value;
item.Count = dataReader.GetInt32("Count").Value;
this.SetObjectState(item, Ease.Core.ObjectState.Saved);
}
protected override T CreateObject<T>(DataReader dataReader)
{
QTAuthorization item = new QTAuthorization();
MapObject(item, dataReader);
return item as T;
}
protected QTAuthorization CreateObject(DataReader dataReader)
{
QTAuthorization item = new QTAuthorization();
MapObject(item, dataReader);
return item;
}
public void SaveQtAuthorization(QTAuthorization item)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
if (item.IsNew)
{
int id = tc.GenerateID("QTAuthorization", "QTAuthorizationID");
base.SetObjectID(item, id);
QTAuthorizationDA.Insert(tc, item);
}
else
{
QTAuthorizationDA.Update(tc, item);
}
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
}
}
}