132 lines
6.0 KiB
C#
132 lines
6.0 KiB
C#
|
using System;
|
|||
|
using Payroll.BO;
|
|||
|
using System.Data;
|
|||
|
using System.Linq;
|
|||
|
using Ease.CoreV35.Model;
|
|||
|
using System.Data.SqlClient;
|
|||
|
using Ease.CoreV35.DataAccess;
|
|||
|
using System.Collections.Generic;
|
|||
|
using Ease.CoreV35.DataAccess.SQL;
|
|||
|
|
|||
|
namespace Payroll.Service
|
|||
|
{
|
|||
|
#region EmployeeHistoryDA
|
|||
|
|
|||
|
internal class EmployeeHistoryDA
|
|||
|
{
|
|||
|
#region Constructor
|
|||
|
|
|||
|
private EmployeeHistoryDA() { }
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Insert function
|
|||
|
|
|||
|
internal static void Insert(TransactionContext tc, EmployeeHistory item)
|
|||
|
{
|
|||
|
tc.ExecuteNonQuery("INSERT INTO EmployeeHistory(ID, employeeID, effectDate, endDate, paramID, remarks, CreatedBy, CreationDate)" +
|
|||
|
" VALUES(%n, %n, %d, %d, %n, %s, %n, %d)", item.ID.Integer, item.EmployeeID.Integer, item.EffectDate, DataReader.GetNullValue(item.EndDate), item.EmployeeStatus, item.Remarks, item.CreatedBy.Integer, item.CreatedDate);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Update function
|
|||
|
|
|||
|
internal static void Update(TransactionContext tc, EmployeeHistory item)
|
|||
|
{
|
|||
|
tc.ExecuteNonQuery("UPDATE EmployeeHistory SET employeeID=%n, effectDate=%d, endDate=%d, paramID=%n, remarks=%s, ModifiedBy=%n, ModifiedDate=%d" +
|
|||
|
" WHERE ID=%n", item.EmployeeID.Integer, item.EffectDate, DataReader.GetNullValue(item.EndDate), item.EmployeeStatus, item.Remarks, item.ModifiedBy.Integer, item.ModifiedDate, item.ID.Integer);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Get Function
|
|||
|
|
|||
|
internal static IDataReader Get(TransactionContext tc)
|
|||
|
{
|
|||
|
return tc.ExecuteReader("SELECT * FROM EmployeeHistory");
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
internal static IDataReader Get(TransactionContext tc, ID nID)
|
|||
|
{
|
|||
|
return tc.ExecuteReader("SELECT * FROM EmployeeHistory WHERE ID=%n", nID.Integer);
|
|||
|
}
|
|||
|
|
|||
|
internal static IDataReader GetByEmpID(TransactionContext tc, ID nEmpID)
|
|||
|
{
|
|||
|
return tc.ExecuteReader("SELECT * FROM EmployeeHistory WHERE EmployeeID=%n", nEmpID.Integer);
|
|||
|
}
|
|||
|
internal static IDataReader GetEmpLastHistory(TransactionContext tc, ID nEmpID)
|
|||
|
{
|
|||
|
return tc.ExecuteReader("SELECT * FROM EmployeeHistory WHERE EmployeeID=%n and effectDate=(select max(effectDate) FROM EmployeeHistory WHERE EmployeeID=%n)", nEmpID.Integer, nEmpID.Integer);
|
|||
|
}
|
|||
|
internal static DateTime GetByEmpIDandParam(TransactionContext tc, int nEmpID, EnumEmployeeStatus ParamID)
|
|||
|
{
|
|||
|
DateTime nDate = DateTime.MinValue;
|
|||
|
object obj = tc.ExecuteScalar("Select max(EffectDate) EffectDate FROM EmployeeHistory WHERE EmployeeID=%n AND ParamID=%n group by employeeid ", nEmpID, ParamID);
|
|||
|
if (obj != null)
|
|||
|
{
|
|||
|
nDate = Convert.ToDateTime(obj);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
nDate = DateTime.MinValue;
|
|||
|
}
|
|||
|
return nDate;
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
internal static DataSet GetEmpHistory(TransactionContext tc, DateTime dEffectDate, DateTime dEffectDate2, int payrollTypeID)
|
|||
|
{
|
|||
|
DataSet oEmpHistories = new DataSet();
|
|||
|
try
|
|||
|
{
|
|||
|
//oEmpHistories = tc.ExecuteDataSet("Select Emp.EMPLOYEENO,Emp.NAME,Deg.NAME AS DESIGNATION,G.DESCRIPTION as Grade,"
|
|||
|
// + " Emp.JOININGDATE,Emp.ENDOFCONTRACTDATE,EH.EFFECTDATE,EH.REMARKS as Comments,US.LoginID as CommitedBy,EH.CreationDate,EH.ParamID"
|
|||
|
// + " from EMPLOYEEHISTORY as EH,EMPLOYEE as Emp ,USERS as US,DESIGNATION as Deg,GRADES as G"
|
|||
|
// + " WHERE Emp.DESIGNATIONID=Deg.DESIGNATIONID"
|
|||
|
// + " AND Emp.GRADEID=G.GRADEID"
|
|||
|
// + " AND US.USERID=EH.CreatedBy"
|
|||
|
// + " AND Emp.ENDOFCONTRACTDATE between %d and %d"
|
|||
|
// + " AND Emp.EmpHistoryID =EH.ID AND Emp.EMPLOYEEID=EH.EMPLOYEEID AND Emp.PayrollTypeID=%n order by Emp.EMPLOYEENO",
|
|||
|
// GlobalFunctions.FirstDateOfMonth(dEffectDate), GlobalFunctions.LastDateOfMonth(dEffectDate),
|
|||
|
// SystemInformation.CurrentSysInfo.PayrollTypeID.Integer);
|
|||
|
|
|||
|
oEmpHistories = tc.ExecuteDataSet("Select Emp.Employeeid,eh.emplifecycleid,Eh.status, Emp.EMPLOYEENO,Emp.NAME,Deg.NAME AS DESIGNATION,G.DESCRIPTION as Grade, Emp.JOININGDATE,"
|
|||
|
+" Emp.ENDOFCONTRACTDATE,EH.EFFECTDATE,EH.REMARKS as Comments,US.LoginID as CommitedBy,EH.CreationDate"
|
|||
|
+" from EmpLifeCycle as EH,EMPLOYEE as Emp ,USERS as US,DESIGNATION as Deg,GRADES as G "
|
|||
|
+" WHERE Emp.DESIGNATIONID=Deg.DESIGNATIONID AND Emp.GRADEID=G.GRADEID AND US.USERID=EH.CreatedBy AND "
|
|||
|
+" Emp.ENDOFCONTRACTDATE between %d and %d AND eh.isdiscontinue=1 AND"
|
|||
|
+" Emp.EMPLOYEEID=EH.EMPLOYEEID AND Emp.PayrollTypeID=%n order by Emp.EMPLOYEENO",
|
|||
|
dEffectDate, dEffectDate2,
|
|||
|
payrollTypeID);
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
throw new Exception(ex.Message);
|
|||
|
}
|
|||
|
return oEmpHistories;
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Delete function
|
|||
|
|
|||
|
internal static void Delete(TransactionContext tc, ID nID)
|
|||
|
{
|
|||
|
tc.ExecuteNonQuery("DELETE FROM [EmployeeHistory] WHERE ID=%n", nID);
|
|||
|
}
|
|||
|
|
|||
|
internal static void DeleteByEmpID(TransactionContext tc, ID nEmpID)
|
|||
|
{
|
|||
|
tc.ExecuteNonQuery("DELETE FROM [EmployeeHistory] WHERE EMPLOYEEID=%n", nEmpID.Integer);
|
|||
|
}
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|