EchoTex_Payroll/HRM.DA/DA/Fund/Loan/LoanCategoryDA.cs

135 lines
5.1 KiB
C#
Raw Normal View History

2024-10-14 10:01:49 +06:00
using System;
using System.Data;
using System.Linq;
using System.Text;
using Ease.Core.DataAccess;
using HRM.BO;
namespace HRM.DA
{
internal class LoanCategoryDA
{
#region Constructor
public LoanCategoryDA()
{
}
#endregion
#region Insert Function
internal static void Insert(TransactionContext tc, LoanCategory loanCategory)
{
string sql = SQLParser.MakeSQL(
"INSERT INTO LoanCategory (LoanCategoryID, LoanCategoryCode, UserObjectName, DefaultInterestRate, Description,IsActive, MaxAlowableFlatAmount, MaxInstallment, MinInstallment, PercentageofFund, Version,CreatedBy, CreatedDate, ProjectID)" +
" VALUES(%n,%s,%s, %n,%s,%n,%n,%n,%n,%n,%n,%n,%D,%n)", loanCategory.ID, loanCategory.LoanCategoryCode,
loanCategory.UserObjectName, loanCategory.DefaultInterestRate, loanCategory.Description,
loanCategory.IsActive, DataReader.GetNullValue(loanCategory.MaxAlowableFlatAmount),
loanCategory.MaxInstallment, loanCategory.MinInstallment,
DataReader.GetNullValue(loanCategory.PercentageofFund), loanCategory.Version, loanCategory.CreatedBy,
loanCategory.CreatedDate, loanCategory.ProjectID);
tc.ExecuteNonQuery(sql);
}
//internal static void Insert(TransactionContext tc, LoanCategory.LoanCategoryFundRelation fundRelation)
//{
// string sql = SQLParser.MakeSQL("INSERT INTO LoanCategoryFundRelation (LoanCategoryID, FundTypeID, ProjectID)" +
// " VALUES(%n,%n, %n)", fundRelation.LoanCategoryID.Integer, fundRelation.FundTypeID.Integer, fundRelation.ProjectID.Integer);
// tc.ExecuteNonQuery(sql);
//}
#endregion
#region Update function
internal static void Update(TransactionContext tc, LoanCategory loanCategory)
{
string sql = SQLParser.MakeSQL("UPDATE LoanCategory Set Version = %n, ModifiedBy = %n, ModifiedDate = %D" +
"WHERE LoanCategoryID = %n ", loanCategory.Version, loanCategory.ModifiedBy,
loanCategory.ModifiedDate, loanCategory.ID);
tc.ExecuteNonQuery(sql);
}
internal static void ChangeStatus(TransactionContext tc, LoanCategory loanCategory,
EnumLoanCategoryStatus status)
{
string sql = SQLParser.MakeSQL("UPDATE LoanCategory Set IsActive = %n,ModifiedBy = %n, ModifiedDate = %D " +
"WHERE LoanCategoryID = %n ", status, loanCategory.ModifiedBy,
loanCategory.ModifiedDate, loanCategory.ID);
tc.ExecuteNonQuery(sql);
}
internal static void UpdateActivity(TransactionContext tc, int ActivityID, int CategoryID)
{
string sql = SQLParser.MakeSQL("UPDATE LoanCategory Set ActivityID = %n" +
"WHERE LoanCategoryID = %n ", ActivityID, CategoryID);
tc.ExecuteNonQuery(sql);
}
#endregion
#region Delete Function
internal static void Delete(TransactionContext tc, int loanCategoryId)
{
tc.ExecuteNonQuery("DELETE FROM LoanCategoryFundRelation WHERE LoanCategoryID=%n", loanCategoryId);
}
#endregion
#region Get Function
internal static IDataReader Get(TransactionContext tc, int loanCategoryID)
{
return tc.ExecuteReader("SELECT * FROM LoanCategory WHERE LoanCategoryID=%n AND Version = %n",
loanCategoryID, 0);
}
internal static IDataReader Get(TransactionContext tc, string loanCategoryCode)
{
return tc.ExecuteReader("SELECT * FROM LoanCategory WHERE LoanCategoryCode=%s AND Version = %n ",
loanCategoryCode, 0);
}
internal static IDataReader Get(TransactionContext tc)
{
return tc.ExecuteReader("SELECT * FROM LoanCategory WHERE Version = %n", 0);
}
internal static IDataReader Get(TransactionContext tc, EnumLoanCategoryStatus status)
{
return tc.ExecuteReader("SELECT * FROM LoanCategory WHERE Version = %n ", 0);
}
internal static IDataReader GetFundRelations(TransactionContext tc, int loanCategoryID)
{
return tc.ExecuteReader("SELECT * FROM LoanCategoryFundRelation WHERE LoanCategoryID=%n", loanCategoryID);
}
#endregion
#region isExists function
internal static bool IsExist(TransactionContext tc, string loanCategoryCode, int version)
{
object ob = tc.ExecuteScalar("SELECT COUNT(*) FROM LoanCategory WHERE LoanCategoryCode=%s AND Version = %n",
loanCategoryCode, version);
return Convert.ToInt32(ob) > 0;
}
#endregion
#region IsIssued
internal static bool IsIssued(TransactionContext tc, int loanCatID)
{
object ob = tc.ExecuteScalar("SELECT COUNT(*) FROM Loan WHERE LoanCategoryID = %n ", loanCatID);
return Convert.ToInt32(ob) > 0;
}
#endregion
}
}