EchoTex_Payroll/HRM.DA/DA/Basic/CostcenterDA.cs

177 lines
7.6 KiB
C#
Raw Permalink Normal View History

2024-10-14 10:01:49 +06:00
using HRM.BO;
using Ease.Core.DataAccess;
using System.Data;
namespace HRM.DA
{
internal class CostcenterDA
{
#region Constructor
private CostcenterDA()
{
}
#endregion
#region Insert function
internal static void Insert(TransactionContext tc, Costcenter item, int payrollTypeID)
{
tc.ExecuteNonQuery(
"INSERT INTO CRG(CrgID, code, description, ProfitCenterName, parentID, PayrollTypeID, parentsID, CreatedBy, CreationDate, SequenceNo, Status, Tier, GrsName, descriptioninbangla)" +
" VALUES(%n, %s, %s, %s, %n, %n, %s, %n, %d, %n, %n, %n, %s, %u)", item.ID, item.Code, item.Name,
DataReader.GetNullValue(item.ProfitCenterName), item.ParentID,
DataReader.GetNullValue(payrollTypeID, 0), item.ParentsID, item.CreatedBy, item.CreatedDate,
item.Sequence, item.Status, item.Tier, item.GrsName, item.NameInBangla);
}
internal static void Insert(TransactionContext tc, Costcenter item)
{
tc.ExecuteNonQuery(
"INSERT INTO CRG(CrgID, code, description, ProfitCenterName, parentID, PayrollTypeID, parentsID, CreatedBy, CreationDate, SequenceNo, Status, Tier, GrsName, descriptioninbangla)" +
" VALUES(%n, %s, %s, %s, %n, %n, %s, %n, %d, %n, %n, %n, %s, %u)", item.ID, item.Code, item.Name,
DataReader.GetNullValue(item.ProfitCenterName), item.ParentID,
item.PayrollTypeID, item.ParentsID, item.CreatedBy, item.CreatedDate,
item.Sequence, item.Status, item.Tier, item.GrsName, item.NameInBangla);
}
#endregion
#region Update function
internal static void Update(TransactionContext tc, Costcenter item, int payrollTypeID)
{
tc.ExecuteNonQuery(
"UPDATE CRG SET code=%s, description=%s, ProfitCenterName=%s, parentID=%n, PayrollTypeID=%n, parentsID=%s, ModifiedBy=%n, ModifiedDate=%d, SequenceNo=%n, Status=%n, Tier=%n, GrsName=%s, descriptioninbangla=%u" +
" WHERE CrgID=%n", item.Code, item.Name, DataReader.GetNullValue(item.ProfitCenterName), item.ParentID,
DataReader.GetNullValue(payrollTypeID, 0), item.ParentsID, item.ModifiedBy, item.ModifiedDate,
item.Sequence, item.Status, item.Tier, item.GrsName, item.NameInBangla, item.ID);
}
internal static void Update(TransactionContext tc, Costcenter item)
{
tc.ExecuteNonQuery(
"UPDATE CRG SET code=%s, description=%s, ProfitCenterName=%s, parentID=%n, PayrollTypeID=%n, parentsID=%s, ModifiedBy=%n, ModifiedDate=%d, SequenceNo=%n, Status=%n, Tier=%n, GrsName=%s, descriptioninbangla=%u" +
" WHERE CrgID=%n", item.Code, item.Name, DataReader.GetNullValue(item.ProfitCenterName), item.ParentID,
item.PayrollTypeID, item.ParentsID, item.ModifiedBy, item.ModifiedDate,
item.Sequence, item.Status, item.Tier, item.GrsName, item.NameInBangla, item.ID);
}
#endregion
#region Get Function
//internal static IDataReader Get(TransactionContext tc, int payrollTypeID)
//{
// return tc.ExecuteReader("SELECT * FROM CRG WHERE PayrollTypeID=%n", payrollTypeID);
//}
internal static IDataReader Get(TransactionContext tc, EnumStatus status, int payrollTypeID)
{
if (EnumStatus.Active == status || EnumStatus.Inactive == status)
{
return tc.ExecuteReader(
"SELECT * FROM CRG Where Status=%n and PayrollTypeID=%n Order By DESCRIPTION",
status, payrollTypeID);
}
else
{
return tc.ExecuteReader("SELECT * FROM CRG Order By DESCRIPTION");
}
}
internal static IDataReader Get(TransactionContext tc)
{
return tc.ExecuteReader("SELECT * FROM CRG");
}
internal static IDataReader Get(TransactionContext tc, string code, int payrollTypeID)
{
return tc.ExecuteReader("SELECT * FROM CRG WHERE CODE = %s AND PayrollTypeID = %n", code, payrollTypeID);
}
internal static IDataReader GetParents(TransactionContext tc, EnumStatus status, int payrollTypeID)
{
if (EnumStatus.Active == status || EnumStatus.Inactive == status)
{
return tc.ExecuteReader(
"SELECT * FROM CRG Where ParentID IS NULL and Status=%n and PayrollTypeID=%n Order By DESCRIPTION",
status, payrollTypeID);
}
else
{
return tc.ExecuteReader("SELECT * FROM CRG Where ParentID IS NULL Order By DESCRIPTION");
}
}
internal static IDataReader GetChilds(TransactionContext tc, int parentID, int payrollTypeID)
{
return tc.ExecuteReader("SELECT * FROM CRG Where ParentID = %n AND PayrollTypeID = %n Order By DESCRIPTION",
parentID, payrollTypeID);
}
internal static IDataReader GetByTire(TransactionContext tc, int nTire, int payrollTypeID)
{
return tc.ExecuteReader("SELECT * FROM CRG Where TIER=%n AND PayrollTypeID=%n ORDER BY CrgID", nTire,
payrollTypeID);
}
internal static IDataReader GetByTireAndProfitCenter(TransactionContext tc, int nTire, string sProfitCenter,
int payrollTypeID)
{
return tc.ExecuteReader("SELECT * FROM CRG Where TIER=%n AND ProfitCenterName =%s AND PayrollTypeID=%n",
nTire, sProfitCenter, payrollTypeID);
}
internal static IDataReader Get(TransactionContext tc, int ID)
{
return tc.ExecuteReader("SELECT * FROM CRG WHERE CrgID=%n ", ID);
}
internal static IDataReader Get(TransactionContext tc, EnumStatus status, int tier, int payrollTypeID)
{
if (EnumStatus.Active == status || EnumStatus.Inactive == status)
{
return tc.ExecuteReader(
"SELECT * FROM CRG Where Status=%n and TIER=%n and payrolltypeid = %n Order By DESCRIPTION", status,
tier, payrollTypeID);
}
else
{
return tc.ExecuteReader("SELECT * FROM CRG Order By DESCRIPTION");
}
}
internal static IDataReader GetAllCostCenter(TransactionContext tc, int payrollTypeID, EnumStatus status,
string code, string name)
{
string sqlClause = string.Empty;
sqlClause = SQLParser.TagSQL(sqlClause) + SQLParser.MakeSQL("PayrollTypeID = %n", payrollTypeID);
if (EnumStatus.Active == status || EnumStatus.Inactive == status)
{
sqlClause = SQLParser.TagSQL(sqlClause) + SQLParser.MakeSQL("status = %n", status);
}
if (!string.IsNullOrWhiteSpace(code))
{
sqlClause = SQLParser.TagSQL(sqlClause) + SQLParser.MakeSQL("Code = %s", code);
}
if (!string.IsNullOrWhiteSpace(name))
{
sqlClause = SQLParser.TagSQL(sqlClause) + SQLParser.MakeSQL("Description LIKE %s", ("%" + name + "%"));
}
return tc.ExecuteReader("SELECT * FROM CRG %q order by Description", sqlClause, payrollTypeID);
}
#endregion
#region Delete function
internal static void Delete(TransactionContext tc, int ID)
{
tc.ExecuteNonQuery("DELETE FROM CRG WHERE CrgID=%n", ID);
}
#endregion
}
}