EchoTex_Payroll/HRM.DA/DA/Users/RoleActionPermissionDA.cs

91 lines
3.4 KiB
C#
Raw 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
{
internal class RoleActionPermissionDA
{
#region Constructor
private RoleActionPermissionDA()
{
}
#endregion
#region Insert function
internal static void Insert(TransactionContext tc, Role.RoleActionPermission item)
{
//item.Status = EnumStatus.Inactive;
item.CreatedDate = DateTime.Now;
tc.ExecuteNonQuery(
"INSERT INTO RoleActionPermission( RoleActionPermissionID ,RoleID, RolePermissionID, CreatedBy, CreatedDate, ModifiedBy, ModifiedDate, PermissionActionCode, Name,ApproveBy,ApproveDate,AuthStatus)" +
" VALUES(%n,%n, %n, %n, %D, %n, %D, %s,%s,%n,%D,%n)", item.ID, item.RoleID, item.RolePermissionID,
item.CreatedBy, item.CreatedDate, item.ModifiedBy, item.ModifiedDate, item.ActionCode, item.Name,
item.ApproveBy, item.ApproveDate, (int)(item.Status));
}
#endregion
#region Update function
internal static void Update(TransactionContext tc, Role.RoleActionPermission item)
{
string sSql = SQLParser.MakeSQL(
"UPDATE RoleActionPermission SET RoleID=%n, RolePermissionID = %n,ModifiedBy=%n,ModifiedDate = %D, PermissionActionCode = %s, Name = %s, ApproveBy = %n,ApproveDate=%D,AuthStatus=%n" +
" WHERE RoleActionPermissionID = %n", item.RoleID, item.RolePermissionID, item.ModifiedBy,
item.ModifiedDate, item.ActionCode, item.Name, item.ApproveBy, item.ApproveDate, (int)item.Status,
item.ID);
tc.ExecuteNonQuery(
"UPDATE RoleActionPermission SET RoleID=%n, RolePermissionID = %n,ModifiedBy=%n,ModifiedDate = %D, PermissionActionCode = %s, Name = %s, ApproveBy = %n,ApproveDate=%D,AuthStatus=%n" +
" WHERE RoleActionPermissionID = %n", item.RoleID, item.RolePermissionID, item.ModifiedBy,
item.ModifiedDate, item.ActionCode, item.Name, item.ApproveBy, item.ApproveDate, (int)item.Status,
item.ID);
}
#endregion
#region Get Function
internal static IDataReader Get(TransactionContext tc, EnumAuthStatus status)
{
return tc.ExecuteReader("SELECT * FROM RoleActionPermission where AuthStatus = %n", status);
}
internal static IDataReader Get(TransactionContext tc)
{
return tc.ExecuteReader("SELECT * FROM RoleActionPermission");
}
internal static IDataReader Get(TransactionContext tc, int id)
{
return tc.ExecuteReader("SELECT * FROM RoleActionPermission WHERE RoleActionPermissionID=%n", id);
}
internal static IDataReader Get(TransactionContext tc, int id, EnumAuthStatus status)
{
return tc.ExecuteReader(
"SELECT * FROM RoleActionPermission WHERE RoleActionPermissionID=%n AND AuthStatus = %n", id, status);
}
#endregion
#region Delete function
internal static void Delete(TransactionContext tc, int id)
{
//tc.ExecuteNonQuery("UPDATE Role SET CreatedBy=%n WHERE RoleID = %n", User.CurrentUser.ID, id);
tc.ExecuteNonQuery("DELETE FROM RoleActionPermission WHERE RoleActionPermissionID = %n", id);
}
#endregion
}
}