EchoTex_Payroll/HRM.DA/DA/Fund/MemberInfo/FinalSettlementDA.cs
2024-10-14 10:01:49 +06:00

126 lines
5.6 KiB
C#

using HRM.BO;
using Ease.Core.DataAccess;
using System;
using System.Data;
namespace HRM.DA.Fund
{
internal class FinalSettlementDA
{
public FinalSettlementDA()
{
}
#region Insert function
internal static void Insert(TransactionContext tc, FinalSettlement oItem)
{
string sql = SQLParser.MakeSQL(@"INSERT INTO FinalSettlement
(FinalSettlementID, MemberID, EmpCode, SettlementDate,
TotalPayment, PaymentMode,LastAudCPF,LastAudEPF,
LastAudCPFInterest,LastAudEPFInterest,LastAudCurrentEPFInterest,LastAudCurrentCPFInterest,
CurrYearEPF,CurrYearCPF,CurrYearEPFInterest,CurrYearCPFInterest,CurrYearInterestPercent,
CreatedDate,CreatedBy)
VALUES(%n,%n,%s,%d,
%n,%s,%n,%n,
%n,%n,%n,%n,
%n,%n,%n,%n,%n,
%d,%n)",
oItem.ID, oItem.MemberID, oItem.EmpCode, oItem.SettlementDate,
oItem.TotalPayment, oItem.PaymentMode, oItem.LastAudCPF, oItem.LastAudEPF,
oItem.LastAudCPFInterest, oItem.LastAudEPFInterest, oItem.LastAudCurrentEPFInterest,
oItem.LastAudCurrentCPFInterest,
oItem.CurrYearEPF, oItem.CurrYearCPF, oItem.CurrYearEPFInterest, oItem.CurrYearCPFInterest,
oItem.CurrYearInterestPercent,
oItem.CreatedDate, oItem.CreatedBy);
tc.ExecuteNonQuery(sql);
}
#endregion
#region Update function
internal static void Update(TransactionContext tc, FinalSettlement oItem)
{
//tc.ExecuteNonQuery("UPDATE FinalSettlement SET MemberID=%n, EmpCode=%s, SettlementDate=%d, TotalPayment=%n, PaymenrMode=%s, CreatedDate=%d, CreatedBy=%n, ModifiedDate=%d, ModifiedBy=%n" +
//" WHERE FinalSettlementID=%n", oItem.MemberID, oItem.EmpCode, oItem.SettlementDate, oItem.TotalPayment, oItem.PaymenrMode, oItem.CreatedDate, oItem.CreatedBy, oItem.ModifiedDate, oItem.ModifiedBy, oItem.FinalSettlementID);
}
#endregion
#region int Generation function
internal static int GetNewID(TransactionContext tc)
{
return tc.GenerateID("FinalSettlement", "FinalSettlementID");
}
#endregion
#region Get Function
internal static IDataReader Get(TransactionContext tc)
{
return tc.ExecuteReader("SELECT * FROM FinalSettlement");
}
internal static IDataReader Get(TransactionContext tc, int nFinalSettlementID)
{
return tc.ExecuteReader("SELECT * FROM FinalSettlement WHERE FinalSettlementID=%n", nFinalSettlementID);
}
//internal static IDataReader GetClearanceNotifications(TransactionContext tc,int regEmpId)
//{
// return tc.ExecuteReader(@"SELECT distinct e.EMPLOYEEID,e.EMPLOYEENO,f.NAME,T.SentDate,T.ClearanceDate,T.SettlementClearanceStatus
// FROM FSHEAD AS f
// INNER JOIN EMPLOYEE AS e ON f.EMPID=e.EMPLOYEEID OR f.EMPIDTwo=e.EMPLOYEEID
// LEFT JOIN SettlementClearance AS sc ON f.EMPID=sc.EMPLOYEEID OR f.EMPIDTwo=sc.EMPLOYEEID
// LEFT JOIN(
// SELECT sc.EmpCleranceID,sc.SentDate,sc.ClearanceDate,sc.SettlementClearanceStatus FROM EmpResignationRequest AS err
// INNER JOIN SettlementClearance AS sc ON err.employeeID=sc.EmpCleranceID
// WHERE sc.EmpCleranceID=%n) t ON t.EmpCleranceID=sc.EmpCleranceID
// ", regEmpId);
//}
internal static IDataReader GetClearanceNotifications(TransactionContext tc, int regEmpId)
{
return tc.ExecuteReader(@";WITH cte AS(
SELECT sc.EmpCleranceID,sc.SentDate,sc.ClearanceDate,sc.SettlementClearanceStatus,sc.EmployeeID
FROM EmpResignationRequest AS err
INNER JOIN SettlementClearance AS sc ON err.employeeID=sc.EmpCleranceID
WHERE sc.EmpCleranceID=%n)
SELECT distinct e.EMPLOYEEID, e.Name EmployeeName, e.EMPLOYEENO,f.NAME,sc.SentDate,sc.ClearanceDate,sc.SettlementClearanceStatus
FROM FSHEAD AS f
INNER JOIN EMPLOYEE AS e ON f.EMPID=e.EMPLOYEEID OR f.EMPIDTwo=e.EMPLOYEEID
LEFT JOIN cte AS sc ON f.EMPID=sc.EMPLOYEEID
", regEmpId);
}
#endregion
internal static DataTable GetCPFContributionData(TransactionContext tc)
{
return tc.ExecuteDataSet("Select * from CPFContribution").Tables[0];
}
internal static void UpdateGLTranID(TransactionContext tc, int finalSettlementID, int glTranID)
{
string sUpdate = SQLParser.MakeSQL("UPDATE FinalSettlement SET GLTranID = %n where FinalSettlementID = %n",
glTranID, finalSettlementID);
tc.ExecuteNonQuery(sUpdate);
}
internal static IDataReader Get(TransactionContext tc, string sSql)
{
return tc.ExecuteReader("SELECT * FROM FinalSettlement %q order by EmpCode", sSql);
}
internal static void Delete(TransactionContext tc, int settlementID)
{
string sUpdate = SQLParser.MakeSQL("Delete FinalSettlement where FinalSettlementID = %n", settlementID);
tc.ExecuteNonQuery(sUpdate);
}
}
}