381 lines
10 KiB
C#
381 lines
10 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]
|
|||
|
|
|||
|
#region InvestmentCategoryService
|
|||
|
|
|||
|
public class InvestmentCategoryService : ServiceTemplate
|
|||
|
{
|
|||
|
#region Private Function And Declaration
|
|||
|
|
|||
|
public InvestmentCategoryService()
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
private void MapObject(InvestmentCategory oInvestmentCategory, DataReader dr)
|
|||
|
{
|
|||
|
base.SetObjectID(oInvestmentCategory, dr.GetInt32("InvestmentCategoryID").Value);
|
|||
|
oInvestmentCategory.Code = dr.GetString("Code");
|
|||
|
oInvestmentCategory.Name = dr.GetString("Name");
|
|||
|
oInvestmentCategory.UserObjectName = dr.GetString("UserObjectName");
|
|||
|
oInvestmentCategory.MinValue = dr.GetDouble("MinValue").Value;
|
|||
|
oInvestmentCategory.ProjectID = dr.GetInt32("ProjectID").Value;
|
|||
|
oInvestmentCategory.CreatedBy = dr.GetInt32("CreatedBy").Value;
|
|||
|
oInvestmentCategory.CreatedDate = dr.GetDateTime("CreatedDate").Value;
|
|||
|
oInvestmentCategory.ModifiedBy = dr.GetInt32("ModifiedBy").Value;
|
|||
|
oInvestmentCategory.ModifiedDate = dr.GetDateTime("ModifiedDate");
|
|||
|
base.SetObjectState(oInvestmentCategory, ObjectState.Saved);
|
|||
|
}
|
|||
|
|
|||
|
protected override T CreateObject<T>(DataReader dr)
|
|||
|
{
|
|||
|
InvestmentCategory item = new InvestmentCategory();
|
|||
|
|
|||
|
MapObject(item, dr);
|
|||
|
|
|||
|
return item as T;
|
|||
|
}
|
|||
|
|
|||
|
private InvestmentCategory CreateObject(DataReader dr)
|
|||
|
{
|
|||
|
InvestmentCategory oInvestmentCategory = new InvestmentCategory();
|
|||
|
MapObject(oInvestmentCategory, dr);
|
|||
|
return oInvestmentCategory;
|
|||
|
}
|
|||
|
|
|||
|
private List<InvestmentCategory> CreateObjects(IDataReader dr)
|
|||
|
{
|
|||
|
List<InvestmentCategory> oInvestmentCategorys = new List<InvestmentCategory>();
|
|||
|
DataReader oreader = new DataReader(dr);
|
|||
|
while (dr.Read())
|
|||
|
{
|
|||
|
InvestmentCategory Item = CreateObject(oreader);
|
|||
|
oInvestmentCategorys.Add(Item);
|
|||
|
}
|
|||
|
|
|||
|
return oInvestmentCategorys;
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Get
|
|||
|
|
|||
|
public InvestmentCategory Get(int id)
|
|||
|
{
|
|||
|
InvestmentCategory oInvestmentCategory = new InvestmentCategory();
|
|||
|
|
|||
|
#region Cache Header
|
|||
|
|
|||
|
if (oInvestmentCategory != null)
|
|||
|
return oInvestmentCategory;
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
IDataReader oreader = InvestmentCategoryDA.Get(tc, id);
|
|||
|
DataReader dr = new DataReader(oreader);
|
|||
|
if (oreader.Read())
|
|||
|
{
|
|||
|
oInvestmentCategory = CreateObject<InvestmentCategory>(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 InvestmentCategory", e);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
#region Cache Footer
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
return oInvestmentCategory;
|
|||
|
}
|
|||
|
|
|||
|
public List<InvestmentCategory> GetbyFundtype(int fundtypeid)
|
|||
|
{
|
|||
|
List<InvestmentCategory> InvestmentCategorys = new List<InvestmentCategory>();
|
|||
|
|
|||
|
#region Cache Header
|
|||
|
|
|||
|
if (InvestmentCategorys != null)
|
|||
|
return InvestmentCategorys;
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
IDataReader dr = InvestmentCategoryDA.Getbyfundtype(tc, fundtypeid);
|
|||
|
InvestmentCategorys = CreateObjects(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 InvestmentCategory ", e);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
#region Cache Footer
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
return InvestmentCategorys;
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region GetbyProjectid(By ID)
|
|||
|
|
|||
|
public InvestmentCategory GetbyProjectid(int ID)
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
|
|||
|
InvestmentCategory InvestmentCategory = new InvestmentCategory();
|
|||
|
if (InvestmentCategory != null)
|
|||
|
return InvestmentCategory;
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader dr = new DataReader(InvestmentCategoryDA.GetbyProjectid(tc, ID));
|
|||
|
if (dr.Read())
|
|||
|
{
|
|||
|
InvestmentCategory = this.CreateObject<InvestmentCategory>(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
|
|||
|
}
|
|||
|
|
|||
|
#region Cache Footer
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
return InvestmentCategory;
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
public bool IsInvestmentCategoryUsed(int categoryid)
|
|||
|
{
|
|||
|
bool found = false;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader dataReader = new DataReader(InvestmentDA.Get(tc, categoryid));
|
|||
|
if (dataReader.Read())
|
|||
|
found = true;
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
return found;
|
|||
|
}
|
|||
|
|
|||
|
#region IsExist
|
|||
|
|
|||
|
public bool IsExist(string code, int fundtypeid)
|
|||
|
{
|
|||
|
bool exists = false;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
exists = InvestmentCategoryDA.IsExist(tc, code, fundtypeid);
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
throw new ServiceException("Failed to Check by code" + e.Message, e);
|
|||
|
}
|
|||
|
|
|||
|
return exists;
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Delete
|
|||
|
|
|||
|
public void Delete(int id)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
InvestmentCategoryDA.Delete(tc, id);
|
|||
|
//InvestmentCategoryDA.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 InvestmentCategory", e);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Insert
|
|||
|
|
|||
|
public void Save(InvestmentCategory investmentCategory)
|
|||
|
{
|
|||
|
InvestmentCategory oInvestmentCategory = new InvestmentCategory();
|
|||
|
oInvestmentCategory = investmentCategory;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
|
|||
|
if (oInvestmentCategory.IsNew)
|
|||
|
{
|
|||
|
int id = tc.GenerateID("InvestmentCategory", "InvestmentCategoryID");
|
|||
|
base.SetObjectID(oInvestmentCategory, (id));
|
|||
|
InvestmentCategoryDA.Insert(tc, oInvestmentCategory);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
InvestmentCategoryDA.Update(tc, oInvestmentCategory);
|
|||
|
}
|
|||
|
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
//#region UpdateActivity
|
|||
|
//internal void UpdateActivityInfo(TransactionContext tc,ID ActivityID, ID RecordID)
|
|||
|
//{
|
|||
|
// try
|
|||
|
// {
|
|||
|
// InvestmentCategoryDA.UpdateActivityID(tc, ActivityID, RecordID);
|
|||
|
// }
|
|||
|
// catch (Exception e)
|
|||
|
// {
|
|||
|
// #region Handle Exception
|
|||
|
// if (tc != null)
|
|||
|
// tc.HandleError();
|
|||
|
// ExceptionLog.Write(e);
|
|||
|
|
|||
|
// throw new ServiceException(e.Message, e);
|
|||
|
// #endregion
|
|||
|
// }
|
|||
|
//}
|
|||
|
|
|||
|
//#endregion
|
|||
|
|
|||
|
#region GetTable
|
|||
|
|
|||
|
public DataTable GetTable(int fundtypeid)
|
|||
|
{
|
|||
|
DataTable dTbl = new DataTable("InvestmentCategory");
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
IDataReader ir = InvestmentCategoryDA.Get(tc, fundtypeid);
|
|||
|
dTbl.Load(ir);
|
|||
|
ir.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 dTbl;
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|