EchoTex_Payroll/HRM.DA/DA/ExceptionReports/SGSExceptionReportDA.cs
2024-10-14 10:01:49 +06:00

728 lines
69 KiB
C#

using Ease.Core.DataAccess;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HRM.DA
{
internal class SGSExceptionReportDA
{
internal static DataSet GetEmpSalarySheet(TransactionContext tc, DateTime dateTime, string sEmpID)
{
DataSet rootDataset = new DataSet();
DataSet tempdataset = new DataSet();
try
{
//string query1 = SQLParser.MakeSQL("select A.EmployeeNo, A.Name,A.GName,A.DName,A.GCode,A.SequenceNo,"
// + " A.Description, SUM(A.changedamount) Amount"
// + " from"
// + "(select S.EmployeeID, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode, "
// + " sd.ItemID, sd.Description,sd.Position, sd.changedamount,G.DESCRIPTION as GName,D.Name as DName,G.Code as GCode,G.SequenceNo"
// + " from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd "
// + " where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d and Sd.ItemGroup in(8) AND sd.ItemCode not in(-133) AND S.EmployeeID IN(%q) "
// + " UNION "
// + " select S.EmployeeID, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode, "
// + " sd.ItemID, sd.Description,sd.Position, sd.changedamount,G.DESCRIPTION as GName,D.Name as DName,G.Code as GCode,G.SequenceNo from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd "
// + " where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d and Sd.ItemGroup in(1) AND sd.ItemCode not in(-133) AND S.EmployeeID IN(%q) "
// + " ) A group by "
// + " A.EmployeeID, A.EmployeeNo, A.Name,A.GName,A.DName,A.SequenceNo,A.GCode,"
// + " A.ItemCode, A.ItemID, A.Description,A.Position order by A.Position,A.SequenceNo,A.GCode,A.EmployeeNo",
// dateTime, sEmpID, dateTime, sEmpID, dateTime, sEmpID);
//string query1 = SQLParser.MakeSQL(@"select A.EmployeeNo,A.Name,A.GName,A.DName,A.GCode,A.Description,
// SUM(A.changedamount) Amount from
// (select S.EmployeeID, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode, sd.ItemID,
// sd.Description,sd.Position, sd.changedamount,G.DESCRIPTION as GName,D.Name as DName,
// G.Code as GCode,G.SequenceNo from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S,
// SalaryMonthlyDetail Sd where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID
// AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID
// AND S.SalaryMonth=%d and Sd.ItemGroup in(1,8) AND sd.ItemCode not in(-133)
// AND S.EmployeeID IN(%q) ) A
// group by A.EmployeeID, A.EmployeeNo, A.Name,A.GName,A.DName,A.GCode,
// A.ItemCode, A.ItemID, A.Description order by
// A.GCode,A.EmployeeNo,A.Description",
// dateTime, sEmpID);
string query1 = SQLParser.MakeSQL(@"select A.EmployeeNo,A.Name,A.GName,A.DName,A.GCode,A.Description,
SUM(A.changedamount) Amount, A.ITEMID, A.ITEMCODE from
(select S.EmployeeID, E.EmployeeNo, E.Name,sd.ItemCode, sd.ItemID,
sd.Description,sd.Position, sd.changedamount,G.DESCRIPTION as GName,D.Name as DName,
G.Code as GCode,G.SequenceNo from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S,
SalaryMonthlyDetail Sd where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID
AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID
AND S.SalaryMonth=%d and Sd.ItemGroup in(1,8) AND sd.ItemCode not in(-133)
AND S.EmployeeID IN(%q)
Union
select S.EmployeeID, E.EmployeeNo, E.Name,sd.ItemCode, sd.ItemID,
sd.Description,sd.Position, -sd.changedamount,G.DESCRIPTION as GName,D.Name as DName,
G.Code as GCode,G.SequenceNo from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S,
SalaryMonthlyDetail Sd where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID
AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID
AND S.SalaryMonth=%d and Sd.ItemGroup in(2) AND sd.ItemCode not in(-133)
AND S.EmployeeID IN(%q)
) A
group by A.EmployeeID, A.EmployeeNo, A.Name,A.GName,A.DName,A.GCode,
A.ItemCode, A.ItemID, A.Description order by
A.GCode,A.EmployeeNo,A.Description", dateTime, sEmpID, dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet(query1);
//tempdataset = tc.ExecuteDataSet("select A.EmployeeNo, A.Name,A.GName,A.DName,A.GCode,A.SequenceNo,"
// + " A.Description, SUM(A.changedamount) Amount"
// + " from"
// + "(select S.EmployeeID, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode, "
// + " sd.ItemID, sd.Description,sd.Position, sd.changedamount,G.DESCRIPTION as GName,D.Name as DName,G.Code as GCode,G.SequenceNo"
// + " from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd "
// + " where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d and Sd.ItemGroup in(8) AND sd.ItemCode not in(-133) AND S.EmployeeID IN(%q) "
// + " UNION "
// + " select S.EmployeeID, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode, "
// + " sd.ItemID, sd.Description,sd.Position, sd.changedamount,G.DESCRIPTION as GName,D.Name as DName,G.Code as GCode,G.SequenceNo from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd "
// + " where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d and Sd.ItemGroup in(1) AND sd.ItemCode not in(-133) AND S.EmployeeID IN(%q) "
// + " ) A group by "
// + " A.EmployeeID, A.EmployeeNo, A.Name,A.GName,A.DName,A.SequenceNo,A.GCode,"
// + " A.ItemCode, A.ItemID, A.Description,A.Position order by A.Position,A.SequenceNo,A.GCode,A.EmployeeNo",
// dateTime, sEmpID, dateTime, sEmpID, dateTime, sEmpID);
tempdataset.Tables[0].TableName = "GrossItem";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query2 = SQLParser.MakeSQL("select E.EmployeeNo, E.Name,A.GName,A.GCode,A.SequenceNo,A.DName,'Total Gross' as Description, Sum(A.amount) as amount "
+ " from"
+ "( select S.EmployeeID, Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,G.Code as GCode,G.SequenceNo,D.Name as DName "
+ " from SALARYMONTHLY S,Grades G,DESIGNATION D, SalaryMonthlyDetail Sd "
+ " where S.SalaryMonthlyID=Sd.SalaryMonthlyID "
+ " AND G.GRADEID=S.GRADEID AND D.DESIGNATIONID=S.DESIGNATIONID AND S.SalaryMonth=%d and Sd.ItemGroup IN (1, 8) AND S.EmployeeID IN(%q) "
+ " group by S.EmployeeID,G.DESCRIPTION,G.SequenceNo,G.Code,D.Name "
+ " UNION"
+ " select S.EmployeeID, -Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,G.Code as GCode,G.sequenceNo,D.Name as DName"
+ " from GRADES G,DESIGNATION D,SALARYMONTHLY S, SalaryMonthlyDetail Sd "
+ " where S.SalaryMonthlyID=Sd.SalaryMonthlyID "
+ " AND S.SalaryMonth=%d AND G.GRADEID=S.GRADEID AND D.DESIGNATIONID=S.DESIGNATIONID and Sd.ItemGroup IN (2) AND S.EmployeeID IN(%q) "
+ " group by S.EmployeeID,G.DESCRIPTION,G.SequenceNo,G.Code,D.Name "
+ " ) A, Employee E where A.EmployeeID = E.EmployeeID "
+ " group by E.EmployeeNo, E.Name,A.GName,A.SequenceNo,A.GCode,A.DName ", dateTime, sEmpID, dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet(query2);
tempdataset.Tables[0].TableName = "TotalGross";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
//string query3 = SQLParser.MakeSQL("select A.EmployeeNo, A.Name,A.GName,A.GCode,A.SequenceNo,A.DName,"
// + " A.Description, SUM(A.changedamount) Amount"
// + " from "
// + "(select S.EmployeeID, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode, "
// + " sd.ItemID, sd.Description,sd.Position, sd.changedamount,G.DESCRIPTION as GName,G.Code as GCode,G.SequenceNo,D.Name as DName "
// + " from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd "
// + " where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d and Sd.ItemGroup=3 AND S.EmployeeID IN(%q) "
// + " union"
// + " select S.EmployeeID, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode, "
// + " sd.ItemID, sd.Description,sd.Position, -sd.changedamount,G.DESCRIPTION as GName,G.Code as GCode,G.sequenceNo,D.Name as DName"
// + " from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd "
// + " where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d and Sd.ItemGroup=2 AND S.EmployeeID IN(%q) "
// + " ) A group by "
// + " A.EmployeeID, A.EmployeeNo, A.Name,A.GName,A.SequenceNo,A.GCode,A.DName, "
// + " A.ItemCode, A.ItemID, A.Description,A.Position order by A.Position,A.SequenceNo,A.GCode,A.EmployeeNo",
// dateTime, sEmpID, dateTime, sEmpID);
string query3 = SQLParser.MakeSQL("select A.EmployeeNo, A.Name,A.GName,A.GCode,A.SequenceNo,A.DName,"
+ " A.Description, SUM(A.changedamount) Amount"
+ " from "
+ "(select S.EmployeeID, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode, "
+ " sd.ItemID, sd.Description,sd.Position, sd.changedamount,G.DESCRIPTION as GName,G.Code as GCode,G.SequenceNo,D.Name as DName "
+ " from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd "
+ " where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d and Sd.ItemGroup=3 AND S.EmployeeID IN(%q) "
+" ) A group by "
+ " A.EmployeeID, A.EmployeeNo, A.Name,A.GName,A.SequenceNo,A.GCode,A.DName, "
+ " A.ItemCode, A.ItemID, A.Description,A.Position order by A.Position,A.SequenceNo,A.GCode,A.EmployeeNo",
dateTime, sEmpID);
// string query3 = SQLParser.MakeSQL(@"select A.EmployeeNo,A.Name,A.GName,A.DName,A.GCode,A.Description,
// SUM(A.changedamount) Amount, A.ITEMID, A.ITEMCODE from
// (select S.EmployeeID, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode, sd.ItemID,
// sd.Description,sd.Position, sd.changedamount,G.DESCRIPTION as GName,D.Name as DName,
// G.Code as GCode,G.SequenceNo from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S,
// SalaryMonthlyDetail Sd where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID
// AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID
// AND S.SalaryMonth=%d and Sd.ItemGroup in(1,8) AND sd.ItemCode not in(-133)
// AND S.EmployeeID IN(%n)
//Union
//select S.EmployeeID, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode, sd.ItemID,
// sd.Description,sd.Position, -sd.changedamount,G.DESCRIPTION as GName,D.Name as DName,
// G.Code as GCode,G.SequenceNo from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S,
// SalaryMonthlyDetail Sd where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID
// AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID
// AND S.SalaryMonth=%d and Sd.ItemGroup in(2) AND sd.ItemCode not in(-133)
// AND S.EmployeeID IN(%n)
//) A
// group by A.EmployeeID, A.EmployeeNo, A.Name,A.GName,A.DName,A.GCode,
// A.ItemCode, A.ItemID, A.Description order by
// A.GCode,A.EmployeeNo,A.Description", dateTime, sEmpID, dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet(query3);
tempdataset.Tables[0].TableName = "DeductItem";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query4 = SQLParser.MakeSQL("select A.EmployeeNo, A.Name,A.GName,A.GCode,A.SequenceNo,A.DName,"
+ " A.Description, SUM(A.changedamount) Amount"
+ " from"
+ " ("
+ " select S.EmployeeID, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode, "
+ " sd.ItemID, sd.Description,sd.Position, sd.changedamount,G.DESCRIPTION as GName,G.Code as GCode,G.SequenceNo,D.Name as DName"
+ " from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd "
+ " where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d and Sd.ITEMCODE =-133 AND S.EmployeeID IN(%q) "
+ " UNION "
+ " select S.EmployeeID, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode, "
+ " sd.ItemID, sd.Description,sd.Position, sd.changedamount,G.DESCRIPTION as GName,G.Code as GCode,G.SequenceNo,D.Name as DName from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd "
+ " where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d and Sd.ITEMCODE =-133 AND S.EmployeeID IN(%q) "
+ " ) A group by "
+ " A.EmployeeID, A.EmployeeNo, A.Name,A.GName,A.SequenceNo,A.GCode,A.DName,"
+ " A.ItemCode, A.ItemID, A.Description,A.Position order by A.Position,A.SequenceNo,A.GCode,A.EmployeeNo", dateTime, sEmpID, dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet("select A.EmployeeNo, A.Name,A.GName,A.GCode,A.SequenceNo,A.DName,"
+ " A.Description, SUM(A.changedamount) Amount"
+ " from"
+ " ("
+ " select S.EmployeeID, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode, "
+ " sd.ItemID, sd.Description,sd.Position, sd.changedamount,G.DESCRIPTION as GName,G.Code as GCode,G.SequenceNo,D.Name as DName"
+ " from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd "
+ " where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d and Sd.ITEMCODE =-133 AND S.EmployeeID IN(%q) "
+ " UNION "
+ " select S.EmployeeID, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode, "
+ " sd.ItemID, sd.Description,sd.Position, sd.changedamount,G.DESCRIPTION as GName,G.Code as GCode,G.SequenceNo,D.Name as DName from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd "
+ " where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d and Sd.ITEMCODE =-133 AND S.EmployeeID IN(%q) "
+ " ) A group by "
+ " A.EmployeeID, A.EmployeeNo, A.Name,A.GName,A.SequenceNo,A.GCode,A.DName,"
+ " A.ItemCode, A.ItemID, A.Description,A.Position order by A.Position,A.SequenceNo,A.GCode,A.EmployeeNo", dateTime, sEmpID, dateTime, sEmpID);
tempdataset.Tables[0].TableName = "LeaveDays";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query5 = SQLParser.MakeSQL("select E.EmployeeNo, E.Name,A.GName,A.GCode,A.sequenceNo,A.DName, 'UnAuthorized' as Description, Sum(A.amount) as amount "
+ " from"
+ " ( select S.EmployeeID, Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,G.Code as GCode,G.SequenceNo,D.Name as DName "
+ " from GRADES G,DESIGNATION D,SALARYMONTHLY S,SalaryMonthlyDetail Sd "
+ " where S.SalaryMonthlyID=Sd.SalaryMonthlyID "
+ " AND S.SalaryMonth=%d AND G.GRADEID=S.GRADEID AND D.DESIGNATIONID=S.DESIGNATIONID and Sd.ItemGroup IN (2) AND S.EmployeeID IN(%q) "
+ " group by S.EmployeeID,G.DESCRIPTION,G.SequenceNo,G.Code,D.Name"
+ " ) A, Employee E where A.EmployeeID = E.EmployeeID group by E.EmployeeNo, E.Name,A.GName,A.SequenceNo,A.GCode,A.DName", dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet("select E.EmployeeNo, E.Name,A.GName,A.GCode,A.sequenceNo,A.DName, 'UnAuthorized' as Description, Sum(A.amount) as amount "
+ " from"
+ " ( select S.EmployeeID, Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,G.Code as GCode,G.SequenceNo,D.Name as DName "
+ " from GRADES G,DESIGNATION D,SALARYMONTHLY S,SalaryMonthlyDetail Sd "
+ " where S.SalaryMonthlyID=Sd.SalaryMonthlyID "
+ " AND S.SalaryMonth=%d AND G.GRADEID=S.GRADEID AND D.DESIGNATIONID=S.DESIGNATIONID and Sd.ItemGroup IN (2) AND S.EmployeeID IN(%q) "
+ " group by S.EmployeeID,G.DESCRIPTION,G.SequenceNo,G.Code,D.Name"
+ " ) A, Employee E where A.EmployeeID = E.EmployeeID group by E.EmployeeNo, E.Name,A.GName,A.SequenceNo,A.GCode,A.DName", dateTime, sEmpID);
tempdataset.Tables[0].TableName = "UnAuthorized";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query6 = SQLParser.MakeSQL("select E.EmployeeNo, E.Name,A.GName,A.GCode,A.SequenceNo,A.DName, 'Total Deduction' as Description, Sum(A.amount) as amount "
+ " from"
+ "( select S.EmployeeID, Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,G.Code as GCode,G.SequenceNo,D.Name as DName "
+ " from GRADES G,DESIGNATION D,SALARYMONTHLY S,SalaryMonthlyDetail Sd "
+ " where S.SalaryMonthlyID=Sd.SalaryMonthlyID "
+ " AND S.SalaryMonth=%d AND G.GRADEID=S.GRADEID AND D.DESIGNATIONID=S.DESIGNATIONID and Sd.ItemGroup IN (2,3) AND S.EmployeeID IN(%q) "
+ " group by S.EmployeeID,G.DESCRIPTION,G.SequenceNo,G.Code,D.Name"
+ " ) A, Employee E where A.EmployeeID = E.EmployeeID group by E.EmployeeNo, E.Name,A.GName,A.SequenceNo,A.GCode,A.DName ", dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet("select E.EmployeeNo, E.Name,A.GName,A.GCode,A.SequenceNo,A.DName, 'Total Deduction' as Description, Sum(A.amount) as amount "
+ " from"
+ "( select S.EmployeeID, Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,G.Code as GCode,G.SequenceNo,D.Name as DName "
+ " from GRADES G,DESIGNATION D,SALARYMONTHLY S,SalaryMonthlyDetail Sd "
+ " where S.SalaryMonthlyID=Sd.SalaryMonthlyID "
+ " AND S.SalaryMonth=%d AND G.GRADEID=S.GRADEID AND D.DESIGNATIONID=S.DESIGNATIONID and Sd.ItemGroup IN (2,3) AND S.EmployeeID IN(%q) "
+ " group by S.EmployeeID,G.DESCRIPTION,G.SequenceNo,G.Code,D.Name"
+ " ) A, Employee E where A.EmployeeID = E.EmployeeID group by E.EmployeeNo, E.Name,A.GName,A.SequenceNo,A.GCode,A.DName ", dateTime, sEmpID);
tempdataset.Tables[0].TableName = "TotalDeduction";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query7 = SQLParser.MakeSQL("Select E.EMPLOYEENO,E.NAME,G.DESCRIPTION as GName,G.Code as GCode,G.SequenceNo,D.Name as DName ,'Net Pay' as Description,SD.CHANGEDAMOUNT as Amount"
+ " from EMPLOYEE as E,GRADES as G,DESIGNATION D,SALARYMONTHLY as S,SALARYMONTHLYDETAIL as Sd"
+ " where S.SalaryMonthlyID=Sd.SalaryMonthlyID "
+ " AND S.SalaryMonth=%d"
+ " AND G.GRADEID=S.GRADEID "
+ " AND D.DESIGNATIONID=S.DESIGNATIONID "
+ " AND E.EMPLOYEEID =S.EMPLOYEEID "
+ " and Sd.ItemGroup IN (5) AND Sd.ItemCode IN(-132) AND S.EmployeeID IN(%q)"
+ " order by G.SequenceNo,G.Code,E.EMPLOYEENO ", dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet("Select E.EMPLOYEENO,E.NAME,G.DESCRIPTION as GName,G.Code as GCode,G.SequenceNo,D.Name as DName ,'Net Pay' as Description,SD.CHANGEDAMOUNT as Amount"
+ " from EMPLOYEE as E,GRADES as G,DESIGNATION D,SALARYMONTHLY as S,SALARYMONTHLYDETAIL as Sd"
+ " where S.SalaryMonthlyID=Sd.SalaryMonthlyID "
+ " AND S.SalaryMonth=%d"
+ " AND G.GRADEID=S.GRADEID "
+ " AND D.DESIGNATIONID=S.DESIGNATIONID "
+ " AND E.EMPLOYEEID =S.EMPLOYEEID "
+ " and Sd.ItemGroup IN (5) AND Sd.ItemCode IN(-132) AND S.EmployeeID IN(%q)"
+ " order by G.SequenceNo,G.Code,E.EMPLOYEENO ", dateTime, sEmpID);
tempdataset.Tables[0].TableName = "NetPay";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return rootDataset;
}
internal static DataSet GetEmpPrevDataForSRecon(TransactionContext tc, DateTime dateTime)
{
DataSet rootDataset = new DataSet();
DataSet tempdataset = new DataSet();
try
{
string tempSql = SQLParser.MakeSQL("select A.EmployeeNo, A.Name,A.GName,A.DName,A.GCode,A.SequenceNo,"
+ " A.Description, SUM(A.changedamount) Amount"
+ " from"
+ "(select S.EmployeeID, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode, "
+ " sd.ItemID, sd.Description,sd.Position, sd.changedamount,G.DESCRIPTION as GName,D.Name as DName,G.Code as GCode,G.SequenceNo"
+ " from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd "
+ " where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d and Sd.ItemGroup in(8) AND sd.ItemCode not in(-133) "
+ " UNION "
+ " select S.EmployeeID, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode, "
+ " sd.ItemID, sd.Description,sd.Position, sd.changedamount,G.DESCRIPTION as GName,D.Name as DName,G.Code as GCode,G.SequenceNo from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd "
+ " where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d and Sd.ItemGroup in(1) AND sd.ItemCode not in(-133) "
+ " ) A group by "
+ " A.EmployeeID, A.EmployeeNo, A.Name,A.GName,A.DName,A.SequenceNo,A.GCode,"
+ " A.ItemCode, A.ItemID, A.Description,A.Position order by A.Position,A.SequenceNo,A.GCode,A.EmployeeNo",
dateTime, dateTime, dateTime);
tempdataset = tc.ExecuteDataSet(tempSql);
tempdataset.Tables[0].TableName = "GrossItem";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
tempSql = SQLParser.MakeSQL("select E.EmployeeNo, E.Name,A.GName,A.GCode,A.SequenceNo,A.DName,'Total Gross' as Description, Sum(A.amount) as amount "
+ " from"
+ "( select S.EmployeeID, Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,G.Code as GCode,G.SequenceNo,D.Name as DName "
+ " from SALARYMONTHLY S,Grades G,DESIGNATION D, SalaryMonthlyDetail Sd "
+ " where S.SalaryMonthlyID=Sd.SalaryMonthlyID "
+ " AND G.GRADEID=S.GRADEID AND D.DESIGNATIONID=S.DESIGNATIONID AND S.SalaryMonth=%d and Sd.ItemGroup IN (1, 8) "
+ " group by S.EmployeeID,G.DESCRIPTION,G.SequenceNo,G.Code,D.Name "
+ " UNION"
+ " select S.EmployeeID, -Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,G.Code as GCode,G.sequenceNo,D.Name as DName"
+ " from GRADES G,DESIGNATION D,SALARYMONTHLY S, SalaryMonthlyDetail Sd "
+ " where S.SalaryMonthlyID=Sd.SalaryMonthlyID "
+ " AND S.SalaryMonth=%d AND G.GRADEID=S.GRADEID AND D.DESIGNATIONID=S.DESIGNATIONID and Sd.ItemGroup IN (2) "
+ " group by S.EmployeeID,G.DESCRIPTION,G.SequenceNo,G.Code,D.Name "
+ " ) A, Employee E where A.EmployeeID = E.EmployeeID "
+ " group by E.EmployeeNo, E.Name,A.GName,A.SequenceNo,A.GCode,A.DName ", dateTime, dateTime);
tempdataset = tc.ExecuteDataSet(tempSql);
tempdataset.Tables[0].TableName = "TotalGross";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
tempSql = SQLParser.MakeSQL("select A.EmployeeNo, A.Name,A.GName,A.GCode,A.SequenceNo,A.DName,"
+ " A.Description, SUM(A.changedamount) Amount"
+ " from "
+ "(select S.EmployeeID, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode, "
+ " sd.ItemID, sd.Description,sd.Position, sd.changedamount,G.DESCRIPTION as GName,G.Code as GCode,G.SequenceNo,D.Name as DName "
+ " from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd "
+ " where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d and Sd.ItemGroup=3 "
+ " union"
+ " select S.EmployeeID, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode, "
+ " sd.ItemID, sd.Description,sd.Position, -sd.changedamount,G.DESCRIPTION as GName,G.Code as GCode,G.sequenceNo,D.Name as DName"
+ " from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd "
+ " where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d and Sd.ItemGroup=2 "
+ " ) A group by "
+ " A.EmployeeID, A.EmployeeNo, A.Name,A.GName,A.SequenceNo,A.GCode,A.DName, "
+ " A.ItemCode, A.ItemID, A.Description,A.Position order by A.Position,A.SequenceNo,A.GCode,A.EmployeeNo",
dateTime, dateTime);
tempdataset = tc.ExecuteDataSet(tempSql);
tempdataset.Tables[0].TableName = "DeductItem";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
tempSql = SQLParser.MakeSQL("select A.EmployeeNo, A.Name,A.GName,A.GCode,A.SequenceNo,A.DName,"
+ " A.Description, SUM(A.changedamount) Amount"
+ " from"
+ " ("
+ " select S.EmployeeID, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode, "
+ " sd.ItemID, sd.Description,sd.Position, sd.changedamount,G.DESCRIPTION as GName,G.Code as GCode,G.SequenceNo,D.Name as DName"
+ " from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd "
+ " where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d and Sd.ITEMCODE =-133 "
+ " UNION "
+ " select S.EmployeeID, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode, "
+ " sd.ItemID, sd.Description,sd.Position, sd.changedamount,G.DESCRIPTION as GName,G.Code as GCode,G.SequenceNo,D.Name as DName from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd "
+ " where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d and Sd.ITEMCODE =-133 "
+ " ) A group by "
+ " A.EmployeeID, A.EmployeeNo, A.Name,A.GName,A.SequenceNo,A.GCode,A.DName,"
+ " A.ItemCode, A.ItemID, A.Description,A.Position order by A.Position,A.SequenceNo,A.GCode,A.EmployeeNo", dateTime, dateTime);
tempdataset = tc.ExecuteDataSet(tempSql);
tempdataset.Tables[0].TableName = "LeaveDays";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
tempSql = SQLParser.MakeSQL("select E.EmployeeNo, E.Name,A.GName,A.GCode,A.sequenceNo,A.DName, 'UnAuthorized' as Description, Sum(A.amount) as amount "
+ " from"
+ " ( select S.EmployeeID, Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,G.Code as GCode,G.SequenceNo,D.Name as DName "
+ " from GRADES G,DESIGNATION D,SALARYMONTHLY S,SalaryMonthlyDetail Sd "
+ " where S.SalaryMonthlyID=Sd.SalaryMonthlyID "
+ " AND S.SalaryMonth=%d AND G.GRADEID=S.GRADEID AND D.DESIGNATIONID=S.DESIGNATIONID and Sd.ItemGroup IN (2) "
+ " group by S.EmployeeID,G.DESCRIPTION,G.SequenceNo,G.Code,D.Name"
+ " ) A, Employee E where A.EmployeeID = E.EmployeeID group by E.EmployeeNo, E.Name,A.GName,A.SequenceNo,A.GCode,A.DName", dateTime);
tempdataset = tc.ExecuteDataSet(tempSql);
tempdataset.Tables[0].TableName = "UnAuthorized";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
tempSql = SQLParser.MakeSQL("select E.EmployeeNo, E.Name,A.GName,A.GCode,A.SequenceNo,A.DName, 'Total Deduction' as Description, Sum(A.amount) as amount "
+ " from"
+ "( select S.EmployeeID, Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,G.Code as GCode,G.SequenceNo,D.Name as DName "
+ " from GRADES G,DESIGNATION D,SALARYMONTHLY S,SalaryMonthlyDetail Sd "
+ " where S.SalaryMonthlyID=Sd.SalaryMonthlyID "
+ " AND S.SalaryMonth=%d AND G.GRADEID=S.GRADEID AND D.DESIGNATIONID=S.DESIGNATIONID and Sd.ItemGroup IN (2,3) "
+ " group by S.EmployeeID,G.DESCRIPTION,G.SequenceNo,G.Code,D.Name"
+ " ) A, Employee E where A.EmployeeID = E.EmployeeID group by E.EmployeeNo, E.Name,A.GName,A.SequenceNo,A.GCode,A.DName ", dateTime);
tempdataset = tc.ExecuteDataSet(tempSql);
tempdataset.Tables[0].TableName = "TotalDeduction";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
tempSql = SQLParser.MakeSQL("Select E.EMPLOYEENO,E.NAME,G.DESCRIPTION as GName,G.Code as GCode,G.SequenceNo,D.Name as DName ,'Net Pay' as Description,SD.CHANGEDAMOUNT as Amount"
+ " from EMPLOYEE as E,GRADES as G,DESIGNATION D,SALARYMONTHLY as S,SALARYMONTHLYDETAIL as Sd"
+ " where S.SalaryMonthlyID=Sd.SalaryMonthlyID "
+ " AND S.SalaryMonth=%d"
+ " AND G.GRADEID=S.GRADEID "
+ " AND D.DESIGNATIONID=S.DESIGNATIONID "
+ " AND E.EMPLOYEEID =S.EMPLOYEEID "
+ " and Sd.ItemGroup IN (5) AND Sd.ItemCode IN(-132)"
+ " order by G.SequenceNo,G.Code,E.EMPLOYEENO ", dateTime);
tempdataset = tc.ExecuteDataSet(tempSql);
tempdataset.Tables[0].TableName = "NetPay";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return rootDataset;
#region Test Reconcilation For SGS
//DataSet rootDataset = new DataSet();
//DataSet tempdataset = new DataSet();
//try
//{
// tempdataset = tc.ExecuteDataSet("select A.EmployeeNo, A.Name,A.GName,A.DName,"
// + " A.Description, SUM(A.changedamount) Amount"
// + " from"
// + "(select S.EmployeeID, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode, "
// + " sd.ItemID, sd.Description,sd.Position, sd.changedamount,G.DESCRIPTION as GName,D.DESCRIPTION as DName"
// + " from Grades G,Department D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd "
// + " where G.GradeID= E.GradeID AND D.DepartmentID=E.DepartmentID AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d and Sd.ItemGroup in(8,4) AND SD.ItemID Not IN(13,11,15,16,14)"
// + " UNION "
// + " select S.EmployeeID, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode, "
// + " sd.ItemID, sd.Description,sd.Position, sd.changedamount,G.DESCRIPTION as GName,D.DESCRIPTION as DName from Grades G,Department D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd "
// + " where G.GradeID= E.GradeID AND D.DepartmentID=E.DepartmentID AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d and Sd.ItemGroup in(1,4) AND SD.ItemID Not IN(13,11,15,16,14)"
// + " ) A group by "
// + " A.EmployeeID, A.EmployeeNo, A.Name,A.GName,A.DName,"
// + " A.ItemCode, A.ItemID, A.Description,A.Position order by A.Position,A.EmployeeNo",
// dateTime,dateTime);
// tempdataset.Tables[0].TableName = "GrossItem";
// rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
// tempdataset = tc.ExecuteDataSet("select E.EmployeeNo, E.Name,A.GName,A.DName,'Total Gross' as Description, Sum(A.amount) as amount "
// + " from"
// + "( select S.EmployeeID, Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,D.DESCRIPTION as DName "
// + " from SALARYMONTHLY S,Grades G,Department D, SalaryMonthlyDetail Sd "
// + " where S.SalaryMonthlyID=Sd.SalaryMonthlyID "
// + " AND G.GRADEID=S.GRADEID AND D.DEPARTMENTID=S.DEPARTMENTID AND S.SalaryMonth=%d and Sd.ItemGroup IN (1, 8) and Sd.ItemID Not In(13,11,15,16,14)"
// + " group by S.EmployeeID,G.DESCRIPTION,D.DESCRIPTION "
// + " UNION"
// + " select S.EmployeeID, -Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,D.DESCRIPTION as DName"
// + " from GRADES G,DEPARTMENT D,SALARYMONTHLY S, SalaryMonthlyDetail Sd "
// + " where S.SalaryMonthlyID=Sd.SalaryMonthlyID "
// + " AND S.SalaryMonth=%d AND G.GRADEID=S.GRADEID AND D.DEPARTMENTID=S.DEPARTMENTID and Sd.ItemGroup IN (2) and Sd.ItemID Not In(13,11,15,16,14)"
// + " group by S.EmployeeID,G.DESCRIPTION,D.DESCRIPTION "
// + " ) A, Employee E where A.EmployeeID = E.EmployeeID "
// + " group by E.EmployeeNo, E.Name,A.GName,A.DName ", dateTime,dateTime);
// tempdataset.Tables[0].TableName = "TotalGross";
// rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
// tempdataset = tc.ExecuteDataSet("select A.EmployeeNo, A.Name,A.GName,A.DName,"
// + " A.Description, SUM(A.changedamount) Amount"
// + " from"
// + "(select S.EmployeeID, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode, "
// + " sd.ItemID, sd.Description,sd.Position, sd.changedamount,G.DESCRIPTION as GName,D.DESCRIPTION as DName"
// + " from Grades G,Department D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd "
// + " where G.GradeID= E.GradeID AND D.DepartmentID=E.DepartmentID AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d and Sd.ItemGroup=8 AND SD.ItemID IN(13,11,15,16,14)"
// + " union"
// + " select S.EmployeeID, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode, "
// + " sd.ItemID, sd.Description,sd.Position, -sd.changedamount,G.DESCRIPTION as GName,D.DESCRIPTION as DName"
// + " from Grades G,Department D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd "
// + " where G.GradeID= E.GradeID AND D.DepartmentID=E.DepartmentID AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d and Sd.ItemGroup=2 AND SD.ItemID IN(13,11,15,16,14)"
// + " UNION "
// + " select S.EmployeeID, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode, "
// + " sd.ItemID, sd.Description,sd.Position, sd.changedamount,G.DESCRIPTION as GName,D.DESCRIPTION as DName from Grades G,Department D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd "
// + " where G.GradeID= E.GradeID AND D.DepartmentID=E.DepartmentID AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d and Sd.ItemGroup=1 AND SD.ItemID IN(13,11,15,16,14)"
// + " ) A group by "
// + " A.EmployeeID, A.EmployeeNo, A.Name,A.GName,A.DName,"
// + " A.ItemCode, A.ItemID, A.Description,A.Position order by A.Position,A.EmployeeNo",
// dateTime, dateTime,dateTime);
// tempdataset.Tables[0].TableName = "LumSumItem";
// rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
// tempdataset = tc.ExecuteDataSet("select E.EmployeeNo, E.Name,A.GName,A.DName,'Grand Total' as Description, Sum(A.amount) as amount "
// + " from"
// + "( select S.EmployeeID, Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,D.DESCRIPTION as DName "
// + " from SALARYMONTHLY S,Grades G,Department D, SalaryMonthlyDetail Sd "
// + " where S.SalaryMonthlyID=Sd.SalaryMonthlyID "
// + " AND G.GRADEID=S.GRADEID AND D.DEPARTMENTID=S.DEPARTMENTID AND S.SalaryMonth=%d and Sd.ItemGroup IN (1, 8) "
// + " group by S.EmployeeID,G.DESCRIPTION,D.DESCRIPTION "
// + " UNION"
// + " select S.EmployeeID, -Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,D.DESCRIPTION as DName"
// + " from GRADES G,DEPARTMENT D,SALARYMONTHLY S, SalaryMonthlyDetail Sd "
// + " where S.SalaryMonthlyID=Sd.SalaryMonthlyID "
// + " AND S.SalaryMonth=%d AND G.GRADEID=S.GRADEID AND D.DEPARTMENTID=S.DEPARTMENTID and Sd.ItemGroup IN (2) "
// + " group by S.EmployeeID,G.DESCRIPTION,D.DESCRIPTION "
// + " ) A, Employee E where A.EmployeeID = E.EmployeeID "
// + " group by E.EmployeeNo, E.Name,A.GName,A.DName ", dateTime,dateTime);
// tempdataset.Tables[0].TableName = "GrandTotal";
// rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
// tempdataset = tc.ExecuteDataSet("select A.EmployeeNo, A.Name,A.GName,A.DName,"
// + " A.Description, SUM(A.changedamount) Amount"
// + " from "
// + "(select S.EmployeeID, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode, "
// + " sd.ItemID, sd.Description,sd.Position, sd.changedamount,G.DESCRIPTION as GName,D.DESCRIPTION as DName "
// + " from Grades G,Department D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd "
// + " where G.GradeID= E.GradeID AND D.DepartmentID=E.DepartmentID AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d and Sd.ItemGroup=3 "
// + " union"
// + " select S.EmployeeID, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode, "
// + " sd.ItemID, sd.Description,sd.Position, -sd.changedamount,G.DESCRIPTION as GName,D.DESCRIPTION as DName"
// + " from Grades G,Department D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd "
// + " where G.GradeID= E.GradeID AND D.DepartmentID=E.DepartmentID AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d and Sd.ItemGroup=2 "
// //+ " UNION "
// //+ " select S.EmployeeID, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode, "
// //+ " sd.ItemID, sd.Description,sd.Position, sd.changedamount from Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd "
// //+ " where E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d and Sd.ItemGroup=1 "
// + " ) A group by "
// + " A.EmployeeID, A.EmployeeNo, A.Name,A.GName,A.DName, "
// + " A.ItemCode, A.ItemID, A.Description,A.Position order by A.Position,A.EmployeeNo",
// dateTime, dateTime);
// tempdataset.Tables[0].TableName = "DeductItem";
// rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
// tempdataset = tc.ExecuteDataSet("select E.EmployeeNo, E.Name,A.GName,A.DName, 'Total Deduction' as Description, Sum(A.amount) as amount "
// + " from"
// + "( select S.EmployeeID, Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,D.DESCRIPTION as DName "
// + " from GRADES G,DEPARTMENT D,SALARYMONTHLY S,SalaryMonthlyDetail Sd "
// + " where S.SalaryMonthlyID=Sd.SalaryMonthlyID "
// + " AND S.SalaryMonth=%d AND G.GRADEID=S.GRADEID AND D.DEPARTMENTID=S.DEPARTMENTID and Sd.ItemGroup IN (3) "
// + " group by S.EmployeeID,G.DESCRIPTION,D.DESCRIPTION"
// + " UNION"
// + " select S.EmployeeID, -Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,D.DESCRIPTION as DName "
// + " from GRADES G,DEPARTMENT D,SALARYMONTHLY S, SalaryMonthlyDetail Sd where S.SalaryMonthlyID=Sd.SalaryMonthlyID "
// + " AND S.SalaryMonth=%d AND G.GRADEID=S.GRADEID AND D.DEPARTMENTID=S.DEPARTMENTID and Sd.ItemGroup IN (2) "
// + " group by S.EmployeeID,G.DESCRIPTION,D.DESCRIPTION"
// + " ) A, Employee E where A.EmployeeID = E.EmployeeID group by E.EmployeeNo, E.Name,A.GName,A.DName ", dateTime,dateTime);
// tempdataset.Tables[0].TableName = "TotalDeduction";
// rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
// tempdataset = tc.ExecuteDataSet("Select E.EMPLOYEENO,E.NAME,G.DESCRIPTION as GName,D.DESCRIPTION as DName ,'Net Pay' as Description,SD.CHANGEDAMOUNT as Amount"
// + " from EMPLOYEE as E,GRADES as G,DEPARTMENT D,SALARYMONTHLY as S,SALARYMONTHLYDETAIL as Sd"
// + " where S.SalaryMonthlyID=Sd.SalaryMonthlyID "
// + " AND S.SalaryMonth=%d"
// + " AND G.GRADEID=S.GRADEID "
// + " AND D.DEPARTMENTID=S.DEPARTMENTID "
// + " AND E.EMPLOYEEID =S.EMPLOYEEID "
// + " and Sd.ItemGroup IN (5)"
// + " order by E.EMPLOYEENO ", dateTime);
// tempdataset.Tables[0].TableName = "NetPay";
// rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
//}
//catch (Exception ex)
//{
// throw new Exception(ex.Message);
//}
//return rootDataset;
#endregion
}
internal static DataSet GetEmpPrevDataForSRecon(TransactionContext tc, DateTime dateTime, string sEmpID)
{
DataSet rootDataset = new DataSet();
DataSet tempdataset = new DataSet();
try
{
string tempSql = SQLParser.MakeSQL("select A.EmployeeNo, A.Name,A.GName,A.DName,A.GCode,A.SequenceNo,"
+ " A.Description, SUM(A.changedamount) Amount, A.ItemID, A.ItemCode"
+ " from"
+ "(select S.EmployeeID, E.EmployeeNo, E.Name,sd.ItemCode, "
+ " sd.ItemID, sd.Description, sd.changedamount,G.DESCRIPTION as GName,D.Name as DName,G.Code as GCode,G.SequenceNo"
+ " from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd "
+ " where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d and Sd.ItemGroup in(8) AND sd.ItemCode not in(-133) "
+ " UNION "
+ " select S.EmployeeID, E.EmployeeNo, E.Name,sd.ItemCode, "
+ " sd.ItemID, sd.Description, sd.changedamount,G.DESCRIPTION as GName,D.Name as DName,G.Code as GCode,G.SequenceNo from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd "
+ " where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d and Sd.ItemGroup in(1) AND sd.ItemCode not in(-133) "
+ " UNION "
+ " select S.EmployeeID, E.EmployeeNo, E.Name,sd.ItemCode, "
+ " sd.ItemID, sd.Description, -sd.changedamount,G.DESCRIPTION as GName,D.Name as DName,G.Code as GCode,G.SequenceNo from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd "
+ " where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d and Sd.ItemGroup in(2) "
+ " ) A where A.EMPLOYEEID IN(%q)"
+ " group by "
+ " A.EmployeeID, A.EmployeeNo, A.Name,A.GName,A.DName,A.SequenceNo,A.GCode,"
+ " A.ItemCode, A.ItemID, A.Description, A.ItemID, A.ItemCode"
+ " order by A.ItemID,A.GCode,A.EmployeeNo",
dateTime, dateTime, dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet(tempSql);
tempdataset.Tables[0].TableName = "GrossItem";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
tempSql = SQLParser.MakeSQL("select E.EmployeeNo, E.Name,A.GName,A.GCode,A.SequenceNo,A.DName,'Total Gross' as Description, Sum(A.amount) as amount "
+ " from"
+ "( select S.EmployeeID, Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,G.Code as GCode,G.SequenceNo,D.Name as DName "
+ " from SALARYMONTHLY S,Grades G,DESIGNATION D, SalaryMonthlyDetail Sd "
+ " where S.SalaryMonthlyID=Sd.SalaryMonthlyID "
+ " AND G.GRADEID=S.GRADEID AND D.DESIGNATIONID=S.DESIGNATIONID AND S.SalaryMonth=%d and Sd.ItemGroup IN (1, 8) "
+ " group by S.EmployeeID,G.DESCRIPTION,G.SequenceNo,G.Code,D.Name "
+ " UNION"
+ " select S.EmployeeID, -Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,G.Code as GCode,G.sequenceNo,D.Name as DName"
+ " from GRADES G,DESIGNATION D,SALARYMONTHLY S, SalaryMonthlyDetail Sd "
+ " where S.SalaryMonthlyID=Sd.SalaryMonthlyID "
+ " AND S.SalaryMonth=%d AND G.GRADEID=S.GRADEID AND D.DESIGNATIONID=S.DESIGNATIONID and Sd.ItemGroup IN (2) "
+ " group by S.EmployeeID,G.DESCRIPTION,G.SequenceNo,G.Code,D.Name "
+ " ) A, Employee E where A.EmployeeID = E.EmployeeID AND A.EMPLOYEEID IN(%q) "
+ " group by E.EmployeeNo, E.Name,A.GName,A.SequenceNo,A.GCode,A.DName ", dateTime, dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet(tempSql);
tempdataset.Tables[0].TableName = "TotalGross";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
tempSql = SQLParser.MakeSQL("select A.EmployeeNo, A.Name,A.GName,A.GCode,A.SequenceNo,A.DName,"
+ " A.Description, SUM(A.changedamount) Amount"
+ " from "
+ "(select S.EmployeeID, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode, "
+ " sd.ItemID, sd.Description,sd.Position, sd.changedamount,G.DESCRIPTION as GName,G.Code as GCode,G.SequenceNo,D.Name as DName "
+ " from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd "
+ " where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d and Sd.ItemGroup=3 "
//+ " union"
//+ " select S.EmployeeID, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode, "
//+ " sd.ItemID, sd.Description,sd.Position, -sd.changedamount,G.DESCRIPTION as GName,G.Code as GCode,G.sequenceNo,D.Name as DName"
//+ " from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd "
//+ " where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d and Sd.ItemGroup=2 "
+ " ) A where A.EMPLOYEEID IN(%q) "
+ " group by "
+ " A.EmployeeID, A.EmployeeNo, A.Name,A.GName,A.SequenceNo,A.GCode,A.DName, "
+ " A.ItemCode, A.ItemID, A.Description,A.Position order by A.Position,A.SequenceNo,A.GCode,A.EmployeeNo",
dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet(tempSql);
tempdataset.Tables[0].TableName = "DeductItem";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
tempSql = SQLParser.MakeSQL("select A.EmployeeNo, A.Name,A.GName,A.GCode,A.SequenceNo,A.DName,"
+ " A.Description, SUM(A.changedamount) Amount"
+ " from"
+ " ("
+ " select S.EmployeeID, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode, "
+ " sd.ItemID, sd.Description,sd.Position, sd.changedamount,G.DESCRIPTION as GName,G.Code as GCode,G.SequenceNo,D.Name as DName"
+ " from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd "
+ " where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d and Sd.ITEMCODE =-133 "
+ " UNION "
+ " select S.EmployeeID, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode, "
+ " sd.ItemID, sd.Description,sd.Position, sd.changedamount,G.DESCRIPTION as GName,G.Code as GCode,G.SequenceNo,D.Name as DName from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd "
+ " where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d and Sd.ITEMCODE =-133 "
+ " ) A where A.EMPLOYEEID IN(%q)"
+" group by "
+ " A.EmployeeID, A.EmployeeNo, A.Name,A.GName,A.SequenceNo,A.GCode,A.DName,"
+ " A.ItemCode, A.ItemID, A.Description,A.Position order by A.Position,A.SequenceNo,A.GCode,A.EmployeeNo", dateTime, dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet(tempSql);
tempdataset.Tables[0].TableName = "LeaveDays";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
tempSql = SQLParser.MakeSQL("select E.EmployeeNo, E.Name,A.GName,A.GCode,A.sequenceNo,A.DName, 'UnAuthorized' as Description, Sum(A.amount) as amount "
+ " from"
+ " ( select S.EmployeeID, Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,G.Code as GCode,G.SequenceNo,D.Name as DName "
+ " from GRADES G,DESIGNATION D,SALARYMONTHLY S,SalaryMonthlyDetail Sd "
+ " where S.SalaryMonthlyID=Sd.SalaryMonthlyID "
+ " AND S.SalaryMonth=%d AND G.GRADEID=S.GRADEID AND D.DESIGNATIONID=S.DESIGNATIONID and Sd.ItemGroup IN (2) "
+ " group by S.EmployeeID,G.DESCRIPTION,G.SequenceNo,G.Code,D.Name"
+ " ) A, Employee E where A.EmployeeID = E.EmployeeID AND A.EMPLOYEEID IN(%q) group by E.EmployeeNo, E.Name,A.GName,A.SequenceNo,A.GCode,A.DName", dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet(tempSql);
tempdataset.Tables[0].TableName = "UnAuthorized";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
tempSql = SQLParser.MakeSQL("select E.EmployeeNo, E.Name,A.GName,A.GCode,A.SequenceNo,A.DName, 'Total Deduction' as Description, Sum(A.amount) as amount "
+ " from"
+ "( select S.EmployeeID, Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,G.Code as GCode,G.SequenceNo,D.Name as DName "
+ " from GRADES G,DESIGNATION D,SALARYMONTHLY S,SalaryMonthlyDetail Sd "
+ " where S.SalaryMonthlyID=Sd.SalaryMonthlyID "
+ " AND S.SalaryMonth=%d AND G.GRADEID=S.GRADEID AND D.DESIGNATIONID=S.DESIGNATIONID and Sd.ItemGroup IN (3) "
+ " group by S.EmployeeID,G.DESCRIPTION,G.SequenceNo,G.Code,D.Name"
+ " ) A, Employee E where A.EmployeeID = E.EmployeeID AND A.EMPLOYEEID IN(%q) group by E.EmployeeNo, E.Name,A.GName,A.SequenceNo,A.GCode,A.DName ", dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet(tempSql);
tempdataset.Tables[0].TableName = "TotalDeduction";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
tempSql = SQLParser.MakeSQL("Select E.EMPLOYEENO,E.NAME,G.DESCRIPTION as GName,G.Code as GCode,G.SequenceNo,D.Name as DName ,'Net Pay' as Description,SD.CHANGEDAMOUNT as Amount"
+ " from EMPLOYEE as E,GRADES as G,DESIGNATION D,SALARYMONTHLY as S,SALARYMONTHLYDETAIL as Sd"
+ " where S.SalaryMonthlyID=Sd.SalaryMonthlyID "
+ " AND S.SalaryMonth=%d"
+ " AND G.GRADEID=S.GRADEID "
+ " AND D.DESIGNATIONID=S.DESIGNATIONID "
+ " AND E.EMPLOYEEID =S.EMPLOYEEID "
+ " and Sd.ItemGroup IN (5) AND Sd.ItemCode IN(-132)"
+" AND E.EMPLOYEEID IN(%q) "
+ " order by G.SequenceNo,G.Code,E.EMPLOYEENO ", dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet(tempSql);
tempdataset.Tables[0].TableName = "NetPay";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return rootDataset;
}
internal static DataTable GetTaxRegionDTByEmpId(TransactionContext tc, int nTaxParamID, int empId)
{
return tc.ExecuteDataTable("SELECT * FROM TaxRegion where employeeID= %n and TaxParameterID=%n ORDER BY EmployeeID ", empId, nTaxParamID);
}
}
}