363 lines
12 KiB
C#
363 lines
12 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Data;
|
|||
|
using HRM.BO;
|
|||
|
using Ease.Core.Model;
|
|||
|
using Ease.Core.DataAccess;
|
|||
|
using Ease.Core.Utility;
|
|||
|
|
|||
|
namespace HRM.DA
|
|||
|
{
|
|||
|
public class BadliDailyPaymentService : ServiceTemplate
|
|||
|
{
|
|||
|
public BadliDailyPaymentService()
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
private void MapObject(BadliDailyPayment oBadliDailyPayment, DataReader oReader)
|
|||
|
{
|
|||
|
base.SetObjectID(oBadliDailyPayment, (oReader.GetInt32("BadliPaymentID").Value));
|
|||
|
oBadliDailyPayment.ItemID = oReader.GetInt32("ItemID", 0);
|
|||
|
oBadliDailyPayment.ItemType = (enumPayrollComponentType)oReader.GetInt32("ItemType").Value;
|
|||
|
oBadliDailyPayment.BadliRecruitID = oReader.GetInt32("BADLIDAILYRECRUITID", 0);
|
|||
|
oBadliDailyPayment.Description = oReader.GetString("Description");
|
|||
|
oBadliDailyPayment.PaidDate = oReader.GetDateTime("PaidDate").Value;
|
|||
|
oBadliDailyPayment.Amount = oReader.GetDouble("Amount").Value;
|
|||
|
oBadliDailyPayment.ChangedAmount = oReader.GetDouble("ChangedAmount").Value;
|
|||
|
oBadliDailyPayment.BadliProcessID = oReader.GetInt32("BadliProcessID", 0);
|
|||
|
oBadliDailyPayment.CreatedBy = oReader.GetInt32("CreatedBy", 0);
|
|||
|
oBadliDailyPayment.CreatedDate = oReader.GetDateTime("CreationDate").Value;
|
|||
|
oBadliDailyPayment.ModifiedBy = oReader.GetInt32("ModifiedBy", 0);
|
|||
|
oBadliDailyPayment.ModifiedDate = oReader.GetDateTime("ModifiedDate");
|
|||
|
this.SetObjectState(oBadliDailyPayment, Ease.Core.ObjectState.Saved);
|
|||
|
}
|
|||
|
|
|||
|
protected override T CreateObject<T>(DataReader oReader)
|
|||
|
{
|
|||
|
BadliDailyPayment oBadliDailyPayment = new BadliDailyPayment();
|
|||
|
MapObject(oBadliDailyPayment, oReader);
|
|||
|
return oBadliDailyPayment as T;
|
|||
|
}
|
|||
|
|
|||
|
public List<BadliDailyPayment> Get()
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader dr = new DataReader(BadliDailyPaymentDA.Get(tc));
|
|||
|
var oBadliDailyPayments = this.CreateObjects<BadliDailyPayment>(dr);
|
|||
|
dr.Close();
|
|||
|
tc.End();
|
|||
|
return oBadliDailyPayments;
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public List<BadliDailyPayment> Get(int badliRecruitId)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader dr = new DataReader(BadliDailyPaymentDA.Get(tc, badliRecruitId));
|
|||
|
var oBadliDailyPayments = this.CreateObjects<BadliDailyPayment>(dr);
|
|||
|
dr.Close();
|
|||
|
tc.End();
|
|||
|
return oBadliDailyPayments;
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public List<BadliDailyPayment> Get(DateTime paymentDate)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader dr = new DataReader(BadliDailyPaymentDA.Get(tc, paymentDate));
|
|||
|
var oBadliDailyPayments = this.CreateObjects<BadliDailyPayment>(dr);
|
|||
|
dr.Close();
|
|||
|
tc.End();
|
|||
|
return oBadliDailyPayments;
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public List<BadliDailyPayment> Get(int employeeID, DateTime paymentDate)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader dr = new DataReader(BadliDailyPaymentDA.Get(tc, employeeID, paymentDate));
|
|||
|
var oBadliDailyPayments = this.CreateObjects<BadliDailyPayment>(dr);
|
|||
|
dr.Close();
|
|||
|
tc.End();
|
|||
|
return oBadliDailyPayments;
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public List<BadliDailyPayment> Get(DateTime fromDate, DateTime todate, string badliRecruitId)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader dr = new DataReader(BadliDailyPaymentDA.Get(tc, fromDate, todate, badliRecruitId));
|
|||
|
var oBadliDailyPayments = this.CreateObjects<BadliDailyPayment>(dr);
|
|||
|
dr.Close();
|
|||
|
tc.End();
|
|||
|
return oBadliDailyPayments;
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public List<BadliDailyPayment> Get(DateTime fromDate, DateTime todate)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader dr = new DataReader(BadliDailyPaymentDA.Get(tc, fromDate, todate));
|
|||
|
var oBadliDailyPayments = this.CreateObjects<BadliDailyPayment>(dr);
|
|||
|
dr.Close();
|
|||
|
tc.End();
|
|||
|
return oBadliDailyPayments;
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public DataSet GetBadliWeeklyPaymentSheet(string ids, DateTime fromdate, DateTime toDate)
|
|||
|
{
|
|||
|
DataSet oWeeklyPaymentSheet = new DataSet();
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
oWeeklyPaymentSheet = BadliDailyPaymentDA.GetBadliWeeklyPaymentSheet(tc, ids, fromdate, toDate);
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
return oWeeklyPaymentSheet;
|
|||
|
}
|
|||
|
|
|||
|
public List<BadliDailyPayment> Get(DateTime paiddate, string badliRecruitId)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader dr = new DataReader(BadliDailyPaymentDA.Get(tc, paiddate, badliRecruitId));
|
|||
|
var oBadliDailyPayments = this.CreateObjects<BadliDailyPayment>(dr);
|
|||
|
dr.Close();
|
|||
|
tc.End();
|
|||
|
return oBadliDailyPayments;
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void Save(List<BadliDailyPayment> oBadliDailyPayments)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
foreach (BadliDailyPayment ac in oBadliDailyPayments)
|
|||
|
{
|
|||
|
if (ac.IsNew)
|
|||
|
{
|
|||
|
if (BadliDailyPaymentDA.IsExist(tc, ac.BadliRecruitID, ac.ItemID, ac.ItemType, ac.PaidDate))
|
|||
|
{
|
|||
|
BadliDailyPaymentDA.Delete(tc, ac);
|
|||
|
}
|
|||
|
|
|||
|
int id = tc.GenerateID("BadliPayment", "BadliPaymentID");
|
|||
|
base.SetObjectID(ac, (id));
|
|||
|
BadliDailyPaymentDA.Insert(tc, ac);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
BadliDailyPaymentDA.Update(tc, ac);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
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 Save(List<BadliDailyPayment> oBadliDailyPayments, TransactionContext tc)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
foreach (BadliDailyPayment ac in oBadliDailyPayments)
|
|||
|
{
|
|||
|
if (ac.IsNew)
|
|||
|
{
|
|||
|
if (BadliDailyPaymentDA.IsExist(tc, ac.BadliRecruitID, ac.ItemID, ac.ItemType, ac.PaidDate))
|
|||
|
{
|
|||
|
BadliDailyPaymentDA.Delete(tc, ac);
|
|||
|
}
|
|||
|
|
|||
|
int id = tc.GenerateID("BadliPayment", "BadliPaymentID");
|
|||
|
base.SetObjectID(ac, (id));
|
|||
|
BadliDailyPaymentDA.Insert(tc, ac);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
BadliDailyPaymentDA.Update(tc, ac);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void SaveAuto(List<BadliDailyPayment> oBadliDailyPayments, List<BadliDailyRecruit> oBadliDailyRecruits)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
foreach (BadliDailyPayment ac in oBadliDailyPayments)
|
|||
|
{
|
|||
|
if (ac.IsNew)
|
|||
|
{
|
|||
|
if (BadliDailyPaymentDA.IsExist(tc, ac.BadliRecruitID, ac.ItemID, ac.ItemType, ac.PaidDate))
|
|||
|
{
|
|||
|
BadliDailyPaymentDA.Delete(tc, ac);
|
|||
|
}
|
|||
|
|
|||
|
int id = tc.GenerateID("BadliPayment", "BadliPaymentID");
|
|||
|
base.SetObjectID(ac, (id));
|
|||
|
BadliDailyPaymentDA.Insert(tc, ac);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
BadliDailyPaymentDA.Update(tc, ac);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
(new BadliDailyRecruitService()).Save(oBadliDailyRecruits, tc);
|
|||
|
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|