207 lines
11 KiB
C#
207 lines
11 KiB
C#
using HRM.BO;
|
|
using Ease.Core.DataAccess;
|
|
using System;
|
|
using System.Data;
|
|
|
|
|
|
namespace HRM.DA
|
|
{
|
|
#region OpiParameterDA
|
|
|
|
public class OpiParameterDA
|
|
{
|
|
#region Constructor
|
|
|
|
public OpiParameterDA()
|
|
{
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Insert function
|
|
|
|
internal static void Insert(TransactionContext tc, OpiParameter oItem)
|
|
{
|
|
tc.ExecuteNonQuery("INSERT INTO OpiParameter("
|
|
+ " OpiParameterID, OpiType, AmountToDistribute, AvgMonth, "
|
|
+ " ProvisionAmount, FlatAmount, GFFlatAmount, GFPercentOfBasic, GFPercentOfGross, FromDate, ToDate, Gender, Status, "
|
|
+ " IsActive, IsEarnedBasic, IsTaxable, OpiItemID, "
|
|
+ " OpiPeriodicity, PercentOfBasic, PercentOfGross, MinAmount, "
|
|
+ " MaxAmount, IsConfirmed, IsFractionate, IsWithException,IsIAApplicable, "
|
|
+ " EntitleType, OpiAvgPayType, OpiAvgPayItemID, NoOfMonth, "
|
|
+ " CreatedBy, CreationDate,PayrollTypeID)" +
|
|
" VALUES(%n, %n, %n, %n, "
|
|
+ " %n, %n, %n, %n, %n, %d, %d, %n, %n, "
|
|
+ " %b, %b, %b, %n, "
|
|
+ " %n, %n, %n, %n, "
|
|
+ " %n, %b, %b, %b,%b, "
|
|
+ " %n, %n, %n, %n, "
|
|
+ " %n, %d,%n)",
|
|
oItem.ID, oItem.OpiType, oItem.AmountToDistribute, oItem.AvgMonth,
|
|
oItem.ProvisionAmount, oItem.FlatAmount, oItem.GFFlatAmount, oItem.GFPercentOfBasic,
|
|
oItem.GFPercentOfGross, DataReader.GetNullValue(oItem.FromDate), DataReader.GetNullValue(oItem.ToDate),
|
|
oItem.Gender, oItem.Status,
|
|
oItem.IsActive, oItem.IsEarnedBasic, oItem.IsTaxable, oItem.OpiItemID,
|
|
oItem.OpiPeriodicity, oItem.PercentOfBasic, oItem.PercentOfGross,
|
|
DataReader.GetNullValue(oItem.MinAmount),
|
|
DataReader.GetNullValue(oItem.MaxAmount), oItem.IsConfirmed, oItem.IsFractionate, oItem.IsWithException,
|
|
oItem.IsIAApplicable,
|
|
oItem.EntitleType, oItem.OpiAvgPayType, DataReader.GetNullValue(oItem.OpiAvgPayItemID), oItem.NoOfMonth,
|
|
oItem.CreatedBy, oItem.CreatedDate, oItem.PayrollTypeID);
|
|
}
|
|
|
|
internal static void InsertGrade(TransactionContext tc, OpiParameterGrade oItem)
|
|
{
|
|
tc.ExecuteNonQuery("INSERT INTO OpiParameterGrade("
|
|
+ " OPIPARAMETERGradeID, GradeID, OpiParameterID, OpiItemId, "
|
|
+ " CreatedBy, CreationDate,PayrollTypeID)"
|
|
+ " VALUES(%n, %n, %n, %n, "
|
|
+ " %n, %d,%n)",
|
|
oItem.ID, oItem.GradeId, oItem.OpiParameterId, oItem.OpiItemId,
|
|
DataReader.GetNullValue(oItem.CreatedBy), DataReader.GetNullValue(oItem.CreatedDate),
|
|
oItem.PayrollTypeID);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Update function
|
|
|
|
internal static void Update(TransactionContext tc, OpiParameter oItem)
|
|
{
|
|
tc.ExecuteNonQuery("UPDATE OpiParameter SET "
|
|
+ " OpiType=%n, AmountToDistribute=%n, AvgMonth=%n, ProvisionAmount=%n, FlatAmount=%n, GFFlatAmount=%n, GFPercentOfBasic=%n, GFPercentOfGross=%n, "
|
|
+ " FromDate=%d, ToDate=%d, Gender=%n, Status=%n, IsActive=%b, "
|
|
+ " IsEarnedBasic=%b, IsTaxable=%b, OpiItemID=%n, OpiPeriodicity=%n, "
|
|
+ " PercentOfBasic=%n, PercentOfGross=%n, MinAmount=%n, MaxAmount=%n, "
|
|
+ " IsConfirmed=%b, IsFractionate=%b, IsWithException=%n,IsIAApplicable=%b, EntitleType=%n, "
|
|
+ " OpiAvgPayType=%n, OpiAvgPayItemID=%n, NoOfMonth=%n, "
|
|
+ " ModifiedBy=%n, ModifiedDate=%d WHERE OpiParameterID=%n AND PayrollTypeID=%n",
|
|
oItem.OpiType, oItem.AmountToDistribute, oItem.AvgMonth, oItem.ProvisionAmount, oItem.FlatAmount,
|
|
oItem.GFFlatAmount, oItem.GFPercentOfBasic, oItem.GFPercentOfGross,
|
|
DataReader.GetNullValue(oItem.FromDate), DataReader.GetNullValue(oItem.ToDate), oItem.Gender,
|
|
oItem.Status, oItem.IsActive,
|
|
oItem.IsEarnedBasic, oItem.IsTaxable, oItem.OpiItemID, oItem.OpiPeriodicity,
|
|
oItem.PercentOfBasic, oItem.PercentOfGross, oItem.MinAmount, oItem.MaxAmount,
|
|
oItem.IsConfirmed, oItem.IsWithException, oItem.IsFractionate, oItem.IsIAApplicable, oItem.EntitleType,
|
|
oItem.OpiAvgPayType, DataReader.GetNullValue(oItem.OpiAvgPayItemID), oItem.NoOfMonth,
|
|
oItem.ModifiedBy, oItem.ModifiedDate, oItem.ID, oItem.PayrollTypeID);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Get Function
|
|
|
|
internal static IDataReader Get(TransactionContext tc, int payrollTypeID)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM OpiParameter where PayrollTypeID=%n", payrollTypeID);
|
|
}
|
|
|
|
internal static IDataReader Get(TransactionContext tc, int nID, int payrollTypeID)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM OpiParameter WHERE OpiParameterID =%n AND PayrollTypeID=%n", nID,
|
|
payrollTypeID);
|
|
}
|
|
|
|
internal static IDataReader GetGrades(TransactionContext tc, int nOpiParameterID, int payrollTypeID)
|
|
{
|
|
return tc.ExecuteReader("Select * from OpiParameterGrade Where OpiParameterID= %n AND PayrollTypeID=%n",
|
|
nOpiParameterID, payrollTypeID);
|
|
}
|
|
|
|
internal static IDataReader Get(TransactionContext tc, EnumStatus status, int payrollTypeID)
|
|
{
|
|
//return tc.ExecuteReader("SELECT * FROM OpiParameter WHERE Status= %n", status);
|
|
if (status == EnumStatus.Regardless)
|
|
return tc.ExecuteReader("SELECT * FROM OpiParameter Where PayrollTypeID=%n", payrollTypeID);
|
|
else
|
|
return tc.ExecuteReader(
|
|
"SELECT OpiParameter.* FROM OpiParameter, OpiItem Where OpiItem.OpiItemID=OpiParameter.OpiItemID AND OpiParameter.Status=%n AND OpiParameter.PayrollTypeID=%n",
|
|
status, payrollTypeID);
|
|
}
|
|
|
|
internal static IDataReader Get(TransactionContext tc, EnumStatus status, EnumOpiType nType, int payrollTypeID)
|
|
{
|
|
if (status == EnumStatus.Regardless)
|
|
return tc.ExecuteReader(
|
|
"SELECT * FROM OpiParameter WHERE OpiType = %n AND PayrollTypeID=%n Order By OpiPeriodicity", nType,
|
|
payrollTypeID);
|
|
else
|
|
return tc.ExecuteReader(
|
|
"SELECT * FROM OpiParameter WHERE OpiType = %n AND Status=%n AND PayrollTypeID=%n Order By OpiPeriodicity",
|
|
nType, status, payrollTypeID);
|
|
//return tc.ExecuteReader("SELECT OpiParameter.* FROM OpiParameter, OpiItem Where OpiItem.OpiItemID=OpiParameter.OpiItemID AND OpiParameter.Status=%n", status);
|
|
}
|
|
|
|
internal static IDataReader Get(TransactionContext tc, EnumStatus enumStatus, EnumOpiType enumOpiType,
|
|
EnumEntitleType enumEntitleType, int payrollTypeID)
|
|
{
|
|
if (enumStatus == EnumStatus.Regardless)
|
|
return tc.ExecuteReader(
|
|
"SELECT * FROM OpiParameter WHERE OpiType = %n AND PayrollTypeID=%n AND EntitleType=%n Order By OpiPeriodicity",
|
|
enumOpiType, payrollTypeID, enumEntitleType);
|
|
else
|
|
return tc.ExecuteReader(
|
|
"SELECT * FROM OpiParameter WHERE OpiType = %n AND Status=%n AND PayrollTypeID=%n AND EntitleType=%n Order By OpiPeriodicity",
|
|
enumOpiType, enumStatus, payrollTypeID, enumEntitleType);
|
|
//return tc.ExecuteReader("SELECT OpiParameter.* FROM OpiParameter, OpiItem Where OpiItem.OpiItemID=OpiParameter.OpiItemID AND OpiParameter.Status=%n", status);
|
|
}
|
|
internal static IDataReader GetUsedGrades(TransactionContext tc, int opiItemid)
|
|
{
|
|
return tc.ExecuteReader(@"select *from OpiParameterGrade where OpiParameterID in (
|
|
select OpiParameterID from OpiParameter where OpiItemID = %n)", opiItemid);
|
|
}
|
|
|
|
internal static IDataReader Get(TransactionContext tc, EnumStatus enumStatus, EnumEntitleType enumEntitleType,
|
|
int payrollTypeID)
|
|
{
|
|
if (enumStatus == EnumStatus.Regardless)
|
|
return tc.ExecuteReader(
|
|
"SELECT * FROM OpiParameter WHERE PayrollTypeID=%n AND EntitleType=%n Order By OpiPeriodicity",
|
|
payrollTypeID, enumEntitleType);
|
|
else
|
|
return tc.ExecuteReader(
|
|
"SELECT * FROM OpiParameter WHERE Status=%n AND PayrollTypeID=%n AND EntitleType=%n Order By OpiPeriodicity",
|
|
enumStatus, payrollTypeID, enumEntitleType);
|
|
//return tc.ExecuteReader("SELECT OpiParameter.* FROM OpiParameter, OpiItem Where OpiItem.OpiItemID=OpiParameter.OpiItemID AND OpiParameter.Status=%n", status);
|
|
}
|
|
internal static void ChangeStatus(TransactionContext tc, int id, EnumStatus enumStatus)
|
|
{
|
|
string sql = string.Empty;
|
|
bool IsCurrentlyActive = (enumStatus == EnumStatus.Active) ? true : false;
|
|
|
|
sql = SQLParser.MakeSQL(@"UPDATE OpiParameter
|
|
SET
|
|
IsActive=%b,
|
|
STATUS=%n
|
|
Where OpiParameterID=%n", IsCurrentlyActive, (int)enumStatus, id);
|
|
|
|
tc.ExecuteNonQuery(sql);
|
|
}
|
|
#endregion
|
|
|
|
#region Delete function
|
|
|
|
internal static void Delete(TransactionContext tc, int nID)
|
|
{
|
|
tc.ExecuteNonQuery("DELETE FROM OpiParameterGrade WHERE OpiParameterID=%n ", nID);
|
|
tc.ExecuteNonQuery("DELETE FROM OpiParameterIndividual WHERE OpiParameterID=%n ", nID);
|
|
tc.ExecuteNonQuery("DELETE FROM OpiParameter WHERE OpiParameterID=%n ", nID);
|
|
}
|
|
|
|
internal static void DeleteGrades(TransactionContext tc, int nOpiParameterID)
|
|
{
|
|
tc.ExecuteNonQuery("DELETE FROM OpiParameterGrade WHERE OpiParameterID=%n ",
|
|
nOpiParameterID);
|
|
}
|
|
|
|
#endregion
|
|
|
|
internal static IDataReader GetGrades(TransactionContext tc, int payrollTypeID)
|
|
{
|
|
string sql = SQLParser.MakeSQL(@"Select * from OpiParameterGrade Where PayrollTypeID=%n", payrollTypeID);
|
|
return tc.ExecuteReader(sql);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
} |