EchoTex_Payroll/HRM.DA/DA/Employee/EmployeeStatusDA.cs
2024-10-14 10:01:49 +06:00

185 lines
7.3 KiB
C#

using HRM.BO;
using Ease.Core.DataAccess;
using System;
using System.Data;
namespace HRM.DA
{
#region EmployeeStatusDA
internal class EmployeeStatusDA
{
#region Constructor
private EmployeeStatusDA()
{
}
#endregion
#region Insert function
internal static void Insert(TransactionContext tc, EmployeeStatus.EmpStatusComponent item)
{
tc.ExecuteNonQuery(
"INSERT INTO EmployeeStatusComponent(EmployeeStatusComponentID, StatusID, EmployeeStatusComponent)" +
" VALUES(%n, %n, %n)", item.ID, item.StatusID, item.ComponentType);
}
internal static void Insert(TransactionContext tc, EmployeeStatus item)
{
tc.ExecuteNonQuery(
"INSERT INTO EmployeeStatus(StatusID, EmpStatus, Description, ContinueOwnPartPF, ContinueCmpPartPF, ContinueGratuity, CreatedBy, CreatedDate, SequenceNo, Status, IsPromotion, IsJoining,IsTransferReceived)" +
" VALUES(%n, %n, %s, %b, %b, %b, %n, %d, %n, %n, %b,%b,%b)", item.ID, item.EmpStatus, item.Description,
item.ContinueOwnPartPF, item.ContinueCmpPartPF, item.ContinueGratuity, item.CreatedBy, item.CreatedDate,
item.Sequence, item.Status, item.IsPromotion, item.IsJoining,item.IsTransferReceived);
}
internal static void Insert(TransactionContext tc, EmployeeStatus.EmployeeStatusComponentUser item)
{
tc.ExecuteNonQuery(
"INSERT INTO EmployeeStatusComponentUser(EmployeeStatusComponentUserID, EmployeeStatusID, UserID)" +
" VALUES(%n, %n, %n)", item.ID, item.EmployeeStatusID, item.UserID);
}
internal static void Insert(TransactionContext tc, EmployeeStatus.EmpStatusComponent item, string name)
{
tc.ExecuteNonQuery(
"INSERT INTO EmployeeStatusComponent(StatusID, EmployeeStatusComponentID, NAME, EmployeeStatusComponent)" +
" VALUES(%n, %n, %s, %n)", 0, item.ID, name, item.ComponentType);
}
#endregion
#region Update function
internal static void Update(TransactionContext tc, EmployeeStatus item)
{
tc.ExecuteNonQuery(
"UPDATE EmployeeStatus SET EmpStatus=%n, Description=%s, ContinueOwnPartPF=%b, ContinueCmpPartPF=%b, ContinueGratuity=%b, SequenceNo=%n, Status=%n, isJoining=%b, isPromotion=%b, isTransferReceived=%b" +
" WHERE StatusID=%n", item.EmpStatus, item.Description, item.ContinueOwnPartPF, item.ContinueCmpPartPF,
item.ContinueGratuity, item.Sequence, item.Status, item.IsJoining, item.IsPromotion,item.IsTransferReceived, item.ID);
}
#endregion
#region Get Function
internal static IDataReader Get(TransactionContext tc, EnumStatus status)
{
if (status == EnumStatus.Regardless)
return tc.ExecuteReader("SELECT * FROM EmployeeStatus Order By sequenceNo");
else
return tc.ExecuteReader("SELECT * FROM EmployeeStatus Where Status=%n Order By sequenceNo", status);
}
internal static IDataReader Get(TransactionContext tc, EnumStatus status,
EnumLifeCycleComponent sComponentStatus)
{
if (status == EnumStatus.Regardless)
return tc.ExecuteReader(
"SELECT * FROM EMPLOYEESTATUS WHERE STATUSID IN (SELECT STATUSID FROM EMPLOYEESTATUSCOMPONENT ec WHERE ec.EMPLOYEESTATUSCOMPONENT=%n)",
sComponentStatus);
else
return tc.ExecuteReader(
"SELECT * FROM EMPLOYEESTATUS WHERE STATUSID IN (SELECT STATUSID FROM EMPLOYEESTATUSCOMPONENT ec WHERE ec.EMPLOYEESTATUSCOMPONENT=%n) AND EMPSTATUS=%n",
sComponentStatus, status);
}
internal static IDataReader Get(TransactionContext tc)
{
return tc.ExecuteReader("SELECT * FROM EmployeeStatus");
}
internal static IDataReader GetChild(TransactionContext tc, int parentID)
{
return tc.ExecuteReader("SELECT * FROM EmployeeStatusComponent WHERE statusID=%n", parentID);
}
internal static IDataReader GetallComponenet(TransactionContext tc)
{
return tc.ExecuteReader("SELECT * FROM EmployeeStatusComponent ");
}
internal static IDataReader GetAllEmpStatusComponentUser(TransactionContext tc)
{
return tc.ExecuteReader("SELECT * FROM EmployeeStatusComponentUser ");
}
internal static IDataReader GetEmpStatusComponentUser(TransactionContext tc, int parentID)
{
return tc.ExecuteReader("SELECT * FROM EmployeeStatusComponentUser WHERE EmployeeStatusID=%n", parentID);
}
internal static IDataReader GetByEmpStatus(TransactionContext tc, EnumStatus status,
EnumEmployeeStatus empStatus)
{
if (EnumStatus.Active == status || EnumStatus.Inactive == status)
{
return tc.ExecuteReader(
"SELECT * FROM EmployeeStatus Where Status=%n and EmpStatus=%n Order By sequenceNo", status,
empStatus);
}
else
{
return tc.ExecuteReader("SELECT * FROM EmployeeStatus Where EmpStatus=%n Order By sequenceNo",
empStatus);
}
}
internal static IDataReader Get(TransactionContext tc, int nID)
{
return tc.ExecuteReader("SELECT * FROM EmployeeStatus WHERE StatusID=%n", nID);
}
internal static IDataReader GetByUserID(TransactionContext tc, int userID)
{
return tc.ExecuteReader("SELECT u.* FROM EmployeeStatus u, EmployeeStatusComponentUser us" +
" WHERE u.StatusID= us.EmployeeStatusID and us.UserID=%n", userID);
}
//internal static GetStatusIDByStatus(TransactionContext tc,EnumStatus status)
//{
// return tc.ExecuteReader("SELECT STATUSID FROM EmployeeStatus Where Status=%n",status);
//}
#endregion
#region Delete function
internal static void Delete(TransactionContext tc, int nID)
{
tc.ExecuteNonQuery("DELETE FROM EmployeeStatus WHERE StatusID=%n", nID);
}
internal static void DeleteChild(TransactionContext tc, int nID)
{
tc.ExecuteNonQuery(@"DELETE FROM EMPLOYEESTATUSCOMPONENT WHERE STATUSID=%n", nID);
}
internal static void DeleteEmpStatusComponentUser(TransactionContext tc, int nID)
{
tc.ExecuteNonQuery(@"DELETE FROM EmployeeStatusComponentUser WHERE EmployeeStatusID=%n", nID);
}
internal static void DeleteAll(TransactionContext tc, EnumEmployeeStatus type)
{
string SQLAttribute =
string.Format(
"Delete from EmployeeStatusComponent where ParentID in (Select EmployeeStatusID from EmployeeStatus where type={0})",
Convert.ToInt32(type));
tc.ExecuteNonQuery(SQLAttribute);
string SQLConfig = string.Format("Delete from EmployeeStatus Where type = {0}", Convert.ToInt32(type));
tc.ExecuteNonQuery(SQLConfig);
}
#endregion
}
#endregion
}