315 lines
8.8 KiB
C#
315 lines
8.8 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;
|
|
|
|
namespace HRM.DA
|
|
{
|
|
#region Bonus Service
|
|
|
|
public class BonusService : ServiceTemplate, IBonusService
|
|
{
|
|
public BonusService()
|
|
{
|
|
}
|
|
|
|
private void MapObject(Bonus oBonus, DataReader oReader)
|
|
{
|
|
base.SetObjectID(oBonus, (oReader.GetInt32("BonusID").Value));
|
|
oBonus.Code = oReader.GetString("code");
|
|
oBonus.Name = oReader.GetString("name");
|
|
oBonus.NameInBangla = oReader.GetString("nameinbangla", true, null);
|
|
oBonus.Sequence = oReader.GetInt32("SequenceNo").Value;
|
|
oBonus.Status = (EnumStatus)oReader.GetInt32("Status").Value;
|
|
oBonus.CreatedBy = oReader.GetInt32("CreatedBy", 0);
|
|
oBonus.CreatedDate = oReader.GetDateTime("CreatedDate").HasValue
|
|
? oReader.GetDateTime("CreatedDate").Value
|
|
: DateTime.MinValue;
|
|
oBonus.ModifiedBy = oReader.GetInt32("ModifiedBy", 0);
|
|
oBonus.ModifiedDate = oReader.GetDateTime("ModifiedDate").HasValue
|
|
? oReader.GetDateTime("ModifiedDate").Value
|
|
: (DateTime?)null;
|
|
oBonus.PayrollTypeID = oReader.GetInt32("payrollTypeID", 0);
|
|
this.SetObjectState(oBonus, Ease.Core.ObjectState.Saved);
|
|
}
|
|
|
|
protected override T CreateObject<T>(DataReader oReader)
|
|
{
|
|
Bonus oBonus = new Bonus();
|
|
MapObject(oBonus, oReader);
|
|
return oBonus as T;
|
|
}
|
|
|
|
protected Bonus CreateObject(DataReader oReader)
|
|
{
|
|
Bonus oBonus = new Bonus();
|
|
MapObject(oBonus, oReader);
|
|
return oBonus;
|
|
}
|
|
|
|
#region Service implementation
|
|
|
|
public Bonus Get(int id)
|
|
{
|
|
Bonus oBonus = new Bonus();
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(BonusDA.Get(tc, id));
|
|
if (oreader.Read())
|
|
{
|
|
oBonus = this.CreateObject<Bonus>(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 oBonus;
|
|
}
|
|
|
|
public List<Bonus> Get(EnumStatus status, int payrollTypeID)
|
|
{
|
|
List<Bonus> bonuss = null;
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(BonusDA.Get(tc, status, payrollTypeID));
|
|
bonuss = this.CreateObjects<Bonus>(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 bonuss;
|
|
}
|
|
|
|
public List<Bonus> GetParameterizedBonus(EnumStatus status, int payrollTypeID)
|
|
{
|
|
List<Bonus> bonuss = null;
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(BonusDA.GetParameterizedBonus(tc, status, payrollTypeID));
|
|
bonuss = this.CreateObjects<Bonus>(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 bonuss;
|
|
}
|
|
|
|
public List<Bonus> GetActiveProccessedBonus(int payrollTypeID, DateTime bonusMonth)
|
|
{
|
|
List<Bonus> bonuses = new List<Bonus>();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(BonusDA.GetActiveProccessedBonus(tc, payrollTypeID, bonusMonth));
|
|
bonuses = this.CreateObjects<Bonus>(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 bonuses;
|
|
}
|
|
|
|
public int Save(Bonus oBonus)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
if (oBonus.IsNew)
|
|
{
|
|
int id = tc.GenerateID("Bonus", "BonusID");
|
|
base.SetObjectID(oBonus, (id));
|
|
int seqNo = tc.GenerateID("Bonus", "SequenceNo");
|
|
oBonus.Sequence = seqNo;
|
|
BonusDA.Insert(tc, oBonus);
|
|
}
|
|
else
|
|
{
|
|
BonusDA.Update(tc, oBonus);
|
|
}
|
|
|
|
tc.End();
|
|
return oBonus.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);
|
|
BonusDA.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 List<Bonus> GetAllBonus(int payrollTypeID, EnumStatus status, string code, string name)
|
|
{
|
|
List<Bonus> bonus = new List<Bonus>();
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(BonusDA.GetAllBonus(tc, payrollTypeID, status, code, name));
|
|
bonus = this.CreateObjects<Bonus>(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 bonus;
|
|
}
|
|
public DataSet GetCCWiseBonusSummary(DateTime bMonthDate, string bonus)
|
|
{
|
|
DataSet obonus = new DataSet();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
obonus = BonusDA.GetCCWiseBonusSummary(tc, bMonthDate, bonus);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
#endregion
|
|
}
|
|
return obonus;
|
|
}
|
|
|
|
public DataSet GetCCWiseBonus(DateTime bMonthDate, string bonus)
|
|
{
|
|
DataSet obonus = new DataSet();
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
obonus = BonusDA.GetCCWiseBonus(tc, bMonthDate, bonus);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
#endregion
|
|
}
|
|
return obonus;
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
|
|
#endregion
|
|
} |