753 lines
60 KiB
C#
753 lines
60 KiB
C#
|
using HRM.BO;
|
|||
|
using Ease.Core.DataAccess;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Data;
|
|||
|
|
|||
|
namespace HRM.DA
|
|||
|
{
|
|||
|
class TrainingDA
|
|||
|
{
|
|||
|
#region Get Function
|
|||
|
|
|||
|
public static IDataReader Get(TransactionContext tc, int id)
|
|||
|
{
|
|||
|
return tc.ExecuteReader("SELECT * from Training WHERE TRAININGID=%n", id);
|
|||
|
}
|
|||
|
|
|||
|
public static IDataReader GetbyTypeID(TransactionContext tc, int id)
|
|||
|
{
|
|||
|
return tc.ExecuteReader("SELECT * from Training WHERE trainingTypeID=%n", id);
|
|||
|
}
|
|||
|
public static IDataReader Get(TransactionContext tc)
|
|||
|
{
|
|||
|
return tc.ExecuteReader("SELECT * from Training ORDER BY Name");
|
|||
|
}
|
|||
|
|
|||
|
internal static IDataReader Get(TransactionContext tc, string query)
|
|||
|
{
|
|||
|
return tc.ExecuteReader(query);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Get DataSet
|
|||
|
|
|||
|
public static DataSet GetEmployeeWiseTrainingSummary(TransactionContext tc, string sEmpIDs, DateTime fromDate,
|
|||
|
DateTime toDate, int tNature, int tTrainingTypeID, int trainingID, int deptID, int instituteID,
|
|||
|
int payrollTypeID)
|
|||
|
{
|
|||
|
DataSet oDataSet = null;
|
|||
|
string sql = String.Format(
|
|||
|
@"SELECT tr9.EmployeeNo, tr9.EmployeeName,tr9.DCode,tr9.Designation,tr9.DEPARTMENTID,tr9.Department,tr9.branch, tr8.* From
|
|||
|
(SELECT * FROM
|
|||
|
(SELECT tr6.*,ISNULL(tr7.TotalTrainingMinutes,0) TotalTrainingMinutes,cast(ISNULL((tr7.TotalTrainingMinutes/60),0)AS VARCHAR(MAX))+':'+Cast(ISNULL((tr7.TotalTrainingMinutes%60),0)AS VARCHAR(MAX)) TrainingHour FROM
|
|||
|
(SELECT tr4.*,ISNULL(tr5.TrainingCost,0) TrainingCost
|
|||
|
FROM
|
|||
|
(SELECT tss.TrainingScheduleEmployeeID,tss.TrainingScheduleID,tss.Institute,tss.EmployeeID,tss.TrainingID,tss.StartDate,tss.EndDate,tss.Venue,tss.TrainingNature,tn.TrainingName,tn.TrainingType
|
|||
|
FROM
|
|||
|
(SELECT * FROM (SELECT tse.* FROM TrainingScheduleEmployee tse {0}) t
|
|||
|
LEFT JOIN
|
|||
|
( SELECT a.TrainingScheduleID TSID,i.NAME Institute,a.TrainingID,a.StartDate,a.EndDate,a.Venue,b.[NAME] TrainingNature
|
|||
|
from TrainingSchedule a ,NATUREOFTRAINING b,Institution i
|
|||
|
WHERE a.TrainingNatureID = b.NATUREOFTRAININGID AND a.StartDate BETWEEN '{1}' AND '{2}' AND a.PAYROLLTYPEID={3}
|
|||
|
AND a.InstituteID = i.INSTITUTIONID {4} {6} {7}) ts
|
|||
|
ON t.TrainingScheduleID = ts.TSID) tss
|
|||
|
JOIN
|
|||
|
( SELECT trr.TRAININGID, trr.[NAME] TrainingName,trt.[NAME] TrainingType
|
|||
|
FROM TRAINING trr ,TRAININGTYPE trt
|
|||
|
WHERE trr.TRAININGTYPEID = trt.TRAININGTYPEID {5}) tn
|
|||
|
ON tss.TrainingID = tn.TRAININGID) tr4
|
|||
|
LEFT JOIN
|
|||
|
(SELECT SUM(tsec.Amount) TrainingCost,tsec.TrainSchEmpID
|
|||
|
FROM TrainingSchEmpCost tsec
|
|||
|
GROUP BY tsec.TrainSchEmpID) tr5
|
|||
|
ON tr4.TrainingScheduleEmployeeID = tr5.TrainSchEmpID) tr6
|
|||
|
LEFT JOIN
|
|||
|
(SELECT SUM(DATEDIFF(minute,tsds.StartTime,tsds.EndTime)) TotalTrainingMinutes,tsds.TrainingScheduleID
|
|||
|
FROM [TrainingScheduleDate] tsds
|
|||
|
GROUP BY tsds.TrainingScheduleID) tr7
|
|||
|
ON tr6.TrainingScheduleID = tr7.TrainingScheduleID) tr10 ) tr8,(SELECT e.EMPLOYEEID,e.EMPLOYEENO, e.[NAME] EmployeeName,d.CODE DCode,d.[NAME] Designation,d2.DEPARTMENTID,d2.[DESCRIPTION] Department,l.[DESCRIPTION] branch
|
|||
|
FROM vw_employeedept e LEFT JOIN DESIGNATION d ON e.DESIGNATIONID=d.DESIGNATIONID LEFT JOIN DEPARTMENT d2 ON e.DEPARTMENTID=d2.DEPARTMENTID LEFT JOIN LOCATION l ON e.LOCATIONID=l.LOCATIONID) tr9
|
|||
|
WHERE tr8.EmployeeID = tr9.EMPLOYEEID {8} ORDER BY tr9.DCode,tr9.EmployeeName,tr8.StartDate",
|
|||
|
sEmpIDs.Trim() == string.Empty ? "" : "where tse.employeeid in (" + sEmpIDs + ")",
|
|||
|
fromDate.ToString("dd MMM yyyy"), toDate.ToString("dd MMM yyyy"), payrollTypeID,
|
|||
|
tNature == 0 ? "" : " AND b.NATUREOFTRAININGID = " + tNature,
|
|||
|
tTrainingTypeID == 0 ? "" : "AND trr.TRAININGTYPEID=" + tTrainingTypeID,
|
|||
|
trainingID == 0 ? "" : " AND a.TRAININGID=" + trainingID,
|
|||
|
instituteID == 0 ? "" : " AND a.InstituteID=" + instituteID,
|
|||
|
deptID == 0 ? "" : " AND tr9.DEPARTMENTID=" + deptID);
|
|||
|
oDataSet = tc.ExecuteDataSet(sql);
|
|||
|
return oDataSet;
|
|||
|
}
|
|||
|
|
|||
|
public static DataSet GetTrainingWiseReport(TransactionContext tc, string sEmpIDs, int trainingID,
|
|||
|
DateTime fromDate, DateTime toDate, int nTypeID, int nNatureID, int ndeptID, int instituteID,
|
|||
|
int payrollTypeID)
|
|||
|
{
|
|||
|
DataSet oDataSet = null;
|
|||
|
// string sql = String.Format(@"SELECT scEmp.*,empGr.ttlPrsEmpCount
|
|||
|
// From
|
|||
|
// (SELECT d.DEPARTMENTID,d.DESCRIPTION DeptName,Count(*) EmpCount
|
|||
|
// FROM TrainingScheduleEmployee tse,Employee e,Department d ,TrainingSchedule ts
|
|||
|
// WHERE tse.ScheduleEmpStatus = 2 AND tse.EmployeeID = e.EMPLOYEEID AND ts.TrainingScheduleID=tse.TrainingScheduleID
|
|||
|
// AND e.DEPARTMENTID = d.DEPARTMENTID AND ts.TRAININGID={0} AND e.PAYROLLTYPEID = {1}
|
|||
|
// GROUP BY d.DEPARTMENTID,d.DESCRIPTION) scEmp
|
|||
|
// LEFT Join
|
|||
|
// (Select Count(*) ttlPrsEmpCount,e.DEPARTMENTID
|
|||
|
// FROM EMPLOYEE e
|
|||
|
// WHERE STATUS = 1 AND PAYROLLTYPEID = {2}
|
|||
|
// GROUP BY e.DEPARTMENTID) empGr
|
|||
|
// ON empGr.DEPARTMENTID= scEmp.DEPARTMENTID", trainingID, SystemInformation.CurrentSysInfo.PayrollTypeID, SystemInformation.CurrentSysInfo.PayrollTypeID);
|
|||
|
|
|||
|
string sql = String.Format(@"SELECT scEmp.*,empGr.ttlPrsEmpCount
|
|||
|
From
|
|||
|
(SELECT t.[NAME], ts.TRAININGID, d.DEPARTMENTID,d.DESCRIPTION DeptName,Count(*) EmpCount
|
|||
|
FROM TrainingScheduleEmployee tse,vw_EmployeeDept e,Department d ,TrainingSchedule ts,Training t
|
|||
|
WHERE t.TRAININGID=ts.TRAININGID AND tse.ScheduleEmpStatus IN (2, 4) AND tse.EmployeeID = e.EMPLOYEEID AND ts.TrainingScheduleID=tse.TrainingScheduleID
|
|||
|
AND e.DEPARTMENTID = d.DEPARTMENTID {0} AND ts.PAYROLLTYPEID = {1} AND ts.StartDate BETWEEN '{2}' AND '{3}' {4} {5} {6} {7}
|
|||
|
GROUP BY d.DEPARTMENTID,d.DESCRIPTION,ts.TRAININGID,t.[NAME]) scEmp
|
|||
|
LEFT Join
|
|||
|
(Select Count(*) ttlPrsEmpCount,e.DEPARTMENTID
|
|||
|
FROM vw_EmployeeDept e
|
|||
|
|
|||
|
GROUP BY e.DEPARTMENTID) empGr
|
|||
|
ON empGr.DEPARTMENTID= scEmp.DEPARTMENTID
|
|||
|
ORDER BY scEmp.NAME,scEmp.DeptName ",
|
|||
|
trainingID == 0 ? "AND ts.TRAININGID=" + trainingID : "", payrollTypeID,
|
|||
|
fromDate.ToString("dd MMM yyyy"), toDate.ToString("dd MMM yyyy"),
|
|||
|
nTypeID != 0 ? " AND t.TRAININGTYPEID=" + nTypeID : "",
|
|||
|
nNatureID != 0 ? " AND ts.TrainingNatureID=" + nNatureID : ""
|
|||
|
, instituteID == 0 ? "" : " AND ts.InstituteID=" + instituteID,
|
|||
|
sEmpIDs.Trim() == string.Empty ? "" : " AND tse.EmployeeID in (" + sEmpIDs + ")");
|
|||
|
|
|||
|
oDataSet = tc.ExecuteDataSet(sql);
|
|||
|
return oDataSet;
|
|||
|
}
|
|||
|
|
|||
|
public static DataSet GetDeptWiseTrainingReport(TransactionContext tc, int dptID, DateTime fromDate,
|
|||
|
DateTime toDate, int tNatureID, int tTrainingTypeID, int instituteID, int trainingID, int payrollTypeID)
|
|||
|
{
|
|||
|
DataSet oDataSet = null;
|
|||
|
string sql = String.Format(@"SELECT scEmp.*,empGr.ttlPrsEmpCount
|
|||
|
From
|
|||
|
(SELECT n.[NAME] Nature,tt.[NAME] TrainingType , d.DEPARTMENTID, t.[NAME],t.TRAININGID,d.DESCRIPTION DeptName,Count(*) EmpCount
|
|||
|
FROM TrainingScheduleEmployee tse,vw_employeedept e,Department d ,TrainingSchedule ts ,Training t, TRAININGTYPE tt, NATUREOFTRAINING n
|
|||
|
WHERE t.TRAININGTYPEID=tt.TRAININGTYPEID AND ts.TrainingNatureID=n.NATUREOFTRAININGID AND t.TRAININGID=ts.TRAININGID AND tse.ScheduleEmpStatus IN (2, 4) AND tse.EmployeeID = e.EMPLOYEEID
|
|||
|
AND ts.TrainingScheduleID=tse.TrainingScheduleID AND ts.StartDate BETWEEN '{2}' AND '{3}'
|
|||
|
AND e.DEPARTMENTID = d.DEPARTMENTID {0} AND ts.PAYROLLTYPEID = {1} {4} {5} {6} {7}
|
|||
|
GROUP BY t.TRAININGID,t.[NAME],d.DESCRIPTION ,d.DEPARTMENTID,n.[NAME],tt.[NAME]) scEmp
|
|||
|
LEFT Join
|
|||
|
(Select Count(*) ttlPrsEmpCount,e.DEPARTMENTID
|
|||
|
FROM vw_employeedept e GROUP BY e.DEPARTMENTID) empGr
|
|||
|
ON empGr.DEPARTMENTID= scEmp.DEPARTMENTID",
|
|||
|
dptID != 0 ? "AND d.DEPARTMENTID=" + dptID : "", payrollTypeID,
|
|||
|
fromDate.ToString("dd MMM yyyy"), toDate.ToString("dd MMM yyyy"),
|
|||
|
tTrainingTypeID != 0 ? " AND tt.TRAININGTYPEID=" + tTrainingTypeID : "",
|
|||
|
tNatureID != 0 ? " AND ts.TrainingNatureID = " + tNatureID : "",
|
|||
|
instituteID != 0 ? " AND ts.InstituteID=" + instituteID : "",
|
|||
|
trainingID != 0 ? " AND ts.TRAININGID=" + trainingID : "");
|
|||
|
oDataSet = tc.ExecuteDataSet(sql);
|
|||
|
return oDataSet;
|
|||
|
}
|
|||
|
|
|||
|
public static DataSet GetEmployeeWiseTrainingReport(TransactionContext tc, string sEmpID, int nNatureID,
|
|||
|
int nTrainingTypeID, int ndeptID, int instituteID, int year, int payrollTypeID)
|
|||
|
{
|
|||
|
DataSet oDataSet = null;
|
|||
|
// string sql = String.Format(@"SELECT emp.EmployeeName,emp.DEPARTMENTID,emp.Designation,EMP.JOININGDATE, COUNT(*) NoOfTraining
|
|||
|
// FROM (select distinct EmployeeID From TrainingScheduleAttn) tsa,TrainingScheduleEmployee te,
|
|||
|
// (SELECT e.EMPLOYEEID,e.DEPARTMENTID, e.[NAME] EmployeeName,e.JOININGDATE,d.[NAME] Designation,d2.[DESCRIPTION] Department
|
|||
|
// FROM Employee e LEFT JOIN DESIGNATION d ON e.DESIGNATIONID=d.DESIGNATIONID
|
|||
|
// LEFT JOIN DEPARTMENT d2 ON e.DEPARTMENTID=d2.DEPARTMENTID)emp
|
|||
|
// WHERE emp.EMPLOYEEID=tsa.EmployeeID AND te.EmployeeID=emp.EMPLOYEEID
|
|||
|
// GROUP BY emp.EMPLOYEEID,emp.EmployeeName,emp.DEPARTMENTID,emp.Designation,EMP.JOININGDATE");
|
|||
|
|
|||
|
|
|||
|
#region Old
|
|||
|
|
|||
|
// string sql = String.Format(@"SELECT emp.EMPLOYEENO,emp.EMPLOYEEID,emp.EmployeeName,emp.JOININGDATE, emp.DEPARTMENTID,
|
|||
|
// emp.DesCode,emp.Designation,ar.Assigned,ar.Received,
|
|||
|
// ISNULL(C.ReceivedTillDate,0) ReceivedTillDate,ISNULL(D.ReceivedLastYear,0) ReceivedLastYear, D.TrainingNature
|
|||
|
// FROM
|
|||
|
// (SELECT e.EMPLOYEENO, e.EMPLOYEEID,e.DEPARTMENTID, e.[NAME] EmployeeName,e.JOININGDATE,d.[NAME] Designation,d.CODE DesCode ,d2.[DESCRIPTION] Department
|
|||
|
// FROM vw_employeedept e LEFT JOIN DESIGNATION d ON e.DESIGNATIONID=d.DESIGNATIONID
|
|||
|
// LEFT JOIN DEPARTMENT d2 ON e.DEPARTMENTID=d2.DEPARTMENTID) emp,
|
|||
|
//
|
|||
|
// (SELECT ISNULL(A.employeeID,B.employeeID) EmployeeID,ISNULL(A.Assaigned,0) Assigned,ISNULL(B.Received,0) Received FROM
|
|||
|
//
|
|||
|
// (SELECT COUNT(a.ScheduleStatus) 'Assaigned' ,a.employeeID
|
|||
|
// FROM
|
|||
|
// (SELECT tse.EmployeeID,ts.TrainingScheduleID,ts.ScheduleStatus,ts.StartDate
|
|||
|
// FROM trainingscheduleemployee tse
|
|||
|
// INNER JOIN TrainingSchedule ts
|
|||
|
// ON ts.TrainingScheduleID = tse.TrainingScheduleID
|
|||
|
// INNER JOIN TRAINING t
|
|||
|
// ON t.TRAININGID=ts.TRAININGID
|
|||
|
// WHERE ts.StartDate>='{0}' AND ts.PAYROLLTYPEID={3} {4} {5} {6}) a
|
|||
|
// GROUP BY a.EMPLOYEEID) A
|
|||
|
//
|
|||
|
// FULL OUTER JOIN
|
|||
|
// ( SELECT COUNT(a.ScheduleStatus) 'Received' ,a.employeeID FROM
|
|||
|
// (SELECT tse.EMPLOYEEID,ts.TrainingScheduleID,ts.ScheduleStatus
|
|||
|
// FROM trainingscheduleemployee tse
|
|||
|
// INNER JOIN TrainingSchedule ts
|
|||
|
// ON ts.TrainingScheduleID = tse.TrainingScheduleID
|
|||
|
// INNER JOIN TRAINING t
|
|||
|
// ON t.TRAININGID=ts.TRAININGID
|
|||
|
// WHERE ts.ScheduleStatus=0 AND ts.PAYROLLTYPEID={3} AND ts.StartDate>='{0}' {4} {5} {6}) a
|
|||
|
// GROUP BY a.EMPLOYEEID) B
|
|||
|
//
|
|||
|
// ON A.employeeID = B.employeeID
|
|||
|
//
|
|||
|
// ) ar
|
|||
|
// FULL OUTER JOIN
|
|||
|
// ( SELECT COUNT(a.ScheduleStatus) 'ReceivedTillDate' ,a.employeeID FROM
|
|||
|
// (SELECT tse.EMPLOYEEID,ts.TrainingScheduleID,ts.ScheduleStatus
|
|||
|
// FROM trainingscheduleemployee tse
|
|||
|
// INNER JOIN TrainingSchedule ts
|
|||
|
// ON ts.TrainingScheduleID = tse.TrainingScheduleID
|
|||
|
// INNER JOIN TRAINING t
|
|||
|
// ON t.TRAININGID=ts.TRAININGID
|
|||
|
// WHERE ts.ScheduleStatus=0 AND ts.PAYROLLTYPEID={3} {4} {5} {6}) a
|
|||
|
// GROUP BY a.EMPLOYEEID) C
|
|||
|
// ON C.employeeID=ar.employeeID
|
|||
|
// FULL OUTER JOIN
|
|||
|
// ( SELECT COUNT(a.ScheduleStatus) 'ReceivedLastYear' ,a.employeeID, a.TrainingNature
|
|||
|
// FROM
|
|||
|
//
|
|||
|
// (SELECT tse.EMPLOYEEID,ts.TrainingScheduleID,ts.ScheduleStatus, n.[NAME] TrainingNature
|
|||
|
// FROM trainingscheduleemployee tse
|
|||
|
// INNER JOIN TrainingSchedule ts
|
|||
|
// ON ts.TrainingScheduleID = tse.TrainingScheduleID
|
|||
|
// LEFT JOIN NATUREOFTRAINING n
|
|||
|
// ON ts.TrainingNatureID = n.NATUREOFTRAININGID
|
|||
|
// INNER JOIN TRAINING t
|
|||
|
// ON t.TRAININGID=ts.TRAININGID
|
|||
|
// WHERE ts.ScheduleStatus=0 AND ts.PAYROLLTYPEID={3} AND YEAR(ts.StartDate)='{1}' {4} {5} {6}) a
|
|||
|
//
|
|||
|
// GROUP BY a.EMPLOYEEID,a.TrainingNature ) D
|
|||
|
// ON C.employeeID=D.employeeID
|
|||
|
// WHERE ar.EmployeeID=emp.EMPLOYEEID {2}
|
|||
|
// ORDER BY emp.DesCode,emp.EMPLOYEENO
|
|||
|
// ", DateTime.Today.Year, DateTime.Today.Year - 1, sEmpID.Trim() == string.Empty ? "" : "AND emp.EMPLOYEEID IN (" + sEmpID + ")",
|
|||
|
// SystemInformation.CurrentSysInfo.PayrollTypeID, nNatureID != 0 ? " AND ts.TrainingNatureID=" + nNatureID : "",
|
|||
|
// nTrainingTypeID != 0 ? " AND t.TRAININGTYPEID=" + nTrainingTypeID : "", instituteID != 0 ? " AND ts.InstituteID=" + instituteID : "");
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
string sql = String.Format(
|
|||
|
@"SELECT emp.EMPLOYEENO,emp.EMPLOYEEID,emp.EmployeeName,emp.JOININGDATE, emp.DEPARTMENTID,emp.DesCode,emp.Designation,ISNULL(tmp.Assigned,0) Assigned,ISNULL(tmp.Received,0) Received,
|
|||
|
ISNULL(tmp.ReceivedTillDate,0) ReceivedTillDate,ISNULL(tmp.ReceivedLastYear,0) ReceivedLastYear FROM
|
|||
|
(SELECT em.* from(SELECT e.EMPLOYEENO, e.EMPLOYEEID,e.DEPARTMENTID, e.[NAME] EmployeeName,e.JOININGDATE,d.[NAME] Designation,d.CODE DesCode ,d2.[DESCRIPTION] Department
|
|||
|
FROM vw_employeedept e LEFT JOIN DESIGNATION d ON e.DESIGNATIONID=d.DESIGNATIONID
|
|||
|
LEFT JOIN DEPARTMENT d2 ON e.DEPARTMENTID=d2.DEPARTMENTID) em {2} ) emp LEFT OUTER JOIN
|
|||
|
(
|
|||
|
SELECT
|
|||
|
--
|
|||
|
ISNULL(ar.EmployeeID,ISNULL(C.employeeID,D.employeeID)) EmployeeID,ar.Assigned,ar.Received,
|
|||
|
ISNULL(C.ReceivedTillDate,0) ReceivedTillDate,ISNULL(D.ReceivedLastYear,0) ReceivedLastYear, D.TrainingNature
|
|||
|
FROM
|
|||
|
|
|||
|
(SELECT ISNULL(A.employeeID,B.employeeID) EmployeeID,ISNULL(A.Assaigned,0) Assigned,ISNULL(B.Received,0) Received FROM
|
|||
|
|
|||
|
(SELECT COUNT(a.ScheduleStatus) 'Assaigned' ,a.employeeID
|
|||
|
FROM
|
|||
|
(SELECT tse.EmployeeID,ts.TrainingScheduleID,ts.ScheduleStatus,ts.StartDate
|
|||
|
FROM trainingscheduleemployee tse
|
|||
|
INNER JOIN TrainingSchedule ts
|
|||
|
ON ts.TrainingScheduleID = tse.TrainingScheduleID
|
|||
|
INNER JOIN TRAINING t
|
|||
|
ON t.TRAININGID=ts.TRAININGID
|
|||
|
WHERE ts.StartDate>='{0}' AND ts.PAYROLLTYPEID={3} {4} {5} {6}) a
|
|||
|
GROUP BY a.EMPLOYEEID) A
|
|||
|
|
|||
|
FULL OUTER JOIN
|
|||
|
( SELECT COUNT(a.ScheduleStatus) 'Received' ,a.employeeID FROM
|
|||
|
(SELECT tse.EMPLOYEEID,ts.TrainingScheduleID,ts.ScheduleStatus
|
|||
|
FROM trainingscheduleemployee tse
|
|||
|
INNER JOIN TrainingSchedule ts
|
|||
|
ON ts.TrainingScheduleID = tse.TrainingScheduleID
|
|||
|
INNER JOIN TRAINING t
|
|||
|
ON t.TRAININGID=ts.TRAININGID
|
|||
|
WHERE ts.ScheduleStatus=0 AND ts.PAYROLLTYPEID={3} AND ts.StartDate>='{0}' {4} {5} {6}) a
|
|||
|
GROUP BY a.EMPLOYEEID) B
|
|||
|
|
|||
|
ON A.employeeID = B.employeeID
|
|||
|
|
|||
|
) ar
|
|||
|
FULL OUTER JOIN
|
|||
|
( SELECT COUNT(a.ScheduleStatus) 'ReceivedTillDate' ,a.employeeID FROM
|
|||
|
(SELECT tse.EMPLOYEEID,ts.TrainingScheduleID,ts.ScheduleStatus
|
|||
|
FROM trainingscheduleemployee tse
|
|||
|
INNER JOIN TrainingSchedule ts
|
|||
|
ON ts.TrainingScheduleID = tse.TrainingScheduleID
|
|||
|
INNER JOIN TRAINING t
|
|||
|
ON t.TRAININGID=ts.TRAININGID
|
|||
|
WHERE ts.ScheduleStatus=0 AND ts.PAYROLLTYPEID={3} {4} {5} {6}) a
|
|||
|
GROUP BY a.EMPLOYEEID) C
|
|||
|
ON C.employeeID=ar.employeeID
|
|||
|
FULL OUTER JOIN
|
|||
|
( SELECT COUNT(a.ScheduleStatus) 'ReceivedLastYear' ,a.employeeID, a.TrainingNature
|
|||
|
FROM
|
|||
|
|
|||
|
(SELECT tse.EMPLOYEEID,ts.TrainingScheduleID,ts.ScheduleStatus, n.[NAME] TrainingNature
|
|||
|
FROM trainingscheduleemployee tse
|
|||
|
INNER JOIN TrainingSchedule ts
|
|||
|
ON ts.TrainingScheduleID = tse.TrainingScheduleID
|
|||
|
LEFT JOIN NATUREOFTRAINING n
|
|||
|
ON ts.TrainingNatureID = n.NATUREOFTRAININGID
|
|||
|
INNER JOIN TRAINING t
|
|||
|
ON t.TRAININGID=ts.TRAININGID
|
|||
|
WHERE ts.ScheduleStatus=0 AND ts.PAYROLLTYPEID={3} AND YEAR(ts.StartDate)='{1}' {4} {5} {6}) a
|
|||
|
|
|||
|
GROUP BY a.EMPLOYEEID,a.TrainingNature ) D
|
|||
|
ON C.employeeID=D.employeeID)tmp
|
|||
|
|
|||
|
ON tmp.EmployeeID=emp.EMPLOYEEID
|
|||
|
ORDER BY emp.DesCode,emp.EmployeeName
|
|||
|
", year, year - 1,
|
|||
|
sEmpID.Trim() == string.Empty ? "" : "Where em.EMPLOYEEID IN (" + sEmpID + ")",
|
|||
|
payrollTypeID, nNatureID != 0 ? " AND ts.TrainingNatureID=" + nNatureID : "",
|
|||
|
nTrainingTypeID != 0 ? " AND t.TRAININGTYPEID=" + nTrainingTypeID : "",
|
|||
|
instituteID != 0 ? " AND ts.InstituteID=" + instituteID : "");
|
|||
|
|
|||
|
|
|||
|
oDataSet = tc.ExecuteDataSet(sql);
|
|||
|
return oDataSet;
|
|||
|
}
|
|||
|
|
|||
|
public static DataSet GetTrainingAttendenceReport(TransactionContext tc, string sEmpIDs, int trainingID,
|
|||
|
DateTime dStartDate, DateTime dEndDate, int tTrainingTypeID, int nNatureID, int instituteID,
|
|||
|
int nScheduleID, int payrollTypeID)
|
|||
|
{
|
|||
|
DataSet oDataSet = null;
|
|||
|
string sql = String.Format(@"select a.*,b.Atteddence from
|
|||
|
(select e.employeeno, d.code,e.name 'Name',tsa.employeeid 'EmployeeID',e.departmentid 'DepartmentID',l.[DESCRIPTION] 'BranchName',
|
|||
|
d.name 'DesignationName',tse.ScheduleEmpStatus
|
|||
|
from Trainingschedule ts
|
|||
|
join trainingscheduleattn tsa
|
|||
|
on tsa.trainingscheduleid=ts.trainingscheduleid
|
|||
|
join vw_employeedept e
|
|||
|
on tsa.employeeid=e.employeeid
|
|||
|
join Location l
|
|||
|
on e.LOCATIONID = l.LOCATIONID
|
|||
|
join designation d
|
|||
|
on e.designationid=d.designationid
|
|||
|
JOIN TRAINING t
|
|||
|
ON t.TRAININGID = ts.TRAININGID
|
|||
|
JOIN TrainingScheduleEmployee tse
|
|||
|
ON tse.TrainingScheduleID= ts.TrainingScheduleID AND tsa.EmployeeID = tse.EmployeeID
|
|||
|
Where ts.trainingid={0} AND ts.PAYROLLTYPEID={1} AND ts.StartDate BETWEEN '{7}' AND '{8}' {3} {4} {5} {6}
|
|||
|
group by tsa.employeeid,e.name,e.departmentid,d.name,d.code,e.employeeno,l.[DESCRIPTION],tse.ScheduleEmpStatus) a
|
|||
|
inner join
|
|||
|
(select employeeid,count(TrainingScheduleID) 'Atteddence'
|
|||
|
from trainingscheduleattn
|
|||
|
group by employeeid) b
|
|||
|
on a.employeeid=b.employeeid {2}
|
|||
|
order by a.code,a.Name",
|
|||
|
trainingID, payrollTypeID, sEmpIDs != string.Empty ? " WHERE a.EmployeeID IN(" + sEmpIDs + ")" : "",
|
|||
|
nNatureID != 0 ? " AND ts.TrainingNatureID=" + nNatureID : "",
|
|||
|
instituteID != 0 ? " AND ts.InstituteID=" + instituteID : "",
|
|||
|
tTrainingTypeID != 0 ? " AND t.TRAININGTYPEID=" + tTrainingTypeID : "",
|
|||
|
nScheduleID != 0 ? " AND ts.TrainingScheduleID=" + nScheduleID : "", dStartDate.ToString("dd MMM yyyy"),
|
|||
|
dEndDate.ToString("dd MMM yyyy"));
|
|||
|
oDataSet = tc.ExecuteDataSet(sql);
|
|||
|
return oDataSet;
|
|||
|
}
|
|||
|
|
|||
|
public static DataSet GetEmployeeWiseTrainingDetails(TransactionContext tc, string sEmpIDs, DateTime fromDate,
|
|||
|
DateTime toDate, int nTypeID, int nNatureID, int instituteID, int payrollTypeID)
|
|||
|
{
|
|||
|
DataSet oDataSet = null;
|
|||
|
string sql = String.Format(
|
|||
|
@"SELECT tr9.CODE,tr9.EMPLOYEEID,YEAR(tr8.StartDate) 'YEAR',tr9.EMPLOYEENO,tr9.DEPARTMENTID, tr9.EmployeeName,tr9.Designation,tr9.JOININGDATE,tr9.Department,tr9.branch, tr8.*
|
|||
|
From
|
|||
|
(SELECT * FROM
|
|||
|
(SELECT tr6.*,ISNULL(tr7.TotalTrainngMinutes,0) TotalTrainngMinutes,cast(ISNULL((tr7.TotalTrainngMinutes/60),0)AS VARCHAR(MAX))+':'+Cast(ISNULL((tr7.TotalTrainngMinutes%60),0)AS VARCHAR(MAX)) TrainingHour FROM
|
|||
|
(SELECT tr4.*,ISNULL(tr5.TrainingCost,0) TrainingCost
|
|||
|
FROM
|
|||
|
(SELECT tss.TrainingScheduleEmployeeID,tss.Venue,tss.TrainingScheduleID,tss.InstituteID,tss.EmployeeID,tss.TrainingID,tss.StartDate,tss.EndDate,tss.TrainingNature,tn.TrainingName,tn.TrainingType
|
|||
|
FROM
|
|||
|
(SELECT * FROM (SELECT tse.* FROM TrainingScheduleEmployee tse {0}) t
|
|||
|
LEFT JOIN
|
|||
|
( SELECT a.TrainingScheduleID TSID,a.Venue,a.TrainingID, a.InstituteID,a.StartDate,a.EndDate,b.[NAME] TrainingNature
|
|||
|
from TrainingSchedule a ,NATUREOFTRAINING b
|
|||
|
WHERE a.PAYROLLTYPEID={4} AND a.TrainingNatureID = b.NATUREOFTRAININGID AND a.StartDate BETWEEN '{2}' AND '{3}' {6} {7}) ts
|
|||
|
ON t.TrainingScheduleID = ts.TSID) tss
|
|||
|
JOIN
|
|||
|
( SELECT trr.TRAININGID, trr.[NAME] TrainingName,trt.[NAME] TrainingType
|
|||
|
FROM TRAINING trr ,TRAININGTYPE trt
|
|||
|
WHERE trr.TRAININGTYPEID = trt.TRAININGTYPEID {5}) tn
|
|||
|
ON tss.TrainingID = tn.TRAININGID) tr4
|
|||
|
LEFT JOIN
|
|||
|
(SELECT SUM(tsec.Amount) TrainingCost,tsec.TrainSchEmpID
|
|||
|
FROM TrainingSchEmpCost tsec
|
|||
|
GROUP BY tsec.TrainSchEmpID) tr5
|
|||
|
ON tr4.TrainingScheduleEmployeeID = tr5.TrainSchEmpID) tr6
|
|||
|
LEFT JOIN
|
|||
|
(SELECT SUM(DATEDIFF(minute,tsds.StartTime,tsds.EndTime)) TotalTrainngMinutes,tsds.TrainingScheduleID
|
|||
|
FROM [TrainingScheduleDate] tsds
|
|||
|
GROUP BY tsds.TrainingScheduleID) tr7
|
|||
|
ON tr6.TrainingScheduleID = tr7.TrainingScheduleID) tr10 ) tr8,(SELECT e.EMPLOYEEID,e.EMPLOYEENO, d.CODE, e.JOININGDATE ,e.[NAME] EmployeeName,d.[NAME] Designation,d2.[DESCRIPTION] Department,d2.DEPARTMENTID,l.[DESCRIPTION] branch
|
|||
|
FROM vw_employeedept e LEFT JOIN DESIGNATION d ON e.DESIGNATIONID=d.DESIGNATIONID LEFT JOIN DEPARTMENT d2 ON e.DEPARTMENTID=d2.DEPARTMENTID LEFT JOIN Location l ON e.LOCATIONID=l.LOCATIONID) tr9
|
|||
|
WHERE tr8.EmployeeID = tr9.EMPLOYEEID {1} ORDER BY tr9.EMPLOYEEID, tr9.CODE,tr9.EmployeeName, tr8.TrainingNature,tr8.TrainingType ",
|
|||
|
sEmpIDs.Trim() == string.Empty ? "" : "where tse.employeeid in (" + sEmpIDs + ")",
|
|||
|
sEmpIDs.Trim() == string.Empty ? "" : "AND tr9.EMPLOYEEID IN(" + sEmpIDs + ")",
|
|||
|
fromDate.ToString("dd MMM yyyy"), toDate.ToString("dd MMM yyyy"), payrollTypeID,
|
|||
|
nTypeID != 0 ? " AND trr.TRAININGTYPEID=" + nTypeID : "",
|
|||
|
nNatureID != 0 ? " AND a.TrainingNatureID=" + nNatureID : "",
|
|||
|
instituteID != 0 ? "AND a.InstituteID=" + instituteID : "");
|
|||
|
oDataSet = tc.ExecuteDataSet(sql);
|
|||
|
return oDataSet;
|
|||
|
}
|
|||
|
|
|||
|
public static DataSet GetTrainingNameWiseDetails(TransactionContext tc, string sEmpIDs, DateTime dStartDate,
|
|||
|
DateTime dEndDate, int nTyprID, int nNatureID, int instituteID, int trainingID, int payrollTypeID)
|
|||
|
{
|
|||
|
DataSet oDataSet = null;
|
|||
|
string sql = String.Format(@"SELECT * FROM
|
|||
|
(SELECT t.NAME 'TrainingName',e.NAME,d.[DESCRIPTION] Department,e.employeeno,d2.[NAME] Designation,d2.CODE,e.employeeID,d.DEPARTMENTID, YEAR(ts.StartDate) YEAR, ts.Venue,tcost.TrainingCost,
|
|||
|
tse.TrainingScheduleEmployeeID,ts.TrainingScheduleID,t.trainingID, ts.StartDate,ts.EndDate,ts.TrainingHour,ts.InstituteID
|
|||
|
|
|||
|
FROM vw_employeedept e JOIN TrainingScheduleEmployee tse
|
|||
|
|
|||
|
ON e.EMPLOYEEID=tse.EmployeeID JOIN vw_TrainingSchWithHour ts
|
|||
|
ON tse.TrainingScheduleID = ts.TrainingScheduleID JOIN TRAINING t
|
|||
|
ON t.TRAININGID = ts.TRAININGID JOIN DEPARTMENT d
|
|||
|
ON d.DEPARTMENTID = e.DEPARTMENTID JOIN (SELECT SUM(tsec.Amount) TrainingCost,tsec.TrainSchEmpID FROM TrainingSchEmpCost tsec GROUP BY tsec.TrainSchEmpID) tCost
|
|||
|
ON tcost.TrainSchEmpID=tse.TrainingScheduleEmployeeID JOIN DESIGNATION d2
|
|||
|
ON d2.DESIGNATIONID = e.DESIGNATIONID
|
|||
|
WHERE ts.PAYROLLTYPEID={3} AND ts.StartDate BETWEEN '{1}' AND '{2}' {0} {4} {5} {6} {7}
|
|||
|
GROUP BY t.NAME,e.NAME,e.employeeno,e.employeeID,tse.TrainingScheduleEmployeeID,ts.TrainingScheduleID,t.trainingID,d2.[NAME],d2.CODE,
|
|||
|
ts.Venue, d.[DESCRIPTION],YEAR(ts.StartDate),tcost.TrainingCost,d.DEPARTMENTID, ts.StartDate,ts.EndDate,ts.TrainingHour,ts.InstituteID) a
|
|||
|
ORDER BY a.TrainingName,a.CODE,a.NAME",
|
|||
|
sEmpIDs.Trim() == string.Empty ? "" : "AND e.EMPLOYEEID IN (" + sEmpIDs + ")",
|
|||
|
dStartDate.ToString("dd MMM yyyy"), dEndDate.ToString("dd MMM yyyy"),
|
|||
|
payrollTypeID, nTyprID != 0 ? " AND t.TRAININGTYPEID=" + nTyprID : "",
|
|||
|
nNatureID != 0 ? " AND ts.TrainingNatureID=" + nNatureID : "",
|
|||
|
trainingID != 0 ? " AND ts.TRAININGID=" + trainingID : "",
|
|||
|
instituteID != 0 ? " AND ts.InstituteID=" + instituteID : "");
|
|||
|
oDataSet = tc.ExecuteDataSet(sql);
|
|||
|
return oDataSet;
|
|||
|
}
|
|||
|
|
|||
|
public static DataSet GetDepartmentWiseTrainingExpense(TransactionContext tc, string sEmpIDs, int nNatureID,
|
|||
|
int nTrainingTypeID, int instituteID, int year, int payrollTypeID)
|
|||
|
{
|
|||
|
DataSet oDataSet = null;
|
|||
|
string sql = String.Format(
|
|||
|
@"SELECT dpt.DEPARTMENTID,dpt.DeptName, Count(*) EmpCount, SUM(TC.Amount) Cost,Sum(dpt.TotalTrainingMinutes) TotalTrainingMinutes, cast(ISNULL((Sum(dpt.TotalTrainingMinutes)/60),0)AS VARCHAR(MAX))+':'
|
|||
|
+Cast(ISNULL((SUM(dpt.TotalTrainingMinutes)%60),0)AS VARCHAR(MAX)) TrainingHour FROM
|
|||
|
(SELECT d.DEPARTMENTID,d.DESCRIPTION DeptName ,e.EMPLOYEEID,tse.TrainingScheduleEmployeeID, SUM(ts.TotalTrainingMinutes) TotalTrainingMinutes
|
|||
|
FROM TrainingScheduleEmployee tse,vw_employeedept e,Department d ,vw_TrainingSchWithHour ts, TRAINING t
|
|||
|
|
|||
|
WHERE e.EmployeeID=tse.EmployeeID AND d.DEPARTMENTID=e.DEPARTMENTID AND tse.ScheduleEmpStatus IN (2, 4)
|
|||
|
AND ts.TrainingScheduleID=tse.TrainingScheduleID {2} {3} {4} AND t.TRAININGID=ts.TRAININGID {5}
|
|||
|
AND e.DEPARTMENTID = d.DEPARTMENTID AND YEAR (ts.StartDate)={0} AND e.PAYROLLTYPEID = {1}
|
|||
|
GROUP BY d.DEPARTMENTID,d.DESCRIPTION ,e.EMPLOYEEID,tse.TrainingScheduleEmployeeID,tse.TrainingScheduleID) dpt
|
|||
|
LEFT JOIN
|
|||
|
(SELECT SUM(tsec.Amount) Amount,tsec.TrainSchEmpID FROM TrainingSchEmpCost tsec GROUP BY tsec.TrainSchEmpID) TC
|
|||
|
ON TC.TrainSchEmpID=dpt.TrainingScheduleEmployeeID
|
|||
|
GROUP BY dpt.DEPARTMENTID,dpt.DeptName ORDER BY dpt.DeptName
|
|||
|
", year, payrollTypeID,
|
|||
|
sEmpIDs != "" ? " AND e.EMPLOYEEID IN(" + sEmpIDs + ")" : "",
|
|||
|
instituteID != 0 ? " AND ts.InstituteID=" + instituteID : "",
|
|||
|
nNatureID != 0 ? " AND ts.TrainingNatureID=" + nNatureID : "",
|
|||
|
nTrainingTypeID != 0 ? " AND t.TRAININGTYPEID=" + nTrainingTypeID : "");
|
|||
|
// string sql = String.Format(@"SELECT dpt.DEPARTMENTID,dpt.DeptName, Count(*) EmpCount, SUM(TC.Amount) Cost FROM
|
|||
|
// (SELECT d.DEPARTMENTID,d.DESCRIPTION DeptName ,e.EMPLOYEEID,tse.TrainingScheduleEmployeeID
|
|||
|
// FROM TrainingScheduleEmployee tse,vw_employeedept e,Department d ,TrainingSchedule ts, TRAINING t
|
|||
|
//
|
|||
|
// WHERE e.EmployeeID=tse.EmployeeID AND d.DEPARTMENTID=e.DEPARTMENTID AND tse.ScheduleEmpStatus IN (2, 4)
|
|||
|
// AND ts.TrainingScheduleID=tse.TrainingScheduleID {2} {3} {4} AND t.TRAININGID=ts.TRAININGID {5}
|
|||
|
// AND e.DEPARTMENTID = d.DEPARTMENTID AND ts.StartDate>='{0}' AND e.PAYROLLTYPEID = {1}) dpt
|
|||
|
// LEFT JOIN
|
|||
|
// (SELECT SUM(tsec.Amount) Amount,tsec.TrainSchEmpID FROM TrainingSchEmpCost tsec GROUP BY tsec.TrainSchEmpID) TC
|
|||
|
// ON TC.TrainSchEmpID=dpt.TrainingScheduleEmployeeID
|
|||
|
// GROUP BY dpt.DEPARTMENTID,dpt.DeptName ORDER BY dpt.DeptName
|
|||
|
// ", DateTime.Today.Year-1, SystemInformation.CurrentSysInfo.PayrollTypeID, sEmpIDs!=""?" AND e.EMPLOYEEID IN("+sEmpIDs+")":"",instituteID!=0?" AND ts.InstituteID="+instituteID:"",
|
|||
|
// nNatureID != 0 ? " AND ts.TrainingNatureID=" + nNatureID : "", nTrainingTypeID != 0 ? " AND t.TRAININGTYPEID=" + nTrainingTypeID : "");
|
|||
|
oDataSet = tc.ExecuteDataSet(sql);
|
|||
|
return oDataSet;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
public static DataSet GetTrainingConductedByDepartment(TransactionContext tc, int dptID, DateTime fromDate,
|
|||
|
DateTime toDate, int tNature, int tTrainingType, int trainingID, int instituteID, int payrollTypeID)
|
|||
|
{
|
|||
|
DataSet oDataSet = null;
|
|||
|
string sql = String.Format(
|
|||
|
@"SELECT tna.DepartmentID, tna.[DESCRIPTION], trs.training,trs.nature,trs.TrainingType,COUNT(*) NoOfSession, trs.TotalSchedule from
|
|||
|
(SELECT ts.*,n.[NAME] nature, tt.[NAME] TrainingType, t.[NAME] training,totalSch.TotalSchedule
|
|||
|
FROM TrainingSchedule ts,training t,NATUREOFTRAINING n,TRAININGTYPE tt,(SELECT ts.trainingID,COUNT(*) TotalSchedule
|
|||
|
FROM TrainingSchedule ts
|
|||
|
WHERE ts.PAYROLLTYPEID={0} AND ts.StartDate BETWEEN '{2}' AND '{3}' {4}
|
|||
|
GROUP BY ts.trainingID) totalSch
|
|||
|
WHERE ts.TRAININGID=totalSch.trainingID AND ts.TRAININGID=t.TRAININGID AND tt.TRAININGTYPEID=t.TRAININGTYPEID AND ts.PAYROLLTYPEID={0} AND n.NATUREOFTRAININGID=ts.TrainingNatureID AND ts.StartDate BETWEEN '{2}' AND '{3}' {5} {6} {7}) trs
|
|||
|
JOIN
|
|||
|
(SELECT TrainingNeedAnalysisID,tna.DepartmentID,d.[DESCRIPTION] FROM TrainingNeedAnalysis tna ,Department d WHERE tna.Conduct_Required=1 AND d.DEPARTMENTID=tna.DepartmentID {1}) tna
|
|||
|
ON trs.TNAnalysisID=tna.TrainingNeedAnalysisID
|
|||
|
GROUP BY trs.training,trs.nature,trs.TrainingType,tna.DepartmentID,tna.[DESCRIPTION], trs.TotalSchedule
|
|||
|
ORDER BY tna.DepartmentID", payrollTypeID,
|
|||
|
dptID != 0 ? "AND tna.DepartmentID=" + dptID : "", fromDate.ToString("dd MMM yyyy"),
|
|||
|
toDate.ToString("dd MMM yyyy"), tNature != 0 ? " AND ts.TrainingNatureID =" + tNature : "",
|
|||
|
tTrainingType != 0 ? " AND t.TRAININGTYPEID=" + tTrainingType : "",
|
|||
|
trainingID != 0 ? " AND t.TRAININGID=" + trainingID : "",
|
|||
|
instituteID != 0 ? " AND ts.InstituteID=" + instituteID : "");
|
|||
|
oDataSet = tc.ExecuteDataSet(sql);
|
|||
|
return oDataSet;
|
|||
|
}
|
|||
|
|
|||
|
public static DataSet GetEntityWiseTrainingSummery(TransactionContext tc, string sEmpIDs, DateTime fromDate,
|
|||
|
DateTime toDate, int tNature, int tTrainingType, int instituteID)
|
|||
|
{
|
|||
|
DataSet oDataSet = null;
|
|||
|
string sql = String.Format(@"SELECT p.[DESCRIPTION],t3.* FROM
|
|||
|
(SELECT ISNULL(t1.PAYROLLTYPEID,t2.PAYROLLTYPEID) PAYROLLTYPEID ,ISNULL(t1.[NAME],t2.NAME) TrainingType,
|
|||
|
ISNULL(t2.NoOfTrainings,0) NoOfTrainings , ISNULL(t1.NoOfParticipants,0) NoOfParticipants,t1.Cost,t1.TotalTrainingMinutes, CAST(ISNULL(t1.TotalTrainingMinutes/60,0)AS VARCHAR(MAX))+':'+Cast(ISNULL(t1.TotalTrainingMinutes%60,0)AS VARCHAR(MAX)) TrainingHour
|
|||
|
FROM
|
|||
|
(SELECT tccc.PAYROLLTYPEID,tccc.[Name],COUNT(tccc.EmployeeID) NoOfParticipants,SUM(tccc.Cost) Cost , SUM(tccc.TotalTrainingMinutes) TotalTrainingMinutes
|
|||
|
FROM
|
|||
|
(SELECT tcc.PAYROLLTYPEID, tcc.[NAME],tcc.EmployeeID,tcc.TrainingScheduleEmployeeID, ISNULL(SUM(tcc.TotalTrainingMinutes),0) TotalTrainingMinutes,ISNULL(SUM(tsec.Amount),0) Cost From
|
|||
|
(SELECT ts.PAYROLLTYPEID,ts.TotalTrainingMinutes, tt.[NAME],tse.EmployeeID,tse.TrainingScheduleEmployeeID
|
|||
|
FROM vw_TrainingSchWithHour ts,TrainingScheduleEmployee tse,TrainingType tt,Training t
|
|||
|
WHERE ts.TrainingScheduleID=tse.TrainingScheduleID AND t.TRAININGID=ts.TRAININGID AND t.TRAININGTYPEID=tt.TRAININGTYPEID
|
|||
|
AND ts.StartDate BETWEEN '{0}' AND '{1}' AND tse.ScheduleEmpStatus IN(2,4) {2} {3} {4} {5}) tcc
|
|||
|
LEFT JOIN TrainingSchEmpCost tsec
|
|||
|
ON tsec.TrainSchEmpID = tcc.TrainingScheduleEmployeeID
|
|||
|
GROUP BY tcc.PAYROLLTYPEID, tcc.[NAME],tcc.EmployeeID,tcc.TrainingScheduleEmployeeID) tccc
|
|||
|
|
|||
|
GROUP BY tccc.[NAME],tccc.PAYROLLTYPEID) t1
|
|||
|
FULL OUTER JOIN
|
|||
|
(SELECT ts.PAYROLLTYPEID, tt.[NAME],COUNT(*) NoOfTrainings
|
|||
|
FROM TrainingSchedule ts,TrainingType tt,Training t
|
|||
|
WHERE t.TRAININGID=ts.TRAININGID AND t.TRAININGTYPEID=tt.TRAININGTYPEID
|
|||
|
AND ts.StartDate BETWEEN '{0}' AND '{1}' {2} {3} {4} {5}
|
|||
|
GROUP BY tt.[NAME],ts.PAYROLLTYPEID) t2
|
|||
|
ON t1.[NAME] = t2.[NAME]
|
|||
|
AND t1.PAYROLLTYPEID = t2.PAYROLLTYPEID) t3,
|
|||
|
PAYROLLTYPE p
|
|||
|
WHERE p.PAYROLLTYPEID=t3.PAYROLLTYPEID ORDER BY t3.PAYROLLTYPEID,t3.TrainingType",
|
|||
|
fromDate.ToString("dd MMM yyyy"), toDate.ToString("dd MMM yyyy"),
|
|||
|
instituteID != 0 ? " AND ts.InstituteID=" + instituteID : "",
|
|||
|
tNature != 0 ? " AND ts.TrainingNatureID=" + tNature : "",
|
|||
|
tTrainingType != 0 ? " AND t.TRAININGTYPEID=" + tTrainingType : "",
|
|||
|
sEmpIDs != string.Empty ? " AND tse.EmployeeID IN (" + sEmpIDs + ")" : "");
|
|||
|
|
|||
|
// string sql = String.Format(@"SELECT p.[DESCRIPTION],t3.* FROM
|
|||
|
// (SELECT ISNULL(t1.PAYROLLTYPEID,t2.PAYROLLTYPEID) PAYROLLTYPEID ,ISNULL(t1.[NAME],t2.NAME) TrainingType,
|
|||
|
// ISNULL(t2.NoOfTrainings,0) NoOfTrainings , ISNULL(t1.NoOfParticipants,0) NoOfParticipants,t1.Cost
|
|||
|
// FROM
|
|||
|
// (SELECT tccc.PAYROLLTYPEID,tccc.[Name],COUNT(tccc.EmployeeID) NoOfParticipants,SUM(tccc.Cost) Cost
|
|||
|
// FROM
|
|||
|
// (SELECT tcc.*,ISNULL(SUM(tsec.Amount),0) Cost From
|
|||
|
// (SELECT ts.PAYROLLTYPEID, tt.[NAME],tse.EmployeeID,tse.TrainingScheduleEmployeeID
|
|||
|
// FROM TrainingSchedule ts,TrainingScheduleEmployee tse,TrainingType tt,Training t
|
|||
|
// WHERE ts.TrainingScheduleID=tse.TrainingScheduleID AND t.TRAININGID=ts.TRAININGID AND t.TRAININGTYPEID=tt.TRAININGTYPEID
|
|||
|
// AND ts.StartDate BETWEEN '{0}' AND '{1}' AND tse.ScheduleEmpStatus IN(2,4) {2} {3} {4} {5}) tcc
|
|||
|
// LEFT JOIN TrainingSchEmpCost tsec
|
|||
|
// ON tsec.TrainSchEmpID = tcc.TrainingScheduleEmployeeID
|
|||
|
// GROUP BY tcc.PAYROLLTYPEID, tcc.[NAME],tcc.EmployeeID,tcc.TrainingScheduleEmployeeID) tccc
|
|||
|
//
|
|||
|
// GROUP BY tccc.[NAME],tccc.PAYROLLTYPEID) t1
|
|||
|
// FULL OUTER JOIN
|
|||
|
// (SELECT ts.PAYROLLTYPEID, tt.[NAME],COUNT(*) NoOfTrainings
|
|||
|
// FROM TrainingSchedule ts,TrainingType tt,Training t
|
|||
|
// WHERE t.TRAININGID=ts.TRAININGID AND t.TRAININGTYPEID=tt.TRAININGTYPEID
|
|||
|
// AND ts.StartDate BETWEEN '{0}' AND '{1}' {2} {3} {4} {5}
|
|||
|
// GROUP BY tt.[NAME],ts.PAYROLLTYPEID) t2
|
|||
|
// ON t1.[NAME] = t2.[NAME]
|
|||
|
// AND t1.PAYROLLTYPEID = t2.PAYROLLTYPEID) t3,
|
|||
|
// PAYROLLTYPE p
|
|||
|
// WHERE p.PAYROLLTYPEID=t3.PAYROLLTYPEID ORDER BY t3.PAYROLLTYPEID,t3.TrainingType", fromDate.ToString("dd MMM yyyy"), toDate.ToString("dd MMM yyyy"),
|
|||
|
// instituteID != 0 ? " AND ts.InstituteID=" + instituteID : "", tNature != 0 ? " AND ts.TrainingNatureID=" + tNature : "", tTrainingType != 0 ? " AND t.TRAININGTYPEID=" + tTrainingType : "",
|
|||
|
// sEmpIDs != string.Empty ? " AND tse.EmployeeID IN (" + sEmpIDs + ")" : "");
|
|||
|
oDataSet = tc.ExecuteDataSet(sql);
|
|||
|
return oDataSet;
|
|||
|
}
|
|||
|
|
|||
|
public static DataSet GetTrainingCostDetailsReport(TransactionContext tc, string sEmpIDs)
|
|||
|
{
|
|||
|
DataSet oDataSet = null;
|
|||
|
string sql = String.Format(
|
|||
|
@"SELECT e.[NAME],tch.TrainingCostHeadID,e.EMPLOYEENO,e.EMPLOYEEID,d.[NAME] Designation,e.DEPARTMENTID,ts.Venue,
|
|||
|
tch.[Name] CostType,tsec.Amount,t.[NAME] TrainingTopics,
|
|||
|
TotalEmp.TotalEmployee,TimeDiff.DiffDate,TimeDiff.DiffHour,TimeDiff.StartDate,TimeDiff.EndDate
|
|||
|
FROM vw_employeedept e JOIN TrainingScheduleEmployee tse ON tse.EmployeeID = e.EMPLOYEEID
|
|||
|
JOIN TrainingSchedule ts ON ts.TrainingScheduleID = tse.TrainingScheduleID
|
|||
|
JOIN TrainingSchEmpCost tsec ON tsec.TrainSchEmpID = tse.TrainingScheduleEmployeeID
|
|||
|
JOIN TrainingCostHead tch ON tch.TrainingCostHeadID = tsec.CostHdID
|
|||
|
JOIN TRAINING t ON t.TRAININGID = ts.TRAININGID
|
|||
|
JOIN DESIGNATION d ON d.DESIGNATIONID = e.DESIGNATIONID
|
|||
|
JOIN (SELECT COUNT(*) TotalEmployee,tse.TrainingScheduleID
|
|||
|
FROM vw_employeedept e, TrainingScheduleEmployee tse
|
|||
|
WHERE e.EMPLOYEEID = tse.EmployeeID
|
|||
|
GROUP BY tse.TrainingScheduleID) TotalEmp ON TotalEmp.TrainingScheduleID = ts.TrainingScheduleID
|
|||
|
JOIN (SELECT ts.TrainingScheduleID,CONVERT(VARCHAR(11),StartDate,106) StartDate,CONVERT(VARCHAR(11),EndDate,106) EndDate,DATEDIFF(day,StartDate,EndDate) DiffDate,DATEDIFF(hh,StartDate,EndDate) DiffHour
|
|||
|
FROM TrainingSchedule ts) TimeDiff ON TimeDiff.TrainingScheduleID=ts.TrainingScheduleID
|
|||
|
WHERE e.EMPLOYEEID IN({0})
|
|||
|
ORDER BY d.CODE
|
|||
|
", sEmpIDs);
|
|||
|
oDataSet = tc.ExecuteDataSet(sql);
|
|||
|
return oDataSet;
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Insert Function
|
|||
|
|
|||
|
public static void Insert(TransactionContext tc, Training oItem)
|
|||
|
{
|
|||
|
tc.ExecuteNonQuery(
|
|||
|
"INSERT INTO Training(TRAININGID, CODE, Name,TRAININGTYPEID,STANDARDDURATION,LEARNINGOBJECTIVE,STANDARDCOST,CREATEDBY,CREATEDDATE)" +
|
|||
|
" VALUES(%n,%s,%s,%n,%n,%s,%n,%n,%d)", oItem.ID, oItem.Code, oItem.Name,
|
|||
|
DataReader.GetNullValue(oItem.TrainingTypeID, 0), DataReader.GetNullValue(oItem.TrainingDuration),
|
|||
|
DataReader.GetNullValue(oItem.LearningObjective), DataReader.GetNullValue(oItem.StandardCost),
|
|||
|
DataReader.GetNullValue(oItem.CreatedBy), DataReader.GetNullValue(oItem.CreatedDate));
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Update Function
|
|||
|
|
|||
|
public static void Update(TransactionContext tc, Training oItem)
|
|||
|
{
|
|||
|
tc.ExecuteNonQuery(
|
|||
|
"UPDATE Training SET CODE=%s,Name=%s,TRAININGTYPEID=%n,STANDARDDURATION=%n,LEARNINGOBJECTIVE=%s,STANDARDCOST=%n,MODIFIEDBY=%n,MODIFIEDDATE=%d" +
|
|||
|
" WHERE TRAININGID=%n", oItem.Code, oItem.Name, DataReader.GetNullValue(oItem.TrainingTypeID, 0),
|
|||
|
DataReader.GetNullValue(oItem.TrainingDuration), DataReader.GetNullValue(oItem.LearningObjective),
|
|||
|
DataReader.GetNullValue(oItem.StandardCost), DataReader.GetNullValue(oItem.ModifiedBy),
|
|||
|
DataReader.GetNullValue(oItem.ModifiedDate), oItem.ID);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Delete Function
|
|||
|
|
|||
|
public static void Delete(TransactionContext tc, int id)
|
|||
|
{
|
|||
|
tc.ExecuteNonQuery("Delete from Training where TRAININGID=%n", id);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
|
|||
|
public static bool IsExists(string TableName, string ColName, string sCode, TransactionContext tc)
|
|||
|
{
|
|||
|
object ob = tc.ExecuteScalar("SELECT COUNT(*) FROM " + TableName + " WHERE " + ColName + "=%s", sCode);
|
|||
|
return (Convert.ToInt32(ob) > 0);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
public static DataSet GetTrainingCostingInfoReport(TransactionContext tc, string sEmpIDs, DateTime dFromDate,
|
|||
|
DateTime dToDate, int tNature, int instituteID, int tTrainingType, int payrollTypeID)
|
|||
|
{
|
|||
|
DataSet oDataSet = null;
|
|||
|
string sql = string.Empty;
|
|||
|
if (tTrainingType > 0)
|
|||
|
{
|
|||
|
sql = String.Format(
|
|||
|
@"SELECT ISNULL(lt.DEPARTMENTID,ft.DEPARTMENTID) DepartmentID, ISNULL(lt.DeptName,ft.DeptName) DeptName,ISNULL(lt.localNoOfTraining,0) localNoOfTraining, ISNULL(lt.EmpCount,0) locEmpCount,ISNULL(lt.Cost,0) locCost,
|
|||
|
ISNULL(ft.forNoOfTraining,0) forNoOfTraining, ISNULL(ft.EmpCount,0) forEmpCount,ISNULL(ft.Cost,0) forCost
|
|||
|
From
|
|||
|
|
|||
|
( SELECT ltt.*,dlsc.localNoOfTraining FROM
|
|||
|
(SELECT dpt.DEPARTMENTID,dpt.DeptName, Count(*) EmpCount, SUM(TC.Amount) Cost FROM
|
|||
|
(SELECT d.DEPARTMENTID,d.DESCRIPTION DeptName ,e.EMPLOYEEID,tse.TrainingScheduleEmployeeID
|
|||
|
FROM TrainingScheduleEmployee tse,vw_employeedept e,Department d ,TrainingSchedule ts ,Training t
|
|||
|
WHERE t.TRAININGID=ts.TRAININGID AND e.EmployeeID=tse.EmployeeID AND t.TRAININGTYPEID={6} AND d.DEPARTMENTID=e.DEPARTMENTID AND ts.TrainingScheduleID=tse.TrainingScheduleID
|
|||
|
AND e.DEPARTMENTID = d.DEPARTMENTID AND e.PAYROLLTYPEID = {5} AND ts.StartDate BETWEEN '{0}' AND '{1}' {2} {3} {4}) dpt
|
|||
|
LEFT JOIN
|
|||
|
(SELECT SUM(tsec.Amount) Amount,tsec.TrainSchEmpID FROM TrainingSchEmpCost tsec GROUP BY tsec.TrainSchEmpID) TC
|
|||
|
ON TC.TrainSchEmpID=dpt.TrainingScheduleEmployeeID
|
|||
|
GROUP BY dpt.DEPARTMENTID,dpt.DeptName) ltt
|
|||
|
LEFT JOIN
|
|||
|
(SELECT e.DEPARTMENTID,Count(DISTINCT tse.TrainingScheduleID) localNoOfTraining
|
|||
|
FROM TrainingSchedule ts, TrainingScheduleEmployee tse , vw_employeedept e ,Training t
|
|||
|
WHERE t.TRAININGID=ts.TRAININGID AND
|
|||
|
e.EMPLOYEEID = tse.EmployeeID AND ts.TrainingScheduleID=tse.TrainingScheduleID AND ts.StartDate BETWEEN '{0}' AND '{1}' AND t.TRAININGTYPEID={6} {2} {3} {4}
|
|||
|
Group BY e.DEPARTMENTID ) dlsc
|
|||
|
ON ltt.DEPARTMENTID=dlsc.DEPARTMENTID) lt
|
|||
|
|
|||
|
FULL OUTER JOIN
|
|||
|
(SELECT ftt.*,dfsc.forNoOfTraining FROM
|
|||
|
(SELECT dpt.DEPARTMENTID,dpt.DeptName, Count(*) EmpCount, SUM(TC.Amount) Cost FROM
|
|||
|
(SELECT d.DEPARTMENTID,d.DESCRIPTION DeptName ,e.EMPLOYEEID,tse.TrainingScheduleEmployeeID
|
|||
|
FROM TrainingScheduleEmployee tse,vw_employeedept e,Department d ,TrainingSchedule ts ,Training t
|
|||
|
WHERE t.TRAININGID=ts.TRAININGID AND e.EmployeeID=tse.EmployeeID AND t.TRAININGTYPEID ={7} AND d.DEPARTMENTID=e.DEPARTMENTID AND ts.TrainingScheduleID=tse.TrainingScheduleID
|
|||
|
AND e.DEPARTMENTID = d.DEPARTMENTID AND e.PAYROLLTYPEID = {5} AND ts.StartDate BETWEEN '{0}' AND '{1}' {2} {3} {4}) dpt
|
|||
|
LEFT JOIN
|
|||
|
(SELECT SUM(tsec.Amount) Amount,tsec.TrainSchEmpID FROM TrainingSchEmpCost tsec GROUP BY tsec.TrainSchEmpID) TC
|
|||
|
ON TC.TrainSchEmpID=dpt.TrainingScheduleEmployeeID
|
|||
|
GROUP BY dpt.DEPARTMENTID,dpt.DeptName)ftt
|
|||
|
LEFT JOIN
|
|||
|
(SELECT e.DEPARTMENTID,Count(DISTINCT tse.TrainingScheduleID) forNoOfTraining
|
|||
|
FROM TrainingSchedule ts, TrainingScheduleEmployee tse , vw_employeedept e ,Training t
|
|||
|
WHERE t.TRAININGID=ts.TRAININGID AND
|
|||
|
e.EMPLOYEEID = tse.EmployeeID AND ts.TrainingScheduleID=tse.TrainingScheduleID AND ts.StartDate BETWEEN '{0}' AND '{1}' AND t.TRAININGTYPEID={7} {2} {3} {4}
|
|||
|
Group BY e.DEPARTMENTID) dfsc
|
|||
|
ON ftt.DEPARTMENTID=dfsc.DEPARTMENTID) ft
|
|||
|
|
|||
|
ON lt.DepartmentID=ft.DepartmentID", dFromDate.ToString("dd MMM yyyy"),
|
|||
|
dToDate.ToString("dd MMM yyyy"), instituteID != 0 ? " AND ts.InstituteID=" + instituteID : "",
|
|||
|
tNature != 0 ? " AND ts.TrainingNatureID=" + tNature : "",
|
|||
|
sEmpIDs != string.Empty ? " AND tse.EmployeeID IN (" + sEmpIDs + ")" : "", payrollTypeID,
|
|||
|
tTrainingType != 4 ? tTrainingType : 0, tTrainingType != 4 ? 0 : tTrainingType);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
sql = String.Format(
|
|||
|
@"SELECT ISNULL(lt.DEPARTMENTID,ft.DEPARTMENTID) DepartmentID, ISNULL(lt.DeptName,ft.DeptName) DeptName,ISNULL(lt.localNoOfTraining,0) localNoOfTraining, ISNULL(lt.EmpCount,0) locEmpCount,ISNULL(lt.Cost,0) locCost,
|
|||
|
ISNULL(ft.forNoOfTraining,0) forNoOfTraining, ISNULL(ft.EmpCount,0) forEmpCount,ISNULL(ft.Cost,0) forCost
|
|||
|
From
|
|||
|
|
|||
|
( SELECT ltt.*,dlsc.localNoOfTraining FROM
|
|||
|
(SELECT dpt.DEPARTMENTID,dpt.DeptName, Count(*) EmpCount, SUM(TC.Amount) Cost FROM
|
|||
|
(SELECT d.DEPARTMENTID,d.DESCRIPTION DeptName ,e.EMPLOYEEID,tse.TrainingScheduleEmployeeID
|
|||
|
FROM TrainingScheduleEmployee tse,vw_employeedept e,Department d ,TrainingSchedule ts ,Training t
|
|||
|
WHERE t.TRAININGID=ts.TRAININGID AND e.EmployeeID=tse.EmployeeID AND t.TRAININGTYPEID NOT IN (4) AND d.DEPARTMENTID=e.DEPARTMENTID AND ts.TrainingScheduleID=tse.TrainingScheduleID
|
|||
|
AND e.DEPARTMENTID = d.DEPARTMENTID AND e.PAYROLLTYPEID = {5} AND ts.StartDate BETWEEN '{0}' AND '{1}' {2} {3} {4}) dpt
|
|||
|
LEFT JOIN
|
|||
|
(SELECT SUM(tsec.Amount) Amount,tsec.TrainSchEmpID FROM TrainingSchEmpCost tsec GROUP BY tsec.TrainSchEmpID) TC
|
|||
|
ON TC.TrainSchEmpID=dpt.TrainingScheduleEmployeeID
|
|||
|
GROUP BY dpt.DEPARTMENTID,dpt.DeptName) ltt
|
|||
|
LEFT JOIN
|
|||
|
(SELECT e.DEPARTMENTID,Count(DISTINCT tse.TrainingScheduleID) localNoOfTraining
|
|||
|
FROM TrainingSchedule ts, TrainingScheduleEmployee tse , vw_employeedept e ,Training t
|
|||
|
WHERE t.TRAININGID=ts.TRAININGID AND
|
|||
|
e.EMPLOYEEID = tse.EmployeeID AND ts.TrainingScheduleID=tse.TrainingScheduleID AND ts.StartDate BETWEEN '{0}' AND '{1}' AND t.TRAININGTYPEID NOT IN (4) {2} {3} {4}
|
|||
|
Group BY e.DEPARTMENTID ) dlsc
|
|||
|
ON ltt.DEPARTMENTID=dlsc.DEPARTMENTID) lt
|
|||
|
|
|||
|
FULL OUTER JOIN
|
|||
|
(SELECT ftt.*,dfsc.forNoOfTraining FROM
|
|||
|
(SELECT dpt.DEPARTMENTID,dpt.DeptName, Count(*) EmpCount, SUM(TC.Amount) Cost FROM
|
|||
|
(SELECT d.DEPARTMENTID,d.DESCRIPTION DeptName ,e.EMPLOYEEID,tse.TrainingScheduleEmployeeID
|
|||
|
FROM TrainingScheduleEmployee tse,vw_employeedept e,Department d ,TrainingSchedule ts ,Training t
|
|||
|
WHERE t.TRAININGID=ts.TRAININGID AND e.EmployeeID=tse.EmployeeID AND t.TRAININGTYPEID IN (4) AND d.DEPARTMENTID=e.DEPARTMENTID AND ts.TrainingScheduleID=tse.TrainingScheduleID
|
|||
|
AND e.DEPARTMENTID = d.DEPARTMENTID AND e.PAYROLLTYPEID = {5} AND ts.StartDate BETWEEN '{0}' AND '{1}' {2} {3} {4}) dpt
|
|||
|
LEFT JOIN
|
|||
|
(SELECT SUM(tsec.Amount) Amount,tsec.TrainSchEmpID FROM TrainingSchEmpCost tsec GROUP BY tsec.TrainSchEmpID) TC
|
|||
|
ON TC.TrainSchEmpID=dpt.TrainingScheduleEmployeeID
|
|||
|
GROUP BY dpt.DEPARTMENTID,dpt.DeptName)ftt
|
|||
|
LEFT JOIN
|
|||
|
(SELECT e.DEPARTMENTID,Count(DISTINCT tse.TrainingScheduleID) forNoOfTraining
|
|||
|
FROM TrainingSchedule ts, TrainingScheduleEmployee tse , vw_employeedept e ,Training t
|
|||
|
WHERE t.TRAININGID=ts.TRAININGID AND
|
|||
|
e.EMPLOYEEID = tse.EmployeeID AND ts.TrainingScheduleID=tse.TrainingScheduleID AND ts.StartDate BETWEEN '{0}' AND '{1}' AND t.TRAININGTYPEID IN (4) {2} {3} {4}
|
|||
|
Group BY e.DEPARTMENTID) dfsc
|
|||
|
ON ftt.DEPARTMENTID=dfsc.DEPARTMENTID) ft
|
|||
|
|
|||
|
ON lt.DepartmentID=ft.DepartmentID", dFromDate.ToString("dd MMM yyyy"),
|
|||
|
dToDate.ToString("dd MMM yyyy"), instituteID != 0 ? " AND ts.InstituteID=" + instituteID : "",
|
|||
|
tNature != 0 ? " AND ts.TrainingNatureID=" + tNature : "",
|
|||
|
sEmpIDs != string.Empty ? " AND tse.EmployeeID IN (" + sEmpIDs + ")" : "", payrollTypeID);
|
|||
|
}
|
|||
|
|
|||
|
oDataSet = tc.ExecuteDataSet(sql);
|
|||
|
|
|||
|
return oDataSet;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|