using System; using Payroll.BO; using System.Data; using System.Linq; using Ease.CoreV35.Model; using System.Data.SqlClient; using Ease.CoreV35.DataAccess; using System.Collections.Generic; using Ease.CoreV35.DataAccess.SQL; namespace Payroll.Service { #region ExitInterviewDA internal class ExitInterviewDA { #region Constructor private ExitInterviewDA() { } #endregion #region Insert function internal static void Insert(TransactionContext tc, ExitInterview item) { tc.ExecuteNonQuery("INSERT INTO ExitInterview(ExitInterviewID,EmployeeID, Name,JobTitle,DepartmentName,ManagerName,SourceofHire,HireDate,TermDate,CultureandClimate,CareerDevelopment,Settingobjectives,Providingfeedbackonperformance,Facilitatingteamwork,Communicatinginformationaffects,Relationshipwithemployees,Other,AdditionalComments,CreatedBy,CreationDate,ExitInteviewDate,CommentForCompany)" + " VALUES(%n,%n, %s, %s, %s, %s, %s, %d, %d, %s,%s, %s, %s,%s, %s, %s, %s,%s,%n,%d,%d,%s)", item.ID.Integer, item.EmployeeID.Integer, item.Name, item.JobTitle, item.DepartmentName, item.ManagerName, item.SourceofHire, item.HireDate, item.TermDate, item.CultureandClimate, item.CareerDevelopment, item.Settingobjectives, item.Providingfeedbackonperformance, item.Facilitatingteamwork, item.Communicatinginformationaffects, item.Relationshipwithemployees, item.Other, item.AdditionalComments, item.CreatedBy.Integer, DataReader.GetNullValue(item.CreatedDate), item.ExitInteviewDate, item.CommentForCompany); } internal static void Insert(TransactionContext tc, ReasonsForLeaving item) { tc.ExecuteNonQuery("INSERT INTO ReasonsForLeaving(ReasonsForLeavingID,ExitInterviewID, ReasonID)" + " VALUES(%n, %n,%n)", item.ID.Integer, item.ExitInterviewID.Integer, item.ReasonID.Integer); } #endregion #region Update function internal static void Update(TransactionContext tc, ExitInterview item) { tc.ExecuteNonQuery("UPDATE ExitInterview SET EmployeeID=%n,Name=%s,JobTitle=%s,DepartmentName=%s,ManagerName=%s,SourceofHire=%s,HireDate=%d,TermDate=%d,CultureandClimate=%s,CareerDevelopment=%s,Settingobjectives=%s,Providingfeedbackonperformance=%s,Facilitatingteamwork=%s,Communicatinginformationaffects=%s,Relationshipwithemployees=%s,Other=%s,AdditionalComments=%s,ModifiedBy=%n,ModifiedDate=%d,ExitInteviewDate=%d,CommentForCompany=%s" + "WHERE ExitInterviewID=%n", item.EmployeeID.Integer, item.Name, item.JobTitle, item.DepartmentName, item.ManagerName, item.SourceofHire, item.HireDate, item.TermDate, item.CultureandClimate, item.CareerDevelopment, item.Settingobjectives, item.Providingfeedbackonperformance, item.Facilitatingteamwork, item.Communicatinginformationaffects, item.Relationshipwithemployees, item.Other, item.AdditionalComments,item.ModifiedBy.Integer,item.ModifiedDate,item.ExitInteviewDate,item.CommentForCompany, item.ID.Integer); } #endregion #region Get Function internal static IDataReader Get(TransactionContext tc) { return tc.ExecuteReader("SELECT * FROM ExitInterview"); } internal static IDataReader Get(TransactionContext tc, DateTime dtFrom, DateTime dtTo, int nReasonID) { if(nReasonID==20) return tc.ExecuteReader("SELECT * FROM ExitInterview Where ExitInteviewDate between %d AND %d", dtFrom, dtTo); else return tc.ExecuteReader("SELECT * FROM ExitInterview Where ExitInteviewDate between %d AND %d AND ExitInterviewID in(select ExitInterviewID from ReasonsForLeaving where ReasonID=%n)", dtFrom, dtTo,nReasonID); } internal static IDataReader Get(TransactionContext tc, ID nID) { return tc.ExecuteReader("SELECT * FROM ExitInterview WHERE ExitInterviewID=%n", nID.Integer); } internal static IDataReader GetByEmployeeID(TransactionContext tc, ID nID) { return tc.ExecuteReader("SELECT * FROM ExitInterview WHERE EmployeeID=%n", nID.Integer); } internal static IDataReader GetReasonsForLeaving(TransactionContext tc, ID nID) { return tc.ExecuteReader("SELECT * FROM ReasonsForLeaving WHERE ExitInterviewID=%n", nID.Integer); } #endregion #region Delete function internal static void Delete(TransactionContext tc, ID nID) { tc.ExecuteNonQuery("DELETE FROM ReasonsForLeaving WHERE ExitInterviewID=%n", nID.Integer); tc.ExecuteNonQuery("DELETE FROM ExitInterview WHERE ExitInterviewID=%n", nID.Integer); } internal static void DeleteReasonsForLeaving(TransactionContext tc, ID nID) { tc.ExecuteNonQuery("DELETE FROM ReasonsForLeaving WHERE ExitInterviewID=%n", nID.Integer); } #endregion } #endregion }