EchoTex_Payroll/HRM.DA/DA/OPI/OpiParameterIndividualDA.cs

120 lines
4.7 KiB
C#
Raw Permalink Normal View History

2024-10-14 10:01:49 +06:00
using HRM.BO;
using Ease.Core.DataAccess;
using System;
using System.Data;
namespace HRM.DA
{
#region OpiParameterIndividualDA
public class OpiParameterIndividualDA
{
#region Constructor
public OpiParameterIndividualDA()
{
}
#endregion
#region Insert function
internal static void Insert(TransactionContext tc, OpiParameterIndividual oItem)
{
string strSQL = SQLParser.MakeSQL(@"INSERT INTO OpiParameterIndividual
(OpiParameterIndividualID, ArrearType, EmployeeId,
FromDate, ToDate, IndividualType,
OpiItemId, OpiParameterId, OpiPeriodicity,
Value, ValueType, CreatedBy, CreationDate,PayrollTypeID)
VALUES(%n, %n, %n, %d, %d, %n, %n, %n, %n, %n, %n, %n, %d,%n)",
oItem.ID, oItem.ArrearType, oItem.EmployeeId,
oItem.FromDate, DataReader.GetNullValue(oItem.ToDate), oItem.IndividualType,
oItem.OpiItemId, oItem.OpiParameterID, oItem.OpiPeriodicity,
oItem.Value, oItem.ValueType, DataReader.GetNullValue(oItem.CreatedBy),
DataReader.GetNullValue(oItem.CreatedDate), oItem.PayrollTypeID);
tc.ExecuteNonQuery(strSQL);
}
#endregion
#region Update function
internal static void Update(TransactionContext tc, OpiParameterIndividual oItem)
{
tc.ExecuteNonQuery(
@"UPDATE OpiParameterIndividual SET
ArrearType=%n, EmployeeId=%n, FromDate=%d,
ToDate=%d, IndividualType=%n, OpiItemId=%n,
OpiParameterId=%n, OpiPeriodicity=%n, Value=%n,
ValueType=%n, ModifiedBy=%n, ModifiedDate=%d,PayrollTypeID = %n
WHERE OpiParameterIndividualID=%n",
oItem.ArrearType, oItem.EmployeeId, oItem.FromDate,
DataReader.GetNullValue(oItem.ToDate), oItem.IndividualType, oItem.OpiItemId,
oItem.OpiParameterID, oItem.OpiPeriodicity, oItem.Value, oItem.ValueType,
DataReader.GetNullValue(oItem.ModifiedBy), DataReader.GetNullValue(oItem.ModifiedDate),
oItem.PayrollTypeID);
}
#endregion
#region Get Function
internal static IDataReader Get(TransactionContext tc)
{
return tc.ExecuteReader("SELECT * FROM OpiParameterIndividual");
}
internal static IDataReader Get(TransactionContext tc, int nID)
{
return tc.ExecuteReader("SELECT * FROM OpiParameterIndividual WHERE OpiParameterIndividualID =%n", nID);
}
internal static IDataReader Get(TransactionContext tc, int paramid, int employeeid, int itemid)
{
return tc.ExecuteReader(
"SELECT TOP 1 * FROM OpiParameterIndividual WHERE OpiParameterID =%n AND OpiItemID=%n AND EmployeeId=%n order by FromDate DESC",
paramid, itemid, employeeid);
}
internal static IDataReader GetByParameterID(TransactionContext tc, int nParameterID)
{
return tc.ExecuteReader("SELECT OpiParameterIndividual.*, e.Name employeeName, e.employeeNo employeeNo FROM OpiParameterIndividual" +
" inner join Employee e on e.EmployeeID = OpiParameterIndividual.EmployeeID WHERE OpiParameterID =%n", nParameterID);
}
internal static IDataReader GetIndividuals(TransactionContext tc, int nOpiPAramID, EnumOPIIndivdualType type)
{
return tc.ExecuteReader(
"SELECT * FROM OpiParameterIndividual WHERE OpiParameterID=%n AND IndividualType=%n", nOpiPAramID,
type);
}
internal static IDataReader Get(TransactionContext tc, DateTime fromDate, DateTime toDate)
{
return tc.ExecuteReader("SELECT OPI.* FROM OpiParameter OP, OpiParameterIndividual OPI "
+ " WHERE OP.OpiParameterID=OPI.OpiParameterID AND OPI.IndividualType=%n AND OP.IsActive <> 0 "
+ " AND ( (OPI.ToDate >= %d OR OPI.ToDate IS Null) AND "
+ " (OPI.FromDate <= %d))", EnumOPIIndivdualType.AppliedToIndividual, fromDate,
toDate);
}
#endregion
#region Delete function
internal static void DeletebyOpiParamId(TransactionContext tc, int nOpiParamID)
{
tc.ExecuteNonQuery("DELETE FROM OpiParameterIndividual WHERE OpiParameterID=%n", nOpiParamID);
}
internal static void Delete(TransactionContext tc, int nID)
{
tc.ExecuteNonQuery("DELETE FROM OpiParameterIndividual WHERE OpiParameterIndividualID=%n", nID);
}
#endregion
}
#endregion
}