EchoTex_Payroll/HRM.DA/DA/Attendance/CardOperationDA.cs
2024-10-14 10:01:49 +06:00

99 lines
3.4 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ease.CoreV35.DataAccess;
using System.Data;
using HRM.BO;
using Ease.Core.DataAccess;
namespace HRM.DA
{
#region CardOperationDA
internal class CardOperationDA
{
#region Constructor
private CardOperationDA()
{
}
#endregion
#region Insert function
internal static void Insert(TransactionContext tc, CardOperation item)
{
string sql = SQLParser.MakeSQL("INSERT INTO CardOperation(CardOperationID, CardID, CardNumber, CardStatus, EmployeeID, Comments, AssignDate, CreatedBy, CreatedDate)" +
" VALUES(%n, %n, %s, %n, %n, %s, %d, %n, %d)", item.ID, item.CardID, item.CardNumber, item.Status,
item.EmployeeID, item.Comments, item.AssignDate, item.CreatedBy, item.CreatedDate);
tc.ExecuteNonQuery(sql);
}
#endregion
#region Update function
internal static void Update(TransactionContext tc, CardOperation item)
{
tc.ExecuteNonQuery(
"UPDATE CardOperation SET CardID=%n, CardNumber=%s, CardStatus=%n, EmployeeID=%n, Comments=%s, AssignDate=%d, ModifiedBy=%n, ModifiedDate=%d" +
" WHERE CardOperationID=%n", item.CardID, item.CardNumber, item.Status, item.EmployeeID, item.Comments,
item.AssignDate, item.ModifiedBy, item.ModifiedDate, item.ID);
}
#endregion
#region Get Function
internal static IDataReader Get(TransactionContext tc)
{
return tc.ExecuteReader("SELECT * FROM CardOperation");
}
internal static IDataReader Get(TransactionContext tc, int nID)
{
return tc.ExecuteReader("SELECT * FROM CardOperation WHERE CardOperationID=%n", nID);
}
internal static IDataReader GetByCardID(TransactionContext tc, int nID)
{
return tc.ExecuteReader("SELECT * FROM CardOperation WHERE CardID=%n", nID);
}
internal static IDataReader GetByEmpIDAndCardID(TransactionContext tc, int empId, int cardId)
{
return tc.ExecuteReader("SELECT * FROM CardOperation WHERE CardID=%n and EmployeeID=%n", cardId, empId);
}
internal static IDataReader Get(TransactionContext tc, string CardNumber)
{
return tc.ExecuteReader("SELECT * FROM CardOperation WHERE CardNumber=%s", CardNumber);
}
#endregion
#region Delete function
internal static void Delete(TransactionContext tc, int nID)
{
tc.ExecuteNonQuery("DELETE FROM CardOperation WHERE CardOperationID=%n", nID);
}
#endregion
internal static DataSet GetEmployeeWiseCardOperations(TransactionContext tc, string sEmpIDs)
{
string sql = SQLParser.MakeSQL(@"SELECT e.EMPLOYEENO,e.NAME EmployeeName,ch.CardNumber
,dbo.GetFormattedDate(ch.AssignDate,1) AssignDate, dbo.GetFormattedDate(ch.TillDate,1) TillDate
FROM EmpCardHistory ch
INNER JOIN (Select * From EMPLOYEE where EmployeeID in(%q)) e
ON e.EMPLOYEEID = ch.EmployeeID", sEmpIDs);
return tc.ExecuteDataSet(sql);
}
}
#endregion
}