233 lines
7.1 KiB
C#
233 lines
7.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using Ease.CoreV35.Model;
|
|
using Payroll.BO;
|
|
using Ease.CoreV35.DataAccess;
|
|
using Payroll.Service.Budget.DA;
|
|
using System.Data;
|
|
using Ease.CoreV35;
|
|
|
|
namespace Payroll.Service
|
|
{
|
|
public class AppraisalPointRatingService : ServiceTemplate, IAppraisalPointRatingService
|
|
{
|
|
|
|
#region Object Mapping
|
|
|
|
private void MapObject(AppraisalPointRating oAppraisalPointRating, DataReader oReader)
|
|
{
|
|
SetObjectID(oAppraisalPointRating, oReader.GetID("AppraisalPointRatingID"));
|
|
oAppraisalPointRating.AppraisalPointID = oReader.GetID("AppraisalPointID");
|
|
oAppraisalPointRating.MaxParcent = (double)oReader.GetDouble("MaxParcent");
|
|
oAppraisalPointRating.MinParcent = (double)oReader.GetDouble("MinParcent");
|
|
oAppraisalPointRating.Parcent = (double)oReader.GetDouble("Parcent");
|
|
oAppraisalPointRating.AppraisalYear = (DateTime)oReader.GetDateTime("AppraisalYear");
|
|
oAppraisalPointRating.Status = (EnumStatus)oReader.GetInt32("Status");
|
|
|
|
if (oReader.GetDateTime("CreatedDate") != null)
|
|
{
|
|
oAppraisalPointRating.CreatedDate = (DateTime)oReader.GetDateTime("CreatedDate");
|
|
}
|
|
else oAppraisalPointRating.CreatedDate = DateTime.MinValue;
|
|
|
|
if (oReader.GetDateTime("ModifiedDate") != null)
|
|
{
|
|
oAppraisalPointRating.ModifiedDate = (DateTime)oReader.GetDateTime("ModifiedDate");
|
|
}
|
|
else oAppraisalPointRating.ModifiedDate = null;
|
|
|
|
if (oReader.GetInt32("CreatedBy") != null)
|
|
{
|
|
oAppraisalPointRating.CreatedBy = oReader.GetID("CreatedBy");
|
|
}
|
|
else oAppraisalPointRating.CreatedBy = null;
|
|
|
|
if (oReader.GetInt32("ModifiedBy") != null)
|
|
{
|
|
oAppraisalPointRating.ModifiedBy = oReader.GetID("ModifiedBy");
|
|
}
|
|
else oAppraisalPointRating.ModifiedBy = null;
|
|
|
|
this.SetObjectState(oAppraisalPointRating, ObjectState.Saved);
|
|
|
|
|
|
}
|
|
|
|
protected override T CreateObject<T>(DataReader oReader)
|
|
{
|
|
AppraisalPointRating oAppraisalPointRating = new AppraisalPointRating();
|
|
MapObject(oAppraisalPointRating, oReader);
|
|
return oAppraisalPointRating as T;
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region Service Implementation
|
|
|
|
|
|
public ObjectsTemplate<AppraisalPointRating> Get()
|
|
{
|
|
ObjectsTemplate<AppraisalPointRating> oAppraisalPointRating = null;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(AppraisalPointRatingDA.Get(tc));
|
|
oAppraisalPointRating = this.CreateObjects<AppraisalPointRating>(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 oAppraisalPointRating;
|
|
}
|
|
|
|
|
|
public ObjectsTemplate<AppraisalPointRating> Get(DateTime Appyear)
|
|
{
|
|
ObjectsTemplate<AppraisalPointRating> oAppraisalPointRating = null;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(AppraisalPointRatingDA.Get(tc, Appyear));
|
|
oAppraisalPointRating = this.CreateObjects<AppraisalPointRating>(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 oAppraisalPointRating;
|
|
}
|
|
|
|
|
|
|
|
public ID Save(AppraisalPointRating item)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
if (item.IsNew)
|
|
{
|
|
int id = tc.GenerateID("AppraisalPointRating", "AppraisalPointRatingID");
|
|
SetObjectID(item, ID.FromInteger(id));
|
|
AppraisalPointRatingDA.Insert(tc, item);
|
|
}
|
|
|
|
else
|
|
{
|
|
AppraisalPointRatingDA.Update(tc, item);
|
|
}
|
|
tc.End();
|
|
|
|
return item.ID;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
|
|
public void Update(AppraisalPointRating item)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
AppraisalPointRatingDA.Update(tc, item);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public void Delete(ID id)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
AppraisalPointRatingDA.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
|
|
}
|
|
}
|
|
|
|
|
|
public bool CheckAppraisalPointRating(ID id, DateTime year)
|
|
{
|
|
bool flag = true;
|
|
DataSet ds = null;
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
ds = AppraisalPointRatingDA.CheckAppraisalPointRating(tc, id,year);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
#endregion
|
|
}
|
|
if (ds.Tables[0].Rows.Count >= 1)
|
|
{
|
|
flag = false;
|
|
}
|
|
return flag;
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
}
|