321 lines
14 KiB
C#
321 lines
14 KiB
C#
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 FM_MemberDetail(MemberID,EmpCode,Name,MembershipNo,
|
|
MembershipDate,DOB,DOJ, CompanyName,Status, IsSentToFAS,CreatedBy,CreatedDate,FundTypeID,
|
|
Email,FinalSettlementDate, DOL, IsProfitPartner, Designation, currentBasic)
|
|
VALUES(%n,%s,%s,%s,%d,%d,%d,%s,%n,%n,%n,%d,%n,%s,%d,%d,%n, %s, %n)",
|
|
oItem.ID, oItem.EmpCode, oItem.Name, oItem.MembershipNo,
|
|
oItem.MembershipDate, DataReader.GetNullValue(oItem.DOB), oItem.DOJ, oItem.CompanyName, oItem.MemberStatus, oItem.IsSentToFAS, oItem.CreatedBy, oItem.CreatedDate, oItem.FundTypeID,
|
|
oItem.Email, oItem.FinalSettlementDate, oItem.DOL, oItem.IsProfitPartner, oItem.Designation, oItem.CurrentBasic);
|
|
tc.ExecuteNonQuery(sql);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Update function
|
|
|
|
internal static void Update(TransactionContext tc, Member oItem)
|
|
{
|
|
string sql = SQLParser.MakeSQL(@"UPDATE FM_MemberDetail
|
|
SET Name = %s, MembershipNo = %s, MembershipDate = %d, DOB = %d, DOJ = %d,
|
|
CompanyName = %s, Status = %n, IsSentToFAS = %n, ModifiedBy = %n,
|
|
ModifiedDate = %d, FundTypeID = %n, Email = %s,
|
|
FinalSettlementDate = %d, DOL = %d, IsProfitPartner = %n, Designation = %s, currentBasic = %n
|
|
WHERE MemberID = %n",
|
|
oItem.Name, oItem.MembershipNo, oItem.MembershipDate, DataReader.GetNullValue(oItem.DOB), oItem.DOJ,
|
|
oItem.CompanyName, oItem.MemberStatus, oItem.IsSentToFAS, oItem.ModifiedBy,
|
|
oItem.ModifiedDate, oItem.FundTypeID, oItem.Email, oItem.FinalSettlementDate,
|
|
oItem.DOL, oItem.IsProfitPartner, oItem.Designation, oItem.CurrentBasic, oItem.ID);
|
|
tc.ExecuteNonQuery(sql);
|
|
}
|
|
|
|
internal static void UpdateSettlement(TransactionContext tc, Member oItem)
|
|
{
|
|
string sSQL = SQLParser.MakeSQL(
|
|
"UPDATE FM_MemberDetail SET Status = %n, ModifiedBy = %n, ModifiedDate = %d, FinalSettlementDate = %d, DOL = %d" +
|
|
" WHERE MemberID=%n", Convert.ToInt16(oItem.MemberStatus), 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 FM_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("FM_MemberDetail", "MemberID");
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Get Function
|
|
|
|
internal static IDataReader GetAuditLiveMemberOn(TransactionContext tc, DateTime YearEndDate,
|
|
DateTime ActualAuditDate, int fundtypeid)
|
|
{
|
|
string sSQL = SQLParser.MakeSQL(
|
|
@"SELECT * FROM FM_MemberDetail Where FundTypeID=%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 FM_MemberDetail Where FundTypeID=%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 FM_MemberDetail Where FundTypeID=%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 id)
|
|
{
|
|
string sSQL = SQLParser.MakeSQL("SELECT * FROM FM_MemberDetail Where MemberID=%n", id);
|
|
return tc.ExecuteReader(sSQL);
|
|
}
|
|
internal static IDataReader GetByStatus(TransactionContext tc, EnumEmpSearchType status, int fundtypeid)
|
|
{
|
|
string sSQL = "";
|
|
if (status == EnumEmpSearchType.Discontinued)
|
|
{
|
|
sSQL = SQLParser.MakeSQL("Select * from FM_MemberDetail where status !=%n and fundtypeid =%n", EnumEmpSearchType.Live, fundtypeid);
|
|
}
|
|
else
|
|
{
|
|
sSQL = SQLParser.MakeSQL("SELECT * FROM FM_MemberDetail where status =%n and fundtypeid =%n", status, fundtypeid);
|
|
}
|
|
return tc.ExecuteReader(sSQL);
|
|
}
|
|
internal static IDataReader GetByFundType(TransactionContext tc, int fundTypeID)
|
|
{
|
|
string sSQL = SQLParser.MakeSQL("SELECT * FROM FM_MemberDetail where FundTypeID =%n", fundTypeID);
|
|
return tc.ExecuteReader(sSQL);
|
|
}
|
|
internal static IDataReader Get(TransactionContext tc)
|
|
{
|
|
string sSQL = SQLParser.MakeSQL("SELECT * FROM FM_MemberDetail");
|
|
return tc.ExecuteReader(sSQL);
|
|
}
|
|
|
|
internal static IDataReader Get(TransactionContext tc, int statusInInt, int fundtypeid)
|
|
{
|
|
string sSQL = SQLParser.MakeSQL("SELECT * FROM FM_MemberDetail Where STATUS=%n AND FundTypeID=%n", statusInInt,
|
|
fundtypeid);
|
|
return tc.ExecuteReader(sSQL);
|
|
}
|
|
|
|
internal static IDataReader Get(TransactionContext tc, string code, int fundtypeid)
|
|
{
|
|
string Ssql = SQLParser.MakeSQL("SELECT * FROM FM_MemberDetail WHERE EmpCode=%s AND FundTypeID=%n", code,
|
|
fundtypeid);
|
|
return tc.ExecuteReader(Ssql);
|
|
}
|
|
|
|
internal static IDataReader Get(TransactionContext tc, string empCode, EnumFundType fundtype)
|
|
{
|
|
string Ssql = SQLParser.MakeSQL("SELECT * FROM FM_MemberDetail WHERE EmpCode=%s and fundtypeid in" +
|
|
" (select fundtypeid from FM_fundtype where Type=%n)", empCode, fundtype);
|
|
return tc.ExecuteReader(Ssql);
|
|
}
|
|
|
|
//internal static IDataReader Get(string empCode, string FMConn)
|
|
//{
|
|
// string Ssql = SQLParser.MakeSQL("SELECT * FROM FM_MemberDetail WHERE EmpCode=%s", empCode);
|
|
|
|
// 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 FM_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.FM_MemberDetail mem
|
|
inner join dbo.FM_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 FM_MemberDetail mem
|
|
where mem.Status=%n AND FundTypeID=%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 FM_MemberDetail where MemberID in(%q)", sEmpID);
|
|
return tc.ExecuteReader(sql);
|
|
}
|
|
internal static IDataReader GetMember(TransactionContext tc, DateTime fromDate, DateTime toDate, int fundtypeid)
|
|
{
|
|
string sql = string.Empty;
|
|
|
|
//sql = SQLParser.MakeSQL(@"Select * from FM_MemberDetail where MemberShipDate <= %d and
|
|
// (FINALSETTLEMENTDATE IS NULL OR FINALSETTLEMENTDATE > %d) AND fundtypeid=%n", toDate, fromDate, fundtypeid);
|
|
sql = SQLParser.MakeSQL(@"Select * from FM_MemberDetail where MemberShipDate BETWEEN %d AND %d and fundtypeid=%n", fromDate, toDate, fundtypeid);
|
|
return tc.ExecuteReader(sql);
|
|
}
|
|
internal static IDataReader GetMembersJoinTransaction(TransactionContext tc, DateTime fromDate, DateTime ToDate, int fundTypeID)
|
|
{
|
|
string sql = string.Empty;
|
|
|
|
sql = SQLParser.MakeSQL(@"SELECT md.* FROM FM_MemberDetail md
|
|
WHERE md.MemberID IN (SELECT distinct mtd.MemberID
|
|
from FM_MembersTransactionDetails mtd
|
|
where mtd.TranDate BETWEEN %d and %d) And md.Status <> 3 And md.FundTypeID = %n
|
|
ORDER BY md.MemberID ", fromDate, ToDate, fundTypeID);
|
|
return tc.ExecuteReader(sql);
|
|
}
|
|
|
|
internal static DataSet GetDashboardMember(TransactionContext tc, string EmpNo)
|
|
{
|
|
DataSet dSet = null;
|
|
string sql = string.Empty;
|
|
|
|
sql = SQLParser.MakeSQL(@"SELECT (e.NAME) Name, e.JoiningDate, (e.EmployeeNo) EmpCode, (d.NAME) Designation,
|
|
dp.DESCRIPTION Department, (e.EMAILADDRESS) EMAILADDRESS,(e.MOBILENO)MOBILENO,e.BASICSALARY, e.ENDOFCONTRACTDATE DiscontinueDate
|
|
FROM EMPLOYEE e
|
|
INNER JOIN DESIGNATION d ON e.DESIGNATIONID = d.DESIGNATIONID
|
|
INNER JOIN DEPARTMENT dp ON e.DepartmentID = dp.DepartmentID
|
|
WHERE (e.EMPLOYEENO) = %s", EmpNo);
|
|
dSet = tc.ExecuteDataSet(sql);
|
|
return dSet;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region MemberList get function
|
|
|
|
internal static IDataReader GetMemberList(TransactionContext tc, string query)
|
|
{
|
|
string sql = string.Empty;
|
|
|
|
sql = SQLParser.MakeSQL("SELECT * FROM FM_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 [FM_MemberDetail] WHERE MemberID=%n", MemberID);
|
|
}
|
|
|
|
internal static IDataReader GetSearchMembers(TransactionContext tc, string empCode, string name, bool isMembershipDate, DateTime membershipFromDate, DateTime membershipToDate, bool isJoiningDate, DateTime joiningFromDate, DateTime joiningToDate, int statusID, int fundTypeID)
|
|
{
|
|
string searchSQL = "SELECT * FROM FM_MEMBERDETAIL WHERE 1=1";
|
|
|
|
if (!string.IsNullOrEmpty(empCode))
|
|
{
|
|
searchSQL += SQLParser.MakeSQL(" AND EMPCODE = %s", empCode);
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(name))
|
|
{
|
|
searchSQL += SQLParser.MakeSQL(" AND NAME LIKE %s", "%" + name + "%");
|
|
}
|
|
|
|
if (isMembershipDate)
|
|
{
|
|
searchSQL += SQLParser.MakeSQL(
|
|
" AND MEMBERSHIPDATE BETWEEN %d AND %d",
|
|
membershipFromDate,
|
|
membershipToDate
|
|
);
|
|
}
|
|
|
|
if (isJoiningDate)
|
|
{
|
|
searchSQL += SQLParser.MakeSQL(
|
|
" AND DOJ BETWEEN %d AND %d",
|
|
joiningFromDate,
|
|
joiningToDate
|
|
);
|
|
}
|
|
|
|
if (statusID > 0)
|
|
{
|
|
searchSQL += SQLParser.MakeSQL(" AND STATUS = %n", statusID);
|
|
}
|
|
if (fundTypeID > 0)
|
|
{
|
|
searchSQL += SQLParser.MakeSQL(" AND FUNDTYPEID = %n", fundTypeID);
|
|
}
|
|
return tc.ExecuteReader(searchSQL);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
} |