EchoTex_Payroll/HRM.DA/DA/Tax/EmpTaxAitDA.cs
2024-10-14 10:01:49 +06:00

118 lines
5.5 KiB
C#

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Ease.Core.DataAccess;
using HRM.BO;
namespace HRM.DA
{
public class EmpTaxAitDA
{
internal static IDataReader Get(TransactionContext tc, int id)
{
return tc.ExecuteReader("Select * from EmpTaxAit where empTaxAitId = %n", id);
}
internal static IDataReader GetAll(TransactionContext tc)
{
return tc.ExecuteReader("Select * from EmpTaxAit");
}
internal static IDataReader GetByEmpId(TransactionContext tc, int empId)
{
return tc.ExecuteReader("Select * from EmpTaxAit where employeeId = %n", empId);
}
internal static IDataReader GetByTaxParamIdForAdmin(TransactionContext tc, int taxParamId, int entryFrom, int taxEffect)
{
string subSql = String.Empty;
if (entryFrom > 0)
{
subSql += SQLParser.MakeSQL("And entryFrom = %n ", entryFrom);
}
if (taxEffect > 0)
{
subSql += SQLParser.MakeSQL("And taxEffect = %n", taxEffect);
}
string sql = SQLParser.MakeSQL("Select * from EmpTaxAit where taxParamId = %n %q",
taxParamId, subSql);
return tc.ExecuteReader(sql);
}
internal static IDataReader GetByTaxParamIdAndEmpId(TransactionContext tc, int taxParamId, int empId)
{
return tc.ExecuteReader("Select * from EmpTaxAit where taxParamId = %n and employeeId = %n", taxParamId, empId);
}
internal static IDataReader GetByTaxParamIdBYEffectForAdmin(TransactionContext tc, int taxParamId, int entryFrom, EnumTaxAITInvestment taxEffectB)
{
string subSql = String.Empty;
if (entryFrom > 0)
{
subSql += SQLParser.MakeSQL("And entryFrom = %n ", entryFrom);
}
string sql = SQLParser.MakeSQL("Select * from EmpTaxAit where taxParamId = %n and taxEffectDone = %n and checkedBy <= 0 %q", taxParamId, taxEffectB, subSql);
return tc.ExecuteReader(sql);
}
internal static void Insert(TransactionContext tc, EmpTaxAit item)
{
string sql = SQLParser.MakeSQL(@"INSERT INTO [dbo].[EmpTaxAit]
([EmpTaxAitId]
,[TaxParamId]
,[EmployeeId]
,[Name]
,[Remarks]
,[Amount]
,[CheckedBy]
,[CheckedDate]
,[CreatedBy]
,[ModifiedBy]
,[CreatedDate]
,[ModifiedDate]
,EntryFrom
,taxeffectDone)
VALUES (%n,%n,%n,%s,%s,%n,%n,%d,%n,%n,%d,%d, %n, %n)", item.ID, item.TaxParamId, item.EmployeeId,
item.Name, item.Remarks, item.Amount, item.CheckedBy, item.CheckedDate, item.CreatedBy, item.ModifiedBy, item.CreatedDate, item.ModifiedDate, item.EntryFrom, item.TaxEffectDone);
tc.ExecuteNonQuery(sql);
}
internal static void Update(TransactionContext tc, EmpTaxAit item)
{
string sql = SQLParser.MakeSQL(@"UPDATE [dbo].[EmpTaxAit]
SET [TaxParamId] = %n
,[EmployeeId] = %n
,[Name] = %s
,[Remarks] = %s
,[Amount] = %n
,[CheckedBy] = %n
,[CheckedDate] = %d
,[CreatedBy] = %n
,[ModifiedBy] = %n
,[CreatedDate] = %d
,[ModifiedDate] = %d
,EntryFrom=%n
,taxeffectDone=%n
WHERE [EmpTaxAitId] = %n", item.TaxParamId, item.EmployeeId,
item.Name, item.Remarks, item.Amount, item.CheckedBy, item.CheckedDate, item.CreatedBy, item.ModifiedBy,
item.CreatedDate, item.ModifiedDate, item.EntryFrom, item.TaxEffectDone, item.ID);
tc.ExecuteNonQuery(sql);
}
internal static void Delete(TransactionContext tc, int id)
{
string sql = SQLParser.MakeSQL("delete from EmpTaxAit where EmpTaxAitId=%n", id);
tc.ExecuteNonQuery(sql);
}
internal static void Delete(TransactionContext tc, int taxParamId, int empId)
{
string sql = SQLParser.MakeSQL(@"delete from EmpTaxAit where taxParamId = %n and employeeId = %n", taxParamId, empId);
tc.ExecuteNonQuery(sql);
}
}
}