243 lines
11 KiB
C#
243 lines
11 KiB
C#
|
|
using HRM.BO;
|
|||
|
|
using Ease.Core.DataAccess;
|
|||
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Data;
|
|||
|
|
|
|||
|
|
namespace HRM.DA
|
|||
|
|
{
|
|||
|
|
class TrainingNeedAnalysisDA
|
|||
|
|
{
|
|||
|
|
#region Get Function
|
|||
|
|
|
|||
|
|
public static IDataReader Get(TransactionContext tc, int id)
|
|||
|
|
{
|
|||
|
|
return tc.ExecuteReader("SELECT * from TrainingNeedAnalysis WHERE TrainingNeedAnalysisID=%n", id);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static IDataReader Get(TransactionContext tc)
|
|||
|
|
{
|
|||
|
|
return tc.ExecuteReader("SELECT * from TrainingNeedAnalysis");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal static IDataReader GetByYear(TransactionContext tc, int year)
|
|||
|
|
{
|
|||
|
|
return tc.ExecuteReader("SELECT * from TrainingNeedAnalysis WHERE TrainingYear=%n", year);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal static IDataReader GetByParam(TransactionContext tc, int year, string sDeptIDs, string sDeptForIDs)
|
|||
|
|
{
|
|||
|
|
//string sql = string.Format(@"SELECT * from TrainingNeedAnalysis tna WHERE tna.TrainingYear={0} {1} {2}",
|
|||
|
|
// year,sDeptIDs!=string.Empty?" AND tna.DepartmentID IN (" + sDeptIDs + ")":"",sDeptForIDs != string.Empty?" AND tna.trainingNeedAnalysisID IN ( select trainingNeedAnalysisID from TrainingDepartment where DepartmentID IN (" + sDeptForIDs + "))":"");
|
|||
|
|
|
|||
|
|
string sql = string.Format(@"SELECT * from TrainingNeedAnalysis tna WHERE tna.TrainingYear={0} {1} {2}",
|
|||
|
|
year, sDeptIDs != string.Empty ? " AND tna.DepartmentID IN (" + sDeptIDs + ")" : "",
|
|||
|
|
sDeptForIDs != string.Empty
|
|||
|
|
? " AND tna.trainingNeedAnalysisID IN ( select trainingNeedAnalysisID from TrainingDepartment where DepartmentID IN (" +
|
|||
|
|
sDeptForIDs + "))"
|
|||
|
|
: "");
|
|||
|
|
|
|||
|
|
return tc.ExecuteReader(sql);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal static IDataReader Get(TransactionContext tc, int trainingID, int departmentID, int departmentForID,
|
|||
|
|
int trainingType)
|
|||
|
|
{
|
|||
|
|
return tc.ExecuteReader("SELECT * from TrainingNeedAnalysis WHERE TrainingID=%n AND departmentID=%n",
|
|||
|
|
trainingID, departmentID);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal static IDataReader Get(TransactionContext tc, string query)
|
|||
|
|
{
|
|||
|
|
return tc.ExecuteReader(query);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Insert Function
|
|||
|
|
|
|||
|
|
public static void Insert(TransactionContext tc, TrainingNeedAnalysis oItem)
|
|||
|
|
{
|
|||
|
|
string sql = SQLParser.MakeSQL(
|
|||
|
|
@"INSERT INTO TrainingNeedAnalysis(
|
|||
|
|
TrainingNeedAnalysisID, TrainingYear, Name,EmployeeID,TrainingID,Description,MaxParticipent,Conduct_Required,DepartmentID,
|
|||
|
|
NeedType, ExpectedDate, ExpectedResults, ObjectiveSetID,
|
|||
|
|
CREATEDBY,CREATEDDATE)
|
|||
|
|
VALUES(%n,%n,%s,%n,%n,%s,%n,%n,%n,%n,%s,%s,%n,%n,%d)",
|
|||
|
|
|
|||
|
|
oItem.ID,
|
|||
|
|
oItem.TrainingYear,
|
|||
|
|
oItem.Name,
|
|||
|
|
oItem.EmployeeID,
|
|||
|
|
oItem.TrainingID,
|
|||
|
|
oItem.Description,
|
|||
|
|
oItem.MaxParticipent,
|
|||
|
|
oItem.Conduct_Required,
|
|||
|
|
oItem.DepartmentID,
|
|||
|
|
|
|||
|
|
DataReader.GetNullValue(oItem.NeedType.HasValue ? (int)oItem.NeedType : (int?)null),
|
|||
|
|
oItem.ExpectedDate,
|
|||
|
|
oItem.ExpectedResults,
|
|||
|
|
oItem.ObjectiveSetID,
|
|||
|
|
|
|||
|
|
DataReader.GetNullValue(oItem.CreatedBy),
|
|||
|
|
DataReader.GetNullValue(oItem.CreatedDate)
|
|||
|
|
);
|
|||
|
|
|
|||
|
|
tc.ExecuteNonQuery(sql);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static void Insert(TransactionContext tc, SubordinateTrainee oItem)
|
|||
|
|
{
|
|||
|
|
tc.ExecuteNonQuery(
|
|||
|
|
"INSERT INTO SubordinateTrainee(SubordinateTraineeID, TrainingNeedAnalysisID, EmployeeID, Remarks)" +
|
|||
|
|
" VALUES(%n,%n,%n,%s)", oItem.ID, DataReader.GetNullValue(oItem.TrainingNeedAnalysisID),
|
|||
|
|
DataReader.GetNullValue(oItem.EmployeeID), oItem.Remarks);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Update Function
|
|||
|
|
|
|||
|
|
public static void Update(TransactionContext tc, TrainingNeedAnalysis oItem)
|
|||
|
|
{
|
|||
|
|
tc.ExecuteNonQuery(
|
|||
|
|
"UPDATE TrainingNeedAnalysis SET TrainingYear=%n,Name=%s,EmployeeID=%n,TrainingID=%n,Description=%s,MaxParticipent=%n,Conduct_Required=%n, DepartmentID=%n," +
|
|||
|
|
" NeedType=%n, ExpectedDate=%s, ExpectedResults=%s, ObjectiveSetID=%n," +
|
|||
|
|
" MODIFIEDBY=%n,MODIFIEDDATE=%d" +
|
|||
|
|
" WHERE TrainingNeedAnalysisID=%n",
|
|||
|
|
|
|||
|
|
oItem.TrainingYear,
|
|||
|
|
oItem.Name,
|
|||
|
|
oItem.EmployeeID,
|
|||
|
|
oItem.TrainingID,
|
|||
|
|
oItem.Description,
|
|||
|
|
oItem.MaxParticipent,
|
|||
|
|
oItem.Conduct_Required,
|
|||
|
|
oItem.DepartmentID,
|
|||
|
|
|
|||
|
|
DataReader.GetNullValue(oItem.NeedType.HasValue ? (int)oItem.NeedType : (int?)null),
|
|||
|
|
DataReader.GetNullValue(oItem.ExpectedDate),
|
|||
|
|
oItem.ExpectedResults,
|
|||
|
|
oItem.ObjectiveSetID,
|
|||
|
|
|
|||
|
|
DataReader.GetNullValue(oItem.ModifiedBy),
|
|||
|
|
DataReader.GetNullValue(oItem.ModifiedDate),
|
|||
|
|
oItem.ID
|
|||
|
|
);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static void Update(TransactionContext tc, SubordinateTrainee oItem)
|
|||
|
|
{
|
|||
|
|
tc.ExecuteNonQuery("UPDATE SubordinateTrainee SET TrainingNeedAnalysisID=%n,EmployeeID=%n,Remarks=%s" +
|
|||
|
|
" WHERE SubordinateTraineeID=%n", DataReader.GetNullValue(oItem.TrainingNeedAnalysisID),
|
|||
|
|
DataReader.GetNullValue(oItem.EmployeeID), oItem.Remarks, oItem.ID);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Delete Function
|
|||
|
|
|
|||
|
|
public static void Delete(TransactionContext tc, int id)
|
|||
|
|
{
|
|||
|
|
tc.ExecuteNonQuery("Delete from TrainingNeedAnalysis where TrainingNeedAnalysisID=%n", id);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
public static bool IsExists(string TableName, string ColName, int id, TransactionContext tc)
|
|||
|
|
{
|
|||
|
|
object ob = tc.ExecuteScalar("SELECT COUNT(*) FROM " + TableName + " WHERE " + ColName + "=%s", id);
|
|||
|
|
return (Convert.ToInt32(ob) > 0);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
internal static IDataReader GetSubordinate(TransactionContext tc)
|
|||
|
|
{
|
|||
|
|
return tc.ExecuteReader("SELECT * from SubordinateTrainee");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal static IDataReader SubordinateGet(TransactionContext tc, int p)
|
|||
|
|
{
|
|||
|
|
throw new NotImplementedException();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal static IDataReader GetByTrainingNeedAnalysisID(TransactionContext tc, int TrainingNeedAnalysisID)
|
|||
|
|
{
|
|||
|
|
return tc.ExecuteReader("SELECT * from SubordinateTrainee where TrainingNeedAnalysisID=%n",
|
|||
|
|
TrainingNeedAnalysisID);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal static IDataReader GetByEmployeeID(TransactionContext tc, string employeeNo)
|
|||
|
|
{
|
|||
|
|
return tc.ExecuteReader("SELECT * FROM TRAININGNEEDANALYSIS WHERE EMPLOYEEID =%s", employeeNo);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal static IDataReader IsExist(TransactionContext tc, int trainingID)
|
|||
|
|
{
|
|||
|
|
return tc.ExecuteReader("SELECT * FROM TRAININGNEEDANALYSIS WHERE TRAININGID = %n", trainingID);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal static IDataReader GetTrainingNeedAnalysisByEmployeeObjectiveSet(TransactionContext tc, int employeeID, int objectiveSetID)
|
|||
|
|
{
|
|||
|
|
string sql = SQLParser.MakeSQL("SELECT * FROM TrainingNeedAnalysis WHERE EmployeeID = %n AND ObjectiveSetID = %n", employeeID, objectiveSetID);
|
|||
|
|
return tc.ExecuteReader(sql);
|
|||
|
|
}
|
|||
|
|
internal static IDataReader GetTrainingNeedAnalysisByEmployee(TransactionContext tc, int employeeID)
|
|||
|
|
{
|
|||
|
|
string sql = SQLParser.MakeSQL("SELECT * FROM TrainingNeedAnalysis WHERE EmployeeID = %n", employeeID);
|
|||
|
|
return tc.ExecuteReader(sql);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal static IDataReader getTrainingNeedAnalysisHistoryByEmployee(TransactionContext tc, int employeeID, int lastyearID)
|
|||
|
|
{
|
|||
|
|
string sql = SQLParser.MakeSQL("SELECT * FROM TrainingNeedAnalysis WHERE EmployeeID = %n AND TRAININGYEAR = %n", employeeID, lastyearID);
|
|||
|
|
return tc.ExecuteReader(sql);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#region Training Need Analysis screen (PMS-year wise)
|
|||
|
|
|
|||
|
|
// TrainingYear holds the PMPProcess ID, not a calendar year - the IDP screens save it that way.
|
|||
|
|
// TNA.TrainingID points at TRAININGTYPE, so the training name shown is the training type name,
|
|||
|
|
// falling back to TNA.NAME (the free-text learning activity) when no type was picked.
|
|||
|
|
// Only needs whose parent ObjectiveSet has been submitted by the employee are shown, so the
|
|||
|
|
// screen never lists a plan the employee is still drafting.
|
|||
|
|
internal static IDataReader GetByPmpYear(TransactionContext tc, int pmpYearId)
|
|||
|
|
{
|
|||
|
|
string sql = SQLParser.MakeSQL(
|
|||
|
|
"SELECT TNA.*, EMP.NAME AS EMPLOYEENAME, EMP.EMPLOYEENO, " +
|
|||
|
|
"DT.DESCRIPTION AS DEPARTMENTNAME, DSG.NAME AS DESIGNATIONNAME, " +
|
|||
|
|
"TT.NAME AS TRAININGTYPENAME " +
|
|||
|
|
"FROM TrainingNeedAnalysis TNA " +
|
|||
|
|
"INNER JOIN OBJECTIVESET OS ON TNA.OBJECTIVESETID = OS.OBJECTIVESETID " +
|
|||
|
|
"LEFT JOIN EMPLOYEE EMP ON TNA.EMPLOYEEID = EMP.EMPLOYEEID " +
|
|||
|
|
"LEFT JOIN DEPARTMENT DT ON EMP.DEPARTMENTID = DT.DEPARTMENTID " +
|
|||
|
|
"LEFT JOIN DESIGNATION DSG ON EMP.DESIGNATIONID = DSG.DESIGNATIONID " +
|
|||
|
|
"LEFT JOIN TRAININGTYPE TT ON TNA.TRAININGID = TT.TRAININGTYPEID " +
|
|||
|
|
"WHERE TNA.TRAININGYEAR = %n AND OS.IDPEMPLOYEESTATUS = %n " +
|
|||
|
|
"ORDER BY TNA.NEEDTYPE, EMP.EMPLOYEENO", pmpYearId, enumIDPStatus.Submitted);
|
|||
|
|
return tc.ExecuteReader(sql);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal static DataSet GetCountByPmpYear(TransactionContext tc, int pmpYearId)
|
|||
|
|
{
|
|||
|
|
string sql = SQLParser.MakeSQL(
|
|||
|
|
"SELECT TRAININGNAME, COUNT(EMPLOYEEID) Total FROM (" +
|
|||
|
|
"SELECT ISNULL(TT.NAME, TNA.NAME) AS TRAININGNAME, TNA.EMPLOYEEID " +
|
|||
|
|
"FROM TrainingNeedAnalysis TNA " +
|
|||
|
|
"INNER JOIN OBJECTIVESET OS ON TNA.OBJECTIVESETID = OS.OBJECTIVESETID " +
|
|||
|
|
"LEFT JOIN TRAININGTYPE TT ON TNA.TRAININGID = TT.TRAININGTYPEID " +
|
|||
|
|
"WHERE TNA.TRAININGYEAR = %n AND OS.IDPEMPLOYEESTATUS = %n) TNASUMMARY " +
|
|||
|
|
"GROUP BY TRAININGNAME ORDER BY TRAININGNAME", pmpYearId, enumIDPStatus.Submitted);
|
|||
|
|
return tc.ExecuteDataSet(sql);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal static void UpdateEnrolledStatus(TransactionContext tc, int trainingNeedAnalysisID, bool enrolled)
|
|||
|
|
{
|
|||
|
|
tc.ExecuteNonQuery("UPDATE TrainingNeedAnalysis SET ENROLLED=%b WHERE TrainingNeedAnalysisID=%n",
|
|||
|
|
enrolled, trainingNeedAnalysisID);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
}
|
|||
|
|
}
|