EchoTex_Payroll/HRM.DA/DA/Employee/EmployeePostingDA.cs

153 lines
6.1 KiB
C#
Raw Normal View History

2024-10-14 10:01:49 +06:00
using Ease.Core.DataAccess;
using System;
using System.Data;
using HRM.BO;
namespace HRM.DA
{
#region EmployeePostingDA
internal class EmployeePostingDA
{
#region Constructor
private EmployeePostingDA()
{
}
#endregion
#region Insert function
internal static void Insert(TransactionContext tc, EmployeePosting item)
{
string sSQL = SQLParser.MakeSQL(
"INSERT INTO EmployeePosting(HREmpPostingID, employeeID, postingDate, departmentID, locationID, designationID, CreatedBy, CreationDate)" +
" VALUES(%n, %n, %d, %n, %n, %n, %n, %d)", item.ID, item.EmployeeID, item.EffectDate, item.DepartmentID,
item.LocationID, item.DesignationID, DataReader.GetNullValue(item.CreatedBy),
DataReader.GetNullValue(item.CreatedDate));
tc.ExecuteNonQuery(sSQL);
}
#endregion
#region Update function
internal static void Update(TransactionContext tc, EmployeePosting item)
{
string sSQL = SQLParser.MakeSQL(
"UPDATE EmployeePosting SET employeeID=%n, postingDate=%d, departmentID=%n, locationID=%n, designationID=%n, ModifiedBy=%n, ModifiedDate=%d" +
" WHERE HREmpPostingID=%n", item.EmployeeID, item.EffectDate, item.DepartmentID, item.LocationID,
item.DesignationID, DataReader.GetNullValue(item.ModifiedBy),
DataReader.GetNullValue(item.ModifiedDate), item.ID);
tc.ExecuteNonQuery(sSQL);
}
#endregion
#region Get Function
internal static IDataReader Get(TransactionContext tc)
{
return tc.ExecuteReader("SELECT * FROM EmployeePosting");
}
internal static DataSet GetEmpCurrentPosting(TransactionContext tc, DateTime EffectDate, int payrollTypeID)
{
DataSet oEmpPosting = new DataSet();
try
{
oEmpPosting = tc.ExecuteDataSet(
"Select Emp.EmployeeID ID,Emp.EMPLOYEENO,Emp.NAME,Deg.NAME CurrentDeg,Dept.description CurrentDept,"
+ " Loc.description CurrentLoc,"
+ " EmpPost.postingdate EffectDate,US.LoginID CommitedBy,EmpPost.CreationDate CommitedOn"
+ " from EMPLOYEE Emp,department Dept,LOCATION Loc ,USERS US,DESIGNATION Deg,employeeposting EmpPost"
+ " WHERE Emp.DESIGNATIONID=Deg.DESIGNATIONID"
+ " AND Emp.departmentid=Dept.departmentid"
+ " AND Emp.locationid=Loc.locationid"
+ " and Emp.EmployeeID=EmpPost.EmployeeID"
+ " AND US.USERID=EmpPost.CreatedBy"
+ " AND EmpPost.postingdate between %d and %d ANd Emp.PayrollTypeID=%n"
+ " order by Emp.EMPLOYEENO", PayrollGlobalFunctions.PayrollFirstDateOfMonth(EffectDate),
PayrollGlobalFunctions.PayrollLastDateOfMonth(EffectDate), payrollTypeID);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return oEmpPosting;
}
internal static DataSet GetEmpPrvPosting(TransactionContext tc, DateTime EffectDate, int payrollTypeID)
{
DataSet oEmpPosting = new DataSet();
try
{
oEmpPosting = tc.ExecuteDataSet(
"Select Emp.EMPLOYEENO,Emp.NAME,Deg.NAME PreviousDeg,Dept.description PreviousDept,"
+ " Loc.description PreviousLoc,EmpPost.postingdate EffectDate,US.UserID CommitedBy,EmpPost.CreationDate CommitedOn"
+ " from EMPLOYEE Emp,department Dept,LOCATION Loc ,USERS US,DESIGNATION Deg,employeeposting EmpPost"
+ " WHERE EmpPost.DESIGNATIONID=Deg.DESIGNATIONID"
+ " AND EmpPost.departmentid=Dept.departmentid"
+ " AND EmpPost.locationid=Loc.locationid"
+ " and Emp.EmployeeID=EmpPost.EmployeeID"
+ " AND US.USERID=EmpPost.CreatedBy"
+ " AND EmpPost.postingdate < %d ANd Emp.PayrollTypeID=%n"
+ " order by Emp.EMPLOYEENO", PayrollGlobalFunctions.PayrollFirstDateOfMonth(EffectDate)
, payrollTypeID);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return oEmpPosting;
}
internal static IDataReader Get(TransactionContext tc, int nID)
{
return tc.ExecuteReader("SELECT * FROM EmployeePosting WHERE HREmpPostingID=%n Order By POSTINGDATE", nID);
}
internal static IDataReader Get(TransactionContext tc, int nEmpID, DateTime dEffectDate, int payrollTypeID)
{
return tc.ExecuteReader(@"Select * from employeeposting where
postingdate=(Select MAX(postingdate) from employeeposting where EMPLOYEEID=%n and postingdate<%d)
AND EMPLOYEEID=(Select EMPLOYEEID from Employee where EMPLOYEEID=%n and PAYROLLTYPEID=%n) ",
nEmpID, dEffectDate, nEmpID, payrollTypeID);
}
internal static IDataReader GetEmpid(TransactionContext tc, int nID)
{
return tc.ExecuteReader("SELECT * FROM EmployeePosting WHERE employeeID=%n Order By POSTINGDATE", nID);
}
#endregion
#region Delete function
internal static void Delete(TransactionContext tc, int nID)
{
tc.ExecuteNonQuery("DELETE FROM EmployeePosting WHERE HREmpPostingID=%n", nID);
}
internal static void DeleteByPostingDate(TransactionContext tc, DateTime postingDate, int empID)
{
string sSQL = SQLParser.MakeSQL("Delete from EmployeePosting Where postingdate >= %d and EMPLOYEEID=%n",
postingDate, empID);
tc.ExecuteNonQuery(sSQL);
}
internal static void DeleteAll(TransactionContext tc)
{
tc.ExecuteNonQuery("DELETE FROM EmployeePosting");
}
#endregion
}
#endregion
}