1092 lines
60 KiB
C#
1092 lines
60 KiB
C#
|
|
using DocumentFormat.OpenXml.Office2010.Excel;
|
|||
|
|
using Ease.Core.DataAccess;
|
|||
|
|
using HRM.BO;
|
|||
|
|
using NPOI.OpenXmlFormats.Dml.Chart;
|
|||
|
|
using System;
|
|||
|
|
using System.Data;
|
|||
|
|
using System.Data.SqlClient;
|
|||
|
|
|
|||
|
|
|
|||
|
|
namespace HRM.DA
|
|||
|
|
{
|
|||
|
|
public class ObjectiveDA
|
|||
|
|
{
|
|||
|
|
internal static IDataReader Get(TransactionContext tc)
|
|||
|
|
{
|
|||
|
|
string sql = SQLParser.MakeSQL("SELECT * FROM Objective");
|
|||
|
|
return tc.ExecuteReader(sql);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal static IDataReader Get(TransactionContext tc, int id)
|
|||
|
|
{
|
|||
|
|
string sql = SQLParser.MakeSQL("SELECT * FROM Objective WHERE ObjectiveID = %n", id);
|
|||
|
|
return tc.ExecuteReader(sql);
|
|||
|
|
}
|
|||
|
|
internal static IDataReader GetObjectiveSet(TransactionContext tc, int ObjectiveSetId)
|
|||
|
|
{
|
|||
|
|
string sql = SQLParser.MakeSQL("SELECT * FROM Objective WHERE ObjectiveSetID = %n", ObjectiveSetId);
|
|||
|
|
return tc.ExecuteReader(sql);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal static void Insert(TransactionContext tc, Objective item)
|
|||
|
|
{
|
|||
|
|
string sql = SQLParser.MakeSQL(
|
|||
|
|
"Insert Into Objective(ObjectiveID, ObjectiveSetID, PMPYearID, Description, Activities, MeasuresOfSuccess, Weightages, EmployeeID, EmployeeNodeID, ObjectiveDate, LMID, LMNodeID, LMRatingID, RagingDate, MYEmployeeComments, MYLMComments, IsDraft,ObjectiveType,YEEmployeeComments, YELMComments,IsOldObjective,PriorityPercent, StartDate, EndDate ,MYAssessRating,MYLMAssessRating,MYStatus,YEStatus,KPIType,yeempmark,yelmmark,GroupID,Tier, Title, MASTERKPIID, ProgressStatus, ObjectiveStatus, PayrollTypeID, ObjectiveSettingRemarksLM, ObjectiveSettingRemarksLM2) " +
|
|||
|
|
"Values(%n, %n, %n, %s, %s, %s, %n, %n, %n, %d, %n, %n, %n, %d, %s, %s, %b,%n,%s,%s, %b,%n, %d, %d,%n,%n,%n,%n,%n,%n,%n,%n,%s,%s, %n, %n, %n, %n, %s, %s)",
|
|||
|
|
item.ID, DataReader.GetNullValue(item.ObjectiveSetID), DataReader.GetNullValue(item.PMPYearID),
|
|||
|
|
item.Description, item.Activities, item.MeasuresOfSuccess, item.Weightages,
|
|||
|
|
DataReader.GetNullValue(item.EmployeeID), DataReader.GetNullValue(item.EmployeeNodeID),
|
|||
|
|
DataReader.GetNullValue(item.ObjectiveDate), DataReader.GetNullValue(item.LMID), DataReader.GetNullValue(item.LMNodeID),
|
|||
|
|
item.LMRatingID, DataReader.GetNullValue(item.RagingDate), item.MYEmployeeComments, item.MYLMComments, item.IsDraft,
|
|||
|
|
(int)item.ObjectiveType, item.YEEmployeeComments, item.YELMComments, item.IsOldObjective,
|
|||
|
|
item.PriorityPercent, item.StartDate, item.EndDate,
|
|||
|
|
item.MYAssessRating, item.MYLMAssessRating, (int)item.MYStatus, (int)item.YEStatus, item.KPIType,
|
|||
|
|
item.YEEmpMark, item.YELMMark, DataReader.GetNullValue(item.GroupID), item.Tier, item.Title, item.MasterKpiId, item.ProgressStatus, (int)item.ObjectiveStatus, item.PayrollTypeID,
|
|||
|
|
item.ObjectiveSettingRemarksLM, item.ObjectiveSettingRemarksLM2);
|
|||
|
|
tc.ExecuteNonQuery(sql);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal static int InsertHistory(TransactionContext tc, EnumOperationalStatus changestatus, ObjectiveSet objectiveSet, Objective oldObjective, Objective newObjective, bool outsideOfSettings = false)
|
|||
|
|
{
|
|||
|
|
DateTime? newFromDate = newObjective == null ? null : DataReader.GetNullValue(newObjective.StartDate);
|
|||
|
|
DateTime? newToDate = newObjective == null ? null : DataReader.GetNullValue(newObjective.EndDate);
|
|||
|
|
double? newWeightage = newObjective == null ? null : DataReader.GetNullValue(newObjective.Weightages);
|
|||
|
|
|
|||
|
|
// TOP 1 ObjectiveHistoryID rather than the original COUNT(*): still the same existence
|
|||
|
|
// check (any row returned = exists), but now also hands back the id of that row so
|
|||
|
|
// callers (e.g. staged attachment linkage) can act on the exact matched history row
|
|||
|
|
// instead of only knowing whether one exists.
|
|||
|
|
Object obj = null;
|
|||
|
|
|
|||
|
|
if (newObjective != null)
|
|||
|
|
// ISNULL, not a plain "=": pre-migration rows have OutsideOfSettings = NULL and must
|
|||
|
|
// still be treated as "false" so the legacy correction-mode dedup keeps matching them.
|
|||
|
|
obj = tc.ExecuteScalar("Select TOP 1 ObjectiveHistoryID FROM ObjectiveHistory WHERE " +
|
|||
|
|
" objectivesetid=%n and objectiveid=%n and employeeid=%n and issubmitted =%b and ISNULL(OutsideOfSettings, 0) = %b ",
|
|||
|
|
objectiveSet.ID, newObjective.ID, newObjective.EmployeeID, false, outsideOfSettings);
|
|||
|
|
|
|||
|
|
int? existingHistoryId = (obj == null || obj == DBNull.Value) ? (int?)null : Convert.ToInt32(obj);
|
|||
|
|
|
|||
|
|
if (existingHistoryId.HasValue)
|
|||
|
|
{
|
|||
|
|
ObjectiveDA.updatetHistory(tc, changestatus, oldObjective, newObjective, outsideOfSettings);
|
|||
|
|
return existingHistoryId.Value;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
string sql = SQLParser.MakeSQL(
|
|||
|
|
@"Insert Into ObjectiveHistory
|
|||
|
|
(
|
|||
|
|
ObjectiveSetID,
|
|||
|
|
EmployeeID,
|
|||
|
|
ObjectiveID,
|
|||
|
|
ChangeType,
|
|||
|
|
ObjectiveTypeID,
|
|||
|
|
Title,
|
|||
|
|
Target,
|
|||
|
|
FromDate,
|
|||
|
|
ToDate,
|
|||
|
|
Weightage,
|
|||
|
|
NewTitle,
|
|||
|
|
NewTarget,
|
|||
|
|
NewFromDate,
|
|||
|
|
NewToDate,
|
|||
|
|
NewWeightage,
|
|||
|
|
Remarks,
|
|||
|
|
UserID,
|
|||
|
|
CreatedDate,
|
|||
|
|
OutsideOfSettings,
|
|||
|
|
PMPYearID
|
|||
|
|
|
|||
|
|
)
|
|||
|
|
Values
|
|||
|
|
(
|
|||
|
|
%n, %n, %n, %n, %n, %s, %s, %D, %D, %n,
|
|||
|
|
%s, %s, %D, %D, %n, %s, %n, %D, %b, %n
|
|||
|
|
)",
|
|||
|
|
objectiveSet.ID,
|
|||
|
|
objectiveSet.EmployeeID,
|
|||
|
|
oldObjective.ID,
|
|||
|
|
changestatus,
|
|||
|
|
oldObjective.ObjectiveType,
|
|||
|
|
oldObjective.Title,
|
|||
|
|
oldObjective.MeasuresOfSuccess,
|
|||
|
|
oldObjective.StartDate,
|
|||
|
|
oldObjective.EndDate,
|
|||
|
|
oldObjective.Weightages,
|
|||
|
|
newObjective == null ? null : (oldObjective.Title == newObjective.Title) ? null : newObjective.Title,
|
|||
|
|
newObjective == null ? null : (oldObjective.MeasuresOfSuccess == newObjective.MeasuresOfSuccess) ? null : newObjective.MeasuresOfSuccess,
|
|||
|
|
newObjective == null ? null : (oldObjective.StartDate == newObjective.StartDate) ? null : newObjective.StartDate,
|
|||
|
|
newObjective == null ? null : (oldObjective.EndDate == newObjective.EndDate) ? null : newObjective.EndDate,
|
|||
|
|
newObjective == null ? null : (oldObjective.Weightages == newObjective.Weightages) ? null : newObjective.Weightages,
|
|||
|
|
null,
|
|||
|
|
objectiveSet.CreatedBy,
|
|||
|
|
DateTime.Today,
|
|||
|
|
outsideOfSettings,
|
|||
|
|
objectiveSet.PMPYearID
|
|||
|
|
);
|
|||
|
|
|
|||
|
|
object newIdObj = tc.ExecuteScalar(sql + "; SELECT CAST(SCOPE_IDENTITY() AS INT)");
|
|||
|
|
return (newIdObj == null || newIdObj == DBNull.Value) ? 0 : Convert.ToInt32(newIdObj);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Stages a brand-new (not-yet-existing) KPI proposed outside of settings. Nothing is written
|
|||
|
|
/// to the Objective table here — the proposal lives only in ObjectiveHistory (ObjectiveID is
|
|||
|
|
/// left NULL) until a line manager approves it (ObjectiveService.ApplyOutsideOfSettingsHistory).
|
|||
|
|
/// Title/Target/FromDate/ToDate/Weightage (the "old value" columns) are NOT NULL in the
|
|||
|
|
/// existing schema, built around every row being a change to something that already exists -
|
|||
|
|
/// there's no real "old" value for a KPI that doesn't exist yet, so the proposed values are
|
|||
|
|
/// written into both the old and new columns rather than widening the schema further.
|
|||
|
|
/// </summary>
|
|||
|
|
internal static int InsertHistoryForNewObjective(TransactionContext tc, ObjectiveSet objectiveSet, Objective newObjective)
|
|||
|
|
{
|
|||
|
|
string sql = SQLParser.MakeSQL(
|
|||
|
|
@"Insert Into ObjectiveHistory
|
|||
|
|
(
|
|||
|
|
ObjectiveSetID,
|
|||
|
|
EmployeeID,
|
|||
|
|
ObjectiveID,
|
|||
|
|
ChangeType,
|
|||
|
|
ObjectiveTypeID,
|
|||
|
|
Title,
|
|||
|
|
Target,
|
|||
|
|
FromDate,
|
|||
|
|
ToDate,
|
|||
|
|
Weightage,
|
|||
|
|
NewTitle,
|
|||
|
|
NewTarget,
|
|||
|
|
NewFromDate,
|
|||
|
|
NewToDate,
|
|||
|
|
NewWeightage,
|
|||
|
|
UserID,
|
|||
|
|
CreatedDate,
|
|||
|
|
OutsideOfSettings,
|
|||
|
|
PMPYearID
|
|||
|
|
)
|
|||
|
|
Values
|
|||
|
|
(
|
|||
|
|
%n, %n, %n, %n, %n, %s, %s, %D, %D, %n, %s, %s, %D, %D, %n, %n, %D, %b, %n
|
|||
|
|
)",
|
|||
|
|
objectiveSet.ID,
|
|||
|
|
objectiveSet.EmployeeID,
|
|||
|
|
null,
|
|||
|
|
(int)EnumOperationalStatus.Add,
|
|||
|
|
newObjective.ObjectiveType,
|
|||
|
|
newObjective.Title,
|
|||
|
|
newObjective.MeasuresOfSuccess,
|
|||
|
|
newObjective.StartDate,
|
|||
|
|
newObjective.EndDate,
|
|||
|
|
newObjective.Weightages,
|
|||
|
|
newObjective.Title,
|
|||
|
|
newObjective.MeasuresOfSuccess,
|
|||
|
|
newObjective.StartDate,
|
|||
|
|
newObjective.EndDate,
|
|||
|
|
newObjective.Weightages,
|
|||
|
|
objectiveSet.CreatedBy,
|
|||
|
|
DateTime.Today,
|
|||
|
|
true,
|
|||
|
|
objectiveSet.PMPYearID
|
|||
|
|
);
|
|||
|
|
object newIdObj = tc.ExecuteScalar(sql + "; SELECT CAST(SCOPE_IDENTITY() AS INT)");
|
|||
|
|
return (newIdObj == null || newIdObj == DBNull.Value) ? 0 : Convert.ToInt32(newIdObj);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// All pending (still-submitted, not yet decided) outside-of-settings history rows for an
|
|||
|
|
/// objective set — the set a LM approve/reject action processes as one batch. pmpYearId is a
|
|||
|
|
/// belt-and-suspenders check on top of ObjectiveSetID (which already implies a single year) -
|
|||
|
|
/// it stops an approve/reject from ever touching a row from the wrong PMP year. IsApproved IS
|
|||
|
|
/// NULL is a second one: a row already decided must never be re-applied/re-rejected even if
|
|||
|
|
/// something else (e.g. a later unrelated resubmit) ever flips IsSubmitted back to true.
|
|||
|
|
/// </summary>
|
|||
|
|
internal static IDataReader GetPendingOutsideOfSettingsHistory(TransactionContext tc, int objectiveSetId, int pmpYearId)
|
|||
|
|
{
|
|||
|
|
string sql = SQLParser.MakeSQL(
|
|||
|
|
@"SELECT ObjectiveHistoryID, ObjectiveID, EmployeeID, ChangeType, ObjectiveTypeID,
|
|||
|
|
NewTitle, NewTarget, NewFromDate, NewToDate, NewWeightage
|
|||
|
|
FROM ObjectiveHistory
|
|||
|
|
WHERE ObjectiveSetID = %n AND PMPYearID = %n AND IsSubmitted = %b AND OutsideOfSettings = %b
|
|||
|
|
AND IsApproved IS NULL",
|
|||
|
|
objectiveSetId, pmpYearId, true, true);
|
|||
|
|
return tc.ExecuteReader(sql);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal static void ApplyHistoryEditToObjective(TransactionContext tc, int objectiveId, string newTitle,
|
|||
|
|
string newTarget, DateTime? newFromDate, DateTime? newToDate, double? newWeightage)
|
|||
|
|
{
|
|||
|
|
string sql = SQLParser.MakeSQL(
|
|||
|
|
@"Update Objective Set
|
|||
|
|
Title = COALESCE(%s, Title),
|
|||
|
|
MeasuresOfSuccess = COALESCE(%s, MeasuresOfSuccess),
|
|||
|
|
StartDate = COALESCE(%D, StartDate),
|
|||
|
|
EndDate = COALESCE(%D, EndDate),
|
|||
|
|
Weightages = COALESCE(%n, Weightages),
|
|||
|
|
ObjectiveStatus = %n
|
|||
|
|
Where ObjectiveID = %n",
|
|||
|
|
newTitle, newTarget, newFromDate, newToDate, newWeightage, (int)EnumObjectiveStatus.No_Change, objectiveId);
|
|||
|
|
tc.ExecuteNonQuery(sql);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal static void SetObjectiveStatus(TransactionContext tc, int objectiveId, EnumObjectiveStatus status)
|
|||
|
|
{
|
|||
|
|
string sql = SQLParser.MakeSQL(
|
|||
|
|
@"Update Objective Set ObjectiveStatus = %n Where ObjectiveID = %n", (int)status, objectiveId);
|
|||
|
|
tc.ExecuteNonQuery(sql);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal static void UpdateHistoryObjectiveID(TransactionContext tc, int objectiveHistoryId, int objectiveId)
|
|||
|
|
{
|
|||
|
|
string sql = SQLParser.MakeSQL(
|
|||
|
|
@"Update ObjectiveHistory Set ObjectiveID = %n Where ObjectiveHistoryID = %n", objectiveId, objectiveHistoryId);
|
|||
|
|
tc.ExecuteNonQuery(sql);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal static void SetHistoryDecision(TransactionContext tc, int objectiveHistoryId, bool isApproved, string remarks, int userId)
|
|||
|
|
{
|
|||
|
|
string sql = SQLParser.MakeSQL(
|
|||
|
|
@"Update ObjectiveHistory Set IsSubmitted = %b, IsApproved = %b, LMActionRemarks = %s,
|
|||
|
|
LMActionDate = %D, UserID = %n
|
|||
|
|
Where ObjectiveHistoryID = %n",
|
|||
|
|
false, isApproved, remarks, DateTime.Today, userId, objectiveHistoryId);
|
|||
|
|
tc.ExecuteNonQuery(sql);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Rows the employee still needs to see: pending outside-of-settings changes (awaiting LM
|
|||
|
|
/// decision) plus rejected ones not yet dismissed by the employee.
|
|||
|
|
/// </summary>
|
|||
|
|
internal static DataTable GetObjectiveHistoryStatus(TransactionContext tc, int objectiveSetId)
|
|||
|
|
{
|
|||
|
|
string sql = SQLParser.MakeSQL(@"
|
|||
|
|
SELECT
|
|||
|
|
oh.ObjectiveHistoryID,
|
|||
|
|
oh.ObjectiveID,
|
|||
|
|
oh.ChangeType,
|
|||
|
|
CASE oh.ChangeType
|
|||
|
|
WHEN 1 THEN 'New'
|
|||
|
|
WHEN 2 THEN 'Modify'
|
|||
|
|
WHEN 3 THEN 'Delete'
|
|||
|
|
ELSE 'Unknown'
|
|||
|
|
END AS ActionType,
|
|||
|
|
COALESCE(o.description, ot.name) as Area,
|
|||
|
|
COALESCE(oh.Title, oh.NewTitle) as Title,
|
|||
|
|
oh.NewTitle,
|
|||
|
|
oh.Target,
|
|||
|
|
oh.NewTarget,
|
|||
|
|
oh.FromDate,
|
|||
|
|
oh.NewFromDate,
|
|||
|
|
oh.ToDate,
|
|||
|
|
oh.NewToDate,
|
|||
|
|
oh.Weightage,
|
|||
|
|
oh.NewWeightage,
|
|||
|
|
oh.IsSubmitted,
|
|||
|
|
oh.IsApproved,
|
|||
|
|
oh.LMActionRemarks as ActionRemarks,
|
|||
|
|
oh.LMActionDate as ActionDate,
|
|||
|
|
oh.PMPYearID
|
|||
|
|
FROM ObjectiveHistory oh
|
|||
|
|
LEFT JOIN Objective o ON oh.ObjectiveID = o.OBJECTIVEID
|
|||
|
|
LEFT JOIN ObjectiveType ot ON oh.ObjectiveTypeID = ot.ObjectiveTypeID
|
|||
|
|
WHERE oh.ObjectiveSetID = %n
|
|||
|
|
AND oh.OutsideOfSettings = %b
|
|||
|
|
AND (oh.IsApproved IS NULL OR oh.IsApproved = %b);",
|
|||
|
|
objectiveSetId, true, false);
|
|||
|
|
return tc.ExecuteDataTable(sql);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Outside-of-settings history rows that still count toward the KPI weightage total: ones
|
|||
|
|
/// still awaiting an LM decision plus ones already approved. Rejected/dismissed rows are
|
|||
|
|
/// excluded since they never take (or no longer take) effect.
|
|||
|
|
/// </summary>
|
|||
|
|
internal static DataTable GetObjectiveHistoryWeightage(TransactionContext tc, int objectiveSetId)
|
|||
|
|
{
|
|||
|
|
string sql = SQLParser.MakeSQL(@"
|
|||
|
|
SELECT
|
|||
|
|
oh.ObjectiveHistoryID,
|
|||
|
|
oh.ObjectiveID,
|
|||
|
|
oh.NewWeightage
|
|||
|
|
FROM ObjectiveHistory oh
|
|||
|
|
WHERE oh.ObjectiveSetID = %n
|
|||
|
|
AND oh.OutsideOfSettings = %b
|
|||
|
|
AND (oh.IsApproved IS NULL OR oh.IsApproved = %b);",
|
|||
|
|
objectiveSetId, true, true);
|
|||
|
|
return tc.ExecuteDataTable(sql);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Clears a single rejected row's pending flag once the employee has seen it - scoped to one
|
|||
|
|
/// ObjectiveHistoryID (not the whole set) so dismissing one KPI's rejection notice doesn't
|
|||
|
|
/// also clear a sibling KPI's.
|
|||
|
|
/// </summary>
|
|||
|
|
internal static void DismissObjectiveHistory(TransactionContext tc, int objectiveHistoryId)
|
|||
|
|
{
|
|||
|
|
string sql = SQLParser.MakeSQL(
|
|||
|
|
@"Update ObjectiveHistory Set OutsideOfSettings = %b
|
|||
|
|
Where ObjectiveHistoryID = %n AND OutsideOfSettings = %b AND IsSubmitted = %b AND IsApproved = %b",
|
|||
|
|
false, objectiveHistoryId, true, false, false);
|
|||
|
|
tc.ExecuteNonQuery(sql);
|
|||
|
|
}
|
|||
|
|
internal static void updatetHistory(TransactionContext tc, EnumOperationalStatus changestatus, Objective oldObjective, Objective newObjective, bool outsideOfSettings = false)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
//string sql = SQLParser.MakeSQL(
|
|||
|
|
// @"update ObjectiveHistory
|
|||
|
|
// set
|
|||
|
|
// NewTitle =%s,
|
|||
|
|
// NewTarget=%s,
|
|||
|
|
// NewFromDate =%d,
|
|||
|
|
// NewToDate=%d,
|
|||
|
|
// NewWeightage=%n,
|
|||
|
|
// UserID=%n,
|
|||
|
|
// CreatedDate=%d
|
|||
|
|
// where objectivesetid=%n and objectiveid=%n and employeeid=%n
|
|||
|
|
// ",
|
|||
|
|
// (oldObjective.Title == newObjective.Title) ? null : newObjective.Title,
|
|||
|
|
// (oldObjective.MeasuresOfSuccess == newObjective.MeasuresOfSuccess) ? null : newObjective.MeasuresOfSuccess,
|
|||
|
|
// (oldObjective.StartDate == newObjective.StartDate) ? null : newObjective.StartDate,
|
|||
|
|
// (oldObjective.EndDate == newObjective.EndDate) ? null : newObjective.EndDate,
|
|||
|
|
// (oldObjective.Weightages == newObjective.Weightages) ? null : newObjective.Weightages,
|
|||
|
|
// oldObjective.CreatedBy,
|
|||
|
|
// DateTime.Today,
|
|||
|
|
// newObjective.ObjectiveSetID,
|
|||
|
|
// newObjective.ID,
|
|||
|
|
// newObjective.EmployeeID
|
|||
|
|
|
|||
|
|
//);
|
|||
|
|
|
|||
|
|
//tc.ExecuteNonQuery(sql);
|
|||
|
|
|
|||
|
|
var setClauses = new System.Collections.Generic.List<string>();
|
|||
|
|
var parameters = new System.Collections.Generic.List<object>();
|
|||
|
|
|
|||
|
|
|
|||
|
|
setClauses.Add("Title=%s");
|
|||
|
|
parameters.Add(oldObjective.Title);
|
|||
|
|
setClauses.Add("Target=%s");
|
|||
|
|
parameters.Add(oldObjective.MeasuresOfSuccess);
|
|||
|
|
setClauses.Add("FromDate=%d");
|
|||
|
|
parameters.Add(oldObjective.StartDate);
|
|||
|
|
setClauses.Add("ToDate=%d");
|
|||
|
|
parameters.Add(oldObjective.EndDate);
|
|||
|
|
setClauses.Add("Weightage=%n");
|
|||
|
|
parameters.Add(oldObjective.Weightages);
|
|||
|
|
|
|||
|
|
if (oldObjective.Title != newObjective.Title)
|
|||
|
|
{
|
|||
|
|
setClauses.Add("NewTitle=%s");
|
|||
|
|
parameters.Add(newObjective.Title);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (oldObjective.MeasuresOfSuccess != newObjective.MeasuresOfSuccess)
|
|||
|
|
{
|
|||
|
|
setClauses.Add("NewTarget=%s");
|
|||
|
|
parameters.Add(newObjective.MeasuresOfSuccess);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (oldObjective.StartDate != newObjective.StartDate)
|
|||
|
|
{
|
|||
|
|
setClauses.Add("NewFromDate=%d");
|
|||
|
|
parameters.Add(newObjective.StartDate);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (oldObjective.EndDate != newObjective.EndDate)
|
|||
|
|
{
|
|||
|
|
setClauses.Add("NewToDate=%d");
|
|||
|
|
parameters.Add(newObjective.EndDate);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (oldObjective.Weightages != newObjective.Weightages)
|
|||
|
|
{
|
|||
|
|
setClauses.Add("NewWeightage=%n");
|
|||
|
|
parameters.Add(newObjective.Weightages);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (setClauses.Count == 0 && !outsideOfSettings)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (outsideOfSettings)
|
|||
|
|
{
|
|||
|
|
// Re-editing a KPI that was previously rejected turns it back into a fresh pending
|
|||
|
|
// draft rather than leaving it stuck showing the old rejection.
|
|||
|
|
setClauses.Add("OutsideOfSettings=%b");
|
|||
|
|
parameters.Add(true);
|
|||
|
|
setClauses.Add("IsApproved=NULL");
|
|||
|
|
setClauses.Add("LMActionRemarks=NULL");
|
|||
|
|
setClauses.Add("LMActionDate=NULL");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
setClauses.Add("ChangeType=%n");
|
|||
|
|
parameters.Add((int)changestatus);
|
|||
|
|
|
|||
|
|
setClauses.Add("UserID=%n");
|
|||
|
|
parameters.Add(oldObjective.CreatedBy);
|
|||
|
|
|
|||
|
|
setClauses.Add("CreatedDate=%d");
|
|||
|
|
parameters.Add(DateTime.Today);
|
|||
|
|
|
|||
|
|
string sql = "update ObjectiveHistory set "
|
|||
|
|
+ string.Join(", ", setClauses)
|
|||
|
|
+ " where objectivesetid=%n and objectiveid=%n and employeeid=%n";
|
|||
|
|
|
|||
|
|
parameters.Add(newObjective.ObjectiveSetID);
|
|||
|
|
parameters.Add(newObjective.ID);
|
|||
|
|
parameters.Add(newObjective.EmployeeID);
|
|||
|
|
|
|||
|
|
|
|||
|
|
string query = SQLParser.MakeSQL(sql, parameters.ToArray());
|
|||
|
|
tc.ExecuteNonQuery(query);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal static void Update(TransactionContext tc, Objective item)
|
|||
|
|
{
|
|||
|
|
//string sql = SQLParser.MakeSQL("Update Objective Set ObjectiveSetID = %n, PMPYearID = %n, Description = %s, Activities = %s, MeasuresOfSuccess = %s, Weightages = %n, EmployeeID = %n, EmployeeNodeID = %n, ObjectiveDate = %d, LMID = %n, LMNodeID = %n, LMRatingID = %n, RagingDate = %d, EmployeeComments= %s, LMComments = %s, IsDraft = %b where ObjectiveID= %n",
|
|||
|
|
// item.ObjectiveSetID, item.PMPYearID, item.Description, item.Activities, item.MeasuresOfSuccess, item.Weightages, item.EmployeeID, item.EmployeeNodeID, item.ObjectiveDate, item.LMID, item.LMNodeID, item.LMRatingID, item.RagingDate, item.EmployeeComments, item.LMComments, item.IsDraft, item.ID);
|
|||
|
|
string sql = SQLParser.MakeSQL(
|
|||
|
|
@"Update Objective Set ObjectiveSetID = %n, PMPYearID = %n, Description = %s, Activities = %s, MeasuresOfSuccess = %s, Weightages = %n, EmployeeID = %n, EmployeeNodeID = %n, ObjectiveDate = %d, LMID = %n, LMNodeID = %n, LMRatingID = %n, RagingDate = %d, ObjComment = %s, MYEmployeeComments= %s, MYLMComments = %s, IsDraft = %b,ObjectiveType=%n,YEEmployeeComments=%s, YELMComments=%s,PriorityPercent=%n,MYAssessRating=%n,MYLMAssessRating=%n,
|
|||
|
|
YEEmpMark = %n, YELMMark =%n, KPIType =%n, StartDate =%d, EndDate =%d, GroupID = %n, Tier =%s, title = %s, MASTERKPIID = %n, YEASSESSRATING=%n, YELMASSESSRATING=%n, ProgressStatus=%n, ObjectiveStatus=%n, YE2NDLMMark=%n, YE2NDLMCOMMENTS=%s, PayrollTypeID=%n
|
|||
|
|
where ObjectiveID= %n",
|
|||
|
|
DataReader.GetNullValue(item.ObjectiveSetID), item.PMPYearID, item.Description, item.Activities,
|
|||
|
|
item.MeasuresOfSuccess, item.Weightages, item.EmployeeID, DataReader.GetNullValue(item.EmployeeNodeID),
|
|||
|
|
item.ObjectiveDate, DataReader.GetNullValue(item.LMID), DataReader.GetNullValue(item.LMNodeID),
|
|||
|
|
item.LMRatingID, item.RagingDate, item.ObjComment, item.MYEmployeeComments, item.MYLMComments,
|
|||
|
|
item.IsDraft, (int)item.ObjectiveType, item.YEEmployeeComments, item.YELMComments, item.PriorityPercent,
|
|||
|
|
item.MYAssessRating, item.MYLMAssessRating, item.YEEmpMark,
|
|||
|
|
item.YELMMark, item.KPIType, item.StartDate, item.EndDate, DataReader.GetNullValue(item.GroupID),
|
|||
|
|
item.Tier, item.Title, item.MasterKpiId, item.YEAssessRating, item.YELMAssessRating, item.ProgressStatus, (int)item.ObjectiveStatus,item.YESecondLMMark, item.YESecondLMComments, item.PayrollTypeID, item.ID);
|
|||
|
|
tc.ExecuteNonQuery(sql);
|
|||
|
|
}
|
|||
|
|
internal static void UpdateYeEmp(TransactionContext tc, Objective item)
|
|||
|
|
{
|
|||
|
|
//string sql = SQLParser.MakeSQL("Update Objective Set ObjectiveSetID = %n, PMPYearID = %n, Description = %s, Activities = %s, MeasuresOfSuccess = %s, Weightages = %n, EmployeeID = %n, EmployeeNodeID = %n, ObjectiveDate = %d, LMID = %n, LMNodeID = %n, LMRatingID = %n, RagingDate = %d, EmployeeComments= %s, LMComments = %s, IsDraft = %b where ObjectiveID= %n",
|
|||
|
|
// item.ObjectiveSetID, item.PMPYearID, item.Description, item.Activities, item.MeasuresOfSuccess, item.Weightages, item.EmployeeID, item.EmployeeNodeID, item.ObjectiveDate, item.LMID, item.LMNodeID, item.LMRatingID, item.RagingDate, item.EmployeeComments, item.LMComments, item.IsDraft, item.ID);
|
|||
|
|
string sql = SQLParser.MakeSQL(
|
|||
|
|
@"Update Objective Set YEEmployeeComments= %s ,YEEmpMark=%n
|
|||
|
|
where ObjectiveID= %n",
|
|||
|
|
item.YEEmployeeComments,
|
|||
|
|
item.YEEmpMark, item.ID);
|
|||
|
|
tc.ExecuteNonQuery(sql);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal static void UpdateMyEmp(TransactionContext tc, Objective item)
|
|||
|
|
{
|
|||
|
|
//string sql = SQLParser.MakeSQL("Update Objective Set ObjectiveSetID = %n, PMPYearID = %n, Description = %s, Activities = %s, MeasuresOfSuccess = %s, Weightages = %n, EmployeeID = %n, EmployeeNodeID = %n, ObjectiveDate = %d, LMID = %n, LMNodeID = %n, LMRatingID = %n, RagingDate = %d, EmployeeComments= %s, LMComments = %s, IsDraft = %b where ObjectiveID= %n",
|
|||
|
|
// item.ObjectiveSetID, item.PMPYearID, item.Description, item.Activities, item.MeasuresOfSuccess, item.Weightages, item.EmployeeID, item.EmployeeNodeID, item.ObjectiveDate, item.LMID, item.LMNodeID, item.LMRatingID, item.RagingDate, item.EmployeeComments, item.LMComments, item.IsDraft, item.ID);
|
|||
|
|
string sql = SQLParser.MakeSQL(
|
|||
|
|
@"Update Objective Set MYEmployeeComments= %s ,MYAssessRating=%n
|
|||
|
|
where ObjectiveID= %n",
|
|||
|
|
item.MYEmployeeComments,
|
|||
|
|
item.MYAssessRating, item.ID);
|
|||
|
|
tc.ExecuteNonQuery(sql);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal static void UpdateMyLM(TransactionContext tc, Objective item)
|
|||
|
|
{
|
|||
|
|
//string sql = SQLParser.MakeSQL("Update Objective Set ObjectiveSetID = %n, PMPYearID = %n, Description = %s, Activities = %s, MeasuresOfSuccess = %s, Weightages = %n, EmployeeID = %n, EmployeeNodeID = %n, ObjectiveDate = %d, LMID = %n, LMNodeID = %n, LMRatingID = %n, RagingDate = %d, EmployeeComments= %s, LMComments = %s, IsDraft = %b where ObjectiveID= %n",
|
|||
|
|
// item.ObjectiveSetID, item.PMPYearID, item.Description, item.Activities, item.MeasuresOfSuccess, item.Weightages, item.EmployeeID, item.EmployeeNodeID, item.ObjectiveDate, item.LMID, item.LMNodeID, item.LMRatingID, item.RagingDate, item.EmployeeComments, item.LMComments, item.IsDraft, item.ID);
|
|||
|
|
string sql = SQLParser.MakeSQL(
|
|||
|
|
@"Update Objective Set MYLMComments= %s ,MYLMAssessRating=%n
|
|||
|
|
where ObjectiveID= %n",
|
|||
|
|
item.MYLMComments,
|
|||
|
|
item.MYLMAssessRating, item.ID);
|
|||
|
|
tc.ExecuteNonQuery(sql);
|
|||
|
|
}
|
|||
|
|
internal static void UpdateYeLM(TransactionContext tc, Objective item)
|
|||
|
|
{
|
|||
|
|
//string sql = SQLParser.MakeSQL("Update Objective Set ObjectiveSetID = %n, PMPYearID = %n, Description = %s, Activities = %s, MeasuresOfSuccess = %s, Weightages = %n, EmployeeID = %n, EmployeeNodeID = %n, ObjectiveDate = %d, LMID = %n, LMNodeID = %n, LMRatingID = %n, RagingDate = %d, EmployeeComments= %s, LMComments = %s, IsDraft = %b where ObjectiveID= %n",
|
|||
|
|
// item.ObjectiveSetID, item.PMPYearID, item.Description, item.Activities, item.MeasuresOfSuccess, item.Weightages, item.EmployeeID, item.EmployeeNodeID, item.ObjectiveDate, item.LMID, item.LMNodeID, item.LMRatingID, item.RagingDate, item.EmployeeComments, item.LMComments, item.IsDraft, item.ID);
|
|||
|
|
string sql = SQLParser.MakeSQL(
|
|||
|
|
@"Update Objective Set YELMComments= %s ,YELMMark=%n
|
|||
|
|
where ObjectiveID= %n",
|
|||
|
|
item.YELMComments,
|
|||
|
|
item.YELMMark, item.ID);
|
|||
|
|
tc.ExecuteNonQuery(sql);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal static void UpdateSecondLM(TransactionContext tc, Objective item)
|
|||
|
|
{
|
|||
|
|
//string sql = SQLParser.MakeSQL("Update Objective Set ObjectiveSetID = %n, PMPYearID = %n, Description = %s, Activities = %s, MeasuresOfSuccess = %s, Weightages = %n, EmployeeID = %n, EmployeeNodeID = %n, ObjectiveDate = %d, LMID = %n, LMNodeID = %n, LMRatingID = %n, RagingDate = %d, EmployeeComments= %s, LMComments = %s, IsDraft = %b where ObjectiveID= %n",
|
|||
|
|
// item.ObjectiveSetID, item.PMPYearID, item.Description, item.Activities, item.MeasuresOfSuccess, item.Weightages, item.EmployeeID, item.EmployeeNodeID, item.ObjectiveDate, item.LMID, item.LMNodeID, item.LMRatingID, item.RagingDate, item.EmployeeComments, item.LMComments, item.IsDraft, item.ID);
|
|||
|
|
string sql = SQLParser.MakeSQL(
|
|||
|
|
@"Update Objective Set YE2NDLMMark=%n, YE2NDLMCOMMENTS=%s
|
|||
|
|
where ObjectiveID= %n",
|
|||
|
|
item.YESecondLMMark, item.YESecondLMComments, item.ID);
|
|||
|
|
tc.ExecuteNonQuery(sql);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal static void UpdateObjectiveSettingRemarksLM(TransactionContext tc, Objective item)
|
|||
|
|
{
|
|||
|
|
string sql = SQLParser.MakeSQL(
|
|||
|
|
@"Update Objective Set ObjectiveSettingRemarksLM= %s
|
|||
|
|
where ObjectiveID= %n",
|
|||
|
|
item.ObjectiveSettingRemarksLM, item.ID);
|
|||
|
|
tc.ExecuteNonQuery(sql);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal static void UpdateObjectiveSettingRemarksLM2(TransactionContext tc, Objective item)
|
|||
|
|
{
|
|||
|
|
string sql = SQLParser.MakeSQL(
|
|||
|
|
@"Update Objective Set ObjectiveSettingRemarksLM2= %s
|
|||
|
|
where ObjectiveID= %n",
|
|||
|
|
item.ObjectiveSettingRemarksLM2, item.ID);
|
|||
|
|
tc.ExecuteNonQuery(sql);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal static void UpdateObjectiveStatus(TransactionContext tc, Objective item)
|
|||
|
|
{
|
|||
|
|
string sql = SQLParser.MakeSQL(
|
|||
|
|
@"Update Objective Set ObjectiveStatus=%n where ObjectiveID= %n", (int)item.ObjectiveStatus, item.ID);
|
|||
|
|
//string sql = SQLParser.MakeSQL(
|
|||
|
|
// @"Update Objective Set ObjectiveStatus=%n ,
|
|||
|
|
// ModifiedBy=%n, ModifiedDate=%D where ObjectiveID= %n", (int)item.ObjectiveStatus, item.ModifiedBy, item.ModifiedDate, item.ID);
|
|||
|
|
tc.ExecuteNonQuery(sql);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal static void Delete(TransactionContext tc, int id)
|
|||
|
|
{
|
|||
|
|
string sql = SQLParser.MakeSQL("Delete From Objective Where ObjectiveID = %n", id);
|
|||
|
|
tc.ExecuteNonQuery(sql);
|
|||
|
|
}
|
|||
|
|
internal static void DeletebyObjectiveSetIDs(TransactionContext tc, string objectiveSetIDs)
|
|||
|
|
{
|
|||
|
|
string sql = SQLParser.MakeSQL("Delete From Objective Where ObjectiveSetID in (%q)", objectiveSetIDs);
|
|||
|
|
tc.ExecuteNonQuery(sql);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal static void DeleteObjByEmpIDsAndPMPYear(TransactionContext tc, int yearID, string empIDs)
|
|||
|
|
{
|
|||
|
|
string sql = SQLParser.MakeSQL("Delete From Objective Where PMPYEARID=%n and EMPLOYEEID in (%q)", yearID, empIDs);
|
|||
|
|
tc.ExecuteNonQuery(sql);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal static void DeleteAllCompanyObj(TransactionContext tc, int yearID)
|
|||
|
|
{
|
|||
|
|
string sql =
|
|||
|
|
SQLParser.MakeSQL(
|
|||
|
|
"delete From Objective WHERE PMPYEARID=%n and Objectivetype=(SELECT objectivetypeid FROM OBJECTIVETYPE WHERE iscompanyObjective=1)",
|
|||
|
|
yearID);
|
|||
|
|
tc.ExecuteNonQuery(sql);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal static IDataReader GetDevelopmentPlans(TransactionContext tc, int iD)
|
|||
|
|
{
|
|||
|
|
string sql = SQLParser.MakeSQL("SELECT * FROM DevelopmentPlan WHERE ObjectiveID = %n", iD);
|
|||
|
|
return tc.ExecuteReader(sql);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal static IDataReader GetLMObjectives(TransactionContext tc, int iD)
|
|||
|
|
{
|
|||
|
|
string sql = SQLParser.MakeSQL("SELECT * FROM LMObjective WHERE ParentID = %n", iD);
|
|||
|
|
return tc.ExecuteReader(sql);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal static IDataReader GetObjectiveEmployees(TransactionContext tc, int iD)
|
|||
|
|
{
|
|||
|
|
string sql = SQLParser.MakeSQL("SELECT * FROM ObjectiveEmployees WHERE ObjectiveID = %n", iD);
|
|||
|
|
return tc.ExecuteReader(sql);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal static IDataReader GetByEmployeeID(TransactionContext tc, int Empid, int PMPID, bool Isdrafted)
|
|||
|
|
{
|
|||
|
|
string sql =
|
|||
|
|
SQLParser.MakeSQL("SELECT * FROM Objective WHERE EmployeeID = %n AND pmpyearid=%n AND IsDraft=%b order by OBJECTIVETYPE",
|
|||
|
|
Empid, PMPID, Isdrafted);
|
|||
|
|
return tc.ExecuteReader(sql);
|
|||
|
|
}
|
|||
|
|
internal static IDataReader GetByEmployeeID(TransactionContext tc, int Empid, int PMPID)
|
|||
|
|
{
|
|||
|
|
string sql =
|
|||
|
|
SQLParser.MakeSQL("SELECT * FROM Objective WHERE EmployeeID = %n AND pmpyearid=%n order by OBJECTIVETYPE",
|
|||
|
|
Empid, PMPID);
|
|||
|
|
return tc.ExecuteReader(sql);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal static IDataReader GetForValidation(TransactionContext tc, int empId, int pmpYearId,
|
|||
|
|
int objectiveTypeId)
|
|||
|
|
{
|
|||
|
|
string sql = SQLParser.MakeSQL(@"SELECT * FROM OBJECTIVE WHERE employeeid=%n AND PMPYEARID=%n AND OBJECTIVETYPE=%n", empId, pmpYearId,
|
|||
|
|
objectiveTypeId);
|
|||
|
|
return tc.ExecuteReader(sql);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal static IDataReader GetByEmployeeID(TransactionContext tc, string Empids, int PMPID, bool Isdrafted)
|
|||
|
|
{
|
|||
|
|
string sql =
|
|||
|
|
SQLParser.MakeSQL("SELECT * FROM Objective WHERE EmployeeID in(%q) AND pmpyearid=%n AND IsDraft=%b",
|
|||
|
|
Empids, PMPID, Isdrafted);
|
|||
|
|
return tc.ExecuteReader(sql);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal static IDataReader GetLMObjs(TransactionContext tc, int Empid, int PMPYID, int nLMID)
|
|||
|
|
{
|
|||
|
|
string sql = SQLParser.MakeSQL(
|
|||
|
|
@"SELECT * FROM Objective o,objectiveset oset WHERE oset.EmployeeID=%n AND o.PMPYearID=%n AND ObjectiveID IN(
|
|||
|
|
SELECT ObjectiveID FROM ObjectiveEmployees oe WHERE employeeid=%n AND oe.ObjectiveID IN(SELECT ObjectiveID FROM Objective o WHERE EmployeeID=%n AND o.PMPYearID=%n))AND o.ObjectiveSetID=oset.ObjectiveSetID AND oset.OBLMComplete IN(1,8)",
|
|||
|
|
nLMID, PMPYID, Empid, nLMID, PMPYID);
|
|||
|
|
return tc.ExecuteReader(sql);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal static IDataReader GetByPMPYearID(TransactionContext tc, int id, string InEmpSQL)
|
|||
|
|
{
|
|||
|
|
if (InEmpSQL == "")
|
|||
|
|
{
|
|||
|
|
string sql = SQLParser.MakeSQL("SELECT * FROM Objective WHERE PMPYearID = %n", id);
|
|||
|
|
return tc.ExecuteReader(sql);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
string sql = SQLParser.MakeSQL("SELECT * FROM Objective WHERE PMPYearID = %n and EmployeeID IN (%q)",
|
|||
|
|
id, InEmpSQL);
|
|||
|
|
return tc.ExecuteReader(sql);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
internal static IDataReader GetByPMPYear(TransactionContext tc, int pmpYearID, int payrollTypeID)
|
|||
|
|
{
|
|||
|
|
string sql = SQLParser.MakeSQL("SELECT * FROM Objective WHERE PMPYearID = %n and PayrollTypeID = %n",
|
|||
|
|
pmpYearID, payrollTypeID);
|
|||
|
|
return tc.ExecuteReader(sql);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal static IDataReader GetByStatus(TransactionContext tc, EnumPMPStatus estatus, bool IsFinalized)
|
|||
|
|
{
|
|||
|
|
string sql =
|
|||
|
|
SQLParser.MakeSQL(
|
|||
|
|
"SELECT * FROM Objective WHERE pmpyearid in(Select pmpprocessid from PMP_Process where Pmpstatus = %n and IsFinalize=%b)",
|
|||
|
|
(int)estatus, IsFinalized);
|
|||
|
|
return tc.ExecuteReader(sql);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal static void DeleteLMObjective(TransactionContext tc, int id)
|
|||
|
|
{
|
|||
|
|
string sql = SQLParser.MakeSQL("Delete From LMObjective Where ParentID = %n", id);
|
|||
|
|
tc.ExecuteNonQuery(sql);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal static void DeleteDevelopmentPlan(TransactionContext tc, int id)
|
|||
|
|
{
|
|||
|
|
string sql = SQLParser.MakeSQL("Delete From DevelopmentPlan Where OBJECTIVESETID = %n", id);
|
|||
|
|
tc.ExecuteNonQuery(sql);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal static void DeleteObjectiveEmployees(TransactionContext tc, int id)
|
|||
|
|
{
|
|||
|
|
string sql = SQLParser.MakeSQL("Delete From ObjectiveEmployees Where ObjectiveID = %n", id);
|
|||
|
|
tc.ExecuteNonQuery(sql);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal static IDataReader GetByLMID(TransactionContext tc, int id)
|
|||
|
|
{
|
|||
|
|
string sql = SQLParser.MakeSQL("SELECT * FROM Objective WHERE EmployeeID = %n", id);
|
|||
|
|
return tc.ExecuteReader(sql);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal static IDataReader GetDraftObjectives(TransactionContext tc, int id, int draft)
|
|||
|
|
{
|
|||
|
|
string sql = SQLParser.MakeSQL("SELECT * FROM Objective WHERE IsDraft = %n AND EmployeeID = %n", draft, id);
|
|||
|
|
return tc.ExecuteReader(sql);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal static IDataReader GetLineManager(TransactionContext tc, int id)
|
|||
|
|
{
|
|||
|
|
string sql = SQLParser.MakeSQL("SELECT * FROM Objective WHERE LMID = %n", id);
|
|||
|
|
return tc.ExecuteReader(sql);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal static DataSet GetComObjAssignedEmpID(TransactionContext tc, int PMPYearID)
|
|||
|
|
{
|
|||
|
|
string sql = SQLParser.MakeSQL(@"SELECT distinct o.EMPLOYEEID
|
|||
|
|
FROM OBJECTIVE o
|
|||
|
|
LEFT JOIN OBJECTIVETYPE ot ON o.OBJECTIVETYPE = ot.OBJECTIVETYPEID
|
|||
|
|
WHERE ot.ISCOMPANYOBJECTIVE = 1 and o.PMPYEARID = %n", PMPYearID);
|
|||
|
|
return tc.ExecuteDataSet(sql);
|
|||
|
|
}
|
|||
|
|
internal static DataSet GetObjectiveByYear(TransactionContext tc, int PMPYearID)
|
|||
|
|
{
|
|||
|
|
string sql = SQLParser.MakeSQL(@"SELECT e.EmployeeNo, e.Name, o.*
|
|||
|
|
FROM OBJECTIVE o, Employee e
|
|||
|
|
where e.EmployeeID=o.EmployeeID and
|
|||
|
|
o.PMPYEARID = %n", PMPYearID);
|
|||
|
|
return tc.ExecuteDataSet(sql);
|
|||
|
|
}
|
|||
|
|
internal static DataSet GetPmsDataEmployeeWise(TransactionContext tc, int pmpYearId, string empIds)
|
|||
|
|
{
|
|||
|
|
DataSet ds = new DataSet();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
string sql = SQLParser.MakeSQL(
|
|||
|
|
"SELECT e.EMPLOYEEID AS EmployeeId, e.EMPLOYEENO AS EmployeeNo, e.NAME AS EmployeeName, d.DESCRIPTION AS Department, " +
|
|||
|
|
"deig.NAME AS Designation, o.TITLE AS 'kpiTitle', o.DESCRIPTION AS 'kpiDescription'," +
|
|||
|
|
"o.WEIGHTAGES,o.MYLMASSESSRATING AS MidYearRating, o.YELMMARK AS FinalRating " +
|
|||
|
|
"FROM OBJECTIVE o " +
|
|||
|
|
"LEFT JOIN EMPLOYEE e ON e.EMPLOYEEID = o.EMPLOYEEID " +
|
|||
|
|
"LEFT JOIN DEPARTMENT d ON e.DEPARTMENTID = d.DEPARTMENTID " +
|
|||
|
|
"LEFT JOIN DESIGNATION deig ON e.DESIGNATIONID = deig.DESIGNATIONID " +
|
|||
|
|
"WHERE o.PMPYEARID = %n " +
|
|||
|
|
"AND o.OBJECTIVETYPE = 1 " +
|
|||
|
|
"AND o.employeeId in (%q) ", pmpYearId, empIds);
|
|||
|
|
ds = tc.ExecuteDataSet(sql);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
throw new Exception(ex.Message);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return ds;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal static DataSet GetPmsLmGoalReport(TransactionContext tc, int pmpYearId, int empId)
|
|||
|
|
{
|
|||
|
|
DataSet ds = new DataSet();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
string sql1 = SQLParser.MakeSQL(
|
|||
|
|
"SELECT e.EMPLOYEEID AS EmployeeId, e.EMPLOYEENO AS EmployeeNo, e.NAME AS EmployeeName, d.DESCRIPTION AS Department, " +
|
|||
|
|
"deig.NAME AS Designation,o.TITLE AS Theme, o.DESCRIPTION AS Goal, o.targets AS Target, o.Scale AS Scale, o.MEASURESOFSUCCESS " +
|
|||
|
|
"AS Measure, o.WEIGHTAGES,o.MYLMASSESSRATING AS MidYearRating, o.YELMMARK AS FinalRating " +
|
|||
|
|
"FROM OBJECTIVE o " +
|
|||
|
|
"LEFT JOIN EMPLOYEE e ON e.EMPLOYEEID = o.EMPLOYEEID " +
|
|||
|
|
"LEFT JOIN DEPARTMENT d ON e.DEPARTMENTID = d.DEPARTMENTID " +
|
|||
|
|
"LEFT JOIN DESIGNATION deig ON e.DESIGNATIONID = deig.DESIGNATIONID " +
|
|||
|
|
"WHERE o.PMPYEARID = %n " +
|
|||
|
|
"AND o.OBJECTIVETYPE = 1 " +
|
|||
|
|
"AND e.employeeid IN (SELECT employeeid FROM EMPLOYEE WHERE LINEMANAGERID IN" +
|
|||
|
|
"(SELECT employeeid FROM EMPLOYEE WHERE linemanagerId = %n)) ", pmpYearId, empId);
|
|||
|
|
DataTable dataTable = tc.ExecuteDataSet(sql1).Tables[0];
|
|||
|
|
dataTable.TableName = "SubordinateTeam";
|
|||
|
|
ds.Tables.Add(dataTable.Copy());
|
|||
|
|
|
|||
|
|
|
|||
|
|
string sql2 = SQLParser.MakeSQL(
|
|||
|
|
"SELECT e.EMPLOYEEID AS EmployeeId, e.EMPLOYEENO AS EmployeeNo, e.NAME AS EmployeeName, d.DESCRIPTION AS Department, " +
|
|||
|
|
"deig.NAME AS Designation,o.TITLE AS Theme, o.DESCRIPTION AS Goal, o.targets AS Target, o.Scale AS Scale, o.MEASURESOFSUCCESS " +
|
|||
|
|
"AS Measure, o.WEIGHTAGES,o.MYLMASSESSRATING AS MidYearRating, o.YELMMARK AS FinalRating " +
|
|||
|
|
"FROM OBJECTIVE o " +
|
|||
|
|
"LEFT JOIN EMPLOYEE e ON e.EMPLOYEEID = o.EMPLOYEEID " +
|
|||
|
|
"LEFT JOIN DEPARTMENT d ON e.DEPARTMENTID = d.DEPARTMENTID " +
|
|||
|
|
"LEFT JOIN DESIGNATION deig ON e.DESIGNATIONID = deig.DESIGNATIONID " +
|
|||
|
|
"WHERE o.PMPYEARID = %n " +
|
|||
|
|
"AND o.OBJECTIVETYPE = 1 " +
|
|||
|
|
"AND e.LINEMANAGERID = %n ", pmpYearId, empId);
|
|||
|
|
dataTable = tc.ExecuteDataSet(sql2).Tables[0];
|
|||
|
|
dataTable.TableName = "ImmediateSubordinates";
|
|||
|
|
ds.Tables.Add(dataTable.Copy());
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
throw new Exception(ex.Message);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return ds;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal static DataSet GetPmsIndividualGoalData(TransactionContext tc, int pmpYearId, int empId)
|
|||
|
|
{
|
|||
|
|
DataSet ds = new DataSet();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
string sql1 = SQLParser.MakeSQL(
|
|||
|
|
"SELECT e.EMPLOYEEID AS EmployeeId, e.EMPLOYEENO AS EmployeeNo, e.NAME AS EmployeeName, d.DESCRIPTION AS Department, " +
|
|||
|
|
"deig.NAME AS Designation,o.TITLE AS Theme, o.DESCRIPTION AS Goal, o.targets AS Target, o.Scale AS Scale, o.MEASURESOFSUCCESS " +
|
|||
|
|
"AS Measure, o.WEIGHTAGES,o.MYLMASSESSRATING AS MidYearRating, o.YELMMARK AS FinalRating " +
|
|||
|
|
"FROM OBJECTIVE o " +
|
|||
|
|
"LEFT JOIN EMPLOYEE e ON e.EMPLOYEEID = o.EMPLOYEEID " +
|
|||
|
|
"LEFT JOIN DEPARTMENT d ON e.DEPARTMENTID = d.DEPARTMENTID " +
|
|||
|
|
"LEFT JOIN DESIGNATION deig ON e.DESIGNATIONID = deig.DESIGNATIONID " +
|
|||
|
|
"WHERE o.PMPYEARID = %n " +
|
|||
|
|
"AND o.OBJECTIVETYPE = 1 " +
|
|||
|
|
"AND e.employeeId = %n ", pmpYearId, empId);
|
|||
|
|
DataTable dataTable = tc.ExecuteDataSet(sql1).Tables[0];
|
|||
|
|
dataTable.TableName = "IndividualData";
|
|||
|
|
ds.Tables.Add(dataTable.Copy());
|
|||
|
|
string sql2 = SQLParser.MakeSQL(
|
|||
|
|
"SELECT e.EMPLOYEEID AS EmployeeId, e.EMPLOYEENO AS EmployeeNo, e.NAME AS EmployeeName, d.DESCRIPTION AS Department, " +
|
|||
|
|
"deig.NAME AS Designation FROM EMPLOYEE e " +
|
|||
|
|
"LEFT JOIN DEPARTMENT d ON e.DEPARTMENTID = d.DEPARTMENTID " +
|
|||
|
|
"LEFT JOIN DESIGNATION deig ON e.DESIGNATIONID = deig.DESIGNATIONID " +
|
|||
|
|
"WHERE e.employeeid = %n", empId);
|
|||
|
|
dataTable = tc.ExecuteDataSet(sql2).Tables[0];
|
|||
|
|
dataTable.TableName = "EmployeeInfo";
|
|||
|
|
ds.Tables.Add(dataTable.Copy());
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
throw new Exception(ex.Message);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return ds;
|
|||
|
|
}
|
|||
|
|
internal static DataSet getPMSReportData(TransactionContext tc, int pmpYearID, int pmsReportType, string emps)
|
|||
|
|
{
|
|||
|
|
DataSet ds = new DataSet();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
string sql = "";
|
|||
|
|
switch (pmsReportType)
|
|||
|
|
{
|
|||
|
|
case 1:
|
|||
|
|
sql = SQLParser.MakeSQL(@"SELECT e.EMPLOYEENO AS EmployeeID, e.NAME AS Name, ot.NAME AS ObjectiveType, o.WEIGHTAGES AS Weightage, o.TITLE AS Title, o.DESCRIPTION AS DESCRIPTION,
|
|||
|
|
o.MEASURESOFSUCCESS AS Threshold, FORMAT(o.STARTDATE, 'dd MMM yyyy') AS StartDate, FORMAT(o.ENDDATE, 'dd MMM yyyy') AS EndDate,
|
|||
|
|
o.MYEMPLOYEECOMMENTS AS MidYearEmployeeComments, o.MYASSESSRATING AS EmployeeMidYearAssessment,
|
|||
|
|
o.MYLMCOMMENTS AS MidYearLineManagerComments, o.MYLMASSESSRATING AS LineManagerMidYearAssessment,
|
|||
|
|
o.YEEMPMARK AS YearEndEmployeeMark, o.YEASSESSRATING AS YearEndEmployeeRating, o.YEEMPLOYEECOMMENTS AS YearEndEmployeeComments,
|
|||
|
|
o.YELMMARK AS YearEndLineManagerMark, o.YELMASSESSRATING AS YearEndLMRating, o.YELMCOMMENTS AS YearEndLMComments
|
|||
|
|
FROM OBJECTIVE o
|
|||
|
|
INNER JOIN EMPLOYEE e ON e.EMPLOYEEID = o.EMPLOYEEID
|
|||
|
|
INNER JOIN OBJECTIVETYPE ot ON ot.OBJECTIVETYPEID = o.OBJECTIVETYPE
|
|||
|
|
WHERE o.PMPYEARID = %n AND o.EMPLOYEEID IN (%q)", pmpYearID, emps);
|
|||
|
|
break;
|
|||
|
|
case 2:
|
|||
|
|
sql = SQLParser.MakeSQL(@"SELECT E.EMPLOYEENO, E.NAME, OS.YETOTALOBJECTIVEEMPMARK AS EmpObjectivePercent, ROUND(OS.EMPOBJRATING,2) AS EmpObjectiveRating,
|
|||
|
|
ROUND(OS.EMPVALUERATING,2) AS EmpValueRating, ROUND(OS.EMPOVERALLRATING,2) AS EmpRating,
|
|||
|
|
OS.YETOTALOBJECTIVELMMARK AS LmObjectivePercent,ROUND(OS.LMOBJRATING,2) AS LmObjectiveRating,
|
|||
|
|
ROUND(OS.LMVALUERATING,2) AS LmValueRating, ROUND(OS.LMOVERALLRATING,2) AS LMRating, ROUND(OS.SECONDLMOVERALLRATING,2) AS SecondLmRating
|
|||
|
|
FROM OBJECTIVESET OS
|
|||
|
|
INNER JOIN EMPLOYEE E ON E.EMPLOYEEID = OS.EMPLOYEEID
|
|||
|
|
WHERE os.PMPYEARID = %n AND os.EMPLOYEEID IN (%q)", pmpYearID, emps);
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
ds = tc.ExecuteDataSet(sql);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
throw new Exception(ex.Message);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return ds;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal static DataSet getPMSReportDataByUserType(TransactionContext tc, int pmpYearID, int pmsReportType, string userType, string emps, int userId)
|
|||
|
|
{
|
|||
|
|
DataSet ds = new DataSet();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
string sql = "";
|
|||
|
|
string employeeIDs = string.Empty;
|
|||
|
|
switch (userType)
|
|||
|
|
{
|
|||
|
|
case "LM":
|
|||
|
|
employeeIDs = $"AND e.EMPLOYEEID IN (SELECT EMPLOYEEID FROM EMPLOYEE WHERE LINEMANAGERID = {userId})";
|
|||
|
|
break;
|
|||
|
|
case "SecondLM":
|
|||
|
|
employeeIDs = $"AND e.EMPLOYEEID IN (SELECT EMPLOYEEID FROM EMPLOYEE WHERE LINEMANAGERID IN (SELECT EMPLOYEEID FROM EMPLOYEE WHERE LINEMANAGERID = {userId}))";
|
|||
|
|
break;
|
|||
|
|
case "All":
|
|||
|
|
employeeIDs = $"AND e.EMPLOYEEID IN (SELECT EMPLOYEEID FROM EMPLOYEE WHERE PayrolltypeId = 1 and Status = 1)";
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
switch (pmsReportType)
|
|||
|
|
{
|
|||
|
|
case 1:
|
|||
|
|
sql = SQLParser.MakeSQL($@"SELECT e.EMPLOYEENO AS EmployeeID, e.NAME AS Name, ot.NAME AS ObjectiveType, o.WEIGHTAGES AS Weightage, o.TITLE AS Title, o.DESCRIPTION AS DESCRIPTION,
|
|||
|
|
o.MEASURESOFSUCCESS AS Threshold, FORMAT(o.STARTDATE, 'dd MMM yyyy') AS StartDate, FORMAT(o.ENDDATE, 'dd MMM yyyy') AS EndDate,
|
|||
|
|
o.MYEMPLOYEECOMMENTS AS MidYearEmployeeComments, o.MYASSESSRATING AS EmployeeMidYearAssessment,
|
|||
|
|
o.MYLMCOMMENTS AS MidYearLineManagerComments, o.MYLMASSESSRATING AS LineManagerMidYearAssessment,
|
|||
|
|
o.YEEMPMARK AS YearEndEmployeeMark, o.YEASSESSRATING AS YearEndEmployeeRating, o.YEEMPLOYEECOMMENTS AS YearEndEmployeeComments,
|
|||
|
|
o.YELMMARK AS YearEndLineManagerMark, o.YELMASSESSRATING AS YearEndLMRating, o.YELMCOMMENTS AS YearEndLMComments
|
|||
|
|
FROM OBJECTIVE o
|
|||
|
|
INNER JOIN EMPLOYEE e ON e.EMPLOYEEID = o.EMPLOYEEID {employeeIDs}
|
|||
|
|
INNER JOIN OBJECTIVETYPE ot ON ot.OBJECTIVETYPEID = o.OBJECTIVETYPE
|
|||
|
|
WHERE o.PMPYEARID = %n", pmpYearID);
|
|||
|
|
break;
|
|||
|
|
case 2:
|
|||
|
|
sql = SQLParser.MakeSQL($@"SELECT E.EMPLOYEENO, E.NAME, OS.EMPObjAchive AS EmpObjectivePercent, ROUND(OS.EMPOBJRATING,2) AS EmpObjectiveRating,
|
|||
|
|
ROUND(OS.EMPVALUERATING,2) AS EmpValueRating, ROUND(OS.EmpRating,2) AS EmpRating,
|
|||
|
|
OS.LMOBJAchive AS LmObjectivePercent, ROUND(OS.LMOBJRATING,2) AS LmObjectiveRating,
|
|||
|
|
ROUND(OS.LMVALUERATING,2) AS LmValueRating, ROUND(OS.LMRating,2) AS LMRating,
|
|||
|
|
ROUND(OS.SECONDLMOVERALLRATING,2) AS SecondLmRating
|
|||
|
|
FROM OBJECTIVESET OS
|
|||
|
|
INNER JOIN EMPLOYEE E ON E.EMPLOYEEID = OS.EMPLOYEEID {employeeIDs}
|
|||
|
|
WHERE OS.PMPYEARID = %n", pmpYearID);
|
|||
|
|
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
ds = tc.ExecuteDataSet(sql);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
throw new Exception(ex.Message);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return ds;
|
|||
|
|
}
|
|||
|
|
internal static IDataReader GetObjectiveHistorySubmitted(TransactionContext tc, int ObjectiveSetId)
|
|||
|
|
{
|
|||
|
|
string sql = SQLParser.MakeSQL("SELECT * FROM ObjectiveHistory WHERE ObjectiveSetID = %n AND isSubmitted = %b", ObjectiveSetId, true);
|
|||
|
|
return tc.ExecuteReader(sql);
|
|||
|
|
}
|
|||
|
|
internal static DataTable GetObjectiveFromHistoryDT(TransactionContext tc, int ObjectiveSetId)
|
|||
|
|
{
|
|||
|
|
string sql = SQLParser.MakeSQL(@"
|
|||
|
|
|
|||
|
|
SELECT
|
|||
|
|
oh.EmployeeID,
|
|||
|
|
oh.ObjectiveID,
|
|||
|
|
oh.ObjectiveTypeID,
|
|||
|
|
oh.ChangeType,
|
|||
|
|
CASE oh.ChangeType
|
|||
|
|
WHEN 0 THEN 'None'
|
|||
|
|
WHEN 1 THEN 'New'
|
|||
|
|
WHEN 2 THEN 'Modify'
|
|||
|
|
WHEN 3 THEN 'Delete'
|
|||
|
|
WHEN 4 THEN 'Unchanged'
|
|||
|
|
ELSE 'Unknown'
|
|||
|
|
END AS ActionType,
|
|||
|
|
COALESCE(o.description, ot.name) as Area,
|
|||
|
|
oh.Title,
|
|||
|
|
oh.Target,
|
|||
|
|
oh.FromDate,
|
|||
|
|
oh.ToDate,
|
|||
|
|
oh.Weightage,
|
|||
|
|
oh.NewTitle,
|
|||
|
|
oh.NewTarget,
|
|||
|
|
oh.NewFromDate,
|
|||
|
|
oh.NewToDate,
|
|||
|
|
oh.NewWeightage,
|
|||
|
|
oh.Remarks,
|
|||
|
|
oh.IsSubmitted,
|
|||
|
|
oh.IsApproved,
|
|||
|
|
oh.LMActionRemarks as ActionRemarks
|
|||
|
|
FROM ObjectiveHistory oh
|
|||
|
|
LEFT JOIN Objective o
|
|||
|
|
ON oh.ObjectiveID = o.OBJECTIVEID
|
|||
|
|
LEFT JOIN ObjectiveType ot
|
|||
|
|
ON oh.ObjectiveTypeID = ot.ObjectiveTypeID
|
|||
|
|
WHERE oh.ObjectiveSetID = %n
|
|||
|
|
AND oh.IsSubmitted = %b
|
|||
|
|
AND oh.IsApproved IS NULL;", ObjectiveSetId, true);
|
|||
|
|
return tc.ExecuteDataTable(sql);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal static object GetYearRating(TransactionContext tc, int employeeId, int pmpYearId)
|
|||
|
|
{
|
|||
|
|
string sql = SQLParser.MakeSQL(@"SELECT
|
|||
|
|
ROUND(
|
|||
|
|
ISNULL(SUM(CASE WHEN KPITYPE = %n THEN YEEMPMARK ELSE 0 END), 0) * 0.2
|
|||
|
|
+ ISNULL(SUM(CASE WHEN KPITYPE = %n THEN YELMMARK ELSE 0 END), 0) * 0.4
|
|||
|
|
+ ISNULL(SUM(CASE WHEN KPITYPE = %n THEN YE2NDLMMARK ELSE 0 END), 0) * 0.4
|
|||
|
|
+ ISNULL(SUM(CASE WHEN KPITYPE = %n THEN YEEMPMARK ELSE 0 END), 0) * 0.2
|
|||
|
|
+ ISNULL(SUM(CASE WHEN KPITYPE = %n THEN YELMMARK ELSE 0 END), 0) * 0.4
|
|||
|
|
+ ISNULL(SUM(CASE WHEN KPITYPE = %n THEN YE2NDLMMARK ELSE 0 END), 0) * 0.4
|
|||
|
|
, 2)
|
|||
|
|
FROM Objective
|
|||
|
|
WHERE EmployeeID = %n
|
|||
|
|
AND PMPYEARID = %n
|
|||
|
|
AND IsDraft = %b
|
|||
|
|
AND OBJECTIVESTATUS <> %n",
|
|||
|
|
(int)EnumObjectiveType.KPI, (int)EnumObjectiveType.KPI, (int)EnumObjectiveType.KPI,
|
|||
|
|
(int)EnumObjectiveType.Leadership, (int)EnumObjectiveType.Leadership, (int)EnumObjectiveType.Leadership,
|
|||
|
|
employeeId, pmpYearId, false, (int)EnumObjectiveStatus.Removed);
|
|||
|
|
return tc.ExecuteScalar(sql);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#region ObjectiveAttachment
|
|||
|
|
|
|||
|
|
internal static IDataReader GetObjectiveAttachments(TransactionContext tc, int objectiveId)
|
|||
|
|
{
|
|||
|
|
string sql = SQLParser.MakeSQL(
|
|||
|
|
"SELECT * FROM ObjectiveAttachment WHERE ObjectiveID = %n ORDER BY UploadDate DESC",
|
|||
|
|
objectiveId);
|
|||
|
|
return tc.ExecuteReader(sql);
|
|||
|
|
}
|
|||
|
|
internal static IDataReader GetObjectiveAttachmentFileData(TransactionContext tc, int id)
|
|||
|
|
{
|
|||
|
|
string sql = SQLParser.MakeSQL(
|
|||
|
|
"SELECT * FROM ObjectiveAttachment WHERE attachmentID = %n ",
|
|||
|
|
id);
|
|||
|
|
return tc.ExecuteReader(sql);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal static void InsertObjectiveAttachment(TransactionContext tc, ObjectiveAttachment item)
|
|||
|
|
{
|
|||
|
|
// ObjectiveHistoryID is new and nullable: existing callers never set it, so it stays NULL
|
|||
|
|
// and the row behaves exactly as before (a normal attachment on a real ObjectiveID). Only
|
|||
|
|
// the outside-of-settings staging path (ObjectiveService.Save) sets it, alongside
|
|||
|
|
// ObjectiveID left at its default 0, to mark the attachment as pending an LM decision.
|
|||
|
|
string strQuery = @"INSERT INTO ObjectiveAttachment(ObjectiveID, FileData, FileName,EmployeeID, FileType, PMSStage, UploadDate, ObjectiveHistoryID)
|
|||
|
|
Values (@ObjectiveID, @FileData, @FileName, @EmployeeID, @FileType, @PMSStage, @UploadDate, @ObjectiveHistoryID)";
|
|||
|
|
|
|||
|
|
Microsoft.Data.SqlClient.SqlCommand cmd = new Microsoft.Data.SqlClient.SqlCommand(strQuery, (Microsoft.Data.SqlClient.SqlConnection)tc.Connection);
|
|||
|
|
cmd.Transaction = (Microsoft.Data.SqlClient.SqlTransaction)tc.Transaction;
|
|||
|
|
|
|||
|
|
// Convert Base64 string to byte[] if FileData is a string
|
|||
|
|
//byte[] fileBytes = item.FileData is string base64String
|
|||
|
|
// ? Convert.FromBase64String(base64String)
|
|||
|
|
// : item.FileData as byte[];
|
|||
|
|
|
|||
|
|
cmd.Parameters.Add("@ObjectiveID", SqlDbType.Int).Value = item.ObjectiveID;
|
|||
|
|
cmd.Parameters.Add("@FileData", SqlDbType.VarBinary).Value = item.FileData;
|
|||
|
|
cmd.Parameters.Add("@FileName", SqlDbType.VarChar).Value = item.FileName;
|
|||
|
|
cmd.Parameters.Add("@EmployeeID", SqlDbType.Int).Value = 0;
|
|||
|
|
cmd.Parameters.Add("@FileType", SqlDbType.VarChar).Value = item.Filetype;
|
|||
|
|
cmd.Parameters.Add("@PMSStage", SqlDbType.Int).Value = item.PMSStage;
|
|||
|
|
cmd.Parameters.Add("@UploadDate", SqlDbType.DateTime).Value = item.UploadDate;
|
|||
|
|
cmd.Parameters.Add("@ObjectiveHistoryID", SqlDbType.Int).Value =
|
|||
|
|
item.ObjectiveHistoryID.HasValue ? (object)item.ObjectiveHistoryID.Value : DBNull.Value;
|
|||
|
|
|
|||
|
|
cmd.ExecuteNonQuery();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
internal static void DeleteObjectiveAttachmentByObjectiveID(TransactionContext tc, int objectiveid)
|
|||
|
|
{
|
|||
|
|
string sql = SQLParser.MakeSQL(
|
|||
|
|
"DELETE FROM ObjectiveAttachment WHERE objectiveID = %n", objectiveid);
|
|||
|
|
tc.ExecuteNonQuery(sql);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal static void DeleteObjectiveAttachmentByID(TransactionContext tc, int attachmentid)
|
|||
|
|
{
|
|||
|
|
string sql = SQLParser.MakeSQL(
|
|||
|
|
"DELETE FROM ObjectiveAttachment WHERE Attachmentid = %n", attachmentid);
|
|||
|
|
tc.ExecuteNonQuery(sql);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Attachments staged against a pending outside-of-settings ObjectiveHistory row (ObjectiveID
|
|||
|
|
/// still 0/unset) - used to show pending files before the LM has approved/rejected them.
|
|||
|
|
/// </summary>
|
|||
|
|
internal static IDataReader GetObjectiveAttachmentsByHistoryID(TransactionContext tc, int objectiveHistoryId)
|
|||
|
|
{
|
|||
|
|
string sql = SQLParser.MakeSQL(
|
|||
|
|
"SELECT * FROM ObjectiveAttachment WHERE ObjectiveHistoryID = %n ORDER BY UploadDate DESC",
|
|||
|
|
objectiveHistoryId);
|
|||
|
|
return tc.ExecuteReader(sql);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// LM approval of an outside-of-settings add/edit: point the staged attachments at the now-real
|
|||
|
|
/// Objective row and clear the pending link. Called from ApplyOutsideOfSettingsHistory.
|
|||
|
|
/// </summary>
|
|||
|
|
internal static void ReassignObjectiveAttachmentsToObjective(TransactionContext tc, int objectiveHistoryId, int objectiveId)
|
|||
|
|
{
|
|||
|
|
string sql = SQLParser.MakeSQL(
|
|||
|
|
"UPDATE ObjectiveAttachment SET ObjectiveID = %n, ObjectiveHistoryID = NULL WHERE ObjectiveHistoryID = %n",
|
|||
|
|
objectiveId, objectiveHistoryId);
|
|||
|
|
tc.ExecuteNonQuery(sql);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// LM rejection of an outside-of-settings add/edit: the proposed KPI change never took effect,
|
|||
|
|
/// so any attachments staged alongside it are discarded too. Called from RejectObjectiveHistory.
|
|||
|
|
/// </summary>
|
|||
|
|
internal static void DeleteObjectiveAttachmentsByHistoryID(TransactionContext tc, int objectiveHistoryId)
|
|||
|
|
{
|
|||
|
|
string sql = SQLParser.MakeSQL(
|
|||
|
|
"DELETE FROM ObjectiveAttachment WHERE ObjectiveHistoryID = %n", objectiveHistoryId);
|
|||
|
|
tc.ExecuteNonQuery(sql);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
}
|
|||
|
|
}
|