315 lines
18 KiB
C#
315 lines
18 KiB
C#
using HRM.BO;
|
|
using Ease.Core.DataAccess;
|
|
using System;
|
|
using System.Data;
|
|
using Microsoft.Data.SqlClient;
|
|
using System.Net.Mail;
|
|
using NPOI.OpenXmlFormats.Spreadsheet;
|
|
|
|
namespace HRM.DA
|
|
{
|
|
public class RecruitmentLettersDA
|
|
{
|
|
#region Constructor
|
|
|
|
private RecruitmentLettersDA()
|
|
{
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Get
|
|
|
|
internal static System.Data.IDataReader Get(Ease.Core.DataAccess.TransactionContext tc, int id)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM RECRUITMENTLETTERS WHERE RecruitmentLetterID=%n", id);
|
|
}
|
|
|
|
internal static System.Data.IDataReader GetByCandidateID(Ease.Core.DataAccess.TransactionContext tc, int id)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM RECRUITMENTLETTERS WHERE CandidateID=%n", id);
|
|
}
|
|
|
|
internal static System.Data.IDataReader Get(Ease.Core.DataAccess.TransactionContext tc)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM RECRUITMENTLETTERS");
|
|
}
|
|
|
|
internal static System.Data.IDataReader GetbyRequisitionID(Ease.Core.DataAccess.TransactionContext tc,
|
|
int requisitionID)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM RECRUITMENTLETTERS where RequisitionID=%n", requisitionID);
|
|
}
|
|
internal static System.Data.IDataReader GetByProcessID(Ease.Core.DataAccess.TransactionContext tc,
|
|
int nProcessID)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM RECRUITMENTLETTERS where ProcessID=%n", nProcessID);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Update
|
|
|
|
internal static void Update(Ease.Core.DataAccess.TransactionContext tc, RecruitmentLetters oRECRUITMENTLETTERS)
|
|
{
|
|
//,EmployeeID=%n oRECRUITMENTLETTERS.EmployeeID,
|
|
string sSQL = SQLParser.MakeSQL("UPDATE RECRUITMENTLETTERS SET " +
|
|
" [AcceptOfferBefore]=%d,[IssueOfferDate]=%d," +
|
|
" [AcceptOfferDate]=%d,[RejectOfferDate]=%d,[RejectOfferReason]=%s," +
|
|
" [OfferLetterCount]=%n,[OfferCreatedBy]=%n,[OfferCreatedDate]=%d," +
|
|
" [GradeID]=%n,[BasicSalary]=%n,[DepartmentID]=%n,[JobLocation]=%s,[LocationID]=%n," +
|
|
" [NoticePeriod]=%n,[AppAcceptBefore]=%d,[IssueAppLetterDate]=%d," +
|
|
" [RejectAppLetterDate]=%d,[RejectAppLetterReason]=%s,[CarEligible]=%b," +
|
|
" [AppCreatedBy]=%n,[AppCreatedDate]=%d,[AppLetterCount]=%n," +
|
|
" [JoiningLetter]=%b,[VendorMail]=%b,[WelcomeMail]=%b," +
|
|
" [InductionRequest]=%b,[Announcement]=%b,[OtherLetters]=%b," +
|
|
" [OthersCount]=%n,[OtherCreatedBy]=%n,[OtherCreateddate]=%d," +
|
|
" [ModifiedBy]=%n,[ModifiedDate]=%d,ProcessID=%n,JoiningDate=%d,JoiningBeforeDate=%d,ConfirmJoiningDate=%d,GrossSalary=%n,IsPrimarySelected=%n WHERE [RequisitionID]=%n and [CandidateID]=%n",
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.AcceptOfferBefore),
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.IssueOfferDate),
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.AcceptOfferDate),
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.RejectOfferDate),
|
|
oRECRUITMENTLETTERS.RejectOfferReason,
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.OfferLetterCount),
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.OfferCreatedBy),
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.OfferCreatedDate),
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.GradeID),
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.BasicSalary),
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.DepartmentID),
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.JobLocation),
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.LocationID),
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.NoticePeriod),
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.AppAcceptBefore),
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.IssueAppLetterDate),
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.RejectAppLetterDate),
|
|
oRECRUITMENTLETTERS.RejectAppLetterReason, oRECRUITMENTLETTERS.CarEligible,
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.AppCreatedBy),
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.AppCreatedDate),
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.AppLetterCount),
|
|
oRECRUITMENTLETTERS.JoiningLetter, oRECRUITMENTLETTERS.VendorMail,
|
|
oRECRUITMENTLETTERS.WelcomeMail, oRECRUITMENTLETTERS.InductionRequest,
|
|
oRECRUITMENTLETTERS.Announcement, oRECRUITMENTLETTERS.OtherLetters,
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.OthersCount),
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.OtherCreatedBy),
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.OtherCreateddate),
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.ModifiedBy),
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.ModifiedDate),
|
|
oRECRUITMENTLETTERS.ProcessID,
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.JoiningDate),
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.JoiningBeforeDate),
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.ConfirmJoiningDate),
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.GrossSalary),
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.IsPrimarySelected),
|
|
oRECRUITMENTLETTERS.RequisitionID, oRECRUITMENTLETTERS.CandidateID);
|
|
tc.ExecuteNonQuery(sSQL);
|
|
}
|
|
|
|
public static void UpdateOfferLetterAttachment(string connectionString, RecruitmentLetters recruitmentLetter, string letterType)
|
|
{
|
|
using (SqlConnection connection = new SqlConnection(connectionString))
|
|
{
|
|
connection.Open();
|
|
|
|
using (SqlCommand cmd = new SqlCommand())
|
|
{
|
|
cmd.Connection = connection;
|
|
cmd.Parameters.Add("@Id", SqlDbType.Int).Value = recruitmentLetter.ID;
|
|
|
|
string commandText;
|
|
|
|
cmd.Parameters.Add("@CreatedBy", SqlDbType.VarChar).Value = letterType switch
|
|
{
|
|
"offerLetter" => recruitmentLetter.OfferLetterCreatedBy,
|
|
"appointmentLetter" => recruitmentLetter.AppointmentLetterCreatedBy,
|
|
"joiningInformation" => recruitmentLetter.JoiningInformationLetterCreatedBy,
|
|
"mailToLM" => recruitmentLetter.MailToLMLetterCreatedBy,
|
|
_ => throw new ArgumentException("Invalid letterType provided")
|
|
};
|
|
|
|
cmd.Parameters.Add("@CreatedDate", SqlDbType.DateTime).Value = letterType switch
|
|
{
|
|
"offerLetter" => recruitmentLetter.OfferLetterCreatedDate,
|
|
"appointmentLetter" => recruitmentLetter.AppointmentLetterCreatedDate,
|
|
"joiningInformation" => recruitmentLetter.JoiningInformationLetterCreatedDate,
|
|
"mailToLM" => recruitmentLetter.MailToLMLetterCreatedDate,
|
|
_ => throw new ArgumentException("Invalid letterType provided")
|
|
};
|
|
|
|
if (letterType == "offerLetter")
|
|
{
|
|
cmd.Parameters.Add("@FileData", SqlDbType.VarBinary).Value = recruitmentLetter.OfferLetterFileAsByteArray;
|
|
cmd.Parameters.Add("@FileName", SqlDbType.VarChar).Value = recruitmentLetter.OfferLetterFileName;
|
|
commandText = @"UPDATE RECRUITMENTLETTERS
|
|
SET OfferLetterFile = @FileData,
|
|
OfferLetterFileName = @FileName,
|
|
OfferLetterFileCreatedBy = @CreatedBy,
|
|
OfferLetterFileCreatedDate = @CreatedDate
|
|
WHERE RecruitmentLetterID = @Id";
|
|
}
|
|
else if (letterType == "appointmentLetter")
|
|
{
|
|
cmd.Parameters.Add("@FileData", SqlDbType.VarBinary).Value = recruitmentLetter.AppointmentLetterFileAsByteArray;
|
|
cmd.Parameters.Add("@FileName", SqlDbType.VarChar).Value = recruitmentLetter.AppointmentLetterFileName;
|
|
commandText = @"UPDATE RECRUITMENTLETTERS
|
|
SET AppointmentLetterFile = @FileData,
|
|
AppointmentLetterFileName = @FileName,
|
|
AppointmentLetterCreatedBy = @CreatedBy,
|
|
AppointmentLetterCreatedDate = @CreatedDate
|
|
WHERE RecruitmentLetterID = @Id";
|
|
}
|
|
else if (letterType == "joiningInformation")
|
|
{
|
|
commandText = @"UPDATE RECRUITMENTLETTERS
|
|
SET JoiningInformationLetterCreatedBy = @CreatedBy,
|
|
JoiningInformationLetterCreatedDate = @CreatedDate
|
|
WHERE RecruitmentLetterID = @Id";
|
|
}
|
|
else if (letterType == "mailToLM")
|
|
{
|
|
commandText = @"UPDATE RECRUITMENTLETTERS
|
|
SET MailToLMLetterCreatedBy = @CreatedBy,
|
|
MailToLMLetterCreatedDate = @CreatedDate
|
|
WHERE RecruitmentLetterID = @Id";
|
|
}
|
|
else
|
|
{
|
|
throw new ArgumentException("Invalid letterType provided");
|
|
}
|
|
|
|
cmd.CommandText = commandText;
|
|
cmd.CommandType = CommandType.Text;
|
|
|
|
cmd.ExecuteNonQuery();
|
|
}
|
|
}
|
|
}
|
|
|
|
public static void UpdateOfferLetterAttachment(TransactionContext tc, RecruitmentLetters recruitmentLetter, string letterType)
|
|
{
|
|
string sSQL = null;
|
|
if (letterType == "offerLetter")
|
|
{
|
|
sSQL = "UPDATE RECRUITMENTLETTERS SET OfferLetterFile=@file, OfferLetterFileName=@fileName, OfferLetterFileCreatedBy=@createdBy, OfferLetterFileCreatedDate=@createdDate WHERE RecruitmentLetterID=@id";
|
|
|
|
using (SqlCommand cmd = new SqlCommand(sSQL, (SqlConnection)tc.Connection))
|
|
{
|
|
cmd.Transaction = (SqlTransaction)tc.Transaction;
|
|
|
|
cmd.Parameters.AddWithValue("@file", recruitmentLetter.OfferLetterFileAsByteArray ?? (object)DBNull.Value);
|
|
cmd.Parameters.AddWithValue("@fileName", recruitmentLetter.OfferLetterFileName ?? (object)DBNull.Value);
|
|
cmd.Parameters.AddWithValue("@createdBy", recruitmentLetter.OfferLetterCreatedBy);
|
|
cmd.Parameters.AddWithValue("@createdDate", DataReader.GetNullValue(recruitmentLetter.OfferLetterCreatedDate) ?? (object)DBNull.Value);
|
|
cmd.Parameters.AddWithValue("@id", recruitmentLetter.ID);
|
|
cmd.ExecuteNonQuery();
|
|
}
|
|
}
|
|
else if (letterType == "appointmentLetter")
|
|
{
|
|
sSQL = "UPDATE RECRUITMENTLETTERS SET AppointmentLetterFile=@file, AppointmentLetterFileName=@fileName, AppointmentLetterCreatedBy=@createdBy, AppointmentLetterCreatedDate=@createdDate WHERE RecruitmentLetterID=@id";
|
|
|
|
using (SqlCommand cmd = new SqlCommand(sSQL, (SqlConnection)tc.Connection))
|
|
{
|
|
cmd.Transaction = (SqlTransaction)tc.Transaction;
|
|
|
|
cmd.Parameters.AddWithValue("@file", recruitmentLetter.AppointmentLetterFileAsByteArray ?? (object)DBNull.Value);
|
|
cmd.Parameters.AddWithValue("@fileName", recruitmentLetter.AppointmentLetterFileName ?? (object)DBNull.Value);
|
|
cmd.Parameters.AddWithValue("@createdBy", recruitmentLetter.AppointmentLetterCreatedBy);
|
|
cmd.Parameters.AddWithValue("@createdDate", DataReader.GetNullValue(recruitmentLetter.AppointmentLetterCreatedDate) ?? (object)DBNull.Value);
|
|
cmd.Parameters.AddWithValue("@id", recruitmentLetter.ID);
|
|
|
|
cmd.ExecuteNonQuery();
|
|
}
|
|
}
|
|
else if (letterType == "joiningInformation")
|
|
{
|
|
sSQL = SQLParser.MakeSQL(
|
|
"UPDATE RECRUITMENTLETTERS SET JoiningInformationLetterCreatedBy=%n,JoiningInformationLetterCreatedDate=%d WHERE RecruitmentLetterID=%n",
|
|
DataReader.GetNullValue(recruitmentLetter.JoiningInformationLetterCreatedBy), recruitmentLetter.JoiningInformationLetterCreatedDate,
|
|
recruitmentLetter.ID);
|
|
|
|
tc.ExecuteNonQuery(sSQL);
|
|
}
|
|
else if (letterType == "mailToLM")
|
|
{
|
|
sSQL = SQLParser.MakeSQL(
|
|
"UPDATE RECRUITMENTLETTERS SET MailToLMLetterCreatedBy=%n,MailToLMLetterCreatedDate=%d WHERE RecruitmentLetterID=%n",
|
|
DataReader.GetNullValue(recruitmentLetter.MailToLMLetterCreatedBy), recruitmentLetter.MailToLMLetterCreatedDate,
|
|
recruitmentLetter.ID);
|
|
|
|
tc.ExecuteNonQuery(sSQL);
|
|
}
|
|
else
|
|
{
|
|
throw new ArgumentException("Invalid letterType provided");
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Insert
|
|
|
|
internal static void Insert(Ease.Core.DataAccess.TransactionContext tc, RecruitmentLetters oRECRUITMENTLETTERS)
|
|
{
|
|
//,EmployeeID ,%n ,oRECRUITMENTLETTERS.EmployeeID
|
|
|
|
string sSQL = SQLParser.MakeSQL("INSERT INTO RECRUITMENTLETTERS(RecruitmentLetterID, RequisitionID, CandidateID," +
|
|
" AcceptOfferBefore, IssueOfferDate,AcceptOfferDate,RejectOfferDate," +
|
|
" RejectOfferReason, OfferLetterCount,OfferCreatedBy,OfferCreatedDate," +
|
|
" GradeID,BasicSalary,DepartmentID,JobLocation,LocationID,NoticePeriod," +
|
|
" AppAcceptBefore,IssueAppLetterDate,RejectAppLetterDate," +
|
|
" RejectAppLetterReason,CarEligible,AppCreatedBy,AppCreatedDate," +
|
|
" AppLetterCount,JoiningLetter,VendorMail,WelcomeMail,InductionRequest," +
|
|
" Announcement,OtherLetters,OthersCount,OtherCreatedBy,OtherCreateddate," +
|
|
" CreatedBy, CreationDate,ProcessID,JoiningDate,JoiningBeforeDate,ConfirmJoiningDate,GrossSalary,IsPrimarySelected)" +
|
|
" VALUES(%n, %n, %n, %d, %d, %d, %d,%s, %n,%n,%d,%n,%n,%n,%s,%n,%n,%d,%d,%d," +
|
|
" %s,%b,%n,%d,%n,%b,%b,%b,%b,%b,%b,%n,%n,%d,%n,%d,%n,%d,%d,%d,%n,%n)",
|
|
oRECRUITMENTLETTERS.ID, oRECRUITMENTLETTERS.RequisitionID, oRECRUITMENTLETTERS.CandidateID,
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.AcceptOfferBefore),
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.IssueOfferDate),
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.AcceptOfferDate),
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.RejectOfferDate),
|
|
oRECRUITMENTLETTERS.RejectOfferReason,
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.OfferLetterCount),
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.OfferCreatedBy),
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.OfferCreatedDate),
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.GradeID),
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.BasicSalary),
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.DepartmentID),
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.JobLocation),
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.LocationID),
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.NoticePeriod),
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.AppAcceptBefore),
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.IssueAppLetterDate),
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.RejectAppLetterDate),
|
|
oRECRUITMENTLETTERS.RejectAppLetterReason, oRECRUITMENTLETTERS.CarEligible,
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.AppCreatedBy),
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.AppCreatedDate),
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.AppLetterCount),
|
|
oRECRUITMENTLETTERS.JoiningLetter, oRECRUITMENTLETTERS.VendorMail,
|
|
oRECRUITMENTLETTERS.WelcomeMail, oRECRUITMENTLETTERS.InductionRequest,
|
|
oRECRUITMENTLETTERS.Announcement, oRECRUITMENTLETTERS.OtherLetters,
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.OthersCount),
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.OtherCreatedBy),
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.OtherCreateddate),
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.CreatedBy),
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.CreatedDate), oRECRUITMENTLETTERS.ProcessID,
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.JoiningDate),
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.JoiningBeforeDate),
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.ConfirmJoiningDate),
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.GrossSalary),
|
|
DataReader.GetNullValue(oRECRUITMENTLETTERS.IsPrimarySelected));
|
|
tc.ExecuteNonQuery(sSQL);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Delete
|
|
|
|
internal static void Delete(Ease.Core.DataAccess.TransactionContext tc, int id)
|
|
{
|
|
tc.ExecuteNonQuery("DELETE FROM RECRUITMENTLETTERS WHERE RecruitmentLetterID=%n", id);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
} |