CEL_Payroll/Payroll.Service/Employee/DA/EmployeeStatusDA.cs

131 lines
4.9 KiB
C#
Raw Permalink Normal View History

2024-09-17 14:30:13 +06:00
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 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, %s)", item.ID.Integer, item.StatusID.Integer, 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)" +
" VALUES(%n, %n, %s, %b, %b, %b, %n, %d, %n, %n)", item.ID.Integer, item.EmpStatus, item.Description, item.ContinueOwnPartPF, item.ContinueCmpPartPF, item.ContinueGratuity, item.CreatedBy.Integer, item.CreatedDate, item.Sequence, item.Status);
}
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" +
" WHERE StatusID=%n", item.EmpStatus, item.Description, item.ContinueOwnPartPF, item.ContinueCmpPartPF, item.ContinueGratuity, item.Sequence, item.Status, item.ID.Integer);
}
#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)
{
return tc.ExecuteReader("SELECT * FROM EmployeeStatus");
}
internal static IDataReader GetChild(TransactionContext tc, ID parentID)
{
return tc.ExecuteReader("SELECT * FROM EmployeeStatusComponent WHERE statusID=%n", parentID.Integer);
}
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, ID nID)
{
return tc.ExecuteReader("SELECT * FROM EmployeeStatus WHERE StatusID=%n", nID.Integer);
}
//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, ID nID)
{
tc.ExecuteNonQuery("DELETE FROM EmployeeStatus WHERE StatusID=%n", nID.Integer);
}
internal static void DeleteChild(TransactionContext tc, ID nID)
{
tc.ExecuteNonQuery(@"DELETE FROM EMPLOYEESTATUSCOMPONENT WHERE STATUSID=%n", nID.Integer);
}
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
}