809 lines
27 KiB
C#
809 lines
27 KiB
C#
|
using System;
|
|||
|
using System.Data;
|
|||
|
using System.Linq;
|
|||
|
using Ease.CoreV35;
|
|||
|
using Ease.CoreV35.Model;
|
|||
|
using Ease.CoreV35.DataAccess;
|
|||
|
using System.Collections.Generic;
|
|||
|
using Payroll.BO;
|
|||
|
using Ease.CoreV35.Caching;
|
|||
|
|
|||
|
namespace Payroll.Service
|
|||
|
{
|
|||
|
#region EmployeeGradeSalary Service
|
|||
|
[Serializable]
|
|||
|
public class EmployeeGradeSalaryService : ServiceTemplate, IEmployeeGradeSalaryService
|
|||
|
{
|
|||
|
#region Private functions and declaration
|
|||
|
Cache _cache = new Cache(typeof(EmployeeGradeSalary));
|
|||
|
|
|||
|
#endregion
|
|||
|
public EmployeeGradeSalaryService() { }
|
|||
|
|
|||
|
private void MapObject(EmployeeGradeSalary oEmployeeGradeSalary, DataReader oReader)
|
|||
|
{
|
|||
|
base.SetObjectID(oEmployeeGradeSalary, oReader.GetID("EmpGradeSalaryID"));
|
|||
|
oEmployeeGradeSalary.EmployeeSerial = oReader.GetInt32("GradeSalaryID").Value;
|
|||
|
oEmployeeGradeSalary.EmployeeID = oReader.GetID("employeeID");
|
|||
|
oEmployeeGradeSalary.TillDate = oReader.GetDateTime("tillDate");
|
|||
|
oEmployeeGradeSalary.EffectDate = oReader.GetDateTime("effectDate").Value;
|
|||
|
oEmployeeGradeSalary.GradeID = oReader.GetID("gradeID");
|
|||
|
oEmployeeGradeSalary.BasicSalary = oReader.GetDouble("basicSalary").Value;
|
|||
|
oEmployeeGradeSalary.GrossSalary = oReader.GetDouble("grossSalary").Value;
|
|||
|
oEmployeeGradeSalary.PayScaleDetailID = oReader.GetID("payScaleID");
|
|||
|
oEmployeeGradeSalary.ArrearType = (EnumArrearType)oReader.GetInt32("arrearInfo").Value;
|
|||
|
oEmployeeGradeSalary.GradeSalaryTypeID = oReader.GetID("gradeSalaryTypeID");
|
|||
|
oEmployeeGradeSalary.CreatedBy = oReader.GetID("CreatedBy");
|
|||
|
oEmployeeGradeSalary.CreatedDate = oReader.GetDateTime("CreatedDate").Value;
|
|||
|
oEmployeeGradeSalary.ModifiedBy = oReader.GetID("ModifiedBy");
|
|||
|
oEmployeeGradeSalary.ModifiedDate = oReader.GetDateTime("ModifiedDate");
|
|||
|
this.SetObjectState(oEmployeeGradeSalary, Ease.CoreV35.ObjectState.Saved);
|
|||
|
}
|
|||
|
protected override T CreateObject<T>(DataReader oReader)
|
|||
|
{
|
|||
|
EmployeeGradeSalary oEmployeeGradeSalary = new EmployeeGradeSalary();
|
|||
|
MapObject(oEmployeeGradeSalary, oReader);
|
|||
|
return oEmployeeGradeSalary as T;
|
|||
|
}
|
|||
|
protected EmployeeGradeSalary CreateObject(DataReader oReader)
|
|||
|
{
|
|||
|
EmployeeGradeSalary oEmployeeGradeSalary = new EmployeeGradeSalary();
|
|||
|
MapObject(oEmployeeGradeSalary, oReader);
|
|||
|
return oEmployeeGradeSalary;
|
|||
|
}
|
|||
|
public void Save2(TransactionContext tc, ObjectsTemplate<EmployeeGradeSalary> itemsToSave)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
|
|||
|
foreach (EmployeeGradeSalary item in itemsToSave)
|
|||
|
{
|
|||
|
if (item.IsNew)
|
|||
|
{
|
|||
|
int id = tc.GenerateID("GRADESALARYASSIGNMENT", "EmpGradeSalaryID");
|
|||
|
base.SetObjectID(item, ID.FromInteger(id));
|
|||
|
id = tc.GenerateID("GRADESALARYASSIGNMENT", "GradeSalaryID", SQLParser.MakeSQL("WHERE EmployeeID=%n", item.EmployeeID.Integer));
|
|||
|
item.EmployeeSerial = id;
|
|||
|
EmployeeGradeSalaryDA.Insert(tc, item);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
EmployeeGradeSalaryDA.Update(tc, item);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
#region Service implementation
|
|||
|
|
|||
|
public EmployeeGradeSalary Get(ID employeeid, DateTime effectDate, EnumArrearType type)
|
|||
|
{
|
|||
|
EmployeeGradeSalary oEmployeeGradeSalary = null;
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(EmployeeGradeSalaryDA.Get(tc, employeeid, effectDate, type));
|
|||
|
if (oreader.Read())
|
|||
|
{
|
|||
|
oEmployeeGradeSalary = this.CreateObject<EmployeeGradeSalary>(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 oEmployeeGradeSalary;
|
|||
|
}
|
|||
|
public ObjectsTemplate<EmployeeGradeSalary> Get(DateTime effectDate, EnumArrearType type)
|
|||
|
{
|
|||
|
ObjectsTemplate<EmployeeGradeSalary> employeeGradeSalarys = null;
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader dr = new DataReader(EmployeeGradeSalaryDA.Get(tc, effectDate, type));
|
|||
|
employeeGradeSalarys = this.CreateObjects<EmployeeGradeSalary>(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 employeeGradeSalarys;
|
|||
|
}
|
|||
|
|
|||
|
public EmployeeGradeSalary Get(ID employeeid, DateTime effectDate, int payrollTypeID)
|
|||
|
{
|
|||
|
EmployeeGradeSalary oEmployeeGradeSalary = null;
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(EmployeeGradeSalaryDA.Get(tc, employeeid, effectDate, payrollTypeID));
|
|||
|
if (oreader.Read())
|
|||
|
{
|
|||
|
oEmployeeGradeSalary = this.CreateObject<EmployeeGradeSalary>(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 oEmployeeGradeSalary;
|
|||
|
}
|
|||
|
|
|||
|
public EmployeeGradeSalary Get(TransactionContext tc, ID employeeid, DateTime effectDate, EnumArrearType type)
|
|||
|
{
|
|||
|
EmployeeGradeSalary oEmployeeGradeSalary = null;
|
|||
|
|
|||
|
try
|
|||
|
{
|
|||
|
DataReader oreader = new DataReader(EmployeeGradeSalaryDA.Get(tc, employeeid, effectDate, type));
|
|||
|
if (oreader.Read())
|
|||
|
{
|
|||
|
oEmployeeGradeSalary = this.CreateObject<EmployeeGradeSalary>(oreader);
|
|||
|
}
|
|||
|
oreader.Close();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
return oEmployeeGradeSalary;
|
|||
|
}
|
|||
|
|
|||
|
public EmployeeGradeSalary GetMax(int employeeID, EnumArrearType type)
|
|||
|
{
|
|||
|
EmployeeGradeSalary oEmployeeGradeSalary = null;
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(EmployeeGradeSalaryDA.GetMax(tc, employeeID, type));
|
|||
|
if (oreader.Read())
|
|||
|
{
|
|||
|
oEmployeeGradeSalary = this.CreateObject<EmployeeGradeSalary>(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 oEmployeeGradeSalary;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
public EmployeeGradeSalary GetbyID(TransactionContext tc, ID EmpGradeSalaryID)
|
|||
|
{
|
|||
|
EmployeeGradeSalary oEmployeeGradeSalary = null;
|
|||
|
|
|||
|
try
|
|||
|
{
|
|||
|
DataReader oreader = new DataReader(EmployeeGradeSalaryDA.GetbyID(tc, EmpGradeSalaryID));
|
|||
|
if (oreader.Read())
|
|||
|
{
|
|||
|
oEmployeeGradeSalary = this.CreateObject<EmployeeGradeSalary>(oreader);
|
|||
|
}
|
|||
|
oreader.Close();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
return oEmployeeGradeSalary;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
public DataSet GetEmpBasicGrade(DateTime dEffectDate, DateTime dEffectDate2, int payrollTypeID)
|
|||
|
{
|
|||
|
DataSet oEmpBasicGrades = new DataSet();
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
oEmpBasicGrades = EmployeeGradeSalaryDA.GetEmpBasicGrade(tc, dEffectDate, dEffectDate2, payrollTypeID);
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
return oEmpBasicGrades;
|
|||
|
}
|
|||
|
|
|||
|
public DataSet GetEmpPrvBasicGrade(DateTime dEffectDate, int payrollTypeID)
|
|||
|
{
|
|||
|
DataSet oEmpBasicGrades = new DataSet();
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
oEmpBasicGrades = EmployeeGradeSalaryDA.GetEmpPrvBasicGrade(tc, dEffectDate, payrollTypeID);
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
return oEmpBasicGrades;
|
|||
|
}
|
|||
|
|
|||
|
public DataSet GetmultipleTilldatedemp()
|
|||
|
{
|
|||
|
DataSet oEmpBasicGrades = new DataSet();
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
oEmpBasicGrades = EmployeeGradeSalaryDA.GetmultipleTilldatedemp(tc);
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
return oEmpBasicGrades;
|
|||
|
}
|
|||
|
public DataSet GetmultipleTilldatedemp(string sEmpIDs)
|
|||
|
{
|
|||
|
DataSet oEmpBasicGrades = new DataSet();
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
oEmpBasicGrades = EmployeeGradeSalaryDA.GetmultipleTilldatedemp(tc, sEmpIDs);
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
return oEmpBasicGrades;
|
|||
|
}
|
|||
|
public DataSet GetOldGrd(string sEmpIDs)
|
|||
|
{
|
|||
|
DataSet oEmpBasicGrades = new DataSet();
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
oEmpBasicGrades = EmployeeGradeSalaryDA.GetOldGrd(tc, sEmpIDs);
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
return oEmpBasicGrades;
|
|||
|
}
|
|||
|
|
|||
|
public ObjectsTemplate<EmployeeGradeSalary> Get(int employeeID)
|
|||
|
{
|
|||
|
ObjectsTemplate<EmployeeGradeSalary> employeeGradeSalarys = null;
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader dr = new DataReader(EmployeeGradeSalaryDA.Get(tc, employeeID));
|
|||
|
employeeGradeSalarys = this.CreateObjects<EmployeeGradeSalary>(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 employeeGradeSalarys;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
public ObjectsTemplate<EmployeeGradeSalary> Get()
|
|||
|
{
|
|||
|
ObjectsTemplate<EmployeeGradeSalary> employeeGradeSalarys = null;
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader dr = new DataReader(EmployeeGradeSalaryDA.Get(tc));
|
|||
|
employeeGradeSalarys = this.CreateObjects<EmployeeGradeSalary>(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 employeeGradeSalarys;
|
|||
|
}
|
|||
|
|
|||
|
public ObjectsTemplate<EmployeeGradeSalary> GetCurrMonthSalaryItems(DateTime nextPayProcessDate)
|
|||
|
{
|
|||
|
ObjectsTemplate<EmployeeGradeSalary> employeeGradeSalarys = null;
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader dr = new DataReader(EmployeeGradeSalaryDA.GetCurrMonthSalaryItems(tc, nextPayProcessDate));
|
|||
|
employeeGradeSalarys = this.CreateObjects<EmployeeGradeSalary>(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 employeeGradeSalarys;
|
|||
|
}
|
|||
|
|
|||
|
public ObjectsTemplate<EmployeeGradeSalary> GetArrearPaidItems(ID emlpoyeeid, DateTime tillDateFrom)
|
|||
|
{
|
|||
|
ObjectsTemplate<EmployeeGradeSalary> employeeGradeSalarys = null;
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader dr = new DataReader(EmployeeGradeSalaryDA.GetArrearPaidItems(tc, emlpoyeeid, tillDateFrom));
|
|||
|
employeeGradeSalarys = this.CreateObjects<EmployeeGradeSalary>(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 employeeGradeSalarys;
|
|||
|
}
|
|||
|
|
|||
|
public ObjectsTemplate<EmployeeGradeSalary> GetArrearItems()
|
|||
|
{
|
|||
|
ObjectsTemplate<EmployeeGradeSalary> employeeGradeSalarys = null;
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader dr = new DataReader(EmployeeGradeSalaryDA.GetArrearItems(tc));
|
|||
|
employeeGradeSalarys = this.CreateObjects<EmployeeGradeSalary>(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 employeeGradeSalarys;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
public ObjectsTemplate<EmployeeGradeSalary> GetbyTillDate(int employeeId,
|
|||
|
DateTime tillDateFrom, DateTime tillDateTo)
|
|||
|
{
|
|||
|
ObjectsTemplate<EmployeeGradeSalary> employeeGradeSalarys = null;
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader dr = new DataReader(EmployeeGradeSalaryDA.GetbyTillDate(tc, employeeId, tillDateFrom, tillDateTo));
|
|||
|
employeeGradeSalarys = this.CreateObjects<EmployeeGradeSalary>(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 employeeGradeSalarys;
|
|||
|
}
|
|||
|
|
|||
|
public ObjectsTemplate<EmployeeGradeSalary> GetbyEffectDate(ID employeeId,
|
|||
|
DateTime effectDateFrom, DateTime effectDateTo)
|
|||
|
{
|
|||
|
ObjectsTemplate<EmployeeGradeSalary> employeeGradeSalarys = null;
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader dr = new DataReader(EmployeeGradeSalaryDA.GetbyEffectDate(tc, employeeId, effectDateFrom, effectDateTo));
|
|||
|
employeeGradeSalarys = this.CreateObjects<EmployeeGradeSalary>(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 employeeGradeSalarys;
|
|||
|
}
|
|||
|
|
|||
|
public void Save(ObjectsTemplate<EmployeeGradeSalary> itemsToSave)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
this.Save(tc, itemsToSave);
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
public void Save(TransactionContext tc, ObjectsTemplate<EmployeeGradeSalary> itemsToSave)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
|
|||
|
foreach (EmployeeGradeSalary item in itemsToSave)
|
|||
|
{
|
|||
|
if (item.IsNew)
|
|||
|
{
|
|||
|
int id = tc.GenerateID("GRADESALARYASSIGNMENT", "EmpGradeSalaryID");
|
|||
|
base.SetObjectID(item, ID.FromInteger(id));
|
|||
|
id = tc.GenerateID("GRADESALARYASSIGNMENT", "GradeSalaryID", SQLParser.MakeSQL("WHERE EmployeeID=%n", item.EmployeeID.Integer));
|
|||
|
item.EmployeeSerial = id;
|
|||
|
EmployeeGradeSalaryDA.Insert(tc, item);
|
|||
|
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
EmployeeGradeSalaryDA.Update(tc, item);
|
|||
|
}
|
|||
|
EmployeeDA.UpdateOTFlag(tc, item.EmployeeID.Integer);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
bool bvalid = ConfigurationManager.GetBoolValue("hrinterface", "gradefromhr", EnumConfigurationType.Logic);
|
|||
|
if (itemsToSave.Count > 0)
|
|||
|
{
|
|||
|
int employeeid = itemsToSave[itemsToSave.Count - 1].EmployeeID.Integer;
|
|||
|
int gradid = itemsToSave[itemsToSave.Count - 1].GradeID.Integer;
|
|||
|
if (bvalid == false)
|
|||
|
{
|
|||
|
EmployeeDA.UpdateGradeSalary(tc, employeeid, gradid,
|
|||
|
itemsToSave[itemsToSave.Count - 1].BasicSalary, itemsToSave[itemsToSave.Count - 1].GrossSalary);
|
|||
|
EmployeeDA.UpdateOTFlag(tc, employeeid);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
EmployeeDA.UpdateSalary(tc, employeeid,
|
|||
|
itemsToSave[itemsToSave.Count - 1].BasicSalary, itemsToSave[itemsToSave.Count - 1].GrossSalary);
|
|||
|
EmployeeDA.UpdateOTFlag(tc, employeeid);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
/// <summary>
|
|||
|
/// Arrer item delete
|
|||
|
/// </summary>
|
|||
|
/// <param name="gradeSalary"></param>
|
|||
|
public void Delete(EmployeeGradeSalary gradeSalary)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
|
|||
|
this.Delete(tc, gradeSalary);
|
|||
|
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(TransactionContext tc, EmployeeGradeSalary gradeSalary)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
|
|||
|
EmployeeGradeSalary updatedItem = null;
|
|||
|
if (gradeSalary.ArrearType != EnumArrearType.ToCalculate)
|
|||
|
{
|
|||
|
EmployeeGradeSalaryService osvr = new EmployeeGradeSalaryService();
|
|||
|
updatedItem = osvr.Get(tc, gradeSalary.EmployeeID,
|
|||
|
gradeSalary.EffectDate.AddDays(-1), EnumArrearType.NotPresent);
|
|||
|
}
|
|||
|
if (updatedItem != null)
|
|||
|
{
|
|||
|
updatedItem.TillDate = null;
|
|||
|
updatedItem.ModifiedBy = User.CurrentUser.ID;
|
|||
|
updatedItem.ModifiedDate = DateTime.Today;
|
|||
|
this.Delete(tc, updatedItem, gradeSalary);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
EmployeeGradeSalaryDA.Delete(tc, gradeSalary.EmployeeID, gradeSalary.EmployeeSerial);
|
|||
|
if (gradeSalary.ArrearType != EnumArrearType.ToCalculate)
|
|||
|
{
|
|||
|
bool bvalid = ConfigurationManager.GetBoolValue("hrinterface", "gradefromhr", EnumConfigurationType.Logic);
|
|||
|
if (bvalid == false)
|
|||
|
EmployeeDA.UpdateGradeSalary(tc, gradeSalary.EmployeeID.Integer,
|
|||
|
0, 0, 0);
|
|||
|
else
|
|||
|
EmployeeDA.UpdateSalary(tc, gradeSalary.EmployeeID.Integer, 0, 0);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void DeleteAll()
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
EmployeeGradeSalaryDA.DeleteAll(tc);
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void Delete(TransactionContext tc, EmployeeGradeSalary updateItem, EmployeeGradeSalary deletedItem)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
EmployeeGradeSalaryDA.Update(tc, updateItem);
|
|||
|
EmployeeGradeSalaryDA.Delete(tc, deletedItem.EmployeeID, deletedItem.EmployeeSerial);
|
|||
|
|
|||
|
bool bvalid = ConfigurationManager.GetBoolValue("hrinterface", "gradefromhr", EnumConfigurationType.Logic);
|
|||
|
if (bvalid == false)
|
|||
|
EmployeeDA.UpdateGradeSalary(tc, updateItem.EmployeeID.Integer,
|
|||
|
updateItem.GradeID.Integer, updateItem.BasicSalary, updateItem.GrossSalary);
|
|||
|
else
|
|||
|
EmployeeDA.UpdateSalary(tc, updateItem.EmployeeID.Integer, updateItem.BasicSalary, updateItem.GrossSalary);
|
|||
|
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void DeleteFromDate(TransactionContext tc, ID employeeId, DateTime effectDate, EnumArrearType arrtype)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
EmployeeGradeSalaryDA.DeleteOnDate(tc, employeeId, effectDate, arrtype);
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void DeleteFrom(int employeeId, DateTime fromdate)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
EmployeeGradeSalaryDA.DeleteFrom(tc, employeeId, fromdate);
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
}
|
|||
|
#endregion
|
|||
|
}
|