EchoTex_Payroll/HRM.DA/DA/Gratuity/ESBProvisionDA.cs

108 lines
3.6 KiB
C#
Raw Permalink Normal View History

2024-10-14 10:01:49 +06:00
using System;
using System.Data;
using System.Linq;
using Ease.Core.Model;
using System.Data.SqlClient;
using Ease.Core.DataAccess;
using System.Collections.Generic;
using Ease.Core.DataAccess.SQL;
using HRM.BO;
namespace HRM.DA
{
#region ESBProvisionDA
internal class ESBProvisionDA
{
#region Constructor
private ESBProvisionDA()
{
}
#endregion
#region Insert function
internal static void Insert(TransactionContext tc, ESBProvision item)
{
//, ProvisionOne,ProvisionTwo , %n, %n , item.ProvisionOne, item.ProvisionTwo
tc.ExecuteNonQuery(
"INSERT INTO ESBProvision(EmployeeID, SalaryMonthlyID, UserID, ProcessMonthDate, Provision)" +
" VALUES(%n, %n, %n, %d, %n)", item.EmployeeID, item.SalaryMonthlyID, item.UserID,
item.ProcessMonthDate, item.Provision);
}
#endregion
#region Get Function
internal static IDataReader Get(TransactionContext tc, int nID)
{
return tc.ExecuteReader("SELECT * FROM ESBProvision WHERE EmployeeID=%n", nID);
}
internal static IDataReader GetProvision(TransactionContext tc, string sEmpID, DateTime GratuityMonth)
{
string sSQL = string.Empty;
sSQL = SQLParser.MakeSQL("SELECT * FROM ESBProvision WHERE EmployeeID in (%q) and ProcessMonthDate=%d",
sEmpID, GratuityMonth);
return tc.ExecuteReader("SELECT * FROM ESBProvision WHERE EmployeeID in (%q) and ProcessMonthDate=%d",
sEmpID, GratuityMonth);
}
#endregion
#region Delete function
internal static void Delete(TransactionContext tc, int nEmpID, int nSalaryMonthlyID)
{
tc.ExecuteNonQuery("DELETE FROM ESBProvision WHERE EmployeeID=%n and SalaryMonthlyID=%n", nEmpID,
nSalaryMonthlyID);
}
internal static IDataReader GetProvision(TransactionContext tc, DateTime dFromDate, DateTime dToDate)
{
return tc.ExecuteReader("SELECT * FROM ESBProvision where ProcessMonthDate between %d and %d ", dFromDate,
dToDate);
}
internal static IDataReader GetProvision(TransactionContext tc, int nEmpID, DateTime dFromDate,
DateTime dToDate)
{
return tc.ExecuteReader(
"SELECT * FROM ESBProvision where EmployeeID=%n AND ProcessMonthDate between %d and %d ", nEmpID,
dFromDate, dToDate);
}
internal static double GetOpeningBalance(TransactionContext tc, int nEmpID, DateTime fromDate)
{
object amount = tc.ExecuteScalar("SELECT SUM(Provision) FROM ESBProvision WHERE"
+ " EmployeeID=%n AND ProcessMonthDate < %d", nEmpID, fromDate);
if (amount == DBNull.Value)
return 0;
else return Convert.ToDouble(amount);
}
internal static DataSet GetCumulativeProv(TransactionContext tc, DateTime dateTime)
{
DataSet oCumulativeProvs = new DataSet();
try
{
oCumulativeProvs = tc.ExecuteDataSet("SELECT EmployeeID,SUM(Provision) FROM ESBProvision WHERE"
+ " ProcessMonthDate < %d Group by EmployeeID", dateTime);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return oCumulativeProvs;
}
#endregion
}
#endregion
}