CEL_Payroll/Payroll.Service/Common/DA/ErrorSuccessLogDA.cs
2024-09-17 14:30:13 +06:00

96 lines
3.9 KiB
C#

using System;
using Payroll.BO;
using System.Data;
using System.Linq;
using Ease.CoreV35.Model;
using System.Data.SqlClient;
using Ease.CoreV35.DataAccess;
using System.Collections.Generic;
using Ease.CoreV35.DataAccess.SQL;
namespace Payroll.Service
{
#region ErrorSuccessLogDA
internal class ErrorSuccessLogDA
{
#region Constructor
private ErrorSuccessLogDA() { }
#endregion
#region Insert function
internal static void Insert(TransactionContext tc, ErrorSuccessLog item)
{
tc.ExecuteNonQuery("INSERT INTO ErrorSuccessLog(ErrorSuccessLogID, OperationDate, IsLogRead, ReceiveStatus, ViewName)" +
" VALUES(%n, %D, %b, %n, %s)", item.ID.Integer, item.OperationDate, item.IsLogRead, item.ReceiveStatus, item.ViewName);
}
internal static void Update(TransactionContext tc, ErrorSuccessLog item)
{
tc.ExecuteNonQuery("Update ErrorSuccessLog set IsLogRead=%b where ErrorSuccessLogID=%n", item.IsLogRead, item.ID.Integer);
}
internal static void Insert(TransactionContext tc, ErrorLogDetail item)
{
tc.ExecuteNonQuery("INSERT INTO ErrorLogDetail(ErrorLogDetailID,ErrorSuccessLogID, EmployeePIN, EmployeeName,ErrorDescription,ErrorType)" +
" VALUES(%n, %n, %s, %s, %s, %b)", item.ID.Integer, item.ErrorSuccessLogID.Integer, item.EmployeePIN, item.EmployeeName, item.ErrorDescription, item.ErrorType);
}
internal static void Insert(TransactionContext tc, SuccessLogDetail item)
{
tc.ExecuteNonQuery("INSERT INTO SuccessLogDetail(SuccessLogDetailID,ErrorSuccessLogID, EmployeePIN, EmployeeName,SuccessDescription)" +
" VALUES(%n, %n, %s, %s, %s)", item.ID.Integer, item.ErrorSuccessLogID.Integer, item.EmployeePIN, item.EmployeeName, item.SuccessDescription);
}
#endregion
#region Get Function
internal static IDataReader Get(TransactionContext tc, ID nID)
{
return tc.ExecuteReader("SELECT * FROM ErrorSuccessLog WHERE ErrorSuccessLogID=%n", nID.Integer);
}
internal static IDataReader Get(TransactionContext tc)
{
return tc.ExecuteReader("SELECT * FROM ErrorSuccessLog order by ErrorSuccessLogID desc");
}
internal static IDataReader GetErrorLogDetail(TransactionContext tc, ID nID)
{
return tc.ExecuteReader("SELECT * FROM ErrorLogDetail WHERE ErrorSuccessLogID=%n", nID.Integer);
}
internal static IDataReader GetSuccessLogDetail(TransactionContext tc, ID nID)
{
return tc.ExecuteReader("SELECT * FROM SuccessLogDetail WHERE ErrorSuccessLogID=%n", nID.Integer);
}
internal static IDataReader GetByStatus(TransactionContext tc, bool sts)
{
return tc.ExecuteReader("SELECT * FROM ErrorSuccessLog WHERE ReceiveStatus=%n order by ErrorSuccessLogID desc", sts ? 1 : 2);
}
internal static IDataReader GetByStatus(TransactionContext tc, bool sts, DateTime fromDate, DateTime toDate)
{
string sql = SQLParser.MakeSQL("SELECT * FROM ErrorSuccessLog WHERE ReceiveStatus=%n AND OperationDate BETWEEN %d AND %d order by ErrorSuccessLogID desc", sts ? 1 : 2, fromDate.ToString("dd MMM yyyy"), toDate.AddDays(1).ToString("dd MMM yyyy"));
return tc.ExecuteReader(sql);
}
#endregion
#region Delete function
//internal static void Delete(TransactionContext tc, ID nID)
//{
// tc.ExecuteNonQuery("DELETE FROM [ErrorLogDetail] WHERE ErrorSuccessLogID=%n", nID.Integer);
// tc.ExecuteNonQuery("DELETE FROM [SuccessLogDetail] WHERE ErrorSuccessLogID=%n", nID.Integer);
// tc.ExecuteNonQuery("DELETE FROM [ErrorSuccessLog] WHERE ErrorSuccessLogID=%n", nID.Integer);
//}
#endregion
}
#endregion
}