CEL_Payroll/Payroll.Service/Recruitement/DA/RecruitementProcessDA.cs
2024-09-17 14:30:13 +06:00

139 lines
7.0 KiB
C#

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using Ease.CoreV35.Model;
using Payroll.BO;
using Ease.CoreV35.DataAccess;
namespace Payroll.Service
{
public class RecruitementProcessDA
{
internal static void Insert(RecruitementProcess obRecrProc, TransactionContext tc)
{
DateTime? endDate;
if (obRecrProc.EndDate == DateTime.MinValue) endDate = null;
else endDate = obRecrProc.EndDate;
string sql = SQLParser.MakeSQL(@"Insert Into RecruitementProcess(RecruitementProcessID,Code,
Description,StartDate,EndDate,ProcessStatus) Values(%n,%s,%s,%D,%d,%n)", obRecrProc.ID.Integer, obRecrProc.Code,
obRecrProc.Description, obRecrProc.StartDate, DataReader.GetNullValue(endDate), obRecrProc.ProcessStatus);
tc.ExecuteNonQuery(sql);
}
internal static void Update(RecruitementProcess obRecrProc,TransactionContext tc)
{
DateTime? endDate;
if (obRecrProc.EndDate == DateTime.MinValue) endDate = null;
else endDate = obRecrProc.EndDate;
string sql = SQLParser.MakeSQL(@"Update RecruitementProcess Set Code = %s,
Description = %s,StartDate = %D,EndDate = %d,ProcessStatus = %n Where RecruitementProcessID = %n",
obRecrProc.Code, obRecrProc.Description, obRecrProc.StartDate, DataReader.GetNullValue(endDate), obRecrProc.ProcessStatus,obRecrProc.ID.Integer);
tc.ExecuteNonQuery(sql);
}
internal static void Delete(ID id,TransactionContext tc)
{
string sql = SQLParser.MakeSQL(@"Delete From RecruitementProcess Where RecruitementProcessID = %n", id.Integer);
tc.ExecuteNonQuery(sql);
}
internal static IDataReader Get(TransactionContext tc)
{
string sql = SQLParser.MakeSQL(@"Select * From RecruitementProcess");
return tc.ExecuteReader(sql);
}
internal static IDataReader GetByProcessId(TransactionContext tc, ID procID)
{
string sql = SQLParser.MakeSQL(@"Select * From RecruitementProcess Where RecruitementProcessID = %n",
procID.Integer);
return tc.ExecuteReader(sql);
}
internal static DataSet GetShortListedCandidates(ID processID,TransactionContext tc)
{
//// string sql = SQLParser.MakeSQL(@"
//// select A.cvID as candidateID,count(A.cvID) as totalStep ,IsEmployee = 0 from
//// (select cvID from RecruitementCandidate where processID = %n and IsEmployee = 0) as A
//// inner join
//// (
//// select * From recruitementSelectedCandidate Where processID = %n And (
//// stepID in (select RecruitementStepID from RecruitementStep Where ProcessId = %n) And isSelected = 1 and IsEmployee = 0)
//// )
//// as B
//// on
//// A.cvID = B.CandidateID
//// group by cvID having count(A.cvID) = (select count(*) from RecruitementStep where processID = %n)
//// union
//// select A.employeeID as candidateID,count(A.employeeID) as totalStep,IsEmployee = 1 from
//// (select employeeID from RecruitementCandidate where processID = %n and IsEmployee = 1) as A
//// inner join
//// (
//// select * From recruitementSelectedCandidate Where processID = %n And (
//// stepID in (select RecruitementStepID from RecruitementStep Where ProcessId = %n) And isSelected = 1 and IsEmployee = 1)
//// )
//// as B
//// on
//// A.employeeID = B.CandidateID
//// group by employeeID having count(A.employeeID) = (select count(*) from RecruitementStep where processID = %n)",processID.Integer,processID.Integer,processID.Integer,processID.Integer,processID.Integer,processID.Integer,processID.Integer,processID.Integer);
string sql =
SQLParser.MakeSQL(
@"select * From recruitementSelectedCandidate Where processID = %n And (isSelected = 1 And
stepID = (select MAX(RecruitementStepID) from RecruitementStep Where ProcessId = %n) )", processID.Integer, processID.Integer);
return tc.ExecuteDataSet(sql);
}
internal static IDataReader CheckCode(TransactionContext tc, string code)
{
string sql = SQLParser.MakeSQL(@"Select * From RecruitementProcess Where Code = %s", code);
return tc.ExecuteReader(sql);
}
internal static IDataReader GetByCandediateID(TransactionContext tc, ID nCandidateID)
{
string sql = SQLParser.MakeSQL(@"Select * from RecruitementCandidate where CandidateID=%n", nCandidateID.Integer);
return tc.ExecuteReader(sql);
}
internal static IDataReader Get(string query, TransactionContext tc)
{
string sql = SQLParser.MakeSQL(@"Select * From RecruitementProcess Where (%q)", query);
return tc.ExecuteReader(sql);
}
internal static IDataReader GetProcess(TransactionContext tc, int status)
{
string sql = SQLParser.MakeSQL(@"Select * From RecruitementProcess Where ProcessStatus = %n", status);
return tc.ExecuteReader(sql);
}
internal static IDataReader GetProcess(TransactionContext tc, ID processID, ID stepID, int empID)
{
string sql = SQLParser.MakeSQL(@"Select * From RecruitementProcess Where RecruitementProcessID in (select ProcessId"+
" from dbo.RecruitementBoardMember where EmployeeId=%n and StepId=%n and ProcessId=%n)",
empID, stepID.Integer, processID.Integer);
return tc.ExecuteReader(sql);
}
internal static IDataReader GetProcess(TransactionContext tc, int status, int empID)
{
string sql = SQLParser.MakeSQL(@"Select * From RecruitementProcess Where ProcessStatus = %n and RecruitementProcessID in " +
" (select ProcessId from dbo.RecruitementBoardMember where EmployeeId=%n)",
status,empID);
return tc.ExecuteReader(sql);
}
internal static IDataReader GetProcessID(TransactionContext tc, int status, int empID, ID stepID)
{
string sql = SQLParser.MakeSQL(@"Select * From RecruitementProcess Where RecruitementProcessID in (select ProcessId" +
" from dbo.RecruitementBoardMember where EmployeeId=%n and StepId=%n )", empID, stepID.Integer);
return tc.ExecuteReader(sql);
}
}
}