CEL_Payroll/Payroll.Service/Tax/DA/EmployeeTaxInvestmentDA.cs

118 lines
4.7 KiB
C#
Raw Normal View History

2024-09-17 14:30:13 +06:00
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 EmployeeTaxInvestmentDA
internal class EmployeeTaxInvestmentDA
{
#region Constructor
private EmployeeTaxInvestmentDA() { }
#endregion
#region Insert function
internal static void Insert(TransactionContext tc, EmployeeTaxInvestment item)
{
tc.ExecuteNonQuery("INSERT INTO ITINVESTMENT(InvestmentID, employeeID, amount, taxParamID, typeID, CreatedBy, CreationDate, SequenceNo, Status)" +
" VALUES(%n, %n, %n, %n, %n, %n, %d, %n, %n)", item.ID.Integer, item.EmployeeID.Integer, item.Amount, item.TaxparameterId.Integer, item.TypeID.Integer, item.CreatedBy.Integer, item.CreatedDate, item.Sequence, item.Status);
}
#endregion
#region Update function
internal static void Update(TransactionContext tc, EmployeeTaxInvestment item)
{
tc.ExecuteNonQuery("UPDATE ITINVESTMENT SET employeeID=%n, amount=%n, taxParamID=%n, typeID=%n, ModifiedBy=%n, ModifiedDate=%d, SequenceNo=%n, Status=%n" +
" WHERE InvestmentID=%n", item.EmployeeID.Integer, item.Amount, item.TaxparameterId.Integer, item.TypeID.Integer, 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 ITINVESTMENT");
}
internal static IDataReader Get(TransactionContext tc, ID nID)
{
return tc.ExecuteReader("SELECT * FROM ITINVESTMENT WHERE InvestmentID=%n", nID);
}
internal static double GetAmount(TransactionContext tc, ID nTaxParamID,ID nEmployeeID)
{
object InvestAmount = tc.ExecuteScalar("SELECT Sum(amount) Amount FROM ITINVESTMENT WHERE taxParamID=%n AND employeeID=%n", nTaxParamID.Integer, nEmployeeID.Integer);
if (InvestAmount == DBNull.Value)
return 0.0;
return Convert.ToDouble(InvestAmount);
}
#endregion
#region Delete function
internal static void Delete(TransactionContext tc, ID nID)
{
tc.ExecuteNonQuery("DELETE FROM [ITINVESTMENT] WHERE InvestmentID=%n", nID);
}
internal static void Delete(TransactionContext tc, ID taxparamId, ID emplioyeeid, ID typeID)
{
tc.ExecuteNonQuery("DELETE FROM [ITINVESTMENT] WHERE taxParamID=%n AND employeeID=%n AND typeID=%n", taxparamId.Integer, emplioyeeid.Integer, typeID.Integer);
}
internal static void Delete(TransactionContext tc, int empId, int taxParamId, int typeId)
{
tc.ExecuteNonQuery("DELETE FROM ITINVESTMENT WHERE employeeID=%n AND taxParamID=%n AND typeID=%n", empId, taxParamId, typeId);
}
#endregion
internal static IDataReader GetAllUsersInfo(TransactionContext tc, int taxParamID)
{
// int taxparid = Payroll.BO.SystemInformation.CurrentSysInfo.TaxParamID.Integer;
return tc.ExecuteReader(@"select employeeid ,MAX(INVESTMENTID) as INVESTMENTID, SUM(AMOUNT) as AMOUNT ,MAX(TYPEID) as TYPEID , MAX(INVDATE) as INVDATE ,
MAX(USERID) as USERID,
MAX(TAXPARAMID) as TAXPARAMID,
MAX(SequenceNO) as SequenceNO,
MAX(Status) as Status,
MAX(CreatedBy) as CreatedBy,
MAX(CreationDate) as CreationDate,
MAX(ModifiedBy) as ModifiedBy,
MAX(ModifiedDate) as ModifiedDate
from ITINVESTMENT where TAXPARAMID = %n and
TYPEID in (select TYPEID from ITINVESTMENT) group by EMPLOYEEID", taxParamID);
}
internal static IDataReader GetSingleEmpsInfo(TransactionContext tc, ID id)
{
return tc.ExecuteReader("select employeeid,INVESTMENTID,AMOUNT,TYPEID,INVDATE,USERID,TAXPARAMID,SequenceNO,Status,CreatedBy,CreationDate,ModifiedBy,ModifiedDate from ITINVESTMENT where EMPLOYEEID = %n", id.Integer);
}
#region Other function
public static bool IsExist(TransactionContext tc, int empId, int taxParamId, int typeId)
{
bool Exist = false;
Object obj = tc.ExecuteScalar("Select COUNT (*) FROM ITINVESTMENT WHERE employeeID=%n AND taxParamID=%n AND typeID=%n", empId, taxParamId, typeId);
Exist = Convert.ToInt32(obj) > 0 ? true : false;
return Exist;
}
#endregion
}
#endregion
}