HRM-10/HRM.DA/DA/Workflow/EmployeeNotificationDA.cs

73 lines
2.2 KiB
C#
Raw Normal View History

2026-11-03 13:06:00 +06:00

using Ease.Core.DataAccess;
using HRM.BO;
using System;
using System.Collections.Generic;
using System.Data;
namespace HRM.DA
{
public class EmployeeNotificationDA
{
public EmployeeNotificationDA()
{
}
public static int GetNewID(TransactionContext tc)
{
return tc.GenerateID("EmployeeNotification", "ID");
}
public static void Insert(TransactionContext tc, EmployeeNotification item)
{
tc.ExecuteNonQuery(
"INSERT INTO EmployeeNotification( EmployeeID, Header, Description, Link, CreatedDate, CreatedBy, ReferenceID, IsRead, ReadDate, ReadBy) " +
"VALUES( %n, %s, %s, %s, %D, %n, %n, %n, %D, %n)",
item.EmployeeID,
item.Header,
item.Description,
item.Link,
item.CreatedDate,
item.CreatedBy,
item.ReferenceID,
item.IsRead,
item.ReadDate,
item.ReadBy);
}
public static void ReadUpdate(TransactionContext tc, EmployeeNotification item)
{
tc.ExecuteNonQuery(
"UPDATE EmployeeNotification SET IsRead=%n, ReadDate=%D, ReadBy=%n WHERE ID=%n",
item.IsRead,
item.ReadDate,
item.ReadBy,
item.ID);
}
public static void MakeRead(TransactionContext tc, int employeeID, List<int> ids)
{
if (ids == null || ids.Count == 0)
return;
string idList = string.Join(",", ids);
tc.ExecuteNonQuery(
"UPDATE EmployeeNotification " +
"SET IsRead = 1, ReadDate = %D, ReadBy = %n " +
"WHERE EmployeeID = %n AND ID IN (" + idList + ")",
DateTime.Now,
employeeID,
employeeID
);
}
public static IDataReader Get(TransactionContext tc, int employeeID)
{
return tc.ExecuteReader(
"SELECT * FROM EmployeeNotification WHERE EmployeeID=%n ORDER BY CreatedDate DESC, ID DESC",
employeeID);
}
}
}