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

82 lines
2.6 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 LoanDA
internal class LoanDA
{
#region Constructor
private LoanDA() { }
#endregion
#region Insert function
internal static void Insert(TransactionContext tc, Loan item)
{
tc.ExecuteNonQuery("INSERT INTO LOANBASIC(LoanID, description, isConfirmationRequired, interestRate, CreatedBy, CreationDate, SequenceNo, Status)" +
" VALUES(%n, %s, %b, %n, %n, %d, %n, %n)", item.ID.Integer, item.Name, item.IsConfirmationRequired, item.InterestRate, DataReader.GetNullValue(item.CreatedBy.Integer), DataReader.GetNullValue(item.CreatedDate), item.Sequence, item.Status);
}
#endregion
#region Update function
internal static void Update(TransactionContext tc, Loan item)
{
tc.ExecuteNonQuery("UPDATE LOANBASIC SET description=%s, isConfirmationRequired=%b, interestRate=%n, ModifiedBy=%n, ModifiedDate=%d, SequenceNo=%n, Status=%n" +
" WHERE LoanID=%n", item.Name, item.IsConfirmationRequired, item.InterestRate, DataReader.GetNullValue(item.ModifiedBy.Integer), DataReader.GetNullValue(item.ModifiedDate), item.Sequence, item.Status, item.ID.Integer);
}
#endregion
#region Get Function
internal static IDataReader Get(TransactionContext tc,EnumStatus status)
{
if (EnumStatus.Active == status || EnumStatus.Inactive == status)
{
return tc.ExecuteReader("SELECT * FROM LOANBASIC where Status=%n Order By SequenceNo", status);
}
else
{
return tc.ExecuteReader("SELECT * FROM LOANBASIC Order By SequenceNo");
}
}
internal static IDataReader Get(TransactionContext tc, ID nID)
{
return tc.ExecuteReader("SELECT * FROM LOANBASIC WHERE LoanID=%n", nID.Integer);
}
#endregion
#region Delete function
internal static void Delete(TransactionContext tc, ID nID)
{
tc.ExecuteNonQuery("DELETE FROM [LOANBASIC] WHERE LoanID=%n", nID.Integer);
}
#endregion
internal static IDataReader Get(TransactionContext tc, string loanNo)
{
return tc.ExecuteReader("SELECT * from LoanBasic where LoanID in(select LoanID FROM LOANISSUE where LoanNo=%s)", loanNo);
}
}
#endregion
}