EchoTex_Payroll/HRM.DA/DA/PMP/CompetencyDA.cs

134 lines
5.2 KiB
C#
Raw Permalink Normal View History

2024-10-14 10:01:49 +06:00
using System;
using HRM.BO;
using Ease.Core.DataAccess;
using System.Data;
namespace HRM.DA
{
internal class CompetencyDA
{
#region Insert function
internal static void Insert(TransactionContext tc, Competency item)
{
tc.ExecuteNonQuery(
"INSERT INTO Competency(COMPETENCYID,CODE, DESCRIPTION, TIRE, PARENTID, STATUS, PayrollTypeID, CREATEDBY, CREATIONDATE)" +
" VALUES(%n, %s, %s, %n, %n, %n, %n, %n, %d)", item.ID, item.Code, item.Name, item.Tier, item.ParentID, item.Status, item.PayrollTypeID, item.CreatedBy, item.CreatedDate);
}
#endregion
#region Update function
internal static void Update(TransactionContext tc, Competency item)
{
string sql = string.Empty;
sql = SQLParser.MakeSQL(
@"UPDATE Competency SET code=%s, description=%s, TIRE=%n, parentID=%n, Status=%n, ModifiedBy=%n, ModifiedDate=%d
WHERE CompetencyID=%n", item.Code, item.Name, item.Tier, item.ParentID, item.Status, item.ModifiedBy, item.ModifiedDate,
item.ID);
tc.ExecuteNonQuery(sql);
}
//internal static void UpdateCode(TransactionContext tc, Competency item, string sCode)
//{
// string sSQL = SQLParser.MakeSQL("UPDATE Competency Set code = %s Where CompetencyID = %n", sCode, item.ID);
// tc.ExecuteNonQuery(sSQL);
//}
//internal static void UpdateCostCenter(TransactionContext tc, Competency item)
//{
// //string sSQL = SQLParser.MakeSQL("UPDATE Competency Set CostCenter = %s Where CompetencyID = %n",
// // item.CostCenter.Trim(), item.ID);
// //tc.ExecuteNonQuery(sSQL);
//}
#endregion
#region Delete function
internal static void Delete(TransactionContext tc, int ID)
{
tc.ExecuteNonQuery("DELETE FROM Competency WHERE CompetencyID=%n", ID);
}
#endregion Delete function
#region GetFunction
internal static IDataReader Get(TransactionContext tc)
{
return tc.ExecuteReader("SELECT * FROM Competency");
}
internal static IDataReader Get(TransactionContext tc, int ID)
{
return tc.ExecuteReader("SELECT * FROM Competency WHERE CompetencyID=%n", ID);
}
internal static IDataReader Get(TransactionContext tc, EnumStatus status, int payrollTypeID)
{
if (EnumStatus.Active == status || EnumStatus.Inactive == status)
{
return tc.ExecuteReader(
@"SELECT c.* FROM Competency c where c.status=%n and c.PayrollTypeID=%n order by c.Description",
status, payrollTypeID);
}
else
{
return tc.ExecuteReader(
@"SELECT c.* FROM Competency c Where c.PayrollTypeID=%n order by c.Description", payrollTypeID);
}
}
//internal static IDataReader GetAllCompetency(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("Name LIKE %s", ("%" + name + "%"));
// }
// return tc.ExecuteReader("SELECT * FROM Competency %q order by Description", sqlClause);
//}
//internal static IDataReader GetAllCompetency(TransactionContext tc, int payrollTypeID, EnumStatus status)
//{
// 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);
// }
// return tc.ExecuteReader("SELECT * FROM Competency %q order by Description", sqlClause);
//}
//internal static IDataReader GetAllCompetencyOrderByCode(TransactionContext tc, int payrollTypeID, EnumStatus status)
//{
// 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);
// }
// return tc.ExecuteReader("SELECT * FROM Competency Order By CODE");
//}
#endregion
}
}