140 lines
5.8 KiB
C#
140 lines
5.8 KiB
C#
using Ease.Core.DataAccess;
|
|
using System;
|
|
using System.Data;
|
|
using HRM.BO;
|
|
using iTextSharp.text.pdf.security;
|
|
|
|
namespace HRM.DA
|
|
{
|
|
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, item.EmployeeID, item.EffectDate,
|
|
DataReader.GetNullValue(item.EndDate), item.EmployeeStatus, item.Remarks, item.CreatedBy,
|
|
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, item.EffectDate, DataReader.GetNullValue(item.EndDate),
|
|
item.EmployeeStatus, item.Remarks, item.ModifiedBy, item.ModifiedDate, item.ID);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Get Function
|
|
|
|
internal static IDataReader Get(TransactionContext tc)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM EmployeeHistory");
|
|
}
|
|
|
|
internal static IDataReader Get(TransactionContext tc, int nID)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM EmployeeHistory WHERE ID=%n", nID);
|
|
}
|
|
|
|
internal static IDataReader GetByEmpID(TransactionContext tc, int nEmpID)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM EmployeeHistory WHERE EmployeeID=%n", nEmpID);
|
|
}
|
|
|
|
internal static IDataReader GetEmpLastHistory(TransactionContext tc, int nEmpID)
|
|
{
|
|
return tc.ExecuteReader(
|
|
"SELECT * FROM EmployeeHistory WHERE EmployeeID=%n and effectDate=(select max(effectDate) FROM EmployeeHistory WHERE EmployeeID=%n)",
|
|
nEmpID, nEmpID);
|
|
}
|
|
|
|
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 DESIGNATION,G.DESCRIPTION Grade,"
|
|
// + " Emp.JOININGDATE,Emp.ENDOFCONTRACTDATE,EH.EFFECTDATE,EH.REMARKS Comments,US.LoginID CommitedBy,EH.CreationDate,EH.ParamID"
|
|
// + " from EMPLOYEEHISTORY EH,EMPLOYEE Emp ,USERS US,DESIGNATION Deg,GRADES 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",
|
|
// PayrollGlobalFunctions.PayrollFirstDateOfMonth(dEffectDate), PayrollGlobalFunctions.PayrollLastDateOfMonth(dEffectDate),
|
|
// SystemInformation.CurrentSysInfo.PayrollTypeID);
|
|
|
|
string sql = SQLParser.MakeSQL(
|
|
"Select Emp.Employeeid,eh.emplifecycleid,Eh.status, Emp.EMPLOYEENO,Emp.NAME,Deg.NAME DESIGNATION,G.DESCRIPTION Grade, Emp.JOININGDATE,"
|
|
+ " Emp.ENDOFCONTRACTDATE,EH.EFFECTDATE,EH.REMARKS Comments,US.LoginID CommitedBy,EH.CreationDate"
|
|
+ " from EmpLifeCycle EH,EMPLOYEE Emp ,USERS US,DESIGNATION Deg,GRADES 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);
|
|
|
|
oEmpHistories = tc.ExecuteDataSet(sql);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return oEmpHistories;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Delete function
|
|
|
|
internal static void Delete(TransactionContext tc, int nID)
|
|
{
|
|
tc.ExecuteNonQuery("DELETE FROM EmployeeHistory WHERE ID=%n", nID);
|
|
}
|
|
|
|
internal static void DeleteByEmpID(TransactionContext tc, int nEmpID)
|
|
{
|
|
tc.ExecuteNonQuery("DELETE FROM EmployeeHistory WHERE EMPLOYEEID=%n", nEmpID);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
} |