using HRM.BO; using Ease.Core.DataAccess; using System; using System.Data; namespace HRM.DA { public class EmployeeAppraisalDA { internal static IDataReader Get(TransactionContext tc, EnumStatus status) { if (status == EnumStatus.Regardless) { return tc.ExecuteReader("Select * From EmployeeAppraisal"); } else { return tc.ExecuteReader("Select * From EmployeeAppraisal Where status = %n", Convert.ToInt32(status)); } } internal static IDataReader Get(TransactionContext tc, DateTime appYear) { return tc.ExecuteReader("Select * From EmployeeAppraisal where AppraisalYear=%d", Ease.Core.Utility.Global.DateFunctions.LastDateOfYear(appYear)); } internal static IDataReader GetAppraisalDataFromObjSet(TransactionContext tc, int LMId, DateTime appYear) { string sql = SQLParser.MakeSQL("Select Null ACTIONPLAN, 0 APPRAISALPOINTID," + " ObjSet.LMOverAllRating APPRAISALPOINTRATE, sysdate APPRAISALYEAR, 0 BUDGETAMOUNT," + " Null COLLABORATIVEWORKING, Null COLLABORATIVEWORKINGCOMMENT, 0 CREATEDBY, sysdate CREATEDDATE," + " 0 CURRENTBASIC, Null CUSTOMERFOCUS, Null CUSTOMERFOCUSCOMMENT, E.DEPARTMENTID," + " Null DIGITALAGENDAEXECUTION, Null DIGITALAGENDAEXECUTIONCOMMENT, Null DIGITALBUSINESSACUMEN, Null DIGITALBUSINESSACUMENCOMMENT," + " 0 EMPLOYEEAPPRAISALID, E.EMPLOYEEID, Null EXPERIMENTATION, Null EXPERIMENTATIONCOMMENT, Null FUNCTIONALSKILL, Null FUNCTIONALSKILLCOMMENT," + " Null GROWTHMINDSET, Null GROWTHMINDSETCOMMENT, 0 HRAPPROVEID, 0 HRCHANGEAMOUNT, 0 HRCHANGEPERCENT, Null HRREMARKS, Null INTEGRITYANDETHICS," + " Null INTEGRITYANDETHICSCOMMENT, 0 ISHRDONE, 0 ISLMDONE, Null LEADINGTEAMS, Null LEADINGTEAMSCOMMENT, Null LEADINGTRANSFORMATION," + " Null LEADINGTRANSFORMATIONCOMMENT, 0 LMCHANGEAMOUNT, 0 LMCHANGEPERCENT, 0 LMID, Null LMREMARKS, 0 MKTAMOUNT, 0 MKTSURVEYID," + " Null MOBILITY, Null MODIFIEDBY, Null MODIFIEDDATE, Null NEXTPLANNEDPOSITION, Null NEXTSTEP, Null POTENTIALRATE, Null PROMOTABILITY," + " Null PROMOTABILITY, Null RESTRICTIONS, Null RESTRICTIONS, Null STRATEGICTHINKING, Null STRATEGICTHINKINGCOMMENT, Null STRENGHTS," + " 0 SURVEYON FROM OBJECTIVESET ObjSet JOIN PMP_PROCESS PmpProc ON" + " PmpProc.PMPPROCESSID = ObjSet.PMPYEARID AND PmpProc.PMPYear = %d AND PmpProc.ISFINALIZE = 1 JOIN EMPLOYEE E ON E.Employeeid=objSet.EMPLOYEEID" + " And E.DEPARTMENTID IN(SELECT DEPARTMENTID FROM TALENTDESIGDEPT WHERE EMPLOYEEID = %n)", PayrollGlobalFunctions.LastDateOfYear(appYear), LMId); return tc.ExecuteReader(sql); } internal static IDataReader Get(TransactionContext tc, int employeeId) { string sql = SQLParser.MakeSQL("Select * From EmployeeAppraisal EA Where EA.EmployeeId = %n", employeeId); return tc.ExecuteReader(sql); } internal static IDataReader Get(TransactionContext tc, int LMId, DateTime appYear) { string sql = SQLParser.MakeSQL("Select * From EmployeeAppraisal EA Where EA.DEPARTMENTID IN(SELECT DEPARTMENTID FROM TALENTDESIGDEPT WHERE EMPLOYEEID = %n) And EA.AppraisalYear Between %d AND %d", LMId, PayrollGlobalFunctions.FirstDateOfYear(appYear), PayrollGlobalFunctions.LastDateOfYear(appYear)); return tc.ExecuteReader(sql); } internal static IDataReader GetByLM(TransactionContext tc, int LMId, DateTime appYear) { return tc.ExecuteReader("Select * From EmployeeAppraisal EA Where EA.DEPARTMENTID IN(SELECT DEPARTMENTID FROM TALENTDESIGDEPT WHERE EMPLOYEEID = %n) And EA.LMID = %n And EA.AppraisalYear Between %d AND %d", LMId, LMId, PayrollGlobalFunctions.FirstDateOfYear(appYear), PayrollGlobalFunctions.LastDateOfYear(appYear)); } internal static IDataReader GetPreviouslySavedData(TransactionContext tc, int LMId, DateTime appYear) { return tc.ExecuteReader("Select * From EmployeeAppraisal EA Where EA.DEPARTMENTID IN(SELECT DEPARTMENTID FROM TALENTDESIGDEPT WHERE EMPLOYEEID = %n) And EA.LMID IS NOT NULL And EA.AppraisalYear Between %d AND %d", LMId, PayrollGlobalFunctions.FirstDateOfYear(appYear), PayrollGlobalFunctions.LastDateOfYear(appYear)); } internal static void Insert(TransactionContext tc, EmployeeAppraisal item) { tc.ExecuteNonQuery( "Insert into EmployeeAppraisal(EmployeeAppraisalID, EmployeeID, AppraisalYear, MKTSurveyID, CurrentBasic, SurveyON, BudgetAmount, " + " MKTAmount, LMID, LMChangePercent, LMChangeAmount, LMRemarks, ISLMDone, ISHRDone, HRApproveID, HRChangePercent, HRChangeAmount, " + " HRRemarks, AppraisalPointID, AppraisalPointRate, CreatedDate, CreatedBy) " + " Values(%n, %n, %d, %n, %n, %n, %n, %n, %n, %n, %n, %s, %n, %n, %n, %n, %n, %s, %n, %n, %d, %n)", item.ID, item.EmployeeID, item.AppraisalYear, DataReader.GetNullValue(item.MKTSurveyID), item.CurrentBasic, item.SurveyON, item.BudgetAmount, item.MKTAmount, DataReader.GetNullValue(item.LMID), item.LMChangePercent, item.LMChangeAmount, item.LMRemarks, item.ISLMDone, item.ISHRDone, DataReader.GetNullValue(item.HRApproveID), item.HRChangePercent, item.HRChangeAmount, item.HRRemarks, DataReader.GetNullValue(item.AppraisalPointID), item.AppraisalPointRate, item.CreatedDate, item.CreatedBy); } internal static void Update(TransactionContext tc, EmployeeAppraisal item) { tc.ExecuteNonQuery( "Update EmployeeAppraisal Set EmployeeID = %n , AppraisalYear = %d , MKTSurveyID = %n , CurrentBasic = %n , " + " SurveyON = %n , BudgetAmount = %n , MKTAmount = %n , LMID = %n ,LMChangePercent = %n , LMChangeAmount = %n , " + " LMRemarks = %s, ISLMDone = %n , ISHRDone = %n, HRApproveID = %n ,HRChangePercent = %n,HRChangeAmount = %n, " + " HRRemarks = %s,AppraisalPointID = %n,AppraisalPointRate = %n,CreatedDate = %d,CreatedBy = %n " + " Where EmployeeAppraisalID = %n", item.EmployeeID, item.AppraisalYear, item.MKTSurveyID, item.CurrentBasic, Convert.ToInt32(item.SurveyON), item.BudgetAmount, item.MKTAmount, DataReader.GetNullValue(item.LMID), item.LMChangePercent, item.LMChangeAmount, item.LMRemarks, item.ISLMDone, item.ISHRDone, DataReader.GetNullValue(item.HRApproveID), item.HRChangePercent, item.HRChangeAmount, item.HRRemarks, item.AppraisalPointID, item.AppraisalPointRate, item.ModifiedDate, item.ModifiedBy, item.ID); } internal static void Delete(TransactionContext tc, int id) { tc.ExecuteNonQuery("Delete From EmployeeAppraisal Where EmployeeAppraisalID = %n", id); } internal static void DeleteByEmployeeId(TransactionContext tc, int empId) { tc.ExecuteNonQuery("Delete From EmployeeAppraisal Where EmployeeID = %n", empId); } } }