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

85 lines
2.8 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 BankDA
internal class BankDA
{
#region Constructor
private BankDA() { }
#endregion
#region Insert function
internal static void Insert(TransactionContext tc, Bank item)
{
tc.ExecuteNonQuery("INSERT INTO Banks(BankID, Code, Name, AccountNo,ACCOUNTNOFORMAT, CreatedBy, CreationDate, SequenceNo, Status)" +
" VALUES(%n, %s, %s,%s, %s, %n, %d, %n, %n)", item.ID.Integer, item.Code, item.Name, item.AccountNo,item.Accountingformat, item.CreatedBy.Integer, item.CreatedDate, item.Sequence, item.Status);
}
#endregion
#region Update function
internal static void Update(TransactionContext tc, Bank item)
{
tc.ExecuteNonQuery("UPDATE Banks SET Code=%s, Name=%s, AccountNo = %s,ACCOUNTNOFORMAT=%s, ModifiedBy=%n, ModifiedDate=%d, SequenceNo=%n, Status=%n" +
"WHERE BankID=%n", item.Code, item.Name, item.AccountNo,item.Accountingformat, item.ModifiedBy.Integer, item.ModifiedDate, item.Sequence, item.Status,item.ID.Integer);
}
#endregion
#region Get Function
internal static IDataReader Get(TransactionContext tc)
{
return tc.ExecuteReader("SELECT * FROM Banks Order By SequenceNO");
}
internal static IDataReader Get(TransactionContext tc, EnumStatus status)
{
if(EnumStatus.Active==status ||EnumStatus.Inactive==status)
{
return tc.ExecuteReader("SELECT * FROM Banks where Status=%n order by SequenceNO", status);
}
else
{
return tc.ExecuteReader("SELECT * FROM Banks order by SequenceNO");
}
}
internal static IDataReader Get(TransactionContext tc, ID nID)
{
return tc.ExecuteReader("SELECT * FROM Banks Where BankID=%n",nID.Integer );
}
internal static IDataReader GetByBrancID(TransactionContext tc, ID nID)
{
return tc.ExecuteReader("SELECT * FROM Banks Where BankID=(Select BANKID from Branches where BranchID=%n)", nID.Integer);
}
#endregion
#region Delete function
internal static void Delete(TransactionContext tc, ID nID)
{
tc.ExecuteNonQuery("UPDATE [Banks] SET CreatedBy=%n,ModifiedBy=%n Where BankID=%n", Payroll.BO.User.CurrentUser.ID.Integer, Payroll.BO.User.CurrentUser.ID.Integer, nID.Integer);
tc.ExecuteNonQuery("DELETE FROM [Banks] Where BankID=%n",nID.Integer);
}
#endregion
}
#endregion
}