EchoTex_Payroll/HRM.DA/DA/PMP/PMPProcessDA.cs

677 lines
39 KiB
C#
Raw Permalink Normal View History

2024-10-14 10:01:49 +06:00
using HRM.BO;
using Ease.Core.DataAccess;
using System;
using System.Data;
namespace HRM.DA
{
public class PMPProcessDA
{
internal static IDataReader Get(TransactionContext tc)
{
return tc.ExecuteReader("Select * from PMP_Process");
}
internal static void Insert(TransactionContext tc, PMPProcess item)
{
throw new NotImplementedException();
}
internal static void Update(TransactionContext tc, PMPProcess item)
{
throw new NotImplementedException();
}
internal static void Delete(TransactionContext tc, int id)
{
tc.ExecuteNonQuery("Delete From PMP_Process Where PMPProcessID = %n", id);
}
internal static IDataReader GetAllPMPTargetSettings(TransactionContext tc)
{
return tc.ExecuteReader("Select * From PMP_TargetSetting");
}
internal static void Insert(TransactionContext tc, PMPTargetSetting item)
{
throw new NotImplementedException();
}
internal static void Update(TransactionContext tc, PMPTargetSetting item)
{
throw new NotImplementedException();
}
internal static IDataReader GetEmployeeRatingById(TransactionContext tc, int id)
{
return tc.ExecuteReader("Select * From PMP_EmployeeRating Where PMPEmployeeRatingId = %n", id);
}
internal static IDataReader GetPmpTargetSettingByPmpTargetSettingId(TransactionContext tc, int Id)
{
return tc.ExecuteReader("Select * From PMP_TargetSetting Where PMPTargetSettingId = %n", Id);
}
internal static IDataReader GetPmpValueBehaviorRatingById(TransactionContext tc, int Id)
{
return tc.ExecuteReader("Select * From PMP_ValueBehaviorRating Where PMPValueBehaviorRatingId = %n", Id);
}
internal static void InsertPMPProcessItem(TransactionContext tc, PMPProcess item)
{
string sql = SQLParser.MakeSQL(@"Insert Into PMP_Process
(PmpStatus,PMPProcessID,PmpYear,Description,TargetSettingFrom,TargetSettingTo,MedianAppraisalFrom,MedianAppraisalTo,
FinalApprovalFrom,FinalApprovalTo,IsFinalize,CreatedBy,CreationDate,Status,Sequence,DevelopmentFrom,DevelopmentTo,CUTOFFDATE)
Values(%n,%n,%d,%s,%d,%d,%d,%d,%d,%d,%n,%n,%d,%n,%n,%d,%d,%d)",
item.PmpStatus, item.ID, item.PmpYear, item.Description, item.TargetSettingFrom,
item.TargetSettingTo, item.MedianAppraisalFrom, item.MedianAppraisalTo,
item.FinalApprovalFrom, item.FinalApprovalTo,
Convert.ToInt32(item.IsFinalize), item.CreatedBy, item.CreatedDate, item.Status, item.Sequence,
DataReader.GetNullValue(item.DevelopmentFrom), DataReader.GetNullValue(item.DevelopmentTo), DataReader.GetNullValue(item.CutOffDate));
tc.ExecuteNonQuery(sql);
}
internal static void UpdatePMPProcessItem(TransactionContext tc, PMPProcess item)
{
string sql = SQLParser.MakeSQL(@"Update PMP_Process Set PmpStatus = %n,PmpYear = %d, Description =%s,
TargetSettingFrom = %d,TargetSettingTo = %d,MedianAppraisalFrom = %d,MedianAppraisalTo = %d,
FinalApprovalFrom =%d,FinalApprovalTo = %d,IsFinalize = %n,Status = %n,Sequence = %n,ModifiedBy = %n,ModifiedDate =%d,DevelopmentFrom=%d,DevelopmentTo=%d,CUTOFFDATE=%d,IsPublish=%b
Where PMPProcessID = %n"
, item.PmpStatus, item.PmpYear, item.Description, item.TargetSettingFrom, item.TargetSettingTo,
item.MedianAppraisalFrom, item.MedianAppraisalTo,
item.FinalApprovalFrom, item.FinalApprovalTo, Convert.ToInt32(item.IsFinalize), item.Status,
item.Sequence, item.ModifiedBy, item.ModifiedDate, DataReader.GetNullValue(item.DevelopmentFrom), DataReader.GetNullValue(item.DevelopmentTo),
DataReader.GetNullValue(item.CutOffDate), item.IsPublish, item.ID);
tc.ExecuteNonQuery(sql);
}
internal static void UpdatePMPStatus(TransactionContext tc, PMPProcess item)
{
string sql = SQLParser.MakeSQL(@"Update PMP_EmployeeRating Set PmpStatus = %n, PmpWFStatus = %n"
+ " Where PMPProcessID = %n And PmpWFStatus=%n", item.PmpStatus, null,
item.ID, PMPWFStatus.Complete);
tc.ExecuteNonQuery(sql);
}
internal static void InsertPMPEmployeeRatingItem(TransactionContext tc, PMPEmployeeRating item)
{
double? incrementedPercentByHR = null;
if (item.IncrementedPercentByHR == Double.MinValue) incrementedPercentByHR = null;
else incrementedPercentByHR = item.IncrementedPercentByHR;
tc.ExecuteNonQuery(@"Insert Into PMP_EmployeeRating
(IsFinalized,RemarksByHR,IncrementedPercentByHR,HrValueBehaValueBehaviorRatingID,HrTargetSettingRatingID,SelfValueBehaviorRatingID,SelfObjectRatingID,PmpStatus,PmpWFStatus,PMPEmployeeRatingId,PmpProcessID,EmployeeID,ApprovarID,ApprovarObjectRatingID,AppValueBehaviorRatingID,IsTargetSettingDone,IsMedianDone,IsValueBehaviorDone)
Values(%n,%s,%n,%n,%n,%n,%n,%n,%n,%n,%n,%n,%n,%n,%n,%n,%n,%n)",
Convert.ToInt32(item.IsFinalized), item.RemarksByHR, DataReader.GetNullValue(incrementedPercentByHR),
DataReader.GetNullValue(item.HrValueBehaValueBehaviorRatingID),
DataReader.GetNullValue(item.HrTargetSettingRatingID),
DataReader.GetNullValue(item.SelfValueBehaviorRatingID),
DataReader.GetNullValue(item.SelfObjectRatingID),
item.PmpStatus, item.PmpWFStatus, item.ID, item.PmpProcessID, item.EmployeeID,
DataReader.GetNullValue(item.ApprovarID), DataReader.GetNullValue(item.ApprovarObjectRatingID),
DataReader.GetNullValue(item.AppValueBehaviorRatingID),
item.IsTargetSettingDone, item.IsMedianDone, item.IsValueBehaviorDone);
}
internal static void UpdatePMPEmployeeRatingItem(TransactionContext tc, PMPEmployeeRating item)
{
int? appValueBehaviorId = null;
if (item.AppValueBehaviorRatingID == 0)
appValueBehaviorId = null;
else if (item.ID != 0)
appValueBehaviorId = item.AppValueBehaviorRatingID;
int? appRatingid = null;
if (item.ApprovarObjectRatingID == 0)
appRatingid = null;
else if (item.ID != 0)
appRatingid = item.ApprovarObjectRatingID;
int? appId = null;
if (item.ApprovarID == 0)
appId = null;
else if (item.ID != 0)
appId = item.ApprovarID;
int? selfValueBehaviorId = null;
if (item.SelfValueBehaviorRatingID == 0)
selfValueBehaviorId = null;
else if (item.ID != 0)
selfValueBehaviorId = item.SelfValueBehaviorRatingID;
int? SelfObjectRatingID = null;
if (item.SelfObjectRatingID == 0)
SelfObjectRatingID = null;
else if (item.ID != 0)
SelfObjectRatingID = item.SelfObjectRatingID;
double? incrementedPercentByHR = null;
if (item.IncrementedPercentByHR == Double.MinValue) incrementedPercentByHR = null;
else incrementedPercentByHR = item.IncrementedPercentByHR;
tc.ExecuteNonQuery(
@"Update PMP_EmployeeRating Set IsFinalized = %n,RemarksByHR = %s, IncrementedPercentByHR = %n,HrValueBehaValueBehaviorRatingID = %n,
HrTargetSettingRatingID = %n,SelfValueBehaviorRatingID = %n,SelfObjectRatingID = %n,PmpStatus = %n,PmpWFStatus = %n,PmpProcessID = %n,EmployeeID = %n,ApprovarID = %n,
ApprovarObjectRatingID = %n,AppValueBehaviorRatingID = %n,
IsTargetSettingDone = %n,IsMedianDone = %n,IsValueBehaviorDone = %n Where PMPEmployeeRatingId = %n",
Convert.ToInt32(item.IsFinalized), item.RemarksByHR, DataReader.GetNullValue(incrementedPercentByHR),
DataReader.GetNullValue(item.HrValueBehaValueBehaviorRatingID),
DataReader.GetNullValue(item.HrTargetSettingRatingID),
DataReader.GetNullValue(selfValueBehaviorId), DataReader.GetNullValue(SelfObjectRatingID),
item.PmpStatus, item.PmpWFStatus, item.PmpProcessID, item.EmployeeID, DataReader.GetNullValue(appId),
DataReader.GetNullValue(appRatingid),
DataReader.GetNullValue(appValueBehaviorId), item.IsTargetSettingDone, item.IsMedianDone,
item.IsValueBehaviorDone, item.ID
);
}
internal static void InsertPMPTargetSettingItem(TransactionContext tc, PMPTargetSetting item)
{
DateTime? targetDate = null;
if (item.TargetDate == DateTime.MinValue)
targetDate = null;
else
targetDate = item.TargetDate;
tc.ExecuteNonQuery(@"Insert PMP_TargetSetting
(EmployeeID,ApprovarID,PMPTargetSettingId,PmpProcessId,Objective,ObjectivePercent,TargetDate,EvaluationCriteria,PmpEmployeeRatingID)
Values(%n,%n,%n,%n,%s,%n,%d,%s,%n)", item.EmployeeID,
DataReader.GetNullValue(item.ApprovarID),
item.ID, item.PmpProcessId,
item.Objective, item.ObjectivePercent, DataReader.GetNullValue(targetDate),
item.EvaluationCriteria, item.PmpEmployeeRatingID);
UpdatePMPTargetSettingItem(tc, item);
}
internal static void UpdatePMPTargetSettingItem(TransactionContext tc, PMPTargetSetting item)
{
int? selfRatingid = null;
if (item.SelfRatingID == 0)
selfRatingid = null;
else if (item.ID == 0) selfRatingid = null;
else
selfRatingid = item.SelfRatingID;
int? appRatingid = null;
if (item.ApprovarRatingID == 0)
appRatingid = null;
else if (item.ID == 0) appRatingid = null;
else
appRatingid = item.ApprovarRatingID;
int? appId = null;
if (item.ApprovarID == 0)
appId = null;
else if (item.ID == 0) appId = null;
else
appId = item.ApprovarID;
DateTime? tarDate = null;
if (item.TargetDate == DateTime.MinValue) tarDate = null;
else tarDate = item.TargetDate;
tc.ExecuteNonQuery(
@"Update PMP_TargetSetting Set PmpEmployeeRatingID = %n,EmployeeID = %n,PmpProcessId = %n,Objective = %s,ObjectivePercent = %n,TargetDate = %d,EvaluationCriteria = %s,SelfRatingID = %n,SelfComments = %s,ApprovarRatingID = %n,ApprovarComments = %s,ApprovarID = %n
Where PMPTargetSettingId = %n", item.PmpEmployeeRatingID, item.EmployeeID,
item.PmpProcessId, item.Objective, item.ObjectivePercent, DataReader.GetNullValue(tarDate),
item.EvaluationCriteria, DataReader.GetNullValue(selfRatingid),
DataReader.GetNullValue(item.SelfComments), DataReader.GetNullValue(appRatingid),
DataReader.GetNullValue(item.ApprovarComments), DataReader.GetNullValue(appId), item.ID);
}
internal static void InsertPMPValueBehaviorRatingItem(TransactionContext tc, PMPValueBehaviorRating item)
{
int? selfRatingid = null;
if (item.SelfRatingID == 0)
selfRatingid = null;
else if (item.ID == 0) selfRatingid = null;
else
selfRatingid = item.SelfRatingID;
int? appRatingid = null;
if (item.ApprovarRatingID == 0)
appRatingid = null;
else if (item.ID == 0) appRatingid = null;
else
appRatingid = item.ApprovarRatingID;
tc.ExecuteNonQuery(@"Insert Into PMP_ValueBehaviorRating
(PMPValueBehaviorRatingId,PMPValueBehaviorID,EmployeeID,SelfComments,
SelfRatingID,ApprovarComments,ApprovarRatingID,PmpProcessID,PmpEmployeeRatingID)
Values(%n,%n,%n,%s,%n,%s,%n,%n,%n)", item.ID,
item.PMPValueBehaviorID,
item.EmployeeID, DataReader.GetNullValue(item.SelfComments), DataReader.GetNullValue(selfRatingid),
DataReader.GetNullValue(item.ApprovarComments), DataReader.GetNullValue(appRatingid), item.PmpProcessId,
item.PmpEmployeeRatingID);
UpdatePMPValueBehaviorRatingItem(tc, item);
}
internal static void UpdatePMPValueBehaviorRatingItem(TransactionContext tc, PMPValueBehaviorRating item)
{
int? selfRatingid = null;
if (item.SelfRatingID == 0)
selfRatingid = null;
else if (item.ID == 0) selfRatingid = null;
else selfRatingid = item.SelfRatingID;
int? appRatingid = null;
if (item.ApprovarRatingID == 0)
appRatingid = null;
else if (item.ID == 0) appRatingid = null;
else
appRatingid = item.ApprovarRatingID;
tc.ExecuteNonQuery(
@"Update PMP_ValueBehaviorRating Set PmpEmployeeRatingID = %n,SelfComments = %s, SelfRatingID = %n ,ApprovarComments = %s,ApprovarRatingID = %n Where PMPValueBehaviorRatingId = %n",
item.PmpEmployeeRatingID, DataReader.GetNullValue(item.SelfComments),
DataReader.GetNullValue(item.SelfRatingID), DataReader.GetNullValue(item.ApprovarComments),
DataReader.GetNullValue(appRatingid), item.ID);
}
internal static IDataReader GetByPMPProcessID(TransactionContext tc, int id)
{
return tc.ExecuteReader("Select * From PMP_Process Where PMPProcessID = %n", id);
}
internal static IDataReader Get(TransactionContext tc, DateTime pmpYear)
{
return tc.ExecuteReader("Select * From PMP_Process Where PMPYear = %d",
Ease.Core.Utility.Global.DateFunctions.LastDateOfYear(pmpYear));
}
internal static IDataReader Get(TransactionContext tc, EnumStatus status)
{
if (status == EnumStatus.Regardless)
{
return tc.ExecuteReader("Select * from PMP_Process");
}
else return tc.ExecuteReader("Select * from PMP_Process Where status = %n", status);
}
internal static IDataReader Get(TransactionContext tc, EnumPMPStatus status)
{
if (status == EnumPMPStatus.NotYetInitiate)
{
return tc.ExecuteReader("Select * from PMP_Process");
}
else return tc.ExecuteReader("Select * from PMP_Process Where PmpStatus = %n", status);
}
internal static IDataReader GetByPMPProcessId(TransactionContext tc, int id)
{
return tc.ExecuteReader("Select * From PMP_Process Where PmpProcessID = %n", id);
}
internal static void DeletePMPTargetSettingById(TransactionContext tc, int id)
{
tc.ExecuteNonQuery("Delete From PMP_TargetSetting Where PMPTargetSettingId = %n", id);
}
internal static IDataReader GetPMPTargetSettingsByEmployeeId(TransactionContext tc, int id)
{
return tc.ExecuteReader("Select * From PMP_TargetSetting Where EmployeeID = %n", id);
}
internal static IDataReader GetPMPTargetSettingsByEmployeeIdAndPMPProcessID(TransactionContext tc, int id,
int pmpProcessID)
{
return tc.ExecuteReader("Select * From PMP_TargetSetting Where EmployeeID = %n And PmpProcessID = %n", id,
pmpProcessID);
}
internal static IDataReader GetValueBehaviorRatingsByEmployeeIdAndPmpProcessId(TransactionContext tc, int empId,
int pmpProcessId)
{
return tc.ExecuteReader("Select * From PMP_ValueBehaviorRating Where EmployeeID = %n And PmpProcessID = %n",
empId, pmpProcessId);
}
internal static IDataReader GetPmpEmployeeRatingByEmployeeIdAndPmpProcessId(TransactionContext tc, int empId,
int pmpProcessId)
{
return tc.ExecuteReader("Select * From PMP_EmployeeRating Where PmpProcessID = %n And EmployeeID = %n",
pmpProcessId, empId);
}
internal static IDataReader GetPmpEmployeeRatingByRatingId(TransactionContext tc, int ratingId)
{
return tc.ExecuteReader("Select * From PMP_EmployeeRating Where PMPEmployeeRatingId = %n", ratingId);
}
internal static IDataReader GetEmployeeRating(TransactionContext tc, int processID)
{
return tc.ExecuteReader("Select * From PMP_EmployeeRating Where PmpProcessID = %n", processID);
}
internal static void DeleteValueBehaviorRating(TransactionContext tc, int EmployeeId, int PmpProcessId)
{
tc.ExecuteNonQuery("Delete From PMP_ValueBehaviorRating Where EmployeeID = %n And PmpProcessID = %n",
EmployeeId, PmpProcessId);
}
internal static void DeleteAllPmpTargetSetting(TransactionContext tc, int EmployeeId, int PmpProcessId)
{
tc.ExecuteNonQuery("Delete From PMP_TargetSetting Where EmployeeID = %n And PmpProcessID = %n", EmployeeId,
PmpProcessId);
}
internal static IDataReader GetEmployeeRating(TransactionContext tc, int pmpProcessId, EnumPMPStatus pmpStatus,
PMPWFStatus status)
{
return tc.ExecuteReader(
"Select * From PMP_EmployeeRating Where PmpProcessID = %n And PmpStatus=%n And PmpWFStatus = %n",
pmpProcessId, pmpStatus, status);
}
internal static IDataReader GetEmployeeRatingForDraft(TransactionContext tc, int pmpProcessId)
{
return tc.ExecuteReader(
"Select * From PMP_EmployeeRating Where pmpProcessId = %n And PmpWFStatus Not In (1,2)", pmpProcessId);
}
internal static DataSet GetEmployeeRatingForNotInitiate(TransactionContext tc, int pmpProcessId,
EnumPMPStatus status)
{
return tc.ExecuteDataSet(
"select EmployeeID,EmployeeNo,Name From Employee Where EMPLOYEEID not in (Select EMPLOYEEID From PMP_EmployeeRating Where PmpProcessID = %n And PmpStatus=%n)",
pmpProcessId, status);
}
internal static void DeletePmpTargetSettingsByPMPId(int id)
{
throw new NotImplementedException();
}
internal static void DeletePmpTargetSettingsByPMPId(int id, TransactionContext tc)
{
tc.ExecuteNonQuery("delete from PMP_TargetSetting Where pmpProcessId = %n", id);
}
internal static void DeletePmpValueBehaviorRatingByPMPI(int id, TransactionContext tc)
{
throw new NotImplementedException();
}
internal static void DeletePmpValueBehaviorRatingByPMPId(int id, TransactionContext tc)
{
tc.ExecuteNonQuery("delete from PMP_ValueBehaviorRating where PmpProcessId = %n", id);
}
internal static void DeletePmpEmployeeRatingByPMPIDd(int id, TransactionContext tc)
{
tc.ExecuteNonQuery("delete from PMP_EmployeeRating Where PMPProcessId = %n", id);
}
internal static IDataReader GetCurrentPMPYearWithPmpStatus(TransactionContext tc, EnumPMPStatus pmpStatus, bool IsFinalize)
{
return tc.ExecuteReader("SELECT * FROM PMP_Process WHERE PmpStatus = %n AND IsFinalize= %n",
(int)pmpStatus, IsFinalize);
}
internal static IDataReader GetCurrentPMPYear(TransactionContext tc, bool isFinalize)
{
return tc.ExecuteReader("SELECT * FROM PMP_Process WHERE IsFinalize= %n", isFinalize);
}
internal static IDataReader GetByYear(TransactionContext tc, int pmpYear)
{
return tc.ExecuteReader("SELECT * FROM PMP_PROCESS WHERE Year(pmpyear) = %n",
pmpYear);
}
internal static DataSet GetReportData(TransactionContext tc, EnumPMPReports selectedReport, int PMPYearID,
int locationID, string levelIDs, string designationIDs, int orgaBasicID, int programmeID, int projectID)
{
string sSQL = "";
string sSQL2 = "";
string sWhere = "";
DataSet dsReportData = new DataSet();
try
{
if (locationID != null)
sWhere += SQLParser.MakeSQL(@" AND emp.locationid=%n", locationID);
if (!string.IsNullOrEmpty(levelIDs))
sWhere += SQLParser.MakeSQL(@" AND emp.gradeid IN (%q)", levelIDs);
if (!string.IsNullOrEmpty(designationIDs))
sWhere += SQLParser.MakeSQL(@" AND emp.designationID IN (%q)", designationIDs);
if (programmeID != null)
sWhere += SQLParser.MakeSQL(@" AND emp.departmentid=%n", programmeID);
if (PMPYearID != null && selectedReport != EnumPMPReports.Staffs_Level8_Above_Not_Promoted_8y)
sWhere += SQLParser.MakeSQL(@" AND os.PMPYearID=%n", PMPYearID);
if (orgaBasicID != null)
sWhere += SQLParser.MakeSQL(
@" AND emp.employeeid in(select employeeid from organemployee where nodeid=%n)", orgaBasicID);
switch (selectedReport)
{
case EnumPMPReports.Program_Project_Status_Low_Performing_Staff:
sSQL = SQLParser.MakeSQL(
@"select dept.departmentid,dept.description as Program,dept.tire as depttier,loc.locationid,loc.description as location,
loc.tire as loctier, emp.employeeno as PIN,emp.name,
deg.name as designation,grd.description as level,emp.joiningdate,
emp.lastpromotiondate,
cat.description as StaffType,
case emp.status
when 1 then 'Live'
when 2 then 'Discontinued'
when 3 then 'Secondy'
when 4 then 'Suspend'
when 5 then 'Withheld'
when 6 then 'Waitingforjoin'
else 'Didnotjoin'
end as 'Status'
from employee emp,department dept,category cat,designation deg,location loc,Grades grd,ObjectiveSet os
where os.EmployeeID=emp.EMPLOYEEID AND emp.departmentid=dept.departmentid AND
emp.categoryID=cat.categoryID AND
emp.designationid=deg.designationid AND
emp.locationid=loc.locationid AND
emp.gradeid=grd.gradeid");
break;
case EnumPMPReports.Programme_Level_Assessment_Analysis_Low_Performing_Staff_1to7:
sSQL = SQLParser.MakeSQL(
@"select tab1.gradeid,tab1.departmentid,tab1.Program,tab1.Grade,tab1.EmpCount,tab2.Minimum,tab3.Maximim,tab4.Average from
(SELECT emp.departmentid,dept.[DESCRIPTION] AS Program,emp.gradeid,g.[DESCRIPTION] AS Grade,count(emp.employeeno) as EmpCount
FROM ObjectiveSet os,Employee emp, GRADES g,department dept,PMP_Process pmp
WHERE emp.EMPLOYEEID=os.EmployeeID AND
emp.GRADEID=g.GRADEID AND
emp.departmentid=dept.departmentid
AND pmp.pmpprocessid=os.pmpyearid %q
group by emp.departmentid,dept.[DESCRIPTION],emp.gradeid,g.[DESCRIPTION])tab1,
(SELECT emp.departmentid,emp.gradeid,min(os.OverallOBRating) as Minimum
FROM ObjectiveSet os,Employee emp, GRADES g,PMP_Process pmp
WHERE emp.EMPLOYEEID=os.EmployeeID AND
emp.GRADEID=g.GRADEID
AND pmp.pmpprocessid=os.pmpyearid
group by emp.departmentid,emp.gradeid)tab2,
(SELECT emp.departmentid,emp.gradeid,max(os.OverallOBRating) as Maximim
FROM ObjectiveSet os,Employee emp, GRADES g,PMP_Process pmp
WHERE emp.EMPLOYEEID=os.EmployeeID AND
emp.GRADEID=g.GRADEID
AND pmp.pmpprocessid=os.pmpyearid
group by emp.departmentid,emp.gradeid)tab3,
(SELECT emp.departmentid,emp.gradeid,Avg(os.OverallOBRating) as Average
FROM ObjectiveSet os,Employee emp, GRADES g,PMP_Process pmp
WHERE emp.EMPLOYEEID=os.EmployeeID AND
emp.GRADEID=g.GRADEID
AND pmp.pmpprocessid=os.pmpyearid
group by emp.departmentid,emp.gradeid)tab4
where (tab1.gradeid=tab2.gradeid AND tab1.departmentid=tab2.departmentid) AND
(tab2.gradeid=tab3.gradeid AND tab2.departmentid=tab3.departmentid) AND
(tab3.gradeid=tab4.gradeid AND tab3.departmentid=tab4.departmentid AND tab1.Gradeid<8)",
sWhere);
sWhere = string.Empty;
break;
case EnumPMPReports.Programme_Level_Assessment_Analysis_Low_Performing_Staff_8nAbove:
sSQL = SQLParser.MakeSQL(
@"select tab1.gradeid,tab1.departmentid,tab1.Program,tab1.Grade,tab1.EmpCount,tab2.Minimum,tab3.Maximim,tab4.Average from
(SELECT emp.departmentid,dept.[DESCRIPTION] AS Program,emp.gradeid,g.[DESCRIPTION] AS Grade,count(emp.employeeno) as EmpCount
FROM ObjectiveSet os,Employee emp, GRADES g,department dept,PMP_Process pmp
WHERE emp.EMPLOYEEID=os.EmployeeID AND
emp.GRADEID=g.GRADEID AND
emp.departmentid=dept.departmentid
AND pmp.pmpprocessid=os.pmpyearid %q
group by emp.departmentid,dept.[DESCRIPTION],emp.gradeid,g.[DESCRIPTION])tab1,
(SELECT emp.departmentid,emp.gradeid,min(os.OverallOBRating) as Minimum
FROM ObjectiveSet os,Employee emp, GRADES g,PMP_Process pmp
WHERE emp.EMPLOYEEID=os.EmployeeID AND
emp.GRADEID=g.GRADEID
AND pmp.pmpprocessid=os.pmpyearid %q
group by emp.departmentid,emp.gradeid)tab2,
(SELECT emp.departmentid,emp.gradeid,max(os.OverallOBRating) as Maximim
FROM ObjectiveSet os,Employee emp, GRADES g,PMP_Process pmp
WHERE emp.EMPLOYEEID=os.EmployeeID AND
emp.GRADEID=g.GRADEID
AND pmp.pmpprocessid=os.pmpyearid %q
group by emp.departmentid,emp.gradeid)tab3,
(SELECT emp.departmentid,emp.gradeid,Avg(os.OverallOBRating) as Average
FROM ObjectiveSet os,Employee emp, GRADES g,PMP_Process pmp
WHERE emp.EMPLOYEEID=os.EmployeeID AND
emp.GRADEID=g.GRADEID
AND pmp.pmpprocessid=os.pmpyearid %q
group by emp.departmentid,emp.gradeid)tab4
where (tab1.gradeid=tab2.gradeid AND tab1.departmentid=tab2.departmentid) AND
(tab2.gradeid=tab3.gradeid AND tab2.departmentid=tab3.departmentid) AND
(tab3.gradeid=tab4.gradeid AND tab3.departmentid=tab4.departmentid AND tab1.Gradeid>7)",
sWhere, sWhere, sWhere, sWhere);
sWhere = string.Empty;
break;
case EnumPMPReports.Programme_Level_No_Assessment_Receiving_Status_Low_Performing_Staff:
sSQL = SQLParser.MakeSQL(@"");
break;
case EnumPMPReports.Programme_Level_No_Assessment_Receiving_Status_Low_Performing_Staff_Details:
sSQL = SQLParser.MakeSQL(@"");
break;
case EnumPMPReports.Staffs_Level8_Above_Not_Promoted_8y:
sSQL = SQLParser.MakeSQL(@"select emp.employeeno as PIN,emp.name,
case emp.gender
when 1 then 'Male'
when 2 then 'Female'
else 'NA'
end as 'Gender' ,
dept.description as Program,
grd.description as level,
emp.lastpromotiondate,
emp.joiningdate,
datediff(year,emp.lastpromotiondate,getdate()) as 'Years till last promoted'
from employee emp,department dept,Grades grd
where emp.departmentid=dept.departmentid AND datediff(year,emp.lastpromotiondate,getdate())>7 AND
emp.gradeid=grd.gradeid");
sSQL2 = SQLParser.MakeSQL(
@"SELECT e.DEPARTMENTID,d.[DESCRIPTION] Programme,e.GRADEID,g.[DESCRIPTION] [Level], COUNT(EMPLOYEEID) NoOfStaff
FROM Employee e,Grades g, DEPARTMENT d WHERE g.GRADEID=e.GRADEID AND e.DEPARTMENTID=d.DEPARTMENTID
GROUP BY e.DEPARTMENTID,d.[DESCRIPTION],g.[DESCRIPTION], e.GRADEID order by d.[DESCRIPTION],e.GRADEID");
break;
case EnumPMPReports.Staffs_Nominated_Performance_Allowance:
sSQL = SQLParser.MakeSQL(
@"SELECT emp.*,g.[DESCRIPTION] AS Grade,l.[DESCRIPTION] AS Location, d.[NAME] AS Designation,
os.OverallOBRating AS MARKS,yer.PerformanceAllowance, os.YEEmpAgreed, EL.[DESCRIPTION] AS Academic
FROM YearEndRecomendation yer, ObjectiveSet os,Employee emp, GRADES g, LOCATION l, DESIGNATION d,EducationLevel EL,EMPACADEMIC EA
WHERE yer.RecomendationLevel=%n AND yer.PerformanceAllowance>0 AND yer.RecomendationType=3 AND os.ObjectiveSetID=yer.ObjectiveSetID
AND emp.EMPLOYEEID=ea.EMPLOYEEID AND ea.EDUCATIONLEVELID=EL.EDUCATIONLEVELID AND EA.LASTLEVEL=1
AND emp.EMPLOYEEID=os.EmployeeID AND emp.LOCATIONID=l.LOCATIONID AND emp.GRADEID=g.GRADEID AND emp.DESIGNATIONID=d.DESIGNATIONID ",
(int)EnumRecomendationLevel.Board);
break;
case EnumPMPReports.Staffs_Nominated_Promotion:
sSQL = SQLParser.MakeSQL(
@"SELECT emp.*,g.[DESCRIPTION] AS Grade,l.[DESCRIPTION] AS Location, d.[NAME] AS Designation,ISNULL((SELECT os2.OverallOBRating FROM ObjectiveSet os2 WHERE os2.PMPYearID=(SELECT pp.PMPProcessID
FROM PMP_Process pp WHERE YEAR(pp.PmpYear)= (SELECT year(pp2.PmpYear)-2 FROM PMP_Process pp2 WHERE pp2.PMPProcessID=%n))),0) AS PrePrevMarks,
ISNULL((SELECT os2.OverallOBRating FROM ObjectiveSet os2 WHERE os2.PMPYearID=(SELECT pp.PMPProcessID
FROM PMP_Process pp WHERE YEAR(pp.PmpYear)= (SELECT year(pp2.PmpYear)-1 FROM PMP_Process pp2 WHERE pp2.PMPProcessID=%n))),0) AS PrevMarks,os.OverallOBRating AS MARKS,
(SELECT NAME FROM DESIGNATION d2 WHERE d2.DESIGNATIONID=yer.PromotionDesignationID) AS ProposedDesignation, os.YEEmpAgreed, EL.[DESCRIPTION] AS Academic
FROM YearEndRecomendation yer, ObjectiveSet os,Employee emp, GRADES g, LOCATION l, DESIGNATION d,EducationLevel EL,EMPACADEMIC EA
WHERE yer.RecomendationLevel=%n AND yer.RecomendationType IN(%n,%n,%n) AND os.ObjectiveSetID=yer.ObjectiveSetID
AND emp.EMPLOYEEID=ea.EMPLOYEEID AND ea.EDUCATIONLEVELID=EL.EDUCATIONLEVELID AND EA.LASTLEVEL=1
AND emp.EMPLOYEEID=os.EmployeeID AND emp.LOCATIONID=l.LOCATIONID AND emp.GRADEID=g.GRADEID AND emp.DESIGNATIONID=d.DESIGNATIONID",
PMPYearID, PMPYearID, (int)EnumRecomendationLevel.Board, EnumRecommendationType.Promotion,
EnumRecommendationType.Promotion, EnumRecommendationType.Promotion);
break;
case EnumPMPReports.Employee_not_yet_posting:
sSQL = SQLParser.MakeSQL(
@"select emp.*, d.[NAME] Designation,g.[DESCRIPTION] Grade,dp.[DESCRIPTION] Department
from employee emp, DESIGNATION d, GRADES g, DEPARTMENT dp where employeeid not in (select employeeid from organemployee org)
AND emp.DESIGNATIONID=d.DESIGNATIONID AND emp.GRADEID=g.GRADEID AND emp.DEPARTMENTID=dp.DEPARTMENTID");
sWhere = string.Empty;
break;
case EnumPMPReports.Duplicate_Node:
sSQL = SQLParser.MakeSQL(
@"select org.*,emp.employeeno,emp.name, d.[NAME] Designation,g.[DESCRIPTION] Grade,dp.[DESCRIPTION] Department from organogram org,(
select * from organemployee where employeeid in (
select employeeid from(
select employeeid,count(employeeid) TotalCount from organemployee org
group by employeeid)tab1
where tab1.TotalCount>=2))tab2,employee emp, DESIGNATION d, DEPARTMENT dp, GRADES g
where org.organogramid=tab2.nodeid
AND tab2.employeeid=emp.employeeid AND emp.DESIGNATIONID=d.DESIGNATIONID AND emp.GRADEID=g.GRADEID AND emp.DEPARTMENTID=dp.DEPARTMENTID
AND org.DESIGNATIONID=d.DESIGNATIONID AND org.GRADEID=g.GRADEID AND org.DEPARTMENTID=dp.DEPARTMENTID");
sWhere = string.Empty;
break;
}
if (sWhere != "")
sSQL += sWhere;
dsReportData = tc.ExecuteDataSet(sSQL);
if (sSQL2 != "")
{
DataSet temp = tc.ExecuteDataSet(sSQL2);
temp.Tables[0].TableName = "ProgrammeWiseStaff";
dsReportData.Tables.Add(temp.Tables[0].Copy());
}
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return dsReportData;
}
internal static DataSet GetReportData(TransactionContext tc, int PmpYearYear, int EmployeeID)
{
string sSQL = "";
string sWhere = "";
DataSet dsReportData = new DataSet();
try
{
sSQL = SQLParser.MakeSQL(
@"select org.*,emp.employeeno,emp.name, d.[NAME] Designation,g.[DESCRIPTION] Grade,dp.[DESCRIPTION] Department from organogram org,(
select * from organemployee where employeeid in (
select employeeid from(
select employeeid,count(employeeid) TotalCount from organemployee org
group by employeeid)tab1
where tab1.TotalCount>=2))tab2,employee emp, DESIGNATION d, DEPARTMENT dp, GRADES g
where org.organogramid=tab2.nodeid
AND tab2.employeeid=emp.employeeid AND emp.DESIGNATIONID=d.DESIGNATIONID AND emp.GRADEID=g.GRADEID AND emp.DEPARTMENTID=dp.DEPARTMENTID
AND org.DESIGNATIONID=d.DESIGNATIONID AND org.GRADEID=g.GRADEID AND org.DEPARTMENTID=dp.DEPARTMENTID");
dsReportData = tc.ExecuteDataSet(sSQL);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return dsReportData;
}
}
}