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

115 lines
3.7 KiB
C#

using HRM.BO;
using Ease.Core.DataAccess;
using System;
using System.Data;
namespace HRM.DA
{
internal class ErJobUserDA
{
#region Constructor
private ErJobUserDA() { }
#endregion
#region Insert function
internal static void Insert(TransactionContext tc, ErJobUser item)
{
item.CreatedDate = DateTime.Now;
//####
string sql = SQLParser.MakeSQL(@"INSERT INTO ERJOBUSER(USERID, EMAIL, MOBILE, USERNAME, PASSWORD," +
" USERFROM,CREATEDDATE,ISACTIVE,INACTIVEDATE,INACTIVEREASON)" +
" VALUES(%n, %s, %s, %s, %s, " +
"%n, %d, %b, %d, %s)" ,
item.ID, item.Email, item.Mobile, item.UserName, item.Password,
item.UserFrom, item.CreatedDate, item.IsActive, item.InActiveDate, item.InActiveReason);
tc.ExecuteNonQuery(sql);
}
#endregion
#region Update function
internal static void Update(TransactionContext tc, ErJobUser item)
{
item.CreatedDate = DateTime.Now;
tc.ExecuteNonQuery(@"UPDATE ErJobUser SET EMAIL=%s, MOBILE=%s, USERNAME=%n, PASSWORD=%s, " +
" USERFROM=%n, CREATEDDATE=%s,ISACTIVE=%b, INACTIVEDATE=%d, INACTIVEREASON=%s" +
" WHERE USERID=%n", item.Email, item.Mobile, item.UserName, item.Password,
item.UserFrom, item.CreatedDate, item.IsActive, item.InActiveDate, item.InActiveReason, item.ID);
}
#endregion
#region Get Function
internal static IDataReader Get(TransactionContext tc)
{
return tc.ExecuteReader("SELECT * FROM ErJobUser");
}
internal static IDataReader Get(TransactionContext tc, int id)
{
return tc.ExecuteReader("SELECT * FROM ErJobUser WHERE JOBUSERID=%n", id);
}
internal static IDataReader GetByLoginIDByEmail(TransactionContext tc, string sEmail)
{
string sql = SQLParser.MakeSQL(@"SELECT * FROM ErJobUser WHERE lower(Email)=%s", sEmail.ToLower());
return tc.ExecuteReader(sql);
}
internal static void UpdateIsCvCompleted(TransactionContext tc,int userid)
{
tc.ExecuteNonQuery(@"UPDATE ErJobUser SET isCVCompleted=%b WHERE USERID=%n",true, userid);
}
internal static IDataReader GetByLoginIDAndPassword(TransactionContext tc, string sLogInID, string sPassword)
{
string sql = SQLParser.MakeSQL(@"SELECT * FROM ErJobUser WHERE email=%s AND Password=%s AND isActive = 1", sLogInID, Ease.Core.Utility.Global.CipherFunctions.Encrypt("CeLiMiTeD.AdMIn", sPassword));
return tc.ExecuteReader(sql);
}
internal static IDataReader checkIfEmailOrMobileNoExist(TransactionContext tc, string email, string mobile)
{
string subQuery = string.Empty;
if (!String.IsNullOrEmpty(mobile))
{
subQuery = SQLParser.TagSQL(subQuery) + SQLParser.MakeSQL("eu.mobile=%s", mobile);
}
if (!String.IsNullOrEmpty(email))
{
subQuery = SQLParser.TagSQL(subQuery) + SQLParser.MakeSQL("eu.email LIKE %s", email);
}
return tc.ExecuteReader(
"SELECT Distinct eu.* FROM erJobUser eu %q",
subQuery);
}
#endregion
#region Delete function
internal static void Delete(TransactionContext tc, int UserID)
{
tc.ExecuteNonQuery("delete Users WHERE UserID=%n", UserID);
}
#endregion
}
}