116 lines
3.8 KiB
C#
116 lines
3.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using HRM.BO;
|
|
using Ease.Core.DataAccess;
|
|
|
|
namespace HRM.DA
|
|
{
|
|
#region AccessCardDA
|
|
|
|
internal class AccessCardDA
|
|
{
|
|
#region Insert function
|
|
|
|
internal static void Insert(TransactionContext tc, AccessCard item)
|
|
{
|
|
tc.ExecuteNonQuery("INSERT INTO AccessCard(AccessCardID, CardNumber, TypeID,Status)" +
|
|
" VALUES(%n, %s, %n, %n)", item.ID, item.CardNumber, item.TypeID, item.Status);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Update function
|
|
|
|
internal static void Update(TransactionContext tc, AccessCard item)
|
|
{
|
|
tc.ExecuteNonQuery("UPDATE AccessCard SET CardNumber=%s, TypeID=%n, Status=%n" +
|
|
" WHERE AccessCardID=%n", item.CardNumber, item.TypeID, item.Status, item.ID);
|
|
}
|
|
|
|
internal static void UpdateStatus(TransactionContext tc, int cardID, EnumCardStatus status, int payrollTypeId)
|
|
{
|
|
tc.ExecuteNonQuery("UPDATE AccessCard SET Status=%n, PAYROLLTYPEID=%n WHERE AccessCardID=%n", status, payrollTypeId, cardID);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Get Function
|
|
|
|
internal static IDataReader Get(TransactionContext tc)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM AccessCard");
|
|
}
|
|
|
|
internal static IDataReader Get(TransactionContext tc, EnumCardStatus status)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM AccessCard WHERE Status=%n", status);
|
|
}
|
|
|
|
internal static IDataReader Get(TransactionContext tc, params EnumCardStatus[] status)
|
|
{
|
|
StringBuilder statusEnums = new StringBuilder();
|
|
if (status != null)
|
|
{
|
|
for (int i = 0; i < status.Length; ++i)
|
|
{
|
|
statusEnums.Append((int)status[i]);
|
|
statusEnums.Append(", ");
|
|
}
|
|
}
|
|
|
|
if (statusEnums.Length > 2)
|
|
{
|
|
statusEnums.Remove(statusEnums.Length - 2, 2);
|
|
return tc.ExecuteReader("SELECT * FROM AccessCard WHERE Status IN (%q)", statusEnums.ToString());
|
|
}
|
|
else
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM AccessCard");
|
|
}
|
|
}
|
|
|
|
internal static IDataReader Get(TransactionContext tc, int id)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM AccessCard WHERE AccessCardID=%n", id);
|
|
}
|
|
|
|
internal static IDataReader Get(TransactionContext tc, string CardNumber)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM AccessCard WHERE CardNumber=%s", CardNumber);
|
|
}
|
|
internal static DataTable GetCardInformation(TransactionContext tc, int CardStatus)
|
|
{
|
|
string str = SQLParser.MakeSQL(@"select AccessCard.CardNumber, AccessCard.TypeID, AccessCard.Status, EMPLOYEE.EMPLOYEENO " +
|
|
"from EMPLOYEE join AccessCard on EMPLOYEE.CardID = AccessCard.AccessCardID where AccessCard.Status=%n", CardStatus);
|
|
return tc.ExecuteDataTable(str);
|
|
}
|
|
#endregion
|
|
|
|
#region Delete function
|
|
|
|
internal static void Delete(TransactionContext tc, int id)
|
|
{
|
|
tc.ExecuteNonQuery("DELETE FROM AccessCard WHERE AccessCardID=%n", id);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region IsExist
|
|
|
|
internal static bool IsExist(TransactionContext tc, string CardNumber)
|
|
{
|
|
bool isExist = false;
|
|
object obj = tc.ExecuteScalar("SELECT Count(*) from AccessCard Where CardNumber=%s", CardNumber);
|
|
isExist = Convert.ToInt32(obj) > 0 ? true : false;
|
|
return isExist;
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
|
|
#endregion
|
|
} |