163 lines
5.2 KiB
C#
163 lines
5.2 KiB
C#
|
using HRM.BO;
|
|||
|
using Ease.Core.DataAccess;
|
|||
|
using Ease.Core.Model;
|
|||
|
using Ease.Core.Utility;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
|
|||
|
namespace HRM.DA
|
|||
|
{
|
|||
|
public class MarketSurveyCompanyService : ServiceTemplate, IMarketSurveyCompanyService
|
|||
|
{
|
|||
|
public MarketSurveyCompanyService()
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
private void MapObject(MarketSurveyCompany oMarketSurveyCompany, DataReader oReader)
|
|||
|
{
|
|||
|
//oMarketSurveyCompany.ID = oReader.GetID("MarketSurveyCompanyID");
|
|||
|
base.SetObjectID(oMarketSurveyCompany, oReader.GetInt32("MarketSurveyCompanyID").Value);
|
|||
|
oMarketSurveyCompany.Code = oReader.GetString("Code");
|
|||
|
oMarketSurveyCompany.Name = oReader.GetString("Name");
|
|||
|
oMarketSurveyCompany.Address = oReader.GetString("Address");
|
|||
|
oMarketSurveyCompany.CreatedBy = oReader.GetInt32("CreatedBy", 0);
|
|||
|
oMarketSurveyCompany.CreatedDate = oReader.GetDateTime("CreationDate").Value;
|
|||
|
oMarketSurveyCompany.ModifiedBy = oReader.GetInt32("ModifiedBy", 0);
|
|||
|
oMarketSurveyCompany.ModifiedDate = oReader.GetDateTime("ModifiedDate");
|
|||
|
oMarketSurveyCompany.Status = (EnumStatus)oReader.GetInt32("Status").Value;
|
|||
|
oMarketSurveyCompany.Sequence = oReader.GetInt32("SequenceNO").Value;
|
|||
|
this.SetObjectState(oMarketSurveyCompany, Ease.Core.ObjectState.Saved);
|
|||
|
}
|
|||
|
|
|||
|
protected override T CreateObject<T>(DataReader oReader)
|
|||
|
{
|
|||
|
MarketSurveyCompany oMarketSurveyCompany = new MarketSurveyCompany();
|
|||
|
MapObject(oMarketSurveyCompany, oReader);
|
|||
|
return oMarketSurveyCompany as T;
|
|||
|
}
|
|||
|
|
|||
|
#region Service implementation
|
|||
|
|
|||
|
public MarketSurveyCompany Get(int id)
|
|||
|
{
|
|||
|
MarketSurveyCompany oMarketSurveyCompany = null;
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(MarketSurveyCompanyDA.Get(tc, id));
|
|||
|
if (oreader.Read())
|
|||
|
{
|
|||
|
oMarketSurveyCompany = this.CreateObject<MarketSurveyCompany>(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 oMarketSurveyCompany;
|
|||
|
}
|
|||
|
|
|||
|
public List<MarketSurveyCompany> Get(EnumStatus status)
|
|||
|
{
|
|||
|
List<MarketSurveyCompany> MarketSurveyCompanys = new List<MarketSurveyCompany>();
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader dr = new DataReader(MarketSurveyCompanyDA.Get(tc, status));
|
|||
|
MarketSurveyCompanys = this.CreateObjects<MarketSurveyCompany>(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 MarketSurveyCompanys;
|
|||
|
}
|
|||
|
|
|||
|
public int Save(MarketSurveyCompany oMarketSurveyCompany)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
if (oMarketSurveyCompany.IsNew)
|
|||
|
{
|
|||
|
int id = tc.GenerateID("MarketSurveyCompany", "MarketSurveyCompanyID");
|
|||
|
base.SetObjectID(oMarketSurveyCompany, id);
|
|||
|
int seqNo = tc.GenerateID("MarketSurveyCompany", "SequenceNO");
|
|||
|
oMarketSurveyCompany.Sequence = seqNo;
|
|||
|
MarketSurveyCompanyDA.Insert(tc, oMarketSurveyCompany);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
MarketSurveyCompanyDA.Update(tc, oMarketSurveyCompany);
|
|||
|
}
|
|||
|
|
|||
|
tc.End();
|
|||
|
return oMarketSurveyCompany.ID;
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void Delete(int id)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
MarketSurveyCompanyDA.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
|
|||
|
}
|
|||
|
}
|