264 lines
7.5 KiB
C#
264 lines
7.5 KiB
C#
|
|
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;
|
|||
|
|
using HRM.DA;
|
|||
|
|
|
|||
|
|
namespace HRM.DA.Fund
|
|||
|
|
{
|
|||
|
|
[Serializable]
|
|||
|
|
public class TrusteeInfoService : ServiceTemplate, ITrusteeInfoService
|
|||
|
|
{
|
|||
|
|
string ss = string.Empty;
|
|||
|
|
|
|||
|
|
#region Private Function And Declaration
|
|||
|
|
|
|||
|
|
public TrusteeInfoService()
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void MapObject(TrusteeInfo oTrusteeInfo, DataReader dr)
|
|||
|
|
{
|
|||
|
|
ss = "Map object error";
|
|||
|
|
|
|||
|
|
base.SetObjectID(oTrusteeInfo, dr.GetInt32("TrustyID").Value);
|
|||
|
|
oTrusteeInfo.FundTypeID = dr.GetInt32("FundTypeID").Value;
|
|||
|
|
oTrusteeInfo.Code = dr.GetString("Code");
|
|||
|
|
oTrusteeInfo.Name = dr.GetString("Name");
|
|||
|
|
oTrusteeInfo.Email = dr.GetString("Email");
|
|||
|
|
oTrusteeInfo.Contacts = dr.GetString("Contacts");
|
|||
|
|
oTrusteeInfo.StatusTrustee = dr.GetInt32("Status").Value;
|
|||
|
|
oTrusteeInfo.CreatedBy = dr.GetInt32("CreatedBy").Value;
|
|||
|
|
oTrusteeInfo.CreatedDate = dr.GetDateTime("CreatedDate").Value;
|
|||
|
|
oTrusteeInfo.ModifiedBy = dr.GetInt32("ModifiedBy");
|
|||
|
|
oTrusteeInfo.ModifiedDate = dr.GetDateTime("ModifiedDate");
|
|||
|
|
base.SetObjectState(oTrusteeInfo, ObjectState.Saved);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
protected override T CreateObject<T>(DataReader dr)
|
|||
|
|
{
|
|||
|
|
TrusteeInfo item = new TrusteeInfo();
|
|||
|
|
MapObject(item, dr);
|
|||
|
|
return item as T;
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
public TrusteeInfo Get(int id)
|
|||
|
|
{
|
|||
|
|
TrusteeInfo oTrusteeInfo = new TrusteeInfo();
|
|||
|
|
|
|||
|
|
#region Cache Header
|
|||
|
|
|
|||
|
|
oTrusteeInfo = new TrusteeInfo();
|
|||
|
|
if (oTrusteeInfo != null)
|
|||
|
|
return oTrusteeInfo;
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
TransactionContext tc = null;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
tc = TransactionContext.Begin();
|
|||
|
|
IDataReader oreader = TrusteeInfoDA.Get(tc, id);
|
|||
|
|
DataReader dr = new DataReader(oreader);
|
|||
|
|
if (oreader.Read())
|
|||
|
|
{
|
|||
|
|
oTrusteeInfo = CreateObject<TrusteeInfo>(dr);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
oreader.Close();
|
|||
|
|
tc.End();
|
|||
|
|
}
|
|||
|
|
catch (Exception e)
|
|||
|
|
{
|
|||
|
|
#region Handle Exception
|
|||
|
|
|
|||
|
|
if (tc != null)
|
|||
|
|
tc.HandleError();
|
|||
|
|
ExceptionLog.Write(e);
|
|||
|
|
throw new ServiceException("Failed to Get TrusteeInfo", e);
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#region Cache Footer
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
return oTrusteeInfo;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public List<TrusteeInfo> GetByFundTypeID(int FundTypeID)
|
|||
|
|
{
|
|||
|
|
List<TrusteeInfo> TrusteeInfos = new List<TrusteeInfo>();
|
|||
|
|
TransactionContext tc = null;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
tc = TransactionContext.Begin();
|
|||
|
|
DataReader dr = new DataReader(TrusteeInfoDA.GetByFundTypeID(tc, FundTypeID));
|
|||
|
|
TrusteeInfos = CreateObjects<TrusteeInfo>(dr);
|
|||
|
|
dr.Close();
|
|||
|
|
tc.End();
|
|||
|
|
}
|
|||
|
|
catch (Exception e)
|
|||
|
|
{
|
|||
|
|
#region Handle Exception
|
|||
|
|
|
|||
|
|
if (tc != null)
|
|||
|
|
tc.HandleError();
|
|||
|
|
ExceptionLog.Write(e);
|
|||
|
|
throw new ServiceException("Failed to Get TrusteeInfo " + ss, e);
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
}
|
|||
|
|
return TrusteeInfos;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public bool IsExist(string code, int fundtypeid)
|
|||
|
|
{
|
|||
|
|
bool exists = false;
|
|||
|
|
TransactionContext tc = null;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
tc = TransactionContext.Begin(true);
|
|||
|
|
exists = TrusteeInfoDA.IsExist(tc, code, fundtypeid);
|
|||
|
|
tc.End();
|
|||
|
|
}
|
|||
|
|
catch (Exception e)
|
|||
|
|
{
|
|||
|
|
throw new ServiceException("Failed to Check by code" + e.Message, e);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return exists;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void Delete(int id)
|
|||
|
|
{
|
|||
|
|
TransactionContext tc = null;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
tc = TransactionContext.Begin(true);
|
|||
|
|
TrusteeInfoDA.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 TrusteeInfo", e);
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#region Insert
|
|||
|
|
|
|||
|
|
public void Save(TrusteeInfo trusteeInfo)
|
|||
|
|
{
|
|||
|
|
TrusteeInfo oTrusteeInfo = new TrusteeInfo();
|
|||
|
|
oTrusteeInfo = trusteeInfo;
|
|||
|
|
TransactionContext tc = null;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
tc = TransactionContext.Begin(true);
|
|||
|
|
|
|||
|
|
if (oTrusteeInfo.IsNew)
|
|||
|
|
{
|
|||
|
|
int id = tc.GenerateID("FM_TRUSTYINFO", "TrustyID");
|
|||
|
|
base.SetObjectID(oTrusteeInfo, (id));
|
|||
|
|
TrusteeInfoDA.Insert(tc, oTrusteeInfo);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
TrusteeInfoDA.Update(tc, oTrusteeInfo);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
tc.End();
|
|||
|
|
}
|
|||
|
|
catch (Exception e)
|
|||
|
|
{
|
|||
|
|
#region Handle Exception
|
|||
|
|
|
|||
|
|
if (tc != null)
|
|||
|
|
tc.HandleError();
|
|||
|
|
ExceptionLog.Write(e);
|
|||
|
|
|
|||
|
|
throw new ServiceException(e.Message, e);
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
public DataTable GetTable(int fundtypeid)
|
|||
|
|
{
|
|||
|
|
DataTable dTbl = new DataTable("FM_TRUSTYINFO");
|
|||
|
|
TransactionContext tc = null;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
tc = TransactionContext.Begin();
|
|||
|
|
|
|||
|
|
IDataReader ir = TrusteeInfoDA.Get(tc, fundtypeid);
|
|||
|
|
dTbl.Load(ir);
|
|||
|
|
ir.Close();
|
|||
|
|
|
|||
|
|
tc.End();
|
|||
|
|
}
|
|||
|
|
catch (Exception e)
|
|||
|
|
{
|
|||
|
|
throw new ServiceException("Failed to Get Trustee" + e.Message, e);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return dTbl;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public List<TrusteeInfo> Get()
|
|||
|
|
{
|
|||
|
|
List<TrusteeInfo> trusteeInfo = new List<TrusteeInfo>();
|
|||
|
|
TransactionContext tc = null;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
tc = TransactionContext.Begin();
|
|||
|
|
DataReader dr = new DataReader(TrusteeInfoDA.Get(tc));
|
|||
|
|
|
|||
|
|
trusteeInfo = this.CreateObjects<TrusteeInfo>(dr);
|
|||
|
|
dr.Close();
|
|||
|
|
tc.End();
|
|||
|
|
}
|
|||
|
|
catch(Exception e)
|
|||
|
|
{
|
|||
|
|
throw new ServiceException(e.Message);
|
|||
|
|
}
|
|||
|
|
return trusteeInfo;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public List<TrusteeInfo> GetByFundType(int fundTypeID)
|
|||
|
|
{
|
|||
|
|
List<TrusteeInfo> trusteeInfo = new List<TrusteeInfo>();
|
|||
|
|
TransactionContext tc = null;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
tc = TransactionContext.Begin();
|
|||
|
|
DataReader dr = new DataReader(TrusteeInfoDA.Get(tc, fundTypeID));
|
|||
|
|
|
|||
|
|
trusteeInfo = this.CreateObjects<TrusteeInfo>(dr);
|
|||
|
|
dr.Close();
|
|||
|
|
tc.End();
|
|||
|
|
}
|
|||
|
|
catch (Exception e)
|
|||
|
|
{
|
|||
|
|
throw new ServiceException(e.Message);
|
|||
|
|
}
|
|||
|
|
return trusteeInfo;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|