EchoTex_Payroll/HRM.DA/DA/Fund/MemberInfo/MemberDA.cs

244 lines
10 KiB
C#
Raw Permalink Normal View History

2024-10-14 10:01:49 +06:00
using HRM.BO;
using Ease.Core.DataAccess;
using System;
using System.Data;
using Microsoft.Data.SqlClient;
using System.Data.SqlTypes;
namespace HRM.DA.Fund
{
internal class MemberDA
{
#region Constructor
public MemberDA()
{
}
#endregion
#region Insert function
internal static void Insert(TransactionContext tc, Member oItem)
{
string sql = SQLParser.MakeSQL(@"INSERT INTO MemberDetail(MemberID,EmpCode,Name,MembershipNo,
MembershipDate,DOB,DOJ, CompanyName,Status, IsSentToFAS,CreatedBy,CreatedDate,ProjectID,SignumID,
Email,FinalSettlementDate, DOL, IsProfitPartner)
VALUES(%n,%s,%s,%s,%d,%d,%d,%s,%n,%n,%n,%d,%n,%s,%s,%d,%d,%n)",
oItem.ID, oItem.EmpCode, oItem.Name, oItem.MembershipNo,
DataReader.GetNullValue(oItem.MembershipDate), DataReader.GetNullValue(oItem.DOB),
DataReader.GetNullValue(oItem.DOJ),
oItem.CompanyName, oItem.Status, oItem.IsSentToFAS, oItem.CreatedBy, oItem.CreatedDate, oItem.ID,
oItem.SignumID, oItem.Email, DataReader.GetNullValue(oItem.FinalSettlementDate),
DataReader.GetNullValue(oItem.DOL), DataReader.GetNullValue(oItem.IsProfitPartner));
tc.ExecuteNonQuery(sql);
}
#endregion
#region Update function
internal static void Update(TransactionContext tc, Member oItem)
{
string sql = SQLParser.MakeSQL(
@"UPDATE MemberDetail SET Name = %s, MembershipNo = %s, MembershipDate = %d, DOB = %d,
DOJ = %d, CompanyName = %s, Status = %n,IsSentToFAS = %n, ModifiedBy = %n, ModifiedDate = %d,ProjectID = %n,
SignumID = %s,Email = %s, FinalSettlementDate=%d, DOL=%d, IsProfitPartner=%n WHERE MemberID=%n",
oItem.Name, oItem.MembershipNo, oItem.MembershipDate, DataReader.GetNullValue(oItem.DOB),
DataReader.GetNullValue(oItem.DOJ), oItem.CompanyName, oItem.Status,
oItem.IsSentToFAS, oItem.ModifiedBy, oItem.ModifiedDate, oItem.ID,
oItem.SignumID, DataReader.GetNullValue(oItem.Email),
DataReader.GetNullValue(oItem.FinalSettlementDate), DataReader.GetNullValue(oItem.DOL),
DataReader.GetNullValue(oItem.IsProfitPartner),
oItem.ID);
tc.ExecuteNonQuery(sql);
}
internal static void UpdateSettlement(TransactionContext tc, Member oItem)
{
string sSQL = SQLParser.MakeSQL(
"UPDATE MemberDetail SET Status = %n, ModifiedBy = %n, ModifiedDate = %d, FinalSettlementDate = %d, DOL = %d" +
" WHERE MemberID=%n", Convert.ToInt16(oItem.Status), oItem.ModifiedBy, oItem.ModifiedDate,
DataReader.GetNullValue(oItem.FinalSettlementDate), DataReader.GetNullValue(oItem.DOL), oItem.ID);
tc.ExecuteNonQuery(sSQL);
}
internal static void UpdateMonthlyPension(TransactionContext tc, Member oItem)
{
string sSQL = SQLParser.MakeSQL(
"UPDATE MemberDetail SET MonthlyPension = %n, ModifiedBy = %n, ModifiedDate = %d" +
" WHERE MemberID=%n", oItem.MonthlyPension, oItem.ModifiedBy, oItem.ModifiedDate, oItem.ID);
tc.ExecuteNonQuery(sSQL);
}
#endregion
#region int Generation function
internal static int GetNewID(TransactionContext tc)
{
return tc.GenerateID("MemberDetail", "MemberID");
}
#endregion
#region Get Function
internal static IDataReader GetAuditLiveMemberOn(TransactionContext tc, DateTime YearEndDate,
DateTime ActualAuditDate, int fundtypeid)
{
string sSQL = SQLParser.MakeSQL(
@"SELECT * FROM MemberDetail Where ProjectID=%n AND MembershipDate <=%d AND MemberID NOT IN (
select M.MemberID FROM MemberDetail M Where M.ID=%n AND M.FinalSettlementDate <= %d AND M.Status=%n)",
fundtypeid, YearEndDate, fundtypeid, ActualAuditDate, EnumEmpStatus.Setteled);
return tc.ExecuteReader(sSQL);
}
internal static IDataReader GetLiveMember(TransactionContext tc, DateTime LiveAsOn, int fundtypeid)
{
string sSQL = SQLParser.MakeSQL(
@"SELECT * FROM MemberDetail Where ProjectID=%n AND MembershipDate <=%d AND MemberID NOT IN (
select M.MemberID FROM MemberDetail M Where M.ID=%n AND M.FinalSettlementDate <= %d AND M.Status=%n)",
fundtypeid, LiveAsOn, fundtypeid, LiveAsOn, EnumEmpStatus.Setteled);
return tc.ExecuteReader(sSQL);
}
internal static IDataReader GetSettledMember(TransactionContext tc, DateTime fromDate, DateTime toDate,
int fundtypeid)
{
string sSQL = SQLParser.MakeSQL(
"SELECT * FROM MemberDetail Where ProjectID=%n AND FinalSettlementDate between %d AND %d AND Status=%n",
fundtypeid, fromDate, toDate, EnumEmpStatus.Setteled);
return tc.ExecuteReader(sSQL);
}
internal static IDataReader Get(TransactionContext tc, int fundtypeid)
{
string sSQL = SQLParser.MakeSQL("SELECT * FROM MemberDetail Where ProjectID=%n", fundtypeid);
return tc.ExecuteReader(sSQL);
}
internal static IDataReader Get(TransactionContext tc, int statusInInt, int fundtypeid)
{
string sSQL = SQLParser.MakeSQL("SELECT * FROM MemberDetail Where STATUS=%n AND ProjectID=%n", statusInInt,
fundtypeid);
//return tc.ExecuteReader("SELECT * FROM MemberDetail Where STATUS=%n AND ProjectID=%n", statusInInt, User.CurrentUser.ID);
return tc.ExecuteReader(sSQL);
}
internal static IDataReader GetByMemberid(TransactionContext tc, int memberID)
{
return tc.ExecuteReader("SELECT * FROM MemberDetail WHERE MemberID=%n", memberID);
}
internal static IDataReader Get(TransactionContext tc, string code, int fundtypeid)
{
string Ssql = SQLParser.MakeSQL("SELECT * FROM MemberDetail WHERE EmpCode=%s AND ProjectID=%n", code,
fundtypeid);
return tc.ExecuteReader(Ssql);
}
internal static IDataReader Get(TransactionContext tc, string empCode)
{
string Ssql = SQLParser.MakeSQL("SELECT * FROM MemberDetail WHERE EmpCode=%s", empCode);
return tc.ExecuteReader(Ssql);
}
internal static IDataReader Get(string empCode, string FMConn)
{
string Ssql = SQLParser.MakeSQL("SELECT * FROM MemberDetail WHERE EmpCode=%s", empCode);
//return tc.ExecuteReader(Ssql);
try
{
SqlConnection connection = new SqlConnection(FMConn);
connection.Open();
SqlCommand cmd = new SqlCommand(Ssql, connection);
return cmd.ExecuteReader(CommandBehavior.CloseConnection);
}
catch (Exception ex)
{
throw new Exception("An error occurred while fetching the member details: " + ex.Message);
}
}
internal static bool IsExist(TransactionContext tc, string BankCode)
{
object ob = tc.ExecuteScalar("SELECT COUNT(*) FROM Bank WHERE BankCode=%s", BankCode);
return Convert.ToInt32(ob) > 0;
}
internal static IDataReader GetBalance(TransactionContext tc)
{
string sql = string.Empty;
sql = SQLParser.MakeSQL(@"Select mem.EmpCode,mem.Name,mem.DOJ,mem.DOL,mem.MembershipDate,mem.Status,
mbs.OpeningContribution as ownOpenCon,mbs.Contribution as companyOpnCon,
mbs.OpeningActualInterest as ownInterest,mbs.ContributionActualInterest as companyInterest
from dbo.MemberDetail mem
inner join dbo.MemberBalanceSummary mbs on mem.MemberID=mbs.MembersID
where mem.Status=%n", EnumEmpStatus.Live);
return tc.ExecuteReader(sql);
}
internal static DataSet GetMembersMonthlyPension(TransactionContext tc, int fundtypeid)
{
DataSet dSet = null;
string sql = string.Empty;
sql = SQLParser.MakeSQL(
@"Select mem.MemberID, mem.EmpCode,mem.Name,mem.DOJ,mem.MembershipDate,mem.MonthlyPension Amount
from MemberDetail mem
where mem.Status=%n AND ProjectID=%n", EnumEmpStatus.Live, fundtypeid);
dSet = tc.ExecuteDataSet(sql);
return dSet;
}
internal static IDataReader GetMember(TransactionContext tc, string sEmpID)
{
string sql = string.Empty;
sql = SQLParser.MakeSQL(@"Select * from MemberDetail where MemberID in(%q)", sEmpID);
return tc.ExecuteReader(sql);
}
internal static IDataReader GetMembers(TransactionContext tc, DateTime fromDate, DateTime ToDate)
{
string sql = string.Empty;
sql = SQLParser.MakeSQL(@"SELECT md.* FROM MemberDetail md
WHERE md.MemberID IN (SELECT distinct mtd.MemberID
from MembersTransactionDetails mtd
where mtd.TranDate BETWEEN %d and %d) And md.Status <> 3
ORDER BY md.MemberID ", fromDate, ToDate);
return tc.ExecuteReader(sql);
}
#endregion
#region MemberList get function
internal static IDataReader GetMemberList(TransactionContext tc, string query)
{
string sql = string.Empty;
sql = SQLParser.MakeSQL("SELECT * FROM MemberDetail %q", query);
return tc.ExecuteReader(sql);
}
#endregion MemberList get function
#region Delete function
internal static void Delete(TransactionContext tc, int MemberID)
{
tc.ExecuteNonQuery("DELETE FROM [MemberDetail] WHERE MemberID=%n", MemberID);
}
#endregion
}
}