EchoTex_Payroll/HRM.DA/DA/Basic/BranchDA.cs

90 lines
3.0 KiB
C#
Raw Normal View History

2024-10-14 10:01:49 +06:00
using HRM.BO;
using Ease.Core.DataAccess;
using System.Data;
namespace HRM.DA
{
internal class BranchDA
{
#region Constructor
private BranchDA()
{
}
#endregion
#region Insert function
internal static void Insert(TransactionContext tc, Branch item)
{
tc.ExecuteNonQuery(
"INSERT INTO Branches(BranchID, Code, RoutingNo, Name, Address, Telephone, BankID, CreatedBy, CreationDate, SequenceNo, Status, payrolltypeid)" +
" VALUES(%n, %s, %s, %s, %s, %s, %n, %n, %d, %n, %n, %n)", item.ID, item.Code, item.RoutingNo, item.Name,
item.Address, item.Telephone, item.BankID, item.CreatedBy, item.CreatedDate, item.Sequence,
item.Status, item.PayrollTypeID);
}
#endregion
#region Update function
internal static void Update(TransactionContext tc, Branch item)
{
tc.ExecuteNonQuery(
"UPDATE Branches SET Code=%s, RoutingNo=%s, Name=%s, Address=%s, Telephone=%s, BankID=%n, ModifiedBy=%n, ModifiedDate=%d, SequenceNo=%n, Status=%n" +
"WHERE BranchID=%n", item.Code, item.RoutingNo, item.Name, item.Address, item.Telephone, item.BankID,
item.ModifiedBy, item.ModifiedDate, item.Sequence, item.Status, item.ID);
}
#endregion
#region Get Function
internal static IDataReader GetChild(TransactionContext tc, int bankID)
{
return tc.ExecuteReader("SELECT * FROM Branches Where BankID=%n Order by Name", bankID);
}
//internal static IDataReader Get(TransactionContext tc, EnumStatus status)
//{
// if (EnumStatus.Active == status || EnumStatus.Inactive == status)
// {
// return tc.ExecuteReader("SELECT * FROM Branches Where Status=%n Order by sequenceNo", status);
// }
// else
// {
// return tc.ExecuteReader("SELECT * FROM Branches Order by sequenceNo");
// }
//}
internal static IDataReader Get(TransactionContext tc, EnumStatus status, int payrolltypeid)
{
if (EnumStatus.Active == status || EnumStatus.Inactive == status)
{
return tc.ExecuteReader("SELECT * FROM Branches Where payrolltypeid =%n and Status=%n Order by sequenceNo",
payrolltypeid, status);
}
else
{
return tc.ExecuteReader("SELECT * FROM Branches where payrolltypeid=%n Order by sequenceNo", payrolltypeid);
}
}
internal static IDataReader Get(TransactionContext tc, int ID)
{
return tc.ExecuteReader("SELECT * FROM Branches WHERE BranchID=%n", ID);
}
#endregion
#region Delete function
internal static void Delete(TransactionContext tc, int ID)
{
tc.ExecuteNonQuery("DELETE FROM Branches WHERE BranchID=%n", ID);
}
#endregion
}
}