CEL_Payroll/Payroll.Service/Salary/DA/SalaryMonthlyDA.cs

6871 lines
435 KiB
C#
Raw Permalink Normal View History

2024-09-17 14:30:13 +06:00
using System;
using Payroll.BO;
using System.Data;
using System.Linq;
using Ease.CoreV35.Model;
using System.Data.SqlClient;
using Ease.CoreV35.DataAccess;
using System.Collections.Generic;
using Ease.CoreV35.DataAccess.SQL;
using Ease.CoreV35.Utility;
namespace Payroll.Service
{
#region SalaryMonthlyDA
internal class SalaryMonthlyDA
{
#region Constructor
private SalaryMonthlyDA() { }
#endregion
#region Insert function
internal static void Insert(TransactionContext tc, SalaryMonthly item)
{
string sSQL = SQLParser.MakeSQL("INSERT INTO SalaryMonthly(SalaryMonthlyID, SalaryMonth, EmployeeID, CategoryID, DepartmentID, "
+ "DesignationID, LocationID, GradeID, ISFINALIZED, PaymentDate, "
+ " PrevMonthBasic, ThisMonthBasic, IsConfirmed, IsEligibleOT, "
+ " ReligionID, PayrollTypeID, OUTPAYBRANCHID, "
+ " OutPayAccountNo, Remarks, AccountNo, BranchID, DESIGNATION, "
+ " SalaryProcessID, PFMEMBERTYPE, Gender, ThisMonthGross)"
+ " VALUES(%n, %d, %n, %n, %n, "
+ " %n, %n, %n, %b, %d, "
+ " %n, %n, %b, %b, "
+ " %n, %n, %n, "
+ " %s, %s, %s, %n, %s, "
+ " %n, %n, %n, %n)", item.ID.Integer, item.SalaryMonth, item.EmployeeID.Integer, item.CategoryID.Integer, item.DepartmentID.Integer,
item.DesignationID.Integer, item.LocationID.Integer, item.GradeID.Integer, item.IsFinalized, DataReader.GetNullValue(item.PaymentDate),
item.PrevMonthBasic, item.ThisMonthBasic, item.IsConfirmed, item.IsEligibleOT,
DataReader.GetNullValue(item.ReligionID, IDType.Integer), DataReader.GetNullValue(item.PayrollTypeID, IDType.Integer), DataReader.GetNullValue(item.OutPayBranchID, IDType.Integer),
item.OutPayAccountNo, item.Remarks, item.AccountNo, DataReader.GetNullValue(item.BranchID, IDType.Integer), item.DesignationText,
item.SalaryProcessID.Integer, item.PFMembershipType, item.Gender, item.ThisMonthGross);
tc.ExecuteNonQuery(sSQL);
}
internal static void Insert(TransactionContext tc, SalaryMonthlyDetail item)
{
tc.ExecuteNonQuery("INSERT INTO SalaryMonthlyDetail(DetailID, SALARYMONTHLYID, ITEMID, SUPPORTID, DESCRIPTION, POSITION, "
+ " CALCULATEDAMOUNT, CHANGEDAMOUNT, ITEMCODE, ITEMGROUP)" +
" VALUES(%n, %n, %n, %n, %s, %n, %n, %n, %n, %n)",
item.ID.Integer, item.SalaryMonthlyID.Integer, item.ItemID, DataReader.GetNullValue(item.SupportID, IDType.Integer), item.Description,
item.Position, item.CalculatedAmount, item.ChangedAmount, item.ItemCode,
item.itemGroupCode);
}
internal static void UpdateSalaryDetail(TransactionContext tc, SalaryMonthlyDetail item)
{
tc.ExecuteNonQuery("Update SalaryMonthlyDetail SET DESCRIPTION =%s, POSITION =%n, "
+ " CALCULATEDAMOUNT =%n, CHANGEDAMOUNT =%n WHERE SalaryMonthlyID=%n AND ItemCode=%n AND ItemGroup=%n AND ItemID=%n" +
" ",
item.Description, item.Position,
item.CalculatedAmount, item.ChangedAmount, item.SalaryMonthlyID.Integer, item.ItemCode,
item.itemGroupCode, item.ItemID);
}
internal static void Insert(TransactionContext tc, SalaryEmpCostCenter item)
{
tc.ExecuteNonQuery("INSERT INTO SalaryEmpCostCenter(SALARYMONTHLYID, COSTCENTERID, PERCENTAGE, EMPLOYEEID)" +
" VALUES( %n, %n, %n, %n)", item.SalaryMontlyID.Integer, item.CostCenterID.Integer, item.Percentage, item.EmployeeID.Integer);
}
#endregion
#region Update function
internal static void Update(TransactionContext tc, SalaryMonthly item)
{
tc.ExecuteNonQuery("UPDATE SalaryMonthly SET "
+ " SalaryMonth=%d, EmployeeID=%n, CategoryID=%n, DepartmentID=%n, DesignationID=%n, "
+ " LocationID=%n, GradeID=%n, ISFINALIZED=%b, PaymentDate=%d,"
+ " PrevMonthBasic=%n, ThisMonthBasic=%n, IsConfirmed=%b,"
+ " IsEligibleOT=%b, ReligionID=%n, PayrollTypeID=%n, OUTPAYBRANCHID=%n,"
+ " OUTPAYACCOUNTNO=%s, Remarks=%s, AccountNo=%s, BranchID=%n, "
+ " SalaryProcessID=%n, PFMEMBERTYPE=%n, Gender=%n,rccode=%s"
+ " WHERE SalaryMonthlyID=%n",
item.SalaryMonth, item.EmployeeID.Integer, item.CategoryID.Integer, item.DepartmentID.Integer, item.DesignationID.Integer,
item.LocationID.Integer, item.GradeID.Integer, item.IsFinalized, item.PaymentDate,
item.PrevMonthBasic, item.ThisMonthBasic, item.IsConfirmed,
item.IsEligibleOT, item.ReligionID.Integer, item.PayrollTypeID.Integer, DataReader.GetNullValue(item.OutPayBranchID, IDType.Integer),
item.OutPayAccountNo, item.Remarks, item.AccountNo, DataReader.GetNullValue(item.BranchID, IDType.Integer),
item.SalaryProcessID.Integer, item.PFMembershipType, item.Gender,item.RCCode, item.ID.Integer);
}
#endregion
#region Get Function
internal static IDataReader Get(TransactionContext tc, int payrollTypeID)
{
return tc.ExecuteReader("SELECT * FROM SalaryMonthly where PayrollTypeID=%n", payrollTypeID);
}
internal static IDataReader GetCostCenter(TransactionContext tc, DateTime salaryMonth)
{
return tc.ExecuteReader("SELECT SD.* FROM SalaryEmpCostCenter SD, SalaryMonthly SM WHERE "
+ " SM.SalaryMonth =%d AND SD.SalaryMonthlyID=SM.SalaryMonthlyID Order by SM.SalaryMonthlyID, SD.EmployeeID ", salaryMonth);
}
internal static IDataReader Get(TransactionContext tc, DateTime salaryMonth, ID payrollTypeID)
{
return tc.ExecuteReader("SELECT * FROM SalaryMonthly where SalaryMonth =%d and payrolltypeid=%n", salaryMonth, payrollTypeID.Integer);
}
internal static IDataReader GetDetail(TransactionContext tc, DateTime salaryMonth)
{
//return tc.ExecuteReader("SELECT SD.DetailID, SD.SALARYMONTHLYID, SD.ITEMID, SD.SUPPORTID, SD.DESCRIPTION, SD.POSITION, "
//+ " Round(SD.CALCULATEDAMOUNT,0)CALCULATEDAMOUNT,Round( SD.CHANGEDAMOUNT,0)CHANGEDAMOUNT, SD.ITEMCODE, SD.ITEMGROUP FROM SalaryMonthlyDetail SD, SalaryMonthly SM WHERE "
// + " SM.SalaryMonth =%d AND SD.SalaryMonthlyID=SM.SalaryMonthlyID Order by SM.SalaryMonthlyID, SD.Position ", salaryMonth);
return tc.ExecuteReader("SELECT SD.DetailID, SD.SALARYMONTHLYID, SD.ITEMID, SD.SUPPORTID, SD.DESCRIPTION, SD.POSITION, "
+ " SD.CALCULATEDAMOUNT,SD.CHANGEDAMOUNT, SD.ITEMCODE, SD.ITEMGROUP FROM SalaryMonthlyDetail SD, SalaryMonthly SM WHERE "
+ " SM.SalaryMonth =%d AND SD.SalaryMonthlyID=SM.SalaryMonthlyID Order by SM.SalaryMonthlyID, SD.Position ", salaryMonth);
}
internal static IDataReader Get(TransactionContext tc, ID nID)
{
return tc.ExecuteReader("SELECT * FROM SalaryMonthly WHERE SalaryMonthlyID=%n", nID.Integer);
}
internal static DateTime? GetLastPaidSalaryMonth(TransactionContext tc, int nEmpID)
{
DateTime? maxDate = DateTime.Today;
object obj = tc.ExecuteScalar("select max(salarymonth) from SALARYMONTHLY where employeeid=%n", nEmpID);
if (obj != DBNull.Value)
{
maxDate = Convert.ToDateTime(obj);
}
else
{
maxDate = null;
}
return maxDate;
}
internal static IDataReader Get(TransactionContext tc, string sEmpID, DateTime dMonthDate)
{
return tc.ExecuteReader("SELECT * FROM SalaryMonthly WHERE EmployeeID in(%q) AND SALARYMONTH=%d order by DepartmentID,EmployeeID", sEmpID, dMonthDate);
}
internal static IDataReader GetForWTP(TransactionContext tc, string sEmpID, DateTime dMonthDate)
{
return tc.ExecuteReader("SELECT * FROM SalaryMonthly WHERE EmployeeID in(%q) AND SALARYMONTH=%d order by EmployeeID", sEmpID, dMonthDate);
}
internal static bool IsSalaryProcessed(TransactionContext tc, ID employeeId, DateTime salaryMonth)
{
object isprocessed = tc.ExecuteScalar("SELECT count(*) FROM SalaryMonthly WHERE EmployeeID=%n AND SalaryMonth=%d", employeeId.Integer, salaryMonth);
if (isprocessed == DBNull.Value)
return false;
if (Convert.ToInt32(isprocessed) == 0) return false;
else return true;
}
internal static bool IsSalaryProcessedWeb(TransactionContext tc, DateTime salaryMonth, ID payrollTypeID)
{
object isprocessed = tc.ExecuteScalar("SELECT count(*) FROM SALARYPROCESS WHERE SalaryMonth=%d AND ShowINDesktop=1 AND PayrollTypeID=%n", salaryMonth, payrollTypeID.Integer);
if (isprocessed == DBNull.Value)
return false;
if (Convert.ToInt32(isprocessed) == 0) return false;
else return true;
}
internal static bool IsPermanentEmp(TransactionContext tc, ID employeeId, DateTime salaryMonth, ID payrollTypeID)
{
object isprocessed = tc.ExecuteScalar("SELECT count(*) FROM SalaryMonthly WHERE EmployeeID=%n AND SalaryMonth=%d AND PayrollTypeID=%n", employeeId.Integer, salaryMonth, payrollTypeID.Integer);
if (isprocessed == DBNull.Value)
return false;
if (Convert.ToInt32(isprocessed) == 0) return false;
else return true;
}
internal static bool IsPermanentEmpOld(TransactionContext tc, ID employeeId, DateTime salaryMonth, ID payrollTypeID)
{
object isprocessed = tc.ExecuteScalar("SELECT count(*) FROM GP_SalaryMonthly WHERE EmployeeID=%n AND MONTHYEARDATE=%d AND PayrollTypeID=%n", employeeId.Integer, salaryMonth, payrollTypeID.Integer);
if (isprocessed == DBNull.Value)
return false;
if (Convert.ToInt32(isprocessed) == 0) return false;
else return true;
}
internal static int GetUnAuthorizeDays(TransactionContext tc, ID employeeId, DateTime salaryMonth)
{
object leaveDays = tc.ExecuteScalar("SELECT SUM(ChangedAmount) FROM SalaryMonthly S, SalaryMonthlyDetail SD WHERE EmployeeID=%n AND SalaryMonth=%d"
+ " AND S.SalaryMonthlyID=SD.SalaryMonthlyID and SD.ItemGroup=%n and SD.ItemCode=%n", employeeId.Integer, salaryMonth,
EnumSalaryGroup.Miscellaneous, EnumSalaryItemCode.Tot_UnauthLeave_Days);
if (leaveDays == DBNull.Value)
return 0;
return Convert.ToInt32(leaveDays);
}
internal static int GetTotalEmp(TransactionContext tc, ID SProcessID)
{
int empCount = 0;
object obj = tc.ExecuteScalar("Select COUNT(*) from SALARYMONTHLY where SALARYPROCESSID=%n", SProcessID.Integer);
if (obj != null)
{
empCount = Convert.ToInt32(obj);
}
else
{
empCount = 0;
}
return empCount;
}
internal static bool IsSalaryFinalized(TransactionContext tc, ID employeeId, DateTime salaryMonth)
{
object isprocessed = tc.ExecuteScalar("SELECT count(*) FROM SalaryMonthly WHERE EmployeeID=%n AND SalaryMonth=%d AND ISFINALIZED=%b", employeeId.Integer, salaryMonth, true);
if (isprocessed == DBNull.Value)
return false;
if (Convert.ToInt32(isprocessed) == 0) return false;
else return true;
}
internal static IDataReader GetSalaryDetail(TransactionContext tc, ID nID)
{
return tc.ExecuteReader("SELECT * FROM SalaryMonthlyDetail WHERE SalaryMonthlyID=%n", nID.Integer);
}
internal static IDataReader GetEmpCostCenter(TransactionContext tc, ID nID)
{
string sSQL = SQLParser.MakeSQL("SELECT * FROM SalaryEmpCostCenter WHERE SalaryMonthlyID=%n", nID.Integer);
return tc.ExecuteReader(sSQL);
}
internal static double GetSumOnRange(TransactionContext tc, ID employeeId,
DateTime fromDate, DateTime toDate, EnumSalaryGroup groupCode,
EnumSalaryItemCode itemCode, int itemId, ID payrollTypeID)
{
//string strSQL = SQLParser.MakeSQL("SELECT SUM(ChangedAmount) FROM SalaryMonthlyDetail WHERE"
//+ " ItemGroup=%n AND ItemCode=%n and itemId=%n AND SalaryMonthlyID IN ( SELECT SalaryMonthlyID FROM"
//+ " SalaryMonthly WHERE EmployeeID=%n AND SalaryMonth>=%d AND SalaryMonth<=%d AND WithNoDetail=%b and PayrollTypeID=%n) "
// , groupCode, itemCode, itemId, employeeId.Integer, fromDate, toDate, false, SystemInformation.CurrentSysInfo.PayrollTypeID.Integer);
//object amount = tc.ExecuteScalar(strSQL);
object amount = null;
string sSQL = SQLParser.MakeSQL("SELECT SUM(ChangedAmount) FROM SalaryMonthlyDetail WHERE"
+ " ItemGroup=%n AND ItemCode=%n and itemId==%n AND SalaryMonthlyID IN ( SELECT SalaryMonthlyID FROM"
+ " SalaryMonthly WHERE EmployeeID=%n AND SalaryMonth>=%d AND SalaryMonth<=%d AND WithNoDetail=%b and PayrollTypeID=%n) "
, groupCode, itemCode, itemId, employeeId.Integer, fromDate, toDate, false, payrollTypeID.Integer);
amount = tc.ExecuteScalar(sSQL);
if (amount == DBNull.Value)
return 0;
else return Convert.ToDouble(amount);
//if (amount == DBNull.Value)
//{
// string sTempSQL = SQLParser.MakeSQL("Select ThisMOnthAmount from INCOMETAXTEMP WHERE ItemCode=-212 and itemId=-212 and EmployeeID=%n",itemCode,itemId,employeeId.Integer);
// amount = tc.ExecuteScalar(sTempSQL);
// return Convert.ToDouble(amount);
//}
//else return Convert.ToDouble(amount);
}
internal static double GetPrvTaxAmount(TransactionContext tc, EnumIncomeTaxDataFrom dataFrom, ID employeeId,
DateTime fromDate, DateTime toDate)
{
//object amount = null;
//if (amount ==null)
//{
// string sTempSQL = SQLParser.MakeSQL("Select PreviousAmount from INCOMETAXTEMP WHERE ItemCode=%n and itemId=%n and EmployeeID=%n", (int)EnumIncomeTaxItemGroup.Tax_Deducted,(int)EnumIncomeTaxItemGroup.Tax_Deducted, employeeId.Integer);
// amount = tc.ExecuteScalar(sTempSQL);
// return Convert.ToDouble(amount);
//}
//else return Convert.ToDouble(amount);
object amount = null;
string sTempSQL = "";
if (amount == null)
{
if (EnumIncomeTaxDataFrom.ProcessTempData == dataFrom)
{
sTempSQL = SQLParser.MakeSQL("Select PreviousAmount from INCOMETAXTEMP WHERE ItemCode=%n and itemId=%n and EmployeeID=%n", (int)EnumIncomeTaxItemGroup.Tax_Deducted, (int)EnumIncomeTaxItemGroup.Tax_Deducted, employeeId.Integer);
}
else if (EnumIncomeTaxDataFrom.SalaryITTempData == dataFrom)
{
sTempSQL = SQLParser.MakeSQL("Select PreviousAmount from SALARYTEMPIT WHERE ItemCode=%n and itemId=%n and EmployeeID=%n", (int)EnumIncomeTaxItemGroup.Tax_Deducted, (int)EnumIncomeTaxItemGroup.Tax_Deducted, employeeId.Integer);
}
else if (EnumIncomeTaxDataFrom.ProcessedData == dataFrom)
{
sTempSQL = SQLParser.MakeSQL("Select PreviousAmount from INCOMETAXYEARLY WHERE ItemCode=%n and itemId=%n and EmployeeID=%n", (int)EnumIncomeTaxItemGroup.Tax_Deducted, (int)EnumIncomeTaxItemGroup.Tax_Deducted, employeeId.Integer);
}
amount = tc.ExecuteScalar(sTempSQL);
return Convert.ToDouble(amount);
}
else return Convert.ToDouble(amount);
}
internal static double GetAmountOnDateDiff(TransactionContext tc, ID employeeId,
DateTime fromDate, DateTime toDate, EnumSalaryGroup groupCode,
EnumSalaryItemCode itemCode, int itemId, ID payrollTypeID)
{
object amount = tc.ExecuteScalar("SELECT SUM(ChangedAmount) FROM SalaryMonthlyDetail WHERE"
+ " ItemGroup=%n AND ItemCode=%n and itemId==%n AND SalaryMonthlyID IN ( SELECT SalaryMonthlyID FROM"
+ " SalaryMonthly WHERE EmployeeID=%n AND SalaryMonth>=%d AND SalaryMonth<=%d AND WithNoDetail=%b and PayrollTypeID=%n) "
, groupCode, itemCode, itemId, employeeId.Integer, fromDate, toDate, false, payrollTypeID.Integer);
if (amount == DBNull.Value)
return 0;
else return Convert.ToDouble(amount);
}
internal static IDataReader GetDetail(TransactionContext tc, ID employeeId,
DateTime fromDate, EnumSalaryGroup groupCode,
EnumSalaryItemCode itemCode, int itemId)
{
return tc.ExecuteReader("SELECT * FROM SalaryMonthlyDetail WHERE"
+ " ItemGroup=%n AND ItemCode=%n and itemId==%n AND SalaryMonthlyID IN ( SELECT SalaryMonthlyID FROM"
+ " SalaryMonthly WHERE EmployeeID=%n AND SalaryMonth=%d AND WithNoDetail=%b ) "
, groupCode, itemCode, itemId, employeeId.Integer, fromDate, false);
}
internal static double GetThisMonthBasicOnDateDiff(TransactionContext tc, ID employeeId,
DateTime fromDate, DateTime toDate, EnumSalaryGroup groupCode,
EnumSalaryItemCode itemCode, int itemId, ID payrollTypeID)
{
string sQuary = SQLParser.MakeSQL(@"Select SUM(SM.ThisMonthBasic) from SalaryMonthly as SM ,SalaryMonthlyDetail as SMD
where SM.SalaryMonthlyID=SMD.SalaryMonthlyID
and SMD.ItemCode=%n and SMD.ItemGroup=%n and SMD.ItemID=%n
and SM.EmployeeID=%n and SM.SalaryMonth>=%d AND SM.SalaryMonth<=%d
and SM.PayrollTypeID=%n", itemCode, groupCode, itemId, employeeId.Integer, fromDate, toDate, payrollTypeID.Integer);
object amount = tc.ExecuteScalar(sQuary);
if (amount == DBNull.Value)
return 0;
else return Convert.ToDouble(amount);
}
////////////////////////////////////////////////////////////////////////////////////////////
internal static double GetAmountOnDateDiffForAll(TransactionContext tc, ID employeeId,
DateTime fromDate, DateTime toDate, ID payrollTypeID)
{
object amount = tc.ExecuteScalar("SELECT SUM(ChangedAmount) FROM SalaryMonthlyDetail WHERE"
+ " ItemGroup IN( 3 ) AND ItemCode IN(-118, -119) and itemId IN (SELECT LoanId FROM LoanBasic) AND SalaryMonthlyID IN ( SELECT SalaryMonthlyID FROM"
+ " SalaryMonthly WHERE EmployeeID=%n AND SalaryMonth>=%d AND SalaryMonth<=%d AND WithNoDetail=%b and PayrollTypeID=%n) ",
employeeId.Integer, fromDate, toDate, false, payrollTypeID.Integer);
if (amount == DBNull.Value)
return 0;
else return Convert.ToDouble(amount);
}
///////////////////////////////////////////////////////////////////////////////////////////
internal static double GetUnAuthorizeAmountOnDateRange(TransactionContext tc, ID employeeId, DateTime fromDate, DateTime toDate, EnumSalaryGroup groupCode)
{
object amount = tc.ExecuteScalar("Select Sum(ChangedAmount) as Amount from SalaryMonthlyDetail as SMD"
+ " where SMD.SalaryMonthlyID in("
+ " Select SalaryMonthlyID from SalaryMonthly as SM"
+ " where SM.SalaryMonth between %d and %d"
+ " AND SM.EmployeeID=%n) and SMD.ItemGroup=%n", fromDate, toDate, employeeId.Integer, groupCode);
if (amount == DBNull.Value)
return 0;
else return Convert.ToDouble(amount);
}
internal static double GetUnAuthorizeAmountOnDateRange(TransactionContext tc, ID employeeId, DateTime fromDate, DateTime toDate, EnumSalaryGroup groupCode,EnumSalaryItemCode itemCode)
{
object amount = tc.ExecuteScalar("Select Sum(ChangedAmount) as Amount from SalaryMonthlyDetail as SMD"
+ " where SMD.SalaryMonthlyID in("
+ " Select SalaryMonthlyID from SalaryMonthly as SM"
+ " where SM.SalaryMonth between %d and %d"
+ " AND SM.EmployeeID=%n) and SMD.ItemGroup=%n and SMD.ItemCode=%n", fromDate, toDate, employeeId.Integer, groupCode,itemCode);
if (amount == DBNull.Value)
return 0;
else return Convert.ToDouble(amount);
}
//internal static double GetGrossOnRange(TransactionContext tc, ID employeeId,
// DateTime fromDate, DateTime toDate, EnumSalaryItemCode itemCode, int itemId)
//{
// double grossAmount = 0;
// string strSQL = SQLParser.MakeSQL("SELECT SUM(ChangedAmount) FROM SalaryMonthlyDetail WHERE"
// + " ItemGroup=%n AND ItemCode=%n and itemId==%n AND SalaryMonthlyID IN ( SELECT SalaryMonthlyID FROM"
// + " SalaryMonthly WHERE EmployeeID=%n AND SalaryMonth>=%d AND SalaryMonth<=%d AND WithNoDetail=%b )"
// , EnumSalaryGroup.Gross, itemCode, itemId, employeeId.Integer, fromDate, toDate, false);
// object amount =tc.ExecuteScalar(strSQL);
// if (amount != DBNull.Value) ;
// else grossAmount = grossAmount + Convert.ToDouble(amount);
// amount = tc.ExecuteScalar("SELECT SUM(ChangedAmount) FROM SalaryMonthlyDetail WHERE"
// + " ItemGroup=%n AND ItemCode=%n and itemId==%n AND SalaryMonthlyID IN ( SELECT SalaryMonthlyID FROM"
// + " SalaryMonthly WHERE EmployeeID=%n AND SalaryMonth>=%d AND SalaryMonth<=%d AND WithNoDetail=%b )"
// , groupCode, itemCode, itemId, employeeId.Integer, fromDate, toDate, false);
// if (amount == DBNull.Value)
// return 0;
// else return Convert.ToDouble(amount);
//}
internal static DataSet GetEmpPaySlipGrossForOthers(TransactionContext tc, DateTime dateTime, string sEmpID)
{
DataSet oSMonthlys = new DataSet();
DataSet rootDataset = new DataSet();
try
{
// string sSQL = SQLParser.MakeSQL(@"SELECT E.NAME Name,E.EMPLOYEENO,G.CODE Grade,DG.Name 'Designation',L.Description as LName,
// D.DESCRIPTION Department,CC.DESCRIPTION as RC ,B.NAME as BName,E.BASICSALARY ActualBasic,E.PAYMENTMODE,
// SM.ACCOUNTNO,SM.SalaryMonth,SMD.DESCRIPTION Description,SMD.ITEMGROUP,SM.ISFINALIZED,
// SMD.CHANGEDAMOUNT,SMD.ItemCode,SMD.ItemID,cat.DESCRIPTION as Category,E.JOININGDATE,
// E.DEPARTMENTID
// FROM SALARYMONTHLY SM,Employee E,Grades G,Department D,Designation DG,Location as L,
// SalaryMonthlyDetail SMD,CRG CC,SALARYEMPCOSTCENTER SEmpCC,BANKS as B,BRANCHES as Br,
// CATEGORY cat
// WHERE SM.EMPLOYEEID=E.EMPLOYEEID
// AND SM.GRADEID=G.GRADEID
// AND SM.DEPARTMENTID=D.DEPARTMENTID
// AND SM.DESIGNATIONID=DG.DESIGNATIONID
// AND SM.LOCATIONID=L.LOCATIONID
// AND SM.CATEGORYID = cat.CATEGORYID
// AND CC.CRGID=SEmpCC.COSTCENTERID
// AND SM.EMPLOYEEID=SEmpCC.EMPLOYEEID
// AND SM.SALARYMONTHLYID=SEmpCC.SALARYMONTHLYID
// AND SM.SALARYMONTHLYID=SMD.SALARYMONTHLYID
// AND B.BANKID=Br.BANKID
// AND Br.BRANCHID=SM.BRANCHID
// AND SM.SalaryMonth=%d AND SMD.ITEMGROUP IN(1,2,8) AND SM.EmployeeID IN(%q)
// ORDER BY E.EmployeeNo, Position", dateTime, sEmpID);
// oSMonthlys = tc.ExecuteDataSet(sSQL);
string sSQL = SQLParser.MakeSQL(@"SELECT E.NAME Name,E.EMPLOYEENO,G.CODE Grade,D.[DESCRIPTION] 'Designation',L.Description as LName,
D.DESCRIPTION Department,B.NAME as BName,SM.thismonthbasic ActualBasic,E.PAYMENTMODE,
SM.ACCOUNTNO,SM.SalaryMonth,SM.REMARKS,SMD.DESCRIPTION Description,SMD.ITEMGROUP,SM.ISFINALIZED,
SMD.CHANGEDAMOUNT,SMD.ItemCode,SMD.ItemID,cat.DESCRIPTION as Category,E.JOININGDATE,E.TINNo,
E.DEPARTMENTID
FROM SALARYMONTHLY SM
inner join EMPLOYEE E on SM.EMPLOYEEID=E.EMPLOYEEID
inner join Grades G on Sm.GRADEID=G.GRADEID
inner join DEPARTMENT as D on SM.DEPARTMENTID=D.DEPARTMENTID
inner join DESIGNATION as DG on SM.DESIGNATIONID =DG.DESIGNATIONID
inner join LOCATION as L on SM.LOCATIONID=L.LOCATIONID
left outer join BRANCHES as Br on SM.BRANCHID=Br.BRANCHID
left outer join BANKS as B on Br.BANKID=B.BANKID
inner join CATEGORY cat on E.CATEGORYID=cat.CATEGORYID
inner join SALARYMONTHLYDETAIL as SMD on SM.SALARYMONTHLYID=SMD.SALARYMONTHLYID
AND SM.SalaryMonth=%d AND SMD.ITEMGROUP IN(1,2,8)
AND SM.EmployeeID IN(%q)
UNION
SELECT E.NAME Name,E.EMPLOYEENO,G.CODE Grade,D.[DESCRIPTION] 'Designation',L.Description as LName,
D.DESCRIPTION Department,B.NAME as BName,SM.thismonthbasic ActualBasic,E.PAYMENTMODE,
SM.ACCOUNTNO,SM.SalaryMonth,SM.REMARKS,SMD.DESCRIPTION Description,SMD.ITEMGROUP,SM.ISFINALIZED,
SMD.CHANGEDAMOUNT,SMD.ItemCode,SMD.ItemID,cat.DESCRIPTION as Category,E.JOININGDATE,E.TINNo,
E.DEPARTMENTID
FROM SALARYMONTHLY SM
inner join EMPLOYEE E on SM.EMPLOYEEID=E.EMPLOYEEID
inner join Grades G on Sm.GRADEID=G.GRADEID
inner join DEPARTMENT as D on SM.DEPARTMENTID=D.DEPARTMENTID
inner join DESIGNATION as DG on SM.DESIGNATIONID =DG.DESIGNATIONID
inner join LOCATION as L on SM.LOCATIONID=L.LOCATIONID
left outer join BRANCHES as Br on SM.BRANCHID=Br.BRANCHID
left outer join BANKS as B on Br.BANKID=B.BANKID
inner join CATEGORY cat on E.CATEGORYID=cat.CATEGORYID
inner join SALARYMONTHLYDETAIL as SMD on SM.SALARYMONTHLYID=SMD.SALARYMONTHLYID
AND SM.SalaryMonth=%d AND SMD.ITEMGROUP IN(3) AND smd.ITEMID IN (-128)
AND SM.EmployeeID IN(%q) ", dateTime, sEmpID, dateTime, sEmpID);
oSMonthlys = tc.ExecuteDataSet(sSQL);
oSMonthlys.Tables[0].TableName = "Gross";
rootDataset.Tables.Add(oSMonthlys.Tables[0].Copy());
sSQL = SQLParser.MakeSQL(@"SELECT E.EMPLOYEENO,SMD.DESCRIPTION Description,SMD.ITEMGROUP,SMD.ItemCode,SMD.ItemID,
sum(SMD.CHANGEDAMOUNT)CHANGEDAMOUNT
FROM SALARYMONTHLY SM
inner join EMPLOYEE E on SM.EMPLOYEEID=E.EMPLOYEEID
inner join SALARYMONTHLYDETAIL as SMD on SM.SALARYMONTHLYID=SMD.SALARYMONTHLYID
AND SM.SalaryMonth=%d AND SMD.ITEMGROUP IN(4)
AND SM.EmployeeID IN(%q)
GROUP BY E.EMPLOYEENO,SMD.DESCRIPTION ,SMD.ITEMGROUP,SMD.ItemCode,SMD.ItemID", dateTime, sEmpID);
oSMonthlys = tc.ExecuteDataSet(sSQL);
oSMonthlys.Tables[0].TableName = "Misc";
rootDataset.Tables.Add(oSMonthlys.Tables[0].Copy());
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return rootDataset;
}
internal static DataSet GetEmpPaySlipGrossForOthersOld(TransactionContext tc, DateTime dateTime, string sEmpID)
{
DataSet oSMonthlys = new DataSet();
try
{
// string sSQL = SQLParser.MakeSQL(@"SELECT E.NAME Name,E.EMPLOYEENO,G.CODE Grade,DG.Name 'Designation',L.Description as LName,
// D.DESCRIPTION Department,CC.DESCRIPTION as RC ,B.NAME as BName,E.BASICSALARY ActualBasic,E.PAYMENTMODE,
// SM.ACCOUNTNO,SM.SalaryMonth,SMD.DESCRIPTION Description,SMD.ITEMGROUP,SM.ISFINALIZED,
// SMD.CHANGEDAMOUNT,SMD.ItemCode,SMD.ItemID,cat.DESCRIPTION as Category,E.JOININGDATE,
// E.DEPARTMENTID
// FROM SALARYMONTHLY SM,Employee E,Grades G,Department D,Designation DG,Location as L,
// SalaryMonthlyDetail SMD,CRG CC,SALARYEMPCOSTCENTER SEmpCC,BANKS as B,BRANCHES as Br,
// CATEGORY cat
// WHERE SM.EMPLOYEEID=E.EMPLOYEEID
// AND SM.GRADEID=G.GRADEID
// AND SM.DEPARTMENTID=D.DEPARTMENTID
// AND SM.DESIGNATIONID=DG.DESIGNATIONID
// AND SM.LOCATIONID=L.LOCATIONID
// AND SM.CATEGORYID = cat.CATEGORYID
// AND CC.CRGID=SEmpCC.COSTCENTERID
// AND SM.EMPLOYEEID=SEmpCC.EMPLOYEEID
// AND SM.SALARYMONTHLYID=SEmpCC.SALARYMONTHLYID
// AND SM.SALARYMONTHLYID=SMD.SALARYMONTHLYID
// AND B.BANKID=Br.BANKID
// AND Br.BRANCHID=SM.BRANCHID
// AND SM.SalaryMonth=%d AND SMD.ITEMGROUP IN(1,2,8) AND SM.EmployeeID IN(%q)
// ORDER BY E.EmployeeNo, Position", dateTime, sEmpID);
// oSMonthlys = tc.ExecuteDataSet(sSQL);
string sSQL = SQLParser.MakeSQL(@"SELECT E.NAME Name,E.EMPLOYEENO,G.CODE Grade, DG.Name as Designation,L.Description as LName,
D.DESCRIPTION Department,B.NAME as BName,SM.thismonthbasic ActualBasic,E.PAYMENTMODE,
SM.ACCOUNTNO,SM.monthyeardate SalaryMonth,SMD.DESCRIPTION Description,SMD.ITEMGROUP,SM.ISFINALIZED,
SMD.CHANGEDAMOUNT,SMD.ItemCode,SMD.ItemID,cat.DESCRIPTION as Category,E.JOININGDATE,E.TINNo,
E.DEPARTMENTID,'' REMARKS
FROM gp_SALARYMONTHLY SM
inner join gp_EMPLOYEE E on SM.EMPLOYEEID=E.EMPLOYEEID
inner join gp_Grades G on Sm.GRADEID=G.GRADEID
inner join gp_DEPARTMENT as D on SM.DEPARTMENTID=D.DEPARTMENTID
inner join gp_DESIGNATION as DG on SM.DESIGNATIONID =DG.DESIGNATIONID
inner join gp_LOCATION as L on SM.LOCATIONID=L.LOCATIONID
left outer join gp_BRANCHES as Br on SM.BRANCHID=Br.BRANCHID
left outer join gp_BANKS as B on Br.BANKID=B.BANKID
inner join gp_CATEGORY cat on E.CATEGORYID=cat.CATEGORYID
inner join gp_SALARYMONTHLYDETAIL as SMD on SM.SALARYMONTHLYID=SMD.SALARYMONTHLYID
AND SM.monthyeardate=%d AND SMD.ITEMGROUP IN(1,2,8)
AND SM.EmployeeID IN(%q) ORDER BY E.EmployeeNo, Position", dateTime, sEmpID);
oSMonthlys = tc.ExecuteDataSet(sSQL);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return oSMonthlys;
}
internal static DataSet GetEmpPaySlipDeductForOthers(TransactionContext tc, DateTime dateTime, string sEmpID)
{
DataSet oSMonthlys = new DataSet();
try
{
string sql = SQLParser.MakeSQL(@"SELECT E.NAME Name,E.EMPLOYEEID,E.EMPLOYEENO,E.JOININGDATE,E.TINNO,G.CODE Grade,DG.Name as 'Designation',L.Description as LName,
D.DESCRIPTION Department,B.NAME as BName,E.BASICSALARY ActualBasic,E.PAYMENTMODE,
SM.ACCOUNTNO,SM.SalaryMonth,SM.REMARKS,
'DESCRIPTION' =
(CASE WHEN SMD.DESCRIPTION = 'PF' THEN 'PF Contribution'
ELSE SMD.DESCRIPTION
END
),
SMD.ITEMGROUP,
SMD.CHANGEDAMOUNT,SMD.ItemCode,SMD.ItemID
FROM Employee E Inner join SALARYMONTHLY SM on E.EMPLOYEEID=SM.EMPLOYEEID
inner join Grades G on sm.GRADEID=G.GRADEID
Inner join Department D on Sm.DEPARTMENTID =D.DEPARTMENTID
inner join Designation DG on E.DESIGNATIONID=Dg.DESIGNATIONID
inner join SalaryMonthlyDetail SMD on sm.SALARYMONTHLYID=smd.SALARYMONTHLYID
left outer join BRANCHES Br on sm.BRANCHID=br.BRANCHID
left outer join BANKS B on Br.BANKID=B.BANKID
Inner join Location L on Sm.LocationID =L.LocationID
AND SM.SalaryMonth=%d AND SMD.ITEMGROUP=3 AND SM.EmployeeID IN(%q) ORDER BY E.EmployeeNo, 'DESCRIPTION'", dateTime, sEmpID);
//AND SMD.ITEMCODE Not in(-119)
// oSMonthlys = tc.ExecuteDataSet(@"SELECT E.NAME Name,E.EMPLOYEENO,G.CODE Grade,DG.Name 'Designation',L.Description as LName,
// D.DESCRIPTION Department,B.NAME as BName,E.BASICSALARY ActualBasic,E.PAYMENTMODE,
// SM.ACCOUNTNO,SM.SalaryMonth,SMD.DESCRIPTION Description,SMD.ITEMGROUP,
// SMD.CHANGEDAMOUNT,SMD.ItemCode,SMD.ItemID
// FROM Employee E Inner join SALARYMONTHLY SM on E.EMPLOYEEID=SM.EMPLOYEEID
// inner join Grades G on sm.GRADEID=G.GRADEID
// Inner join Department D on Sm.DEPARTMENTID =D.DEPARTMENTID
// inner join Designation DG on sm.DESIGNATIONID=Dg.DESIGNATIONID
// inner join SalaryMonthlyDetail SMD on sm.SALARYMONTHLYID=smd.SALARYMONTHLYID
// left outer join BRANCHES Br on sm.BRANCHID=br.BRANCHID
// left outer join BANKS B on Br.BANKID=B.BANKID
// Inner join Location L on Sm.LocationID =L.LocationID
// AND SM.SalaryMonth=%d AND SMD.ITEMGROUP=3 AND SM.EmployeeID IN(%q) ORDER BY E.EmployeeNo, Position", dateTime, sEmpID);
oSMonthlys = tc.ExecuteDataSet(sql);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return oSMonthlys;
}
internal static DataSet GetEmpPaySlipDeductForOthersOld(TransactionContext tc, DateTime dateTime, string sEmpID)
{
DataSet oSMonthlys = new DataSet();
try
{
string sql = SQLParser.MakeSQL(@"SELECT E.NAME Name,E.EMPLOYEEID,E.EMPLOYEENO,E.JOININGDATE,E.TINNO,G.CODE Grade,DG.Name as 'Designation',L.Description as LName,
D.DESCRIPTION Department,B.NAME as BName,E.BASICSALARY ActualBasic,E.PAYMENTMODE,
SM.ACCOUNTNO,SM.MonthYearDate SalaryMonth,
'DESCRIPTION' =
(CASE WHEN SMD.DESCRIPTION = 'PF' THEN 'PF Contribution'
ELSE SMD.DESCRIPTION
END
),
SMD.ITEMGROUP,
SMD.CHANGEDAMOUNT,SMD.ItemCode,SMD.ItemID,'' REMARKS
FROM gp_Employee E Inner join gp_SALARYMONTHLY SM on E.EMPLOYEEID=SM.EMPLOYEEID
inner join gp_Grades G on sm.GRADEID=G.GRADEID
Inner join gp_Department D on Sm.DEPARTMENTID =D.DEPARTMENTID
inner join gp_Designation DG on E.DESIGNATIONID=Dg.DESIGNATIONID
inner join gp_SalaryMonthlyDetail SMD on sm.SALARYMONTHLYID=smd.SALARYMONTHLYID
left outer join gp_BRANCHES Br on sm.BRANCHID=br.BRANCHID
left outer join gp_BANKS B on Br.BANKID=B.BANKID
Inner join gp_Location L on Sm.LocationID =L.LocationID
AND SM.MonthYearDate=%d AND SMD.ITEMGROUP=3 AND SM.EmployeeID IN(%q) ORDER BY E.EmployeeNo, 'DESCRIPTION'", dateTime, sEmpID);
//AND SMD.ITEMCODE Not in(-119)
// oSMonthlys = tc.ExecuteDataSet(@"SELECT E.NAME Name,E.EMPLOYEENO,G.CODE Grade,DG.Name 'Designation',L.Description as LName,
// D.DESCRIPTION Department,B.NAME as BName,E.BASICSALARY ActualBasic,E.PAYMENTMODE,
// SM.ACCOUNTNO,SM.SalaryMonth,SMD.DESCRIPTION Description,SMD.ITEMGROUP,
// SMD.CHANGEDAMOUNT,SMD.ItemCode,SMD.ItemID
// FROM Employee E Inner join SALARYMONTHLY SM on E.EMPLOYEEID=SM.EMPLOYEEID
// inner join Grades G on sm.GRADEID=G.GRADEID
// Inner join Department D on Sm.DEPARTMENTID =D.DEPARTMENTID
// inner join Designation DG on sm.DESIGNATIONID=Dg.DESIGNATIONID
// inner join SalaryMonthlyDetail SMD on sm.SALARYMONTHLYID=smd.SALARYMONTHLYID
// left outer join BRANCHES Br on sm.BRANCHID=br.BRANCHID
// left outer join BANKS B on Br.BANKID=B.BANKID
// Inner join Location L on Sm.LocationID =L.LocationID
// AND SM.SalaryMonth=%d AND SMD.ITEMGROUP=3 AND SM.EmployeeID IN(%q) ORDER BY E.EmployeeNo, Position", dateTime, sEmpID);
oSMonthlys = tc.ExecuteDataSet(sql);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return oSMonthlys;
}
internal static DataSet GetEmpPaySlipDeductForCitiOthers(TransactionContext tc, DateTime dateTime, string sEmpID)
{
DataSet oSMonthlys = new DataSet();
try
{
string sql = SQLParser.MakeSQL(@"SELECT E.NAME Name,E.EMPLOYEENO,G.CODE Grade,DG.Name as 'Designation',L.Description as LName,
D.DESCRIPTION Department,B.NAME as BName,E.BASICSALARY ActualBasic,E.PAYMENTMODE,
SM.ACCOUNTNO,SM.SalaryMonth,
'DESCRIPTION' =
(CASE WHEN SMD.DESCRIPTION ='PF' THEN 'PF Contribution'
ELSE SMD.DESCRIPTION
END
),
SMD.ITEMGROUP,
SMD.CHANGEDAMOUNT,SMD.ItemCode,SMD.ItemID
FROM Employee E Inner join SALARYMONTHLY SM on E.EMPLOYEEID=SM.EMPLOYEEID
inner join Grades G on sm.GRADEID=G.GRADEID
Inner join Department D on Sm.DEPARTMENTID =D.DEPARTMENTID
inner join Designation DG on E.DESIGNATIONID=Dg.DESIGNATIONID
inner join SalaryMonthlyDetail SMD on sm.SALARYMONTHLYID=smd.SALARYMONTHLYID
left outer join BRANCHES Br on sm.BRANCHID=br.BRANCHID
left outer join BANKS B on Br.BANKID=B.BANKID
Inner join Location L on Sm.LocationID =L.LocationID
AND SM.SalaryMonth=%d AND SMD.ITEMGROUP=3 AND SM.EmployeeID IN(%q) ORDER BY E.EmployeeNo, 'DESCRIPTION'", dateTime, sEmpID);
oSMonthlys = tc.ExecuteDataSet(sql);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return oSMonthlys;
}
internal static DataSet GetEmpPaySlipDeductForLR(TransactionContext tc, DateTime dateTime, string sEmpID)
{
DataSet oSMonthlys = new DataSet();
try
{
string sql = SQLParser.MakeSQL(@"SELECT E.NAME Name,E.EMPLOYEENO,G.CODE Grade,DG.Name as 'Designation',L.Description as LName,
D.DESCRIPTION Department,B.NAME as BName,E.BASICSALARY ActualBasic,E.PAYMENTMODE,
SM.ACCOUNTNO,SM.SalaryMonth,
'DESCRIPTION' =
(CASE WHEN SMD.DESCRIPTION = 'PF' THEN 'PF Contribution'
ELSE SMD.DESCRIPTION
END
),
SMD.ITEMGROUP,
SMD.CHANGEDAMOUNT,SMD.ItemCode,SMD.ItemID
FROM Employee E Inner join SALARYMONTHLY SM on E.EMPLOYEEID=SM.EMPLOYEEID
inner join Grades G on sm.GRADEID=G.GRADEID
Inner join Department D on Sm.DEPARTMENTID =D.DEPARTMENTID
inner join Designation DG on E.DESIGNATIONID=Dg.DESIGNATIONID
inner join SalaryMonthlyDetail SMD on sm.SALARYMONTHLYID=smd.SALARYMONTHLYID
left outer join BRANCHES Br on sm.BRANCHID=br.BRANCHID
left outer join BANKS B on Br.BANKID=B.BANKID
Inner join Location L on Sm.LocationID =L.LocationID
AND SM.SalaryMonth=%d AND SMD.ITEMGROUP=4 AND SM.EmployeeID IN(%q) AND SMD.ITEMCODE in(-126) ORDER BY E.EmployeeNo, 'DESCRIPTION'", dateTime, sEmpID);
//AND SMD.ITEMCODE Not in(-119)
// oSMonthlys = tc.ExecuteDataSet(@"SELECT E.NAME Name,E.EMPLOYEENO,G.CODE Grade,DG.Name 'Designation',L.Description as LName,
// D.DESCRIPTION Department,B.NAME as BName,E.BASICSALARY ActualBasic,E.PAYMENTMODE,
// SM.ACCOUNTNO,SM.SalaryMonth,SMD.DESCRIPTION Description,SMD.ITEMGROUP,
// SMD.CHANGEDAMOUNT,SMD.ItemCode,SMD.ItemID
// FROM Employee E Inner join SALARYMONTHLY SM on E.EMPLOYEEID=SM.EMPLOYEEID
// inner join Grades G on sm.GRADEID=G.GRADEID
// Inner join Department D on Sm.DEPARTMENTID =D.DEPARTMENTID
// inner join Designation DG on sm.DESIGNATIONID=Dg.DESIGNATIONID
// inner join SalaryMonthlyDetail SMD on sm.SALARYMONTHLYID=smd.SALARYMONTHLYID
// left outer join BRANCHES Br on sm.BRANCHID=br.BRANCHID
// left outer join BANKS B on Br.BANKID=B.BANKID
// Inner join Location L on Sm.LocationID =L.LocationID
// AND SM.SalaryMonth=%d AND SMD.ITEMGROUP=3 AND SM.EmployeeID IN(%q) ORDER BY E.EmployeeNo, Position", dateTime, sEmpID);
oSMonthlys = tc.ExecuteDataSet(sql);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return oSMonthlys;
}
internal static DataSet GetEmpPaySlipDeductForLROld(TransactionContext tc, DateTime dateTime, string sEmpID)
{
DataSet oSMonthlys = new DataSet();
try
{
string sql = SQLParser.MakeSQL(@"SELECT E.NAME Name,E.EMPLOYEENO,G.CODE Grade,DG.Name as 'Designation',L.Description as LName,
D.DESCRIPTION Department,B.NAME as BName,E.BASICSALARY ActualBasic,E.PAYMENTMODE,
SM.ACCOUNTNO,SM.monthyeardate SalaryMonth,
'DESCRIPTION' =
(CASE WHEN SMD.DESCRIPTION = 'PF' THEN 'PF Contribution'
ELSE SMD.DESCRIPTION
END
),
SMD.ITEMGROUP,
SMD.CHANGEDAMOUNT,SMD.ItemCode,SMD.ItemID
FROM Employee E Inner join gp_SALARYMONTHLY SM on E.EMPLOYEEID=SM.EMPLOYEEID
inner join gp_Grades G on sm.GRADEID=G.GRADEID
Inner join gp_Department D on Sm.DEPARTMENTID =D.DEPARTMENTID
inner join gp_Designation DG on E.DESIGNATIONID=Dg.DESIGNATIONID
inner join gp_SalaryMonthlyDetail SMD on sm.SALARYMONTHLYID=smd.SALARYMONTHLYID
left outer join gp_BRANCHES Br on sm.BRANCHID=br.BRANCHID
left outer join gp_BANKS B on Br.BANKID=B.BANKID
Inner join gp_Location L on Sm.LocationID =L.LocationID
AND SM.monthyeardate=%d AND SMD.ITEMGROUP=4 AND SM.EmployeeID IN(%q) AND SMD.ITEMCODE in(-126) ORDER BY E.EmployeeNo, 'DESCRIPTION'", dateTime, sEmpID);
//AND SMD.ITEMCODE Not in(-119)
// oSMonthlys = tc.ExecuteDataSet(@"SELECT E.NAME Name,E.EMPLOYEENO,G.CODE Grade,DG.Name 'Designation',L.Description as LName,
// D.DESCRIPTION Department,B.NAME as BName,E.BASICSALARY ActualBasic,E.PAYMENTMODE,
// SM.ACCOUNTNO,SM.SalaryMonth,SMD.DESCRIPTION Description,SMD.ITEMGROUP,
// SMD.CHANGEDAMOUNT,SMD.ItemCode,SMD.ItemID
// FROM Employee E Inner join SALARYMONTHLY SM on E.EMPLOYEEID=SM.EMPLOYEEID
// inner join Grades G on sm.GRADEID=G.GRADEID
// Inner join Department D on Sm.DEPARTMENTID =D.DEPARTMENTID
// inner join Designation DG on sm.DESIGNATIONID=Dg.DESIGNATIONID
// inner join SalaryMonthlyDetail SMD on sm.SALARYMONTHLYID=smd.SALARYMONTHLYID
// left outer join BRANCHES Br on sm.BRANCHID=br.BRANCHID
// left outer join BANKS B on Br.BANKID=B.BANKID
// Inner join Location L on Sm.LocationID =L.LocationID
// AND SM.SalaryMonth=%d AND SMD.ITEMGROUP=3 AND SM.EmployeeID IN(%q) ORDER BY E.EmployeeNo, Position", dateTime, sEmpID);
oSMonthlys = tc.ExecuteDataSet(sql);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return oSMonthlys;
}
internal static DataSet GetEmpPaySlipIncomeTaxAmountForOthers(TransactionContext tc, DateTime dateTime, string sEmpID)
{
DataSet oSMonthlys = new DataSet();
try
{
oSMonthlys = tc.ExecuteDataSet(@"SELECT E.NAME Name,E.EMPLOYEENO,G.CODE Grade,DG.Name as 'Designation',L.Description as LName,
D.DESCRIPTION Department,E.BASICSALARY ActualBasic,E.PAYMENTMODE,
SM.ACCOUNTNO,SM.SalaryMonth,SMD.DESCRIPTION Description,SMD.ITEMGROUP,
SMD.CHANGEDAMOUNT,SMD.ItemCode,SMD.ItemID
FROM SALARYMONTHLY SM,Employee E,Grades G,Department D,Designation DG,Location L,
SalaryMonthlyDetail SMD
WHERE SM.EMPLOYEEID=E.EMPLOYEEID
AND SM.GRADEID=G.GRADEID
AND SM.DEPARTMENTID=D.DEPARTMENTID
AND SM.LocationID=L.LocationID
AND E.DESIGNATIONID=DG.DESIGNATIONID
AND SM.SALARYMONTHLYID=SMD.SALARYMONTHLYID
AND SM.SalaryMonth=%d AND SMD.ITEMGROUP=5 AND SMD.ITEMCODE IN(-129,-132) AND SM.EmployeeID IN(%q) ORDER BY E.EmployeeNo, Position", dateTime, sEmpID);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return oSMonthlys;
}
internal static DataSet GetEmpPaySlipIncomeTaxAmountForOthersOld(TransactionContext tc, DateTime dateTime, string sEmpID)
{
DataSet oSMonthlys = new DataSet();
try
{
oSMonthlys = tc.ExecuteDataSet(@"SELECT E.NAME Name,E.EMPLOYEENO,G.CODE Grade,DG.Name as 'Designation',L.Description as LName,
D.DESCRIPTION Department,E.BASICSALARY ActualBasic,E.PAYMENTMODE,
SM.ACCOUNTNO,SM.monthyeardate SalaryMonth,SMD.DESCRIPTION Description,SMD.ITEMGROUP,
SMD.CHANGEDAMOUNT,SMD.ItemCode,SMD.ItemID
FROM gp_SALARYMONTHLY SM,gp_Employee E,gp_Grades G,gp_Department D,gp_Designation DG,gp_Location L,
gp_SalaryMonthlyDetail SMD
WHERE SM.EMPLOYEEID=E.EMPLOYEEID
AND SM.GRADEID=G.GRADEID
AND SM.DEPARTMENTID=D.DEPARTMENTID
AND SM.LocationID=L.LocationID
AND E.DESIGNATIONID=DG.DESIGNATIONID
AND SM.SALARYMONTHLYID=SMD.SALARYMONTHLYID
AND SM.monthyeardate=%d AND SMD.ITEMGROUP=5 AND SMD.ITEMCODE IN(-129,-132) AND SM.EmployeeID IN(%q) ORDER BY E.EmployeeNo, Position", dateTime, sEmpID);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return oSMonthlys;
}
internal static DataSet GetEmpSalaryProcessedData(TransactionContext tc, DateTime dateTime, string employeeno)
{
DataSet oSMonthlys = new DataSet();
try
{
oSMonthlys = tc.ExecuteDataSet("SELECT E.NAME Name,E.EMPLOYEENO,G.CODE Grade,DG.CODE 'Designation',D.DESCRIPTION Department,"
+ " E.BASICSALARY ActualBasic,E.PAYMENTMODE,E.ACCOUNTNO,SM.SalaryMonth,SMD.DESCRIPTION Description,SMD.ITEMGROUP, "
+ " SMD.CHANGEDAMOUNT, SMD.CALCULATEDAMOUNT, SMD.ItemCode"
+ " FROM SALARYMONTHLY SM INNER JOIN Employee E ON SM.EMPLOYEEID=E.EMPLOYEEID"
+ " INNER JOIN GRADES G ON SM.GRADEID=G.GRADEID"
+ " INNER JOIN DEPARTMENT D ON SM.DEPARTMENTID=D.DEPARTMENTID"
+ " INNER JOIN DESIGNATION DG ON SM.DESIGNATIONID=DG.DESIGNATIONID"
+ " INNER JOIN SALARYMONTHLYDETAIL SMD ON SM.SALARYMONTHLYID=SMD.SALARYMONTHLYID WHERE SM.SalaryMonth=%d AND E.EMPLOYEENO=%s", dateTime, employeeno);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return oSMonthlys;
}
internal static DataSet GetEmpPaySlipGross(TransactionContext tc, DateTime dateTime, string sEmpID)
{
DataSet oSMonthlys = new DataSet();
try
{
#region Old Code
//oSMonthlys = tc.ExecuteDataSet("SELECT E.NAME Name,E.EMPLOYEENO,G.CODE Grade,DG.Name 'Designation',"
// + " D.DESCRIPTION Department,E.BASICSALARY ActualBasic,E.PAYMENTMODE,"
// + " E.ACCOUNTNO,SM.SalaryMonth,SMD.DESCRIPTION Description,SMD.ITEMGROUP,"
// + " SMD.CHANGEDAMOUNT,SMD.ItemCode,SMD.ItemID"
// + " FROM SALARYMONTHLY SM,Employee E,Grades G,Department D,Designation DG,"
// + " SalaryMonthlyDetail SMD"
// + " WHERE SM.EMPLOYEEID=E.EMPLOYEEID"
// + " AND SM.GRADEID=G.GRADEID"
// + " AND SM.DEPARTMENTID=D.DEPARTMENTID"
// + " AND SM.DESIGNATIONID=DG.DESIGNATIONID"
// + " AND SM.SALARYMONTHLYID=SMD.SALARYMONTHLYID"
// + " AND SM.SalaryMonth=%d AND SMD.ITEMGROUP IN(1,2,8) AND SM.EmployeeID IN(%q) ORDER BY E.EmployeeNo, Position", dateTime,sEmpID);
#endregion
#region Latest Old Code
// oSMonthlys = tc.ExecuteDataSet(@"SELECT E.NAME Name,E.EMPLOYEENO,G.CODE Grade,SM.Designation 'Designation',L.Description as LName,
// D.DESCRIPTION Department,CC.DESCRIPTION as RC ,B.NAME as BName,E.BASICSALARY ActualBasic,E.PAYMENTMODE,
// SM.ACCOUNTNO,SM.SalaryMonth,SMD.DESCRIPTION Description,SMD.ITEMGROUP,SM.ISFINALIZED,
// SMD.CHANGEDAMOUNT,SMD.ItemCode,SMD.ItemID
// FROM SALARYMONTHLY SM,Employee E,Grades G,Department D,Designation DG,Location as L,
// SalaryMonthlyDetail SMD,CRG CC,SALARYEMPCOSTCENTER SEmpCC,BANKS as B,BRANCHES as Br
// WHERE SM.EMPLOYEEID=E.EMPLOYEEID
// AND SM.GRADEID=G.GRADEID
// AND SM.DEPARTMENTID=D.DEPARTMENTID
// AND SM.DESIGNATIONID=DG.DESIGNATIONID
// AND SM.LOCATIONID=L.LOCATIONID
// AND CC.CRGID=SEmpCC.COSTCENTERID
// AND SM.EMPLOYEEID=SEmpCC.EMPLOYEEID
// AND SM.SALARYMONTHLYID=SEmpCC.SALARYMONTHLYID
// AND SM.SALARYMONTHLYID=SMD.SALARYMONTHLYID
// AND B.BANKID=Br.BANKID
// AND Br.BRANCHID=SM.BRANCHID
// AND SM.SalaryMonth=%d AND SMD.ITEMGROUP IN(1,2,8) AND SM.EmployeeID IN(%q) ORDER BY E.EmployeeNo, Position", dateTime, sEmpID);
string sSQL = SQLParser.MakeSQL(@"SELECT E.NAME Name,E.EMPLOYEENO,G.CODE Grade,DG.Name as 'Designation',L.Description as LName,
D.DESCRIPTION Department,CC.DESCRIPTION as RC ,B.NAME as BName,E.BASICSALARY ActualBasic,E.PAYMENTMODE,
SM.ACCOUNTNO,SM.SalaryMonth,SMD.DESCRIPTION Description,SMD.ITEMGROUP,SM.ISFINALIZED,
SMD.CHANGEDAMOUNT,SMD.ItemCode,SMD.ItemID,cat.DESCRIPTION as Category,E.JOININGDATE,
E.DEPARTMENTID
FROM SALARYMONTHLY SM,Employee E,Grades G,Department D,Designation DG,Location as L,
SalaryMonthlyDetail SMD,CRG CC,SALARYEMPCOSTCENTER SEmpCC,BANKS as B,BRANCHES as Br,
CATEGORY cat
WHERE SM.EMPLOYEEID=E.EMPLOYEEID
AND SM.GRADEID=G.GRADEID
AND SM.DEPARTMENTID=D.DEPARTMENTID
AND E.DESIGNATIONID=DG.DESIGNATIONID
AND SM.LOCATIONID=L.LOCATIONID
AND SM.CATEGORYID = cat.CATEGORYID
AND CC.CRGID=SEmpCC.COSTCENTERID
AND SM.EMPLOYEEID=SEmpCC.EMPLOYEEID
AND SM.SALARYMONTHLYID=SEmpCC.SALARYMONTHLYID
AND SM.SALARYMONTHLYID=SMD.SALARYMONTHLYID
AND B.BANKID=Br.BANKID
AND Br.BRANCHID=SM.BRANCHID
AND SM.SalaryMonth=%d AND SMD.ITEMGROUP IN(1,2,8) AND SM.EmployeeID IN(%q)
ORDER BY E.EmployeeNo, Position", dateTime, sEmpID);
oSMonthlys = tc.ExecuteDataSet(sSQL);
#endregion
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return oSMonthlys;
}
internal static DataSet GetEmpPaySlipDeduct(TransactionContext tc, DateTime dateTime, string sEmpID)
{
DataSet oSMonthlys = new DataSet();
try
{
#region Old Code
//oSMonthlys = tc.ExecuteDataSet("SELECT E.NAME Name,E.EMPLOYEENO,G.CODE Grade,DG.Name 'Designation',"
// + " D.DESCRIPTION Department,E.BASICSALARY ActualBasic,E.PAYMENTMODE,"
// + " E.ACCOUNTNO,SM.SalaryMonth,SMD.DESCRIPTION Description,SMD.ITEMGROUP,"
// + " SMD.CHANGEDAMOUNT,SMD.ItemCode,SMD.ItemID"
// + " FROM SALARYMONTHLY SM,Employee E,Grades G,Department D,Designation DG,"
// + " SalaryMonthlyDetail SMD"
// + " WHERE SM.EMPLOYEEID=E.EMPLOYEEID"
// + " AND SM.GRADEID=G.GRADEID"
// + " AND SM.DEPARTMENTID=D.DEPARTMENTID"
// + " AND SM.DESIGNATIONID=DG.DESIGNATIONID"
// + " AND SM.SALARYMONTHLYID=SMD.SALARYMONTHLYID"
// + " AND SM.SalaryMonth=%d AND SMD.ITEMGROUP=3 AND SM.EmployeeID IN(%q) ORDER BY E.EmployeeNo, Position", dateTime, sEmpID);
#endregion
#region Latest Old Code
oSMonthlys = tc.ExecuteDataSet(@"SELECT E.NAME Name,E.EMPLOYEENO,G.CODE Grade,DG.Name as 'Designation',L.Description as LName,
D.DESCRIPTION Department,CC.DESCRIPTION as RC ,B.NAME as BName,E.BASICSALARY ActualBasic,E.PAYMENTMODE,
SM.ACCOUNTNO,SM.SalaryMonth,SMD.DESCRIPTION Description,SMD.ITEMGROUP,
SMD.CHANGEDAMOUNT,SMD.ItemCode,SMD.ItemID
FROM Employee E Inner join SALARYMONTHLY SM on E.EMPLOYEEID=SM.EMPLOYEEID
inner join Grades G on sm.GRADEID=G.GRADEID
Inner join Department D on Sm.DEPARTMENTID =D.DEPARTMENTID
inner join Designation DG on E.DESIGNATIONID=Dg.DESIGNATIONID
inner join SalaryMonthlyDetail SMD on sm.SALARYMONTHLYID=smd.SALARYMONTHLYID
inner join SALARYEMPCOSTCENTER SEmpCC on sm.SALARYMONTHLYID=SEmpCC.SALARYMONTHLYID AND SEmpCC.EMPLOYEEID=E.EMPLOYEEID
inner JOIN CRG cc on SEmpCC.COSTCENTERID=cc.CRGID
inner join BRANCHES Br on sm.BRANCHID=br.BRANCHID
inner JOIN BANKS B on Br.BANKID=B.BANKID
Inner join Location L on Sm.LocationID =L.LocationID
AND SM.SalaryMonth=%d AND SMD.ITEMGROUP=3 AND SM.EmployeeID IN(%q) ORDER BY E.EmployeeNo, Position", dateTime, sEmpID);
#endregion
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return oSMonthlys;
}
internal static DataSet GetEmpOverAllSummaryGross(TransactionContext tc, DateTime dateTime, string sEmpID)
{
DataSet oSMonthlys = new DataSet();
try
{
string sql = SQLParser.MakeSQL("Select SMD.DESCRIPTION,SUM(SMD.CHANGEDAMOUNT) as Amount ,SMD.ITEMGROUP,SMD.ITEMID,SMD.ITEMCODE"
+ " from SALARYMONTHLYDETAIL SMD,SALARYMONTHLY SM"
+ " where SM.EMPLOYEEID in(%q)"
+ " AND SMD.ITEMGROUP IN(1,2,8)"
+ " AND SM.SALARYMONTH=%d"
+ " AND SM.SALARYMONTHLYID=SMD.SALARYMONTHLYID"
+ " AND SMD.CHANGEDAMOUNT<>0"
+ " GROUP by SMD.ITEMID,SMD.ITEMGROUP,SMD.ITEMCODE,SMD.DESCRIPTION order by SMD.ITEMCODE desc", sEmpID, dateTime);
oSMonthlys = tc.ExecuteDataSet(sql);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return oSMonthlys;
}
internal static DataSet GetEmpOverAllSummaryDeduct(TransactionContext tc, DateTime dateTime, string sEmpID)
{
DataSet oSMonthlys = new DataSet();
try
{
oSMonthlys = tc.ExecuteDataSet("Select SMD.DESCRIPTION,SUM(SMD.CHANGEDAMOUNT) as Amount ,SMD.ITEMGROUP,SMD.ITEMID,SMD.ITEMCODE"
+ " from SALARYMONTHLYDETAIL SMD,SALARYMONTHLY SM"
+ " where SM.EMPLOYEEID in(%q)"
+ " AND SMD.ITEMGROUP IN(3)"
+ " AND SM.SALARYMONTH=%d"
+ " AND SM.SALARYMONTHLYID=SMD.SALARYMONTHLYID"
+ " AND SMD.CHANGEDAMOUNT<>0"
+ " GROUP by SMD.ITEMGROUP,SMD.ITEMID,SMD.ITEMCODE,SMD.DESCRIPTION order by SMD.ITEMCODE asc", sEmpID, dateTime);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return oSMonthlys;
}
internal static DataSet GetCasualSalarySheet(TransactionContext tc, DateTime dateTime, string sEmpID)
{
DataSet rootDataset = new DataSet();
DataSet tempdataset = new DataSet();
try
{
string query1 = SQLParser.MakeSQL(@"select A.EmployeeID, A.EmployeeNo, A.Name,A.GName,A.DName,A.DegName, A.GCode,A.SequenceNo,A.ItemID,"
+ " A.Description, SUM(A.changedamount) Amount"
+ " from"
+ "(select S.EmployeeID, E.EmployeeNo, E.Name,E.JoiningDate, sd.ItemGroup,sd.ItemCode,sd.SUPPORTID,"
+ " sd.ItemID, sd.Description,sd.Position, sd.changedamount,G.DESCRIPTION as GName,Deg.Name as DegName,D.Description as DName, G.Code as GCode,G.SequenceNo from Grades G,DESIGNATION Deg,Department D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd "
+ " where D.DepartmentID=E.DepartmentID AND G.GradeID= S.GradeID AND Deg.DESIGNATIONID=E.DESIGNATIONID AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d and Sd.ItemGroup in(1,4) 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.DegName,A.SequenceNo,A.ItemID,A.GCode,"
+ " A.ItemCode, A.ItemID, A.Description,A.Position order by A.EmployeeNo,A.Position,A.SequenceNo,A.GCode",
dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet(query1);
tempdataset.Tables[0].TableName = "GrossItem";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return rootDataset;
}
internal static DataSet GetEmpPNL(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.JoiningDate,A.GCode,A.SequenceNo,
A.Description, SUM(A.changedamount) Amount,A.ACCOUNTNO,A.BankName,A.Division,A.Department
from
(select S.EmployeeID, S.EmployeeNo, S.Name,S.JoiningDate, sd.ItemGroup,sd.ItemCode,
sd.ItemID, sd.Description,sd.Position, sd.changedamount,S.GradeName as GName,S.Designation as DName,S.GCode,S.SequenceNo,S.ACCOUNTNO,S.BankName,S.Division,S.Department
from vw_EmployeeImportantInfoWithSalary S, SalaryMonthlyDetail Sd
where 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, S.EmployeeNo, S.Name,S.JoiningDate, sd.ItemGroup,sd.ItemCode,
sd.ItemID, sd.Description,sd.Position, sd.changedamount,S.GradeName as GName,S.Designation as DName,S.GCode,S.SequenceNo ,S.ACCOUNTNO,S.BankName,S.Division,S.Department
from vw_EmployeeImportantInfoWithSalary S, SalaryMonthlyDetail Sd
where 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,A.JoiningDate,A.ACCOUNTNO,A.BankName,A.Division,A.Department order by A.Position,A.EmployeeNo,A.SequenceNo,A.GCode",
dateTime, sEmpID, dateTime, sEmpID, dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet(query1);
tempdataset.Tables[0].TableName = "GrossItem";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query2 = SQLParser.MakeSQL(@"select A.EmployeeNo, A.Name,A.GName, A.DName,A.JoiningDate,A.GCode,A.SequenceNo,
A.Description, Sum(A.amount) as amount,A.ACCOUNTNO,A.BankName,A.Division,A.Department
from
(
select
S.EmployeeID,S.EmployeeNo,S.JoiningDate, Sum(sd.changedamount) as Amount,
Sd.Description,S.GRADENAME as GName,S.GCode,S.SequenceNo,S.Name,S.DESIGNATION AS Dname,
S.ACCOUNTNO,S.BankName,S.Division,S.Department
from vw_EmployeeImportantInfoWithSalary S, SalaryMonthlyDetail Sd
where S.SalaryMonthlyID=Sd.SalaryMonthlyID
AND S.SalaryMonth=%d and Sd.ItemGroup IN (1, 8)
AND S.EmployeeID IN(%q)
group by S.EmployeeID,S.JoiningDate ,S.EmployeeNo,Sd.DESCRIPTION,S.SequenceNo,S.GCode,
S.Name,S.GRADENAME,S.sequenceNo,S.DESIGNATION,S.ACCOUNTNO,S.BankName,S.Division,S.Department
UNION
select S.EmployeeID,S.EmployeeNo,S.JoiningDate ,-Sum(sd.changedamount) as Amount,
sd.Description,S.GRADENAME as GName,S.GCode,S.sequenceNo,S.Name,
S.DESIGNATION AS Dname,S.ACCOUNTNO,S.BankName,S.Division,S.Department
from vw_EmployeeImportantInfoWithSalary S,SalaryMonthlyDetail Sd
where S.SalaryMonthlyID=Sd.SalaryMonthlyID
AND S.SalaryMonth=%d
and Sd.ItemGroup IN (2) AND S.EmployeeID IN(%q)
group by S.EmployeeID,S.JoiningDate ,S.EmployeeNo,Sd.DESCRIPTION,S.SequenceNo,S.GCode,
S.Name,S.GRADENAME,S.sequenceNo,S.DESIGNATION,S.ACCOUNTNO,S.BankName,S.Division,S.Department
) A
group by A.EmployeeID,A.Description, A.EmployeeNo, A.Name,A.GName,A.SequenceNo,
A.GCode,A.DName,A.JoiningDate,A.ACCOUNTNO,A.BankName,A.Division,A.Department ",
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.DName,A.JoiningDate,A.GCode,A.SequenceNo,
A.Description, Sum(A.amount) as amount,A.ItemCode,A.ItemID,A.ACCOUNTNO,A.BankName,A.Division,A.Department
from
(
select
S.EmployeeID,S.EmployeeNo,S.JoiningDate, Sum(sd.changedamount) as Amount,sd.ItemCode, sd.ItemID,
Sd.Description,S.GRADENAME as GName,S.GCode,S.SequenceNo,S.Name,S.DESIGNATION AS Dname,
S.ACCOUNTNO,S.BankName,S.Division,S.Department
from vw_EmployeeImportantInfoWithSalary S, SalaryMonthlyDetail Sd
where S.SalaryMonthlyID=Sd.SalaryMonthlyID
AND S.SalaryMonth=%d and Sd.ItemGroup IN (3)
AND S.EmployeeID IN(%q)
group by S.EmployeeID,S.JoiningDate ,S.EmployeeNo,Sd.DESCRIPTION,S.SequenceNo,S.GCode,
S.Name,S.GRADENAME,S.sequenceNo,S.DESIGNATION,S.ACCOUNTNO,S.BankName,S.Division,S.Department ,sd.ItemCode, sd.ItemID
UNION
select S.EmployeeID,S.EmployeeNo,S.JoiningDate ,-Sum(sd.changedamount) as Amount,sd.ItemCode, sd.ItemID,
sd.Description,S.GRADENAME as GName,S.GCode,S.sequenceNo,S.Name,
S.DESIGNATION AS Dname,S.ACCOUNTNO,S.BankName,S.Division,S.Department
from vw_EmployeeImportantInfoWithSalary S,SalaryMonthlyDetail Sd
where S.SalaryMonthlyID=Sd.SalaryMonthlyID
AND S.SalaryMonth=%d
and Sd.ItemGroup IN (2) AND S.EmployeeID IN(%q)
group by S.EmployeeID,S.JoiningDate ,S.EmployeeNo,Sd.DESCRIPTION,S.SequenceNo,S.GCode,
S.Name,S.GRADENAME,S.sequenceNo,S.DESIGNATION,S.ACCOUNTNO,S.BankName,S.Division,S.Department,sd.ItemCode, sd.ItemID
) A
group by A.EmployeeID,A.Description, A.EmployeeNo, A.Name,A.GName,A.SequenceNo,
A.GCode,A.DName,A.JoiningDate,A.ACCOUNTNO,A.BankName,A.Division,A.Department,A.ItemCode,A.ItemID
",
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.DName,A.JoiningDate,A.GCode,A.SequenceNo,
A.Description, Sum(A.amount) as amount,A.ItemCode,A.ItemID,A.ACCOUNTNO,A.BankName,A.Division,A.Department
from
(
select
S.EmployeeID,S.EmployeeNo,S.JoiningDate, Sum(sd.changedamount) as Amount,sd.ItemCode, sd.ItemID,
Sd.Description,S.GRADENAME as GName,S.GCode,S.SequenceNo,S.Name,S.DESIGNATION AS Dname,
S.ACCOUNTNO,S.BankName,S.Division,S.Department
from vw_EmployeeImportantInfoWithSalary S, SalaryMonthlyDetail Sd
where S.SalaryMonthlyID=Sd.SalaryMonthlyID
AND S.SalaryMonth=%d and Sd.ITEMCODE =-139 AND Sd.ItemGroup IN (4)
AND S.EmployeeID IN(%q)
group by S.EmployeeID,S.JoiningDate ,S.EmployeeNo,Sd.DESCRIPTION,S.SequenceNo,S.GCode,
S.Name,S.GRADENAME,S.sequenceNo,S.DESIGNATION,S.ACCOUNTNO,S.BankName,S.Division,S.Department ,sd.ItemCode, sd.ItemID
UNION
select S.EmployeeID,S.EmployeeNo,S.JoiningDate ,-Sum(sd.changedamount) as Amount,sd.ItemCode, sd.ItemID,
sd.Description,S.GRADENAME as GName,S.GCode,S.sequenceNo,S.Name,
S.DESIGNATION AS Dname,S.ACCOUNTNO,S.BankName,S.Division,S.Department
from vw_EmployeeImportantInfoWithSalary S,SalaryMonthlyDetail Sd
where S.SalaryMonthlyID=Sd.SalaryMonthlyID
AND S.SalaryMonth=%d
and Sd.ITEMCODE =-139 AND Sd.ItemGroup IN (4) AND S.EmployeeID IN(%q)
group by S.EmployeeID,S.JoiningDate ,S.EmployeeNo,Sd.DESCRIPTION,S.SequenceNo,S.GCode,
S.Name,S.GRADENAME,S.sequenceNo,S.DESIGNATION,S.ACCOUNTNO,S.BankName,S.Division,S.Department,sd.ItemCode, sd.ItemID
) A
group by A.EmployeeID,A.Description, A.EmployeeNo, A.Name,A.GName,A.SequenceNo,
A.GCode,A.DName,A.JoiningDate,A.ACCOUNTNO,A.BankName,A.Division,A.Department,A.ItemCode,A.ItemID
", dateTime, sEmpID, dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet(query4);
tempdataset.Tables[0].TableName = "LeaveDays";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query5 = SQLParser.MakeSQL(@"
select A.EmployeeNo, A.Name,A.GName, A.DName,A.JoiningDate,A.GCode,A.SequenceNo,
A.Description, Sum(A.amount) as amount,A.ItemCode,A.ItemID,A.ACCOUNTNO,A.BankName,A.Division,A.Department
from
(
select
S.EmployeeID,S.EmployeeNo,S.JoiningDate, Sum(sd.changedamount) as Amount,sd.ItemCode, sd.ItemID,
Sd.Description,S.GRADENAME as GName,S.GCode,S.SequenceNo,S.Name,S.DESIGNATION AS Dname,
S.ACCOUNTNO,S.BankName,S.Division,S.Department
from vw_EmployeeImportantInfoWithSalary S, SalaryMonthlyDetail Sd
where S.SalaryMonthlyID=Sd.SalaryMonthlyID
AND S.SalaryMonth=%d
AND Sd.ITEMCODE in(-135,-133,-140,-141,-142)
AND Sd.ItemGroup IN (4)
AND S.EmployeeID IN(%q)
group by S.EmployeeID,S.JoiningDate ,S.EmployeeNo,Sd.DESCRIPTION,S.SequenceNo,S.GCode,
S.Name,S.GRADENAME,S.sequenceNo,S.DESIGNATION,S.ACCOUNTNO,S.BankName,S.Division,S.Department ,sd.ItemCode, sd.ItemID
) A
group by A.EmployeeID,A.Description, A.EmployeeNo, A.Name,A.GName,A.SequenceNo,
A.GCode,A.DName,A.JoiningDate,A.ACCOUNTNO,A.BankName,A.Division,A.Department,A.ItemCode,A.ItemID
", dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet(query5);
tempdataset.Tables[0].TableName = "AttendenceDays";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query6 = SQLParser.MakeSQL(@"select A.EmployeeNo, A.Name,A.GName, A.DName,A.JoiningDate,A.GCode,A.SequenceNo,
A.Description, Sum(A.amount) as amount,A.ItemCode,A.ItemID,A.ACCOUNTNO,A.BankName,A.Division,A.Department
from
(
select
S.EmployeeID,S.EmployeeNo,S.JoiningDate, Sum(sd.changedamount) as Amount,sd.ItemCode, sd.ItemID,
Sd.Description,S.GRADENAME as GName,S.GCode,S.SequenceNo,S.Name,S.DESIGNATION AS Dname,
S.ACCOUNTNO,S.BankName,S.Division,S.Department
from vw_EmployeeImportantInfoWithSalary S, SalaryMonthlyDetail Sd
where S.SalaryMonthlyID=Sd.SalaryMonthlyID
AND S.SalaryMonth=%d
and Sd.ItemGroup IN (2,3)
AND S.EmployeeID IN(%q)
group by S.EmployeeID,S.JoiningDate ,S.EmployeeNo,Sd.DESCRIPTION,S.SequenceNo,S.GCode,
S.Name,S.GRADENAME,S.sequenceNo,S.DESIGNATION,S.ACCOUNTNO,S.BankName,S.Division,S.Department ,sd.ItemCode, sd.ItemID
) A
group by A.EmployeeID,A.Description, A.EmployeeNo, A.Name,A.GName,A.SequenceNo,
A.GCode,A.DName,A.JoiningDate,A.ACCOUNTNO,A.BankName,A.Division,A.Department,A.ItemCode,A.ItemID
", dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet(query6);
tempdataset.Tables[0].TableName = "TotalDeduction";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query7 = SQLParser.MakeSQL(@"select A.EmployeeNo, A.Name,A.GName, A.DName,A.JoiningDate,A.GCode,A.SequenceNo,
A.Description, Sum(A.amount) as amount,A.ItemCode,A.ItemID,A.ACCOUNTNO,A.BankName,A.Division,A.Department
from
(
select
S.EmployeeID,S.EmployeeNo,S.JoiningDate, Sum(sd.changedamount) as Amount,sd.ItemCode, sd.ItemID,
Sd.Description,S.GRADENAME as GName,S.GCode,S.SequenceNo,S.Name,S.DESIGNATION AS Dname,
S.ACCOUNTNO,S.BankName,S.Division,S.Department
from vw_EmployeeImportantInfoWithSalary S, SalaryMonthlyDetail Sd
where S.SalaryMonthlyID=Sd.SalaryMonthlyID
AND S.SalaryMonth=%d
And Sd.ItemGroup IN (5)
AND Sd.ItemCode IN(-132)
AND S.EmployeeID IN(%q)
group by S.EmployeeID,S.JoiningDate ,S.EmployeeNo,Sd.DESCRIPTION,S.SequenceNo,S.GCode,
S.Name,S.GRADENAME,S.sequenceNo,S.DESIGNATION,S.ACCOUNTNO,S.BankName,S.Division,S.Department ,sd.ItemCode, sd.ItemID
) A
group by A.EmployeeID,A.Description, A.EmployeeNo, A.Name,A.GName,A.SequenceNo,
A.GCode,A.DName,A.JoiningDate,A.ACCOUNTNO,A.BankName,A.Division,A.Department,A.ItemCode,A.ItemID
", dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet(query7);
tempdataset.Tables[0].TableName = "NetPay";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query8 = SQLParser.MakeSQL(@"select A.EmployeeNo, A.Name,A.GName, A.DName,A.JoiningDate,A.GCode,A.SequenceNo,
A.Description, Sum(A.amount) as amount,A.ItemCode,A.ItemID,A.ACCOUNTNO,A.BankName,A.Division,A.Department
from
(
select
S.EmployeeID,S.EmployeeNo,S.JoiningDate, Sum(sd.changedamount) as Amount,sd.ItemCode, sd.ItemID,
Sd.Description,S.GRADENAME as GName,S.GCode,S.SequenceNo,S.Name,S.DESIGNATION AS Dname,
S.ACCOUNTNO,S.BankName,S.Division,S.Department
from vw_EmployeeImportantInfoWithSalary S, SalaryMonthlyDetail Sd
where S.SalaryMonthlyID=Sd.SalaryMonthlyID
AND S.SalaryMonth=%d
AND Sd.ItemGroup IN (3)
AND Sd.ItemCode IN(-128)
AND S.EmployeeID IN(%q)
group by S.EmployeeID,S.JoiningDate ,S.EmployeeNo,Sd.DESCRIPTION,S.SequenceNo,S.GCode,
S.Name,S.GRADENAME,S.sequenceNo,S.DESIGNATION,S.ACCOUNTNO,S.BankName,S.Division,S.Department ,sd.ItemCode, sd.ItemID
) A
group by A.EmployeeID,A.Description, A.EmployeeNo, A.Name,A.GName,A.SequenceNo,
A.GCode,A.DName,A.JoiningDate,A.ACCOUNTNO,A.BankName,A.Division,A.Department,A.ItemCode,A.ItemID
", dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet(query8);
tempdataset.Tables[0].TableName = "CPF";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query9 = SQLParser.MakeSQL(@"SELECT e.EmployeeNo,e.Name,e.GradeName as GName, e.Designation as DName,e.JoiningDate,e.GCode,20,oi.Name as Description,Sum(opdi.NetAmount) as Amount ,0 as ItemCode,oi.OPIItemId as ItemID,e.ACCOUNTNO,e.BankName,e.Division,e.Department
FROM vw_EmployeeImportantInfo e, OPIItem oi, OPIProcess op, OPIProcessDetail opd, OPIProcessDetailItem opdi
WHERE op.OPIMonth >= %d AND op.OPIMonth <= %d
AND e.EmployeeId IN(%q)
AND op.OPIProcessID = opd.OPIProcessID
AND e.EmployeeId = opd.EmployeeId
AND opd.OPIProcessDetailId = opdi.OPIProcessDetailId
AND oi.OPIItemId = opdi.OPIItemId
GROUP BY e.EmployeeNo,e.Name,e.GradeName, e.Designation,e.JoiningDate,e.GCode,oi.Name,oi.OPIItemId,e.ACCOUNTNO,e.BankName,e.Division,e.Department
ORDER BY e.EmployeeNo
",
GlobalFunctions.FirstDateOfMonth(dateTime), GlobalFunctions.LastDateOfMonth(dateTime), sEmpID);
tempdataset = tc.ExecuteDataSet(query9);
tempdataset.Tables[0].TableName = "OPI";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
#region UnusedCode
// string query9 = SQLParser.MakeSQL(@"Select E.EMPLOYEENO,E.NAME,E.JoiningDate,G.DESCRIPTION as GName,G.Code as GCode,G.SequenceNo,D.Name as DName ,'CPF' 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 (3) AND Sd.ItemCode IN(-128)
// AND S.EmployeeID IN(%q) order by E.EMPLOYEENO,G.SequenceNo,G.Code ", dateTime, sEmpID);
// tempdataset = tc.ExecuteDataSet(@"Select E.EMPLOYEENO,E.NAME,E.JoiningDate,G.DESCRIPTION as GName,G.Code as GCode,G.SequenceNo,D.Name as DName ,'CPF' 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 (3) AND Sd.ItemCode IN(-128) AND S.EmployeeID IN(%q) order by E.EMPLOYEENO,G.SequenceNo,G.Code ", dateTime, sEmpID);
// tempdataset.Tables[0].TableName = "CPF";
// rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
#endregion
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return rootDataset;
}
internal static DataSet GetOldPayslip(TransactionContext tc, DateTime dateTime, string sEmpID)
{
DataSet rootDataset = new DataSet();
DataSet tempdataset = new DataSet();
try
{
string query1 = SQLParser.MakeSQL(@"SELECT * FROM(SELECT emp.EMPLOYEENO,emp.NAME,emp.JOININGDATE, smd.DESCRIPTION,deg.name degname,grd.DESCRIPTION gname, dept.DESCRIPTION dname,
bnk.NAME bank, brn.NAME branch,sm.accountno,sm.monthyeardate SalaryMonth,
smd.ITEMCODE,smd.ITEMGROUP,smd.ITEMID, smd.CHANGEDAMOUNT,smd.POSITION
FROM GP_SALARYMONTHLY sm, GP_SALARYMONTHLYDETAIL smd,GP_Employee emp,
GP_department dept,GP_designation deg,GP_grades grd,GP_branches brn,GP_banks bnk
WHERE sm.monthyeardate=%d AND
sm.EMPLOYEEID=%n and
smd.ITEMGROUP=1 AND
sm.salarymonthlyid=smd.SALARYMONTHLYID and
sm.employeeid=emp.EMPLOYEEID AND
sm.departmentid=dept.DEPARTMENTID AND
sm.designationid=deg.designationid AND
sm.gradeid=grd.GRADEID AND
sm.branchid=brn.BRANCHID AND
brn.BANKID=bnk.BANKID
UNION
SELECT emp.EMPLOYEENO,emp.NAME,emp.JOININGDATE, smd.DESCRIPTION,deg.name degname,grd.DESCRIPTION gname, dept.DESCRIPTION dname,
bnk.NAME bank, brn.NAME branch,sm.accountno,sm.monthyeardate SalaryMonth,
smd.ITEMCODE,smd.ITEMGROUP,smd.ITEMID, smd.CHANGEDAMOUNT,smd.POSITION
FROM GP_SALARYMONTHLY sm, GP_SALARYMONTHLYDETAIL smd,GP_Employee emp,
GP_department dept,GP_designation deg,GP_grades grd,GP_branches brn,GP_banks bnk
WHERE sm.monthyeardate=%d AND
sm.EMPLOYEEID=%n and
smd.ITEMGROUP=8 AND
sm.salarymonthlyid=smd.SALARYMONTHLYID and
sm.employeeid=emp.EMPLOYEEID AND
sm.departmentid=dept.DEPARTMENTID AND
sm.designationid=deg.designationid AND
sm.gradeid=grd.GRADEID AND
sm.branchid=brn.BRANCHID AND
brn.BANKID=bnk.BANKID ) tab
ORDER BY position",
dateTime, sEmpID, dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet(query1);
tempdataset.Tables[0].TableName = "GrossItem";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query3 = SQLParser.MakeSQL(@"SELECT emp.EMPLOYEENO,emp.NAME,emp.JOININGDATE, smd.DESCRIPTION,deg.name degname,grd.DESCRIPTION gname, dept.DESCRIPTION dname,
bnk.NAME bank, brn.NAME branch,sm.accountno,sm.monthyeardate SalaryMonth,
smd.ITEMCODE,smd.ITEMGROUP,smd.ITEMID, smd.CHANGEDAMOUNT,smd.POSITION
FROM GP_SALARYMONTHLY sm, GP_SALARYMONTHLYDETAIL smd,GP_Employee emp,
GP_department dept,GP_designation deg,GP_grades grd,GP_branches brn,GP_banks bnk
WHERE sm.monthyeardate=%d AND
sm.EMPLOYEEID=%n and
smd.ITEMGROUP=3 AND
sm.salarymonthlyid=smd.SALARYMONTHLYID and
sm.employeeid=emp.EMPLOYEEID AND
sm.departmentid=dept.DEPARTMENTID AND
sm.designationid=deg.designationid AND
sm.gradeid=grd.GRADEID AND
sm.branchid=brn.BRANCHID AND
brn.BANKID=bnk.BANKID
ORDER BY smd.position",
dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet(query3);
tempdataset.Tables[0].TableName = "DeductItem";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query7 = SQLParser.MakeSQL(@"SELECT emp.EMPLOYEENO,emp.NAME,emp.JOININGDATE, smd.DESCRIPTION,deg.name degname,grd.DESCRIPTION gname, dept.DESCRIPTION dname,
bnk.NAME bank, brn.NAME branch,sm.accountno,sm.monthyeardate SalaryMonth,
smd.ITEMCODE,smd.ITEMGROUP,smd.ITEMID, smd.CHANGEDAMOUNT,smd.POSITION
FROM GP_SALARYMONTHLY sm, GP_SALARYMONTHLYDETAIL smd,GP_Employee emp,
GP_department dept,GP_designation deg,GP_grades grd,GP_branches brn,GP_banks bnk
WHERE sm.monthyeardate=%d AND
sm.EMPLOYEEID=%n and
smd.ITEMGROUP=5 AND
sm.salarymonthlyid=smd.SALARYMONTHLYID and
sm.employeeid=emp.EMPLOYEEID AND
sm.departmentid=dept.DEPARTMENTID AND
sm.designationid=deg.designationid AND
sm.gradeid=grd.GRADEID AND
sm.branchid=brn.BRANCHID AND
brn.BANKID=bnk.BANKID
ORDER BY smd.position ", dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet(query7);
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 GetEmpSalarySheet(TransactionContext tc, DateTime dateTime, string sEmpID)
{
DataSet rootDataset = new DataSet();
DataSet tempdataset = new DataSet();
try
{
// string query1 = SQLParser.MakeSQL(@"select A.SalaryMonth,A.EmployeeNo,A.ITEMCODE, A.ItemGroup, A.ITEMID, A.JOININGDATE, A.Name,A.GName,A.DName,A.GCode,A.SequenceNo,A.THISMONTHBASIC, A.Description,Round(SUM(A.changedamount),0)
// Amount from(
// select S.EmployeeID, E.EmployeeNo, E.JOININGDATE, S.SalaryMonth,
// E.Name,Sd.ITEMCODE,Sd.ITEMGROUP,Sd.ITEMID, sd.Description, sd.changedamount,
// G.DESCRIPTION as GName,D.Name as DName,G.Code as GCode,G.SequenceNo,S.THISMONTHBASIC
// from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd
// where G.GradeID= S.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) AND sd.changedamount<>0
// UNION all
// select S.EmployeeID, E.EmployeeNo, E.JOININGDATE,S.SalaryMonth,
// E.Name, Sd.ITEMCODE,Sd.ITEMGROUP,Sd.ITEMID, sd.Description, sd.changedamount,
// G.DESCRIPTION as GName,D.Name as DName,G.Code as GCode,G.SequenceNo,S.THISMONTHBASIC
// from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd
// where G.GradeID= S.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) AND sd.changedamount<>0
// UNION all
// select S.EmployeeID, E.EmployeeNo, E.JOININGDATE,S.SalaryMonth,
// E.Name, Sd.ITEMCODE,Sd.ITEMGROUP,Sd.ITEMID, sd.Description, sd.changedamount,
// G.DESCRIPTION as GName,D.Name as DName,G.Code as GCode,G.SequenceNo,S.THISMONTHBASIC
// from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd
// where G.GradeID= S.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) AND sd.changedamount<>0
// )
// A
// group by A.SalaryMonth,A.EmployeeID, A.EmployeeNo,A.ITEMCODE,A.ItemGroup,A.ITEMID, A.JOININGDATE, A.Name,A.GName,A.DName,A.SequenceNo,A.GCode,
// A.Description,A.THISMONTHBASIC
// order by A.SalaryMonth,A.EmployeeNo,A.SequenceNo,A.GCode", dateTime, sEmpID, dateTime, sEmpID, dateTime, sEmpID);
// tempdataset = tc.ExecuteDataSet(query1);
// tempdataset.Tables[0].TableName = "GrossItem";
// rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query1 = SQLParser.MakeSQL(@"select A.SalaryMonth,A.EmployeeNo,A.ITEMCODE, A.ItemGroup, A.ITEMID, A.JOININGDATE, A.Name,A.GName,A.DName,A.GCode,A.SequenceNo,A.THISMONTHBASIC, A.Description,SUM(A.changedamount)
Amount, A.DeptName, A.DeptSequence from(
select S.EmployeeID, E.EmployeeNo, E.JOININGDATE, S.SalaryMonth,
E.Name,Sd.ITEMCODE,Sd.ITEMGROUP,Sd.ITEMID, sd.Description, Round(sd.changedamount,0)changedamount,
G.DESCRIPTION as GName,D.Name as DName,G.Code as GCode,G.SequenceNo,S.THISMONTHBASIC, Dept.DESCRIPTION DeptName, Dept.SequenceNO DeptSequence
from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd, DEPARTMENT Dept
where G.GradeID= S.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) AND sd.changedamount<>0
AND Dept.DEPARTMENTID = E.DEPARTMENTID)
A
group by A.SalaryMonth,A.EmployeeID, A.EmployeeNo,A.ITEMCODE,A.ItemGroup,A.ITEMID, A.JOININGDATE, A.Name,A.GName,A.DName,A.SequenceNo,A.GCode,
A.Description,A.THISMONTHBASIC , A.DeptName, A.DeptSequence
order by A.SalaryMonth,A.EmployeeNo,A.SequenceNo,A.GCode", dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet(query1);
tempdataset.Tables[0].TableName = "GrossItem";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
// string query2 = SQLParser.MakeSQL(@"select A.SalaryMonth,E.EmployeeNo, E.JOININGDATE, E.Name,A.GName,A.GCode,A.SequenceNo,A.DName,'Total Gross' as Description,
// Round( Sum(A.amount),0) as amount ,A.THISMONTHBASIC
// from
// (
// select S.EmployeeID,S.SalaryMonth,Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,G.Code as GCode,
// G.SequenceNo,D.Name as DName ,S.THISMONTHBASIC
// from SALARYMONTHLY S,Grades G,DESIGNATION D,
// SalaryMonthlyDetail Sd, Employee e
// where S.SalaryMonthlyID=Sd.SalaryMonthlyID AND
// G.GRADEID=S.GRADEID AND D.DESIGNATIONID=E.DESIGNATIONID AND e.EmployeeID=s.employeeID
// AND S.SalaryMonth = %d and Sd.ItemGroup IN (1, 8)
// AND S.EmployeeID IN(%q) AND sd.changedamount<>0
// group by S.SalaryMonth,S.EmployeeID,G.DESCRIPTION,G.SequenceNo,G.Code,D.Name,S.THISMONTHBASIC
//
// UNION
//
// select S.EmployeeID,S.SalaryMonth, -Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,G.Code as GCode,
// G.sequenceNo,D.Name as DName ,S.THISMONTHBASIC
// 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) AND sd.changedamount<>0
// group by S.SalaryMonth,S.EmployeeID,G.DESCRIPTION,G.SequenceNo,G.Code,D.Name ,S.THISMONTHBASIC
//
// ) A, Employee E
// where A.EmployeeID = E.EmployeeID
// group by A.SalaryMonth,E.EmployeeNo, E.JOININGDATE, E.Name,A.GName,A.SequenceNo,A.GCode,A.DName,A.THISMONTHBASIC ", dateTime, sEmpID, dateTime, sEmpID);
// tempdataset = tc.ExecuteDataSet(query2);
// tempdataset.Tables[0].TableName = "TotalGross";
// rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query2 = SQLParser.MakeSQL(@"select A.SalaryMonth,E.EmployeeNo, E.JOININGDATE, E.Name,A.GName,A.GCode,A.SequenceNo,A.DName,'Total Gross' as Description,
Sum(A.amount) as amount ,A.THISMONTHBASIC , A.DeptName, A.DeptSequence
from
(
select S.EmployeeID,S.SalaryMonth,Round(Sum(sd.changedamount),0) as Amount,G.DESCRIPTION as GName,G.Code as GCode,
G.SequenceNo,D.Name as DName ,S.THISMONTHBASIC, Dept.DESCRIPTION DeptName, Dept.SequenceNO DeptSequence
from SALARYMONTHLY S,Grades G,DESIGNATION D,
SalaryMonthlyDetail Sd, Employee e , DEPARTMENT Dept
where S.SalaryMonthlyID=Sd.SalaryMonthlyID AND
G.GRADEID=S.GRADEID AND D.DESIGNATIONID=E.DESIGNATIONID AND e.EmployeeID=s.employeeID AND Dept.DEPARTMENTID = E.DEPARTMENTID
AND S.SalaryMonth = %d and Sd.ItemGroup IN (1, 8)
AND S.EmployeeID IN(%q) AND sd.changedamount<>0
group by S.SalaryMonth,S.EmployeeID,G.DESCRIPTION,G.SequenceNo,G.Code,D.Name,S.THISMONTHBASIC, Dept.DESCRIPTION, Dept.SequenceNO
) A, Employee E
where A.EmployeeID = E.EmployeeID
group by A.SalaryMonth,E.EmployeeNo, E.JOININGDATE, E.Name,A.GName,A.SequenceNo,A.GCode,A.DName,A.THISMONTHBASIC, A.DeptName, A.DeptSequence ", dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet(query2);
tempdataset.Tables[0].TableName = "TotalGross";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query3 = SQLParser.MakeSQL(@"select A.SalaryMonth, A.EmployeeNo, A.Name,A.JoiningDate,A.GName,A.GCode,A.SequenceNo,A.DName,A.ITEMCODE,A.ITEMGROUP,A.ITEMID,
A.Description,SUM(A.changedamount) Amount,A.THISMONTHBASIC, A.DeptName, A.DeptSequence
from
(select S.SalaryMonth, S.EmployeeID, E.EmployeeNo, E.Name,E.JoiningDate,Sd.ITEMCODE,Sd.ITEMGROUP,Sd.ITEMID,
sd.Description, Round( sd.changedamount,0)changedamount,G.DESCRIPTION GName,G.Code GCode,G.SequenceNo,D.Name DName,S.THISMONTHBASIC , Dept.DESCRIPTION DeptName, Dept.SequenceNO DeptSequence
from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd , DEPARTMENT Dept
where G.GradeID= S.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) AND sd.changedamount<>0
AND Dept.DEPARTMENTID = E.DEPARTMENTID
) A group by
A.SalaryMonth,A.EmployeeID, A.EmployeeNo,A.ITEMCODE,A.ITEMGROUP,A.ITEMID, A.Name,A.GName,A.SequenceNo,A.GCode,A.DName,A.THISMONTHBASIC,
A.Description,A.JoiningDate, A.DeptName, A.DeptSequence order by A.EmployeeNo,A.SequenceNo,A.GCode",
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.SalaryMonth, A.EmployeeNo, A.Name,A.JoiningDate,A.GName,A.GCode,A.SequenceNo,A.DName,A.ITEMCODE,A.ITEMGROUP,A.ITEMID,
A.Description, SUM(A.changedamount) Amount,A.THISMONTHBASIC, A.DeptName, A.DeptSequence
from
(select S.SalaryMonth, S.EmployeeID, E.EmployeeNo, E.Name,E.JoiningDate,Sd.ITEMCODE,Sd.ITEMGROUP,Sd.ITEMID,
sd.Description,Round( sd.changedamount,0)changedamount,G.DESCRIPTION GName,G.Code GCode,G.SequenceNo,D.Name DName,S.THISMONTHBASIC , Dept.DESCRIPTION DeptName, Dept.SequenceNO DeptSequence
from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd , DEPARTMENT Dept
where G.GradeID= S.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) AND sd.changedamount<>0
AND Dept.DEPARTMENTID = E.DEPARTMENTID
) A group by
A.SalaryMonth,A.EmployeeID, A.EmployeeNo,A.ITEMCODE,A.ITEMGROUP,A.ITEMID, A.Name,A.GName,A.SequenceNo,A.GCode,A.DName,A.THISMONTHBASIC,
A.Description,A.JoiningDate, A.DeptName, A.DeptSequence order by A.EmployeeNo,A.SequenceNo,A.GCode",
dateTime, sEmpID, dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet(query4);
tempdataset.Tables[0].TableName = "UnAuthorizedLeave";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query6 = SQLParser.MakeSQL(@"select A.SalaryMonth,E.EmployeeNo, E.JOININGDATE, E.Name,A.GName,A.GCode,A.SequenceNo,A.DName,A.THISMONTHBASIC,
'Total Deduction' as Description,
Sum(A.amount) as amount , A.DeptName, A.DeptSequence
from(
select S.SalaryMonth,S.EmployeeID,Round( Sum(sd.changedamount),0) as Amount,
G.DESCRIPTION as GName,G.Code as GCode,G.SequenceNo,D.Name as DName,S.THISMONTHBASIC, Dept.DESCRIPTION DeptName, Dept.SequenceNO DeptSequence
from GRADES G,DESIGNATION D,SALARYMONTHLY S,SalaryMonthlyDetail Sd, Employee e, DEPARTMENT Dept
where S.SalaryMonthlyID=Sd.SalaryMonthlyID AND
S.SalaryMonth = %d AND G.GRADEID=S.GRADEID AND D.DESIGNATIONID=E.DESIGNATIONID AND e.EmployeeID=s.employeeID
and Sd.ItemGroup IN (3) AND S.EmployeeID IN(%q)
AND Dept.DEPARTMENTID = E.DEPARTMENTID
group by S.SalaryMonth,S.EmployeeID,G.DESCRIPTION,G.SequenceNo,G.Code,D.Name ,S.THISMONTHBASIC, Dept.DESCRIPTION, Dept.SequenceNO
) A,Employee E
where A.EmployeeID = E.EmployeeID
group by A.SalaryMonth,E.EmployeeNo,A.THISMONTHBASIC, E.JOININGDATE, E.Name,A.GName,A.SequenceNo,A.GCode,A.DName, A.DeptName, A.DeptSequence", dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet(query6);
tempdataset.Tables[0].TableName = "TotalDeduction";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query7 = SQLParser.MakeSQL(@"Select S.SalaryMonth,E.EMPLOYEENO, E.JOININGDATE,E.NAME,G.DESCRIPTION GName,G.Code GCode,
G.SequenceNo,D.Name DName ,'Net Pay' Description,Round(SD.CHANGEDAMOUNT,0) Amount,S.THISMONTHBASIC, Dept.DESCRIPTION DeptName, Dept.SequenceNO DeptSequence
from
EMPLOYEE E,GRADES G,DESIGNATION D,SALARYMONTHLY S,SALARYMONTHLYDETAIL Sd, DEPARTMENT Dept
where S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth= %d
AND G.GRADEID=S.GRADEID AND D.DESIGNATIONID=E.DESIGNATIONID AND E.EMPLOYEEID =S.EMPLOYEEID
and Sd.ItemGroup IN (5) AND Sd.ItemCode IN(-132) AND S.EmployeeID IN(%q)
AND Dept.DEPARTMENTID = E.DEPARTMENTID
order by S.SalaryMonth,G.SequenceNo,G.Code,E.EMPLOYEENO", dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet(query7);
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 GetEmpReconciliationSalarySheet(TransactionContext tc, DateTime Prevdate, DateTime dateTime, string sEmpID)
{
DataSet rootDataset = new DataSet();
DataSet tempdataset = new DataSet();
try
{
string sTableName;
//sEmpID = IDHelper.GetIDs(tc, sEmpID, out sTableName);
string query1 = SQLParser.MakeSQL(@"SELECT tab3.SalaryMonth,E.EmployeeNo,tab3.ItemGroup, tab3.ItemCode,tab3.ItemID,
E.Name,'' SequenceNo, tab3.Description,Amount
Amount
FROM Employee E,
(
SELECT
IsNull(tab1.EmployeeID,tab2.EmployeeID)EmployeeID,
IsNull(tab1.SalaryMonth,tab2.SalaryMonth)SalaryMonth, IsNull(tab1.ItemGroup,tab2.ItemGroup)ItemGroup,
IsNull(tab1.ItemCode,tab2.ItemCode)ItemCode,IsNull(tab1.ItemID,tab2.ItemID)ItemID,
IsNull(tab1.Description,tab2.Description)Description,(IsNull(tab1.Amount,0) - IsNull(tab2.Amount,0)) Amount
FROM
(
SELECT X.EmployeeID,X.SalaryMonth,X.ItemGroup,x.itemcode,x.ItemID,x.Description,sum(X.changedamount) Amount FROM
(Select S.EmployeeID, S.SalaryMonth,
CASE sd.ItemGroup WHEN 2 THEN 1 ELSE sd.ITEMGROUP END ITEMGROUP,
CASE sd.ItemCode
WHEN -102 THEN -103
ELSE sd.ItemCode END ItemCode,
CASE sd.ItemCode WHEN -103 THEN 2 else sd.ItemID end ItemID,
CASE sd.ItemCode WHEN -103 THEN 'OT' else sd.Description end Description,
case Sd.ItemGroup
WHEN 2 THEN -sd.changedamount
ELSE sd.changedamount END changedamount
from SALARYMONTHLY S, SalaryMonthlyDetail Sd
where S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth = %d
and Sd.ItemGroup in(1,2,8) AND sd.ItemCode not in(-133) AND S.EmployeeID in(%q)
AND sd.changedamount<>0 )X
group by EmployeeID,SalaryMonth, ItemGroup, ItemCode, ItemID,Description
)tab1
FULL OUTER JOIN
(
SELECT Y.EmployeeID,Y.SalaryMonth,Y.ItemGroup,Y.Itemcode,Y.ItemID,Y.Description,sum(Y.changedamount) Amount FROM
(Select S.EmployeeID, S.SalaryMonth,
CASE sd.ItemGroup WHEN 2 THEN 1 ELSE sd.ITEMGROUP END ITEMGROUP,
CASE sd.ItemCode
WHEN -102 THEN -103
ELSE sd.ItemCode END ItemCode,
CASE sd.ItemCode WHEN -103 THEN 2 else sd.ItemID end ItemID,
CASE sd.ItemCode WHEN -103 THEN 'OT' else sd.Description end Description,
case Sd.ItemGroup
WHEN 2 THEN -sd.changedamount
ELSE sd.changedamount END changedamount
from SALARYMONTHLY S, SalaryMonthlyDetail Sd
where S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth = %d
and Sd.ItemGroup in(1,2,8) AND sd.ItemCode not in(-133) AND S.EmployeeID in(%q)
AND sd.changedamount<>0 )Y
group by EmployeeID,SalaryMonth, ItemGroup, ItemCode, ItemID,Description
)tab2
ON tab1.EmployeeID = tab2.EmployeeID
AND tab1.ItemGroup = tab2.ItemGroup
AND tab1.ItemCode = tab2.ItemCode
AND tab1.ItemID = tab2.ItemID
AND tab1.Description = tab2.Description) tab3
WHERE E.employeeid=tab3.employeeid
", dateTime, sEmpID, Prevdate, sEmpID);
tempdataset = tc.ExecuteDataSet(query1);
tempdataset.Tables[0].TableName = "GrossItem";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query2 = SQLParser.MakeSQL(@"SELECT IsNull(X.SalaryMonth,Y.SalaryMonth)SalaryMonth,IsNull(X.EmployeeNo,Y.EmployeeNo)EmployeeNo,
IsNull(X.Name,Y.Name)Name,IsNull(X.Description,Y.Description)Description, IsNull(X.Amount,0) - IsNull(Y.Amount,0)Amount
FROM (select A.SalaryMonth,E.EmployeeNo, E.Name,'Total Gross' as Description,Sum(A.amount) as amount
from
(
select S.EmployeeID,S.SalaryMonth, Sum(sd.changedamount) as Amount
from SALARYMONTHLY S, SalaryMonthlyDetail Sd
where S.SalaryMonthlyID=Sd.SalaryMonthlyID
AND S.SalaryMonth = %d and Sd.ItemGroup IN (1,8)
AND S.EmployeeID IN(%q) AND sd.changedamount<>0
group by S.SalaryMonth,S.EmployeeID
UNION
select S.EmployeeID,S.SalaryMonth, sd.changedamount
from SALARYMONTHLY S, SalaryMonthlyDetail Sd
where S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth = %d
and Sd.ItemGroup IN (2)
AND S.EmployeeID IN(%q) AND sd.changedamount<>0
group by S.SalaryMonth,S.EmployeeID,sd.changedamount
) A, Employee E
where A.EmployeeID = E.EmployeeID
group by A.SalaryMonth,E.EmployeeNo, E.Name
)X
FULL OUTER JOIN
(select A.SalaryMonth,E.EmployeeNo,E.Name,'Total Gross' as Description,
Sum(A.amount) as amount
from (
select S.EmployeeID,S.SalaryMonth, Sum(sd.changedamount) as Amount
from SALARYMONTHLY S, SalaryMonthlyDetail Sd
where S.SalaryMonthlyID=Sd.SalaryMonthlyID
AND S.SalaryMonth = %d and Sd.ItemGroup IN (1,8)
AND S.EmployeeID IN(%q) AND sd.changedamount<>0
group by S.SalaryMonth,S.EmployeeID
UNION
select S.EmployeeID,S.SalaryMonth, -sd.changedamount as Amount
from GRADES G,DESIGNATION D, SALARYMONTHLY S, SalaryMonthlyDetail Sd
where S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth = %d
and Sd.ItemGroup IN (2) AND S.EmployeeID IN(%q) AND sd.changedamount<>0
group by S.SalaryMonth,S.EmployeeID,sd.changedamount
) A, Employee E
where A.EmployeeID = E.EmployeeID
group by A.SalaryMonth,E.EmployeeNo,E.Name
)Y
ON X.EmployeeNo = Y.EmployeeNo AND X.Name = Y.Name
AND X.Description = Y.Description", dateTime, sEmpID, dateTime, sEmpID, Prevdate, sEmpID, Prevdate, sEmpID);
tempdataset = tc.ExecuteDataSet(query2);
tempdataset.Tables[0].TableName = "TotalGross";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query3 = SQLParser.MakeSQL(@"SELECT IsNull(X.SalaryMonth,Y.SalaryMonth)SalaryMonth,IsNull(X.EmployeeNo,Y.EmployeeNo)EmployeeNo,IsNull(X.ItemGroup,Y.ItemGroup)ItemGroup,
IsNull(X.ItemCode,Y.ItemCode)ItemCode,IsNull(X.ItemID,Y.ItemID)ItemID,IsNull(X.Name,Y.Name)Name,
IsNull(X.Description,Y.Description)Description,ISNULL(X.Amount,0) - IsNull(Y.Amount,0) Amount
FROM
(select A.SalaryMonth, A.EmployeeNo,A.Name,A.Description, SUM(A.changedamount) Amount,A.ItemCode,A.ItemID,A.ItemGroup
from
(select S.SalaryMonth, S.EmployeeID, E.EmployeeNo, E.Name,sd.ItemGroup,sd.ItemCode,
sd.ItemID, sd.Description, 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=3 AND S.EmployeeID IN(%q) AND sd.changedamount<>0
union
select S.SalaryMonth, S.EmployeeID, E.EmployeeNo, E.Name,sd.ItemGroup,sd.ItemCode,
sd.ItemID, sd.Description,-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=0
AND S.EmployeeID IN(%q) AND sd.changedamount<>0
) A group by
A.SalaryMonth,A.EmployeeID, A.EmployeeNo, A.Name,A.ItemGroup,
A.ItemCode, A.ItemID, A.Description
)X
FULL OUTER JOIN
(select A.SalaryMonth, A.EmployeeNo,A.Name,A.Description, SUM(A.changedamount) Amount,A.ItemCode,A.ItemID,A.ItemGroup
from
(select S.SalaryMonth, S.EmployeeID, E.EmployeeNo, E.Name,sd.ItemGroup,sd.ItemCode,
sd.ItemID, sd.Description, 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=3 AND S.EmployeeID IN(%q) AND sd.changedamount<>0
union
select S.SalaryMonth, S.EmployeeID, E.EmployeeNo, E.Name,sd.ItemGroup,sd.ItemCode,
sd.ItemID, sd.Description, -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=0
AND S.EmployeeID IN(%q) AND sd.changedamount<>0
) A group by
A.SalaryMonth,A.EmployeeID, A.EmployeeNo, A.Name,A.ItemGroup,
A.ItemCode, A.ItemID, A.Description
)Y
ON X.EmployeeNo = Y.EmployeeNo AND X.Name = Y.Name AND X.ItemGroup = Y.ItemGroup
AND X.ItemCode = Y.ItemCode AND X.ItemID = Y.ItemID AND X.Description = Y.Description",
dateTime, sEmpID, dateTime, sEmpID,Prevdate, sEmpID,Prevdate, sEmpID);
tempdataset = tc.ExecuteDataSet(query3);
tempdataset.Tables[0].TableName = "DeductItem";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query6 = SQLParser.MakeSQL(@"SELECT IsNull(X.SalaryMonth,Y.SalaryMonth)SalaryMonth,IsNull(X.EmployeeNo,Y.EmployeeNo)EmployeeNo,IsNull(X.Name,Y.Name)Name,
IsNull(X.Description,Y.Description)Description, IsNull(X.Amount,0) - IsNull(Y.Amount,0)Amount
FROM
(select A.SalaryMonth,E.EmployeeNo, E.Name,
'Total Deduction' as Description, Sum(A.amount) as amount
from (
select S.SalaryMonth,S.EmployeeID, Sum(sd.changedamount) as Amount,sd.ItemGroup,sd.ItemCode, sd.ItemID
from SALARYMONTHLY S,SalaryMonthlyDetail Sd
where S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth = %d
and Sd.ItemGroup IN (3) AND S.EmployeeID IN(%q)
group by S.SalaryMonth,S.EmployeeID,sd.ItemGroup,sd.ItemCode, sd.ItemID ) A,Employee E
where A.EmployeeID = E.EmployeeID
group by A.SalaryMonth,E.EmployeeNo,A.ItemGroup, E.Name )X
FULL OUTER JOIN
(select A.SalaryMonth,E.EmployeeNo, E.Name,
'Total Deduction' as Description, Sum(A.amount) as amount from (
select S.SalaryMonth,S.EmployeeID, Sum(sd.changedamount) as Amount,sd.ItemGroup,sd.ItemCode, sd.ItemID
from SALARYMONTHLY S,SalaryMonthlyDetail Sd
where S.SalaryMonthlyID=Sd.SalaryMonthlyID And S.SalaryMonth = %d
and Sd.ItemGroup IN (3) AND S.EmployeeID IN(%q)
group by S.SalaryMonth,S.EmployeeID,sd.ItemGroup,sd.ItemCode, sd.ItemID ) A,Employee E
where A.EmployeeID = E.EmployeeID
group by A.SalaryMonth,E.EmployeeNo,A.ItemGroup, E.Name)Y
ON X.EmployeeNo = Y.EmployeeNo AND X.Name = Y.Name AND X.Description = Y.Description",
dateTime, sEmpID,Prevdate, sEmpID);
tempdataset = tc.ExecuteDataSet(query6);
tempdataset.Tables[0].TableName = "TotalDeduction";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query7 = SQLParser.MakeSQL(@"SELECT IsNull(X.SalaryMonth,Y.SalaryMonth)SalaryMonth,IsNull(X.EmployeeNo,Y.EmployeeNo)EmployeeNo,IsNull(X.ItemGroup,Y.ItemGroup)ItemGroup,
IsNull(X.ItemCode,Y.ItemCode)ItemCode,IsNull(X.ItemID,Y.ItemID)ItemID,IsNull(X.Name,Y.Name)Name,IsNull(X.Description,Y.Description)Description,ISNULL(X.Amount,0) - IsNull(Y.Amount,0) Amount
FROM (Select S.SalaryMonth,E.EMPLOYEENO,E.NAME,'Net Pay' Description,SD.CHANGEDAMOUNT Amount,sd.ItemGroup,sd.ItemCode, sd.ItemID
from EMPLOYEE E, SALARYMONTHLY S,SALARYMONTHLYDETAIL
Sd where S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth= %d AND E.EMPLOYEEID =S.EMPLOYEEID
and Sd.ItemGroup IN (5) AND Sd.ItemCode IN(-132) AND S.EmployeeID IN(%q) )X
FULL OUTER JOIN
(Select S.SalaryMonth,E.EMPLOYEENO,E.NAME, 'Net Pay' Description,SD.CHANGEDAMOUNT Amount,sd.ItemGroup,sd.ItemCode, sd.ItemID
from EMPLOYEE E,SALARYMONTHLY S,SALARYMONTHLYDETAIL
Sd where S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth= %d AND E.EMPLOYEEID =S.EMPLOYEEID
and Sd.ItemGroup IN (5) AND Sd.ItemCode IN(-132) AND S.EmployeeID IN(%q)
)Y
ON X.EmployeeNo = Y.EmployeeNo AND X.Name = Y.Name AND X.Description = Y.Description AND X.ItemGroup=Y.ItemGroup AND X.ItemCode= Y.ItemCode AND X.ItemID= Y.ItemID",
dateTime, sEmpID,Prevdate, sEmpID);
tempdataset = tc.ExecuteDataSet(query7);
tempdataset.Tables[0].TableName = "NetPay";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return rootDataset;
}
//New Salary Sheet From Old Tables
internal static DataSet GetEmpSalarySheet(TransactionContext tc, DateTime dateTime)
{
DataSet rootDataset = new DataSet();
DataSet tempdataset = new DataSet();
try
{
string query1 = SQLParser.MakeSQL(@"select A.EmployeeNo, A.Name,A.GName, A.DName,A.JoiningDate,A.GCode,A.SequenceNo,
A.Description, SUM(A.changedamount) Amount,A.ACCOUNTNO,A.BankName,A.Division,A.Department
from
(select S.EmployeeID, S.EmployeeNo, S.Name,S.JoiningDate, sd.ItemGroup,sd.ItemCode,
sd.ItemID, sd.Description,sd.Position, sd.changedamount,S.GradeName as GName,S.Designation as DName,S.GCode,S.SequenceNo,S.ACCOUNTNO,S.BankName,S.Division,S.Department
from vw_EmployeeImportantInfoWithSalaryNew S, GP_SalaryMonthlyDetail Sd
where S.SalaryMonthlyID=Sd.SalaryMonthlyID
AND S.SalaryMonth=%d and Sd.ItemGroup in(8) AND sd.ItemCode not in(-133)
UNION
select S.EmployeeID, S.EmployeeNo, S.Name,S.JoiningDate, sd.ItemGroup,sd.ItemCode,
sd.ItemID, sd.Description,sd.Position, sd.changedamount,S.GradeName as GName,S.Designation as DName,S.GCode,S.SequenceNo ,S.ACCOUNTNO,S.BankName,S.Division,S.Department
from vw_EmployeeImportantInfoWithSalaryNew S, GP_SalaryMonthlyDetail Sd
where 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,A.JoiningDate,A.ACCOUNTNO,A.BankName,A.Division,A.Department order by A.Position,A.EmployeeNo,A.SequenceNo,A.GCode",
dateTime, dateTime, dateTime);
tempdataset = tc.ExecuteDataSet(query1);
tempdataset.Tables[0].TableName = "GrossItem";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query2 = SQLParser.MakeSQL(@"select A.EmployeeNo, A.Name,A.GName, A.DName,A.JoiningDate,A.GCode,A.SequenceNo,
A.Description, Sum(A.amount) as amount,A.ACCOUNTNO,A.BankName,A.Division,A.Department
from
(
select
S.EmployeeID,S.EmployeeNo,S.JoiningDate, Sum(sd.changedamount) as Amount,
Sd.Description,S.GRADENAME as GName,S.GCode,S.SequenceNo,S.Name,S.DESIGNATION AS Dname,
S.ACCOUNTNO,S.BankName,S.Division,S.Department
from vw_EmployeeImportantInfoWithSalaryNew S, GP_SalaryMonthlyDetail Sd
where S.SalaryMonthlyID=Sd.SalaryMonthlyID
AND S.SalaryMonth=%d and Sd.ItemGroup IN (1, 8)
group by S.EmployeeID,S.JoiningDate ,S.EmployeeNo,Sd.DESCRIPTION,S.SequenceNo,S.GCode,
S.Name,S.GRADENAME,S.sequenceNo,S.DESIGNATION,S.ACCOUNTNO,S.BankName,S.Division,S.Department
UNION
select S.EmployeeID,S.EmployeeNo,S.JoiningDate ,-Sum(sd.changedamount) as Amount,
sd.Description,S.GRADENAME as GName,S.GCode,S.sequenceNo,S.Name,
S.DESIGNATION AS Dname,S.ACCOUNTNO,S.BankName,S.Division,S.Department
from vw_EmployeeImportantInfoWithSalaryNew S, GP_SalaryMonthlyDetail Sd
where S.SalaryMonthlyID=Sd.SalaryMonthlyID
AND S.SalaryMonth=%d
and Sd.ItemGroup IN (2)
group by S.EmployeeID,S.JoiningDate ,S.EmployeeNo,Sd.DESCRIPTION,S.SequenceNo,S.GCode,
S.Name,S.GRADENAME,S.sequenceNo,S.DESIGNATION,S.ACCOUNTNO,S.BankName,S.Division,S.Department
) A
group by A.EmployeeID,A.Description, A.EmployeeNo, A.Name,A.GName,A.SequenceNo,
A.GCode,A.DName,A.JoiningDate,A.ACCOUNTNO,A.BankName,A.Division,A.Department ", dateTime, dateTime);
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.DName,A.JoiningDate,A.GCode,A.SequenceNo,
A.Description, Sum(A.amount) as amount,A.ItemCode,A.ItemID,A.ACCOUNTNO,A.BankName,A.Division,A.Department
from
(
select
S.EmployeeID,S.EmployeeNo,S.JoiningDate, Sum(sd.changedamount) as Amount,sd.ItemCode, sd.ItemID,
Sd.Description,S.GRADENAME as GName,S.GCode,S.SequenceNo,S.Name,S.DESIGNATION AS Dname,
S.ACCOUNTNO,S.BankName,S.Division,S.Department
from vw_EmployeeImportantInfoWithSalaryNew S, GP_SalaryMonthlyDetail Sd
where S.SalaryMonthlyID=Sd.SalaryMonthlyID
AND S.SalaryMonth=%d and Sd.ItemGroup IN (3)
group by S.EmployeeID,S.JoiningDate ,S.EmployeeNo,Sd.DESCRIPTION,S.SequenceNo,S.GCode,
S.Name,S.GRADENAME,S.sequenceNo,S.DESIGNATION,S.ACCOUNTNO,S.BankName,S.Division,S.Department ,sd.ItemCode, sd.ItemID
UNION
select S.EmployeeID,S.EmployeeNo,S.JoiningDate ,-Sum(sd.changedamount) as Amount,sd.ItemCode, sd.ItemID,
sd.Description,S.GRADENAME as GName,S.GCode,S.sequenceNo,S.Name,
S.DESIGNATION AS Dname,S.ACCOUNTNO,S.BankName,S.Division,S.Department
from vw_EmployeeImportantInfoWithSalaryNew S,GP_SalaryMonthlyDetail Sd
where S.SalaryMonthlyID=Sd.SalaryMonthlyID
AND S.SalaryMonth=%d
and Sd.ItemGroup IN (2)
group by S.EmployeeID,S.JoiningDate ,S.EmployeeNo,Sd.DESCRIPTION,S.SequenceNo,S.GCode,
S.Name,S.GRADENAME,S.sequenceNo,S.DESIGNATION,S.ACCOUNTNO,S.BankName,S.Division,S.Department,sd.ItemCode, sd.ItemID
) A
group by A.EmployeeID,A.Description, A.EmployeeNo, A.Name,A.GName,A.SequenceNo,
A.GCode,A.DName,A.JoiningDate,A.ACCOUNTNO,A.BankName,A.Division,A.Department,A.ItemCode,A.ItemID", dateTime, dateTime);
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.DName,A.JoiningDate,A.GCode,A.SequenceNo,
A.Description, Sum(A.amount) as amount,A.ItemCode,A.ItemID,A.ACCOUNTNO,A.BankName,A.Division,A.Department
from
(
select
S.EmployeeID,S.EmployeeNo,S.JoiningDate, Sum(sd.changedamount) as Amount,sd.ItemCode, sd.ItemID,
Sd.Description,S.GRADENAME as GName,S.GCode,S.SequenceNo,S.Name,S.DESIGNATION AS Dname,
S.ACCOUNTNO,S.BankName,S.Division,S.Department
from vw_EmployeeImportantInfoWithSalaryNew S, GP_SalaryMonthlyDetail Sd
where S.SalaryMonthlyID=Sd.SalaryMonthlyID
AND S.SalaryMonth=%d and Sd.ITEMCODE =-139 AND Sd.ItemGroup IN (4)
group by S.EmployeeID,S.JoiningDate ,S.EmployeeNo,Sd.DESCRIPTION,S.SequenceNo,S.GCode,
S.Name,S.GRADENAME,S.sequenceNo,S.DESIGNATION,S.ACCOUNTNO,S.BankName,S.Division,S.Department ,sd.ItemCode, sd.ItemID
UNION
select S.EmployeeID,S.EmployeeNo,S.JoiningDate ,-Sum(sd.changedamount) as Amount,sd.ItemCode, sd.ItemID,
sd.Description,S.GRADENAME as GName,S.GCode,S.sequenceNo,S.Name,
S.DESIGNATION AS Dname,S.ACCOUNTNO,S.BankName,S.Division,S.Department
from vw_EmployeeImportantInfoWithSalaryNew S,GP_SalaryMonthlyDetail Sd
where S.SalaryMonthlyID=Sd.SalaryMonthlyID
AND S.SalaryMonth=%d
and Sd.ITEMCODE =-139 AND Sd.ItemGroup IN (4)
group by S.EmployeeID,S.JoiningDate ,S.EmployeeNo,Sd.DESCRIPTION,S.SequenceNo,S.GCode,
S.Name,S.GRADENAME,S.sequenceNo,S.DESIGNATION,S.ACCOUNTNO,S.BankName,S.Division,S.Department,sd.ItemCode, sd.ItemID
) A
group by A.EmployeeID,A.Description, A.EmployeeNo, A.Name,A.GName,A.SequenceNo,
A.GCode,A.DName,A.JoiningDate,A.ACCOUNTNO,A.BankName,A.Division,A.Department,A.ItemCode,A.ItemID", dateTime, dateTime);
tempdataset = tc.ExecuteDataSet(query4);
tempdataset.Tables[0].TableName = "LeaveDays";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query5 = SQLParser.MakeSQL(@"
select A.EmployeeNo, A.Name,A.GName, A.DName,A.JoiningDate,A.GCode,A.SequenceNo,
A.Description, Sum(A.amount) as amount,A.ItemCode,A.ItemID,A.ACCOUNTNO,A.BankName,A.Division,A.Department
from
(
select
S.EmployeeID,S.EmployeeNo,S.JoiningDate, Sum(sd.changedamount) as Amount,sd.ItemCode, sd.ItemID,
Sd.Description,S.GRADENAME as GName,S.GCode,S.SequenceNo,S.Name,S.DESIGNATION AS Dname,
S.ACCOUNTNO,S.BankName,S.Division,S.Department
from vw_EmployeeImportantInfoWithSalaryNew S, GP_SalaryMonthlyDetail Sd
where S.SalaryMonthlyID=Sd.SalaryMonthlyID
AND S.SalaryMonth=%d
AND Sd.ITEMCODE in(-135,-133,-140,-141,-142)
AND Sd.ItemGroup IN (4)
group by S.EmployeeID,S.JoiningDate ,S.EmployeeNo,Sd.DESCRIPTION,S.SequenceNo,S.GCode,
S.Name,S.GRADENAME,S.sequenceNo,S.DESIGNATION,S.ACCOUNTNO,S.BankName,S.Division,S.Department ,sd.ItemCode, sd.ItemID
) A
group by A.EmployeeID,A.Description, A.EmployeeNo, A.Name,A.GName,A.SequenceNo,
A.GCode,A.DName,A.JoiningDate,A.ACCOUNTNO,A.BankName,A.Division,A.Department,A.ItemCode,A.ItemID", dateTime);
tempdataset = tc.ExecuteDataSet(query5);
tempdataset.Tables[0].TableName = "AttendenceDays";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query6 = SQLParser.MakeSQL(@"select A.EmployeeNo, A.Name,A.GName, A.DName,A.JoiningDate,A.GCode,A.SequenceNo,
A.Description, Sum(A.amount) as amount,A.ItemCode,A.ItemID,A.ACCOUNTNO,A.BankName,A.Division,A.Department
from
(
select
S.EmployeeID,S.EmployeeNo,S.JoiningDate, Sum(sd.changedamount) as Amount,sd.ItemCode, sd.ItemID,
Sd.Description,S.GRADENAME as GName,S.GCode,S.SequenceNo,S.Name,S.DESIGNATION AS Dname,
S.ACCOUNTNO,S.BankName,S.Division,S.Department
from vw_EmployeeImportantInfoWithSalaryNew S, GP_SalaryMonthlyDetail Sd
where S.SalaryMonthlyID=Sd.SalaryMonthlyID
AND S.SalaryMonth=%d
and Sd.ItemGroup IN (2,3)
group by S.EmployeeID,S.JoiningDate ,S.EmployeeNo,Sd.DESCRIPTION,S.SequenceNo,S.GCode,
S.Name,S.GRADENAME,S.sequenceNo,S.DESIGNATION,S.ACCOUNTNO,S.BankName,S.Division,S.Department ,sd.ItemCode, sd.ItemID
) A
group by A.EmployeeID,A.Description, A.EmployeeNo, A.Name,A.GName,A.SequenceNo,
A.GCode,A.DName,A.JoiningDate,A.ACCOUNTNO,A.BankName,A.Division,A.Department,A.ItemCode,A.ItemID", dateTime);
tempdataset = tc.ExecuteDataSet(query6);
tempdataset.Tables[0].TableName = "TotalDeduction";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query7 = SQLParser.MakeSQL(@"select A.EmployeeNo, A.Name,A.GName, A.DName,A.JoiningDate,A.GCode,A.SequenceNo,
A.Description, Sum(A.amount) as amount,A.ItemCode,A.ItemID,A.ACCOUNTNO,A.BankName,A.Division,A.Department
from
(
select
S.EmployeeID,S.EmployeeNo,S.JoiningDate, Sum(sd.changedamount) as Amount,sd.ItemCode, sd.ItemID,
Sd.Description,S.GRADENAME as GName,S.GCode,S.SequenceNo,S.Name,S.DESIGNATION AS Dname,
S.ACCOUNTNO,S.BankName,S.Division,S.Department
from vw_EmployeeImportantInfoWithSalaryNew S, GP_SalaryMonthlyDetail Sd
where S.SalaryMonthlyID=Sd.SalaryMonthlyID
AND S.SalaryMonth=%d
And Sd.ItemGroup IN (5)
AND Sd.ItemCode IN(-132)
group by S.EmployeeID,S.JoiningDate ,S.EmployeeNo,Sd.DESCRIPTION,S.SequenceNo,S.GCode,
S.Name,S.GRADENAME,S.sequenceNo,S.DESIGNATION,S.ACCOUNTNO,S.BankName,S.Division,S.Department ,sd.ItemCode, sd.ItemID
) A
group by A.EmployeeID,A.Description, A.EmployeeNo, A.Name,A.GName,A.SequenceNo,
A.GCode,A.DName,A.JoiningDate,A.ACCOUNTNO,A.BankName,A.Division,A.Department,A.ItemCode,A.ItemID
", dateTime);
tempdataset = tc.ExecuteDataSet(query7);
tempdataset.Tables[0].TableName = "NetPay";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query8 = SQLParser.MakeSQL(@"select A.EmployeeNo, A.Name,A.GName, A.DName,A.JoiningDate,A.GCode,A.SequenceNo,
A.Description, Sum(A.amount) as amount,A.ItemCode,A.ItemID,A.ACCOUNTNO,A.BankName,A.Division,A.Department
from
(
select
S.EmployeeID,S.EmployeeNo,S.JoiningDate, Sum(sd.changedamount) as Amount,sd.ItemCode, sd.ItemID,
Sd.Description,S.GRADENAME as GName,S.GCode,S.SequenceNo,S.Name,S.DESIGNATION AS Dname,
S.ACCOUNTNO,S.BankName,S.Division,S.Department
from vw_EmployeeImportantInfoWithSalaryNew S, GP_SalaryMonthlyDetail Sd
where S.SalaryMonthlyID=Sd.SalaryMonthlyID
AND S.SalaryMonth=%d
AND Sd.ItemGroup IN (3)
AND Sd.ItemCode IN(-128)
group by S.EmployeeID,S.JoiningDate ,S.EmployeeNo,Sd.DESCRIPTION,S.SequenceNo,S.GCode,
S.Name,S.GRADENAME,S.sequenceNo,S.DESIGNATION,S.ACCOUNTNO,S.BankName,S.Division,S.Department ,sd.ItemCode, sd.ItemID
) A
group by A.EmployeeID,A.Description, A.EmployeeNo, A.Name,A.GName,A.SequenceNo,
A.GCode,A.DName,A.JoiningDate,A.ACCOUNTNO,A.BankName,A.Division,A.Department,A.ItemCode,A.ItemID
", dateTime);
tempdataset = tc.ExecuteDataSet(query8);
tempdataset.Tables[0].TableName = "CPF";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
#region UnusedCode
// string query9 = SQLParser.MakeSQL(@"Select E.EMPLOYEENO,E.NAME,E.JoiningDate,G.DESCRIPTION as GName,G.Code as GCode,G.SequenceNo,D.Name as DName ,'CPF' as Description,SD.CHANGEDAMOUNT as Amount
// from EMPLOYEE as E,GRADES as G,DESIGNATION D,SALARYMONTHLY as S,GP_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 (3) AND Sd.ItemCode IN(-128)
// order by E.EMPLOYEENO,G.SequenceNo,G.Code ", dateTime, sEmpID);
// tempdataset = tc.ExecuteDataSet(@"Select E.EMPLOYEENO,E.NAME,E.JoiningDate,G.DESCRIPTION as GName,G.Code as GCode,G.SequenceNo,D.Name as DName ,'CPF' as Description,SD.CHANGEDAMOUNT as Amount
// from EMPLOYEE as E,GRADES as G,DESIGNATION D,SALARYMONTHLY as S,GP_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 (3) AND Sd.ItemCode IN(-128) order by E.EMPLOYEENO,G.SequenceNo,G.Code ", dateTime, sEmpID);
// tempdataset.Tables[0].TableName = "CPF";
// rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
#endregion
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return rootDataset;
}
internal static DataSet GetEmpSalarySheet2(TransactionContext tc, DateTime dateTime, string sEmpID)
{
DateTime dtCurrent = GlobalFunctions.LastDateOfMonth(dateTime);
DateTime dtPrevious = GlobalFunctions.LastDateOfMonth(dateTime.AddMonths(-1));
DataSet rootDataset = new DataSet();
DataSet tempdataset = new DataSet();
try
{
string query1 = SQLParser.MakeSQL(@"select tab1.Employeeno EmpNo,tab1.Name ,tab1.Description ColDes,tab2.amount ColValue1,'1' RowSequence,tab2.salarymonth salarymonth1, tab1.amount ColValue2,tab1.salarymonth salarymonth2,'0' ColValue3,'1' SLNo,'20' TotalEmp from
(select A.EmployeeNo, A.Name,A.GName,A.DName,A.GCode,A.JoiningDate,A.SequenceNo,
A.Description,A.salarymonth, SUM(A.changedamount) Amount
from
(select S.EmployeeID, E.EmployeeNo, E.Name,E.JoiningDate, 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,S.salarymonth
from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd
where G.GradeID= S.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,E.JoiningDate, 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,S.salarymonth from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd
where G.GradeID= S.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,A.JoiningDate,A.salarymonth)tab1,
(select A.EmployeeNo, A.Name,A.GName,A.DName,A.GCode,A.JoiningDate,A.SequenceNo,
A.Description,A.salarymonth, SUM(A.changedamount) Amount
from
(select S.EmployeeID, E.EmployeeNo, E.Name,E.JoiningDate, 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,S.salarymonth
from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd
where G.GradeID= S.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,E.JoiningDate, 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,S.salarymonth from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd
where G.GradeID= S.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,A.JoiningDate,A.salarymonth )tab2
where tab1.employeeno=tab2.employeeno AND tab1.description=tab2.description AND tab1.amount-tab2.amount>0",
dtCurrent, sEmpID, dtCurrent, sEmpID, dtPrevious, sEmpID, dtPrevious, sEmpID);
tempdataset = tc.ExecuteDataSet(query1);
tempdataset.Tables[0].TableName = "GrossItem";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query2 = SQLParser.MakeSQL(@"select tab1.Employeeno EmpNo,tab1.Name ,tab1.Description ColDes,tab2.amount ColVal1,'' RowSequence,tab2.salarymonth salarymonth1, tab1.amount ColVal2,tab1.salarymonth salarymonth2,'0' ColValue3,'1' SLNo,'20' TotalEmp from
(select E.EmployeeNo, E.Name,E.JoiningDate,A.GName,A.GCode,A.SequenceNo,A.DName,'Total Gross' as Description,A.salarymonth, 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 ,S.salarymonth
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 ,S.salarymonth
UNION
select S.EmployeeID, -Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,G.Code as GCode,G.sequenceNo,D.Name as DName,S.salarymonth
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 ,S.salarymonth
) A, Employee E where A.EmployeeID = E.EmployeeID
group by E.EmployeeNo, E.Name,A.GName,A.SequenceNo,A.GCode,A.DName,E.JoiningDate,A.salarymonth )tab1,
(select E.EmployeeNo, E.Name,E.JoiningDate,A.GName,A.GCode,A.SequenceNo,A.DName,'Total Gross' as Description,A.salarymonth, 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 ,S.salarymonth
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 ,S.salarymonth
UNION
select S.EmployeeID, -Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,G.Code as GCode,G.sequenceNo,D.Name as DName,S.salarymonth
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 ,S.salarymonth
) A, Employee E where A.EmployeeID = E.EmployeeID
group by E.EmployeeNo, E.Name,A.GName,A.SequenceNo,A.GCode,A.DName,E.JoiningDate,A.salarymonth )tab2
where tab1.employeeno=tab2.employeeno AND tab1.description=tab2.description AND tab1.amount-tab2.amount>0", dtCurrent, sEmpID, dtCurrent, sEmpID, dtPrevious, sEmpID, dtPrevious, sEmpID);
tempdataset = tc.ExecuteDataSet(query2);
tempdataset.Tables[0].TableName = "TotalGross";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query3 = SQLParser.MakeSQL(@"select tab1.Employeeno EmpNo,tab1.Name ,tab1.Description ColDes,tab2.amount ColVal1,'' RowSequence,tab2.salarymonth salarymonth1, tab1.amount ColVal2,tab1.salarymonth salarymonth2,'0' ColValue3,'1' SLNo,'20' TotalEmp from
(select A.EmployeeNo, A.Name,A.JoiningDate,A.GName,A.GCode,A.SequenceNo,A.DName,
A.Description,A.salarymonth, SUM(A.changedamount) Amount,A.ItemCode,A.ItemID
from
(select S.EmployeeID, E.EmployeeNo, E.Name,E.JoiningDate,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 ,S.salarymonth
from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd
where G.GradeID= S.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,E.JoiningDate,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,S.salarymonth
from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd
where G.GradeID= S.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,A.JoiningDate,A.salarymonth )tab1,
(select A.EmployeeNo, A.Name,A.JoiningDate,A.GName,A.GCode,A.SequenceNo,A.DName,
A.Description,A.salarymonth, SUM(A.changedamount) Amount,A.ItemCode,A.ItemID
from
(select S.EmployeeID, E.EmployeeNo, E.Name,E.JoiningDate,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 ,S.salarymonth
from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd
where G.GradeID= S.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,E.JoiningDate,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,S.salarymonth
from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd
where G.GradeID= S.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,A.JoiningDate,A.salarymonth)tab2
where tab1.employeeno=tab2.employeeno AND tab1.description=tab2.description AND tab1.amount-tab2.amount>0
order by tab1.Employeeno,tab1.DESCRIPTION", dtCurrent, sEmpID, dtCurrent, sEmpID, dtPrevious, sEmpID, dtPrevious, sEmpID);
tempdataset = tc.ExecuteDataSet(query3);
tempdataset.Tables[0].TableName = "DeductItem";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query4 = SQLParser.MakeSQL(@"select tab1.Employeeno EmpNo,tab1.Name ,tab1.Description ColDes,tab2.amount ColVal1,'' RowSequence,tab2.salarymonth salarymonth1, tab1.amount ColVal2,tab1.salarymonth salarymonth2,'0' ColValue3,'1' SLNo,'20' TotalEmp from
(select A.EmployeeNo, A.Name,A.GName,A.GCode,A.SequenceNo,A.DName,A.JoiningDate,
A.Description,A.salarymonth, SUM(A.changedamount) Amount
from
(select S.EmployeeID, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode,E.JoiningDate,
sd.ItemID, sd.Description,sd.Position, sd.changedamount,G.DESCRIPTION as GName,G.Code as GCode,G.SequenceNo,D.Name as DName,S.salarymonth
from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd
where G.GradeID= S.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d and Sd.ITEMCODE =-139 AND Sd.ItemGroup IN (4) AND S.EmployeeID IN(%q)
UNION
select S.EmployeeID, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode,E.JoiningDate,
sd.ItemID, sd.Description,sd.Position, sd.changedamount,G.DESCRIPTION as GName,G.Code as GCode,G.SequenceNo,D.Name as DName,S.salarymonth from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd
where G.GradeID= S.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d and Sd.ITEMCODE =-139 AND Sd.ItemGroup IN (4) AND S.EmployeeID IN(%q)
) A group by
A.EmployeeID, A.EmployeeNo, A.Name,A.GName,A.SequenceNo,A.GCode,A.DName,A.JoiningDate,
A.ItemCode, A.ItemID, A.Description,A.Position,A.salarymonth )tab1,
(select A.EmployeeNo, A.Name,A.GName,A.GCode,A.SequenceNo,A.DName,A.JoiningDate,
A.Description,A.salarymonth, SUM(A.changedamount) Amount
from
(select S.EmployeeID, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode,E.JoiningDate,
sd.ItemID, sd.Description,sd.Position, sd.changedamount,G.DESCRIPTION as GName,G.Code as GCode,G.SequenceNo,D.Name as DName,S.salarymonth
from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd
where G.GradeID= S.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d and Sd.ITEMCODE =-139 AND Sd.ItemGroup IN (4) AND S.EmployeeID IN(%q)
UNION
select S.EmployeeID, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode,E.JoiningDate,
sd.ItemID, sd.Description,sd.Position, sd.changedamount,G.DESCRIPTION as GName,G.Code as GCode,G.SequenceNo,D.Name as DName,S.salarymonth from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd
where G.GradeID= S.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d and Sd.ITEMCODE =-139 AND Sd.ItemGroup IN (4) AND S.EmployeeID IN(%q)
) A group by
A.EmployeeID, A.EmployeeNo, A.Name,A.GName,A.SequenceNo,A.GCode,A.DName,A.JoiningDate,
A.ItemCode, A.ItemID, A.Description,A.Position,A.salarymonth
)tab2
where tab1.employeeno=tab2.employeeno AND tab1.description=tab2.description AND tab1.amount-tab2.amount>0
order by tab1.Employeeno,tab1.DESCRIPTION", dtCurrent, sEmpID, dtCurrent, sEmpID, dtPrevious, sEmpID, dtPrevious, sEmpID);
tempdataset = tc.ExecuteDataSet(query4);
tempdataset.Tables[0].TableName = "LeaveDays";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query5 = SQLParser.MakeSQL(@"select tab1.Employeeno EmpNo,tab1.Name ,tab1.Description ColDes,tab2.amount ColVal1,'' RowSequence,tab2.salarymonth salarymonth1, tab1.amount ColVal2,tab1.salarymonth salarymonth2,'0' ColValue3,'1' SLNo,'20' TotalEmp from
(select E.EmployeeNo, E.Name,A.GName,A.GCode,A.sequenceNo,A.DName, A.Description,A.salarymonth, Sum(A.amount) as amount
,E.JoiningDate
from
(select S.EmployeeID,Sd.Description, Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,G.Code as GCode,G.SequenceNo,D.Name as DName ,S.salarymonth
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.ITEMCODE in(-135,-133,-140,-141,-142) AND Sd.ItemGroup IN (4) AND S.EmployeeID IN(%q)
group by S.EmployeeID,Sd.Description,G.DESCRIPTION,G.SequenceNo,G.Code,D.Name,S.salarymonth
) A, Employee E where A.EmployeeID = E.EmployeeID group by E.EmployeeNo, E.Name,A.GName,A.SequenceNo,A.Description,A.GCode,A.DName,E.JoiningDate,A.salarymonth)tab1,
(select E.EmployeeNo, E.Name,A.GName,A.GCode,A.sequenceNo,A.DName, A.Description,A.salarymonth, Sum(A.amount) as amount
,E.JoiningDate from
(select S.EmployeeID,Sd.Description, Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,G.Code as GCode,G.SequenceNo,D.Name as DName ,S.salarymonth
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.ITEMCODE in(-135,-133,-140,-141,-142) AND Sd.ItemGroup IN (4) AND S.EmployeeID IN(%q)
group by S.EmployeeID,Sd.Description,G.DESCRIPTION,G.SequenceNo,G.Code,D.Name,S.salarymonth
) A, Employee E where A.EmployeeID = E.EmployeeID group by E.EmployeeNo, E.Name,A.GName,A.SequenceNo,A.Description,A.GCode,A.DName,E.JoiningDate,A.salarymonth
)tab2
where tab1.employeeno=tab2.employeeno AND tab1.description=tab2.description AND tab1.amount-tab2.amount>0
order by tab1.Employeeno,tab1.DESCRIPTION", dtCurrent, sEmpID, dtPrevious, sEmpID);
tempdataset = tc.ExecuteDataSet(query5);
tempdataset.Tables[0].TableName = "AttendenceDays";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query6 = SQLParser.MakeSQL(@"select tab1.Employeeno EmpNo,tab1.Name ,tab1.Description ColDes,tab2.amount ColVal1,'' RowSequence,tab2.salarymonth salarymonth1, tab1.amount ColVal2,tab1.salarymonth salarymonth2,'0' ColValue3,'1' SLNo,'20' TotalEmp from
(select E.EmployeeNo, E.Name,E.JoiningDate,A.GName,A.GCode,A.SequenceNo,A.DName, 'Total Deduction' as Description,A.salarymonth, 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 ,S.salarymonth
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,S.salarymonth
) A, Employee E where A.EmployeeID = E.EmployeeID group by E.EmployeeNo, E.Name,A.GName,A.SequenceNo,A.GCode,A.DName,E.JoiningDate,A.salarymonth )tab1,
(select E.EmployeeNo, E.Name,E.JoiningDate,A.GName,A.GCode,A.SequenceNo,A.DName, 'Total Deduction' as Description,A.salarymonth, 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 ,S.salarymonth
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,S.salarymonth
) A, Employee E where A.EmployeeID = E.EmployeeID group by E.EmployeeNo, E.Name,A.GName,A.SequenceNo,A.GCode,A.DName,E.JoiningDate,A.salarymonth
)tab2
where tab1.employeeno=tab2.employeeno AND tab1.description=tab2.description AND tab1.amount-tab2.amount>0
order by tab1.Employeeno,tab1.DESCRIPTION", dtCurrent, sEmpID, dtPrevious, sEmpID);
tempdataset = tc.ExecuteDataSet(query6);
tempdataset.Tables[0].TableName = "TotalDeduction";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query7 = SQLParser.MakeSQL(@"select tab1.Employeeno EmpNo,tab1.Name ,tab1.Description ColDes,tab2.amount ColVal1,'' RowSequence,tab2.salarymonth salarymonth1, tab1.amount ColVal2,tab1.salarymonth salarymonth2,'0' ColValue3,'1' SLNo,'20' TotalEmp from
(Select E.EMPLOYEENO,E.NAME,E.JoiningDate,G.DESCRIPTION as GName,G.Code as GCode,G.SequenceNo,D.Name as DName ,'Net Pay' as Description,SD.CHANGEDAMOUNT as Amount,S.salarymonth
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))tab1,
(Select E.EMPLOYEENO,E.NAME,E.JoiningDate,G.DESCRIPTION as GName,G.Code as GCode,G.SequenceNo,D.Name as DName ,'Net Pay' as Description,SD.CHANGEDAMOUNT as Amount,S.salarymonth
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)
)tab2
where tab1.employeeno=tab2.employeeno AND tab1.description=tab2.description AND tab1.amount-tab2.amount>0
order by tab1.Employeeno,tab1.DESCRIPTION ", dtCurrent, sEmpID, dtPrevious, sEmpID);
tempdataset = tc.ExecuteDataSet(query7);
tempdataset.Tables[0].TableName = "NetPay";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query8 = SQLParser.MakeSQL(@"select tab1.Employeeno EmpNo,tab1.Name ,tab1.Description ColDes,tab2.amount ColVal1,'' RowSequence,tab2.salarymonth salarymonth1, tab1.amount ColVal2,tab1.salarymonth salarymonth2,'0' ColValue3,'1' SLNo,'20' TotalEmp from
(Select E.EMPLOYEENO,E.NAME,E.JoiningDate,G.DESCRIPTION as GName,G.Code as GCode,G.SequenceNo,D.Name as DName ,'CPF' as Description,SD.CHANGEDAMOUNT as Amount,S.salarymonth
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 (3) AND Sd.ItemCode IN(-128) AND S.EmployeeID IN(%q) )tab1,
(Select E.EMPLOYEENO,E.NAME,E.JoiningDate,G.DESCRIPTION as GName,G.Code as GCode,G.SequenceNo,D.Name as DName ,'CPF' as Description,SD.CHANGEDAMOUNT as Amount,S.salarymonth
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 (3) AND Sd.ItemCode IN(-128) AND S.EmployeeID IN(%q) )tab2
where tab1.employeeno=tab2.employeeno AND tab1.description=tab2.description AND tab1.amount-tab2.amount>0
order by tab1.Employeeno,tab1.DESCRIPTION ", dtCurrent, sEmpID, dtPrevious, sEmpID);
tempdataset = tc.ExecuteDataSet(query8);
tempdataset.Tables[0].TableName = "CPF";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return rootDataset;
}
internal static DataSet GetExpatSalarySheet(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.JoiningDate,A.SequenceNo,
A.Description, SUM(A.changedamount) Amount
from
(select S.EmployeeID, E.EmployeeNo, E.Name,E.JoiningDate, 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= S.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,E.JoiningDate, 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= S.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,A.JoiningDate order by A.Position,A.EmployeeNo,A.SequenceNo,A.GCode",
dateTime, sEmpID, dateTime, sEmpID, dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet(query1);
tempdataset.Tables[0].TableName = "GrossItem";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query2 = SQLParser.MakeSQL(@"select E.EmployeeNo, E.Name,E.JoiningDate,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,E.JoiningDate ", 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.JoiningDate,A.GName,A.GCode,A.SequenceNo,A.DName,
A.Description, SUM(A.changedamount) Amount,A.ItemCode,A.ItemID
from
(select S.EmployeeID, E.EmployeeNo, E.Name,E.JoiningDate,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= S.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,E.JoiningDate,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= S.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,A.JoiningDate order by A.EmployeeNo,A.Position,A.SequenceNo,A.GCode",
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.JoiningDate,
A.Description, SUM(A.changedamount) Amount
from
(
select S.EmployeeID, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode,E.JoiningDate,
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= S.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d and Sd.ITEMCODE =-139 AND Sd.ItemGroup IN (4) AND S.EmployeeID IN(%q)
UNION
select S.EmployeeID, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode,E.JoiningDate,
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= S.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d and Sd.ITEMCODE =-139 AND Sd.ItemGroup IN (4) AND S.EmployeeID IN(%q)
) A group by
A.EmployeeID, A.EmployeeNo, A.Name,A.GName,A.SequenceNo,A.GCode,A.DName,A.JoiningDate,
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(query4);
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, A.Description, Sum(A.amount) as amount
,E.JoiningDate
from
(select S.EmployeeID,Sd.Description, 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.ITEMCODE in(-135,-133,-140,-141,-142) AND Sd.ItemGroup IN (4) AND S.EmployeeID IN(%q)
group by S.EmployeeID,Sd.Description,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.Description,A.GCode,A.DName,E.JoiningDate
", dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet(query5);
tempdataset.Tables[0].TableName = "AttendenceDays";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query6 = SQLParser.MakeSQL(@"select E.EmployeeNo, E.Name,E.JoiningDate,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,E.JoiningDate order by E.EmployeeNo,A.sequenceno,A.GCode", dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet(query6);
tempdataset.Tables[0].TableName = "TotalDeduction";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query7 = SQLParser.MakeSQL(@"Select E.EMPLOYEENO,E.NAME,E.JoiningDate,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 E.EMPLOYEENO,G.SequenceNo,G.Code ", dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet(query7);
tempdataset.Tables[0].TableName = "NetPay";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query8 = SQLParser.MakeSQL(@"Select E.EMPLOYEENO,E.NAME,E.JoiningDate,G.DESCRIPTION as GName,G.Code as GCode,G.SequenceNo,D.Name as DName ,'CPF' 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 (3) AND Sd.ItemCode IN(-128) AND S.EmployeeID IN(%q) order by E.EMPLOYEENO,G.SequenceNo,G.Code ", dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet(query8);
tempdataset.Tables[0].TableName = "CPF";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query9 = SQLParser.MakeSQL(@"select A.EmployeeNo, A.Name,A.GName,A.DName,A.GCode,A.JoiningDate,A.SequenceNo,
A.Description, SUM(A.changedamount) Amount
from
(select S.EmployeeID, E.EmployeeNo, E.Name,E.JoiningDate, sd.ItemGroup,sd.ItemCode,
sd.ItemID, 'Euro' + ' ' + sd.Description 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= S.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d and Sd.ItemGroup in(4) AND sd.ItemCode in(-113) AND S.EmployeeID IN(%q)
UNION
select S.EmployeeID, E.EmployeeNo, E.Name,E.JoiningDate, sd.ItemGroup,sd.ItemCode,
sd.ItemID, 'Euro' + ' ' + sd.Description 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= S.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d and Sd.ItemGroup in(4) AND sd.ItemCode in(-101) 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,A.JoiningDate order by A.Position,A.EmployeeNo,A.SequenceNo,A.GCode",
dateTime, sEmpID, dateTime, sEmpID, dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet(query9);
tempdataset.Tables[0].TableName = "EuroItem";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query10 = SQLParser.MakeSQL(@"select E.EmployeeNo, E.Name,E.JoiningDate,A.GName,A.GCode,A.SequenceNo,A.DName,'Total Euro Amount' 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 (4) AND sd.ItemCode in(-113) 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 (4) AND sd.ItemCode in(-101) 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,E.JoiningDate ", dateTime, sEmpID, dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet(query10);
tempdataset.Tables[0].TableName = "TotalEuroAmount";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return rootDataset;
}
internal static DataSet GetEmpEuroSalarySheet(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.JoiningDate,A.SequenceNo,
A.Description, SUM(A.changedamount) Amount
from
(select S.EmployeeID, E.EmployeeNo, E.Name,E.JoiningDate, 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= S.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d and Sd.ItemGroup in(4) AND sd.ItemCode in(-113) AND S.EmployeeID IN(%q)
UNION
select S.EmployeeID, E.EmployeeNo, E.Name,E.JoiningDate, 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= S.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d and Sd.ItemGroup in(4) AND sd.ItemCode in(-101) 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,A.JoiningDate order by A.Position,A.EmployeeNo,A.SequenceNo,A.GCode",
dateTime, sEmpID, dateTime, sEmpID, dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet(query1);
tempdataset.Tables[0].TableName = "GrossItem";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query2 = SQLParser.MakeSQL(@"select E.EmployeeNo, E.Name,E.JoiningDate,A.GName,A.GCode,A.SequenceNo,A.DName,'Total Amount' 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 (4) AND sd.ItemCode in(-113) 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 (4) AND sd.ItemCode in(-101) 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,E.JoiningDate ", dateTime, sEmpID, dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet(query2);
tempdataset.Tables[0].TableName = "TotalAmount";
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
{
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) "
+ " 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.Tables[0].TableName = "GrossItem";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
tempdataset = tc.ExecuteDataSet("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.Tables[0].TableName = "TotalGross";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
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.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.Tables[0].TableName = "DeductItem";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
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 "
+ " 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.Tables[0].TableName = "LeaveDays";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
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) "
+ " 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.Tables[0].TableName = "UnAuthorized";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
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) "
+ " 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.Tables[0].TableName = "TotalDeduction";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
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)"
+ " order by G.SequenceNo,G.Code,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;
#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 GetEmpSalarySheetForNovertis(TransactionContext tc, DateTime dateTime, string sEmpID)
{
DataSet rootDataset = new DataSet();
DataSet tempdataset = new DataSet();
#region Old Code
//try
//{
// tempdataset = tc.ExecuteDataSet("select A.EmployeeNo, A.Name,A.GName,A.DName,A.GCode,A.SequenceNo,A.ItemGroup,"
// + " A.Description, 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,2,8,4) "
// + " AND sd.ItemCode not in(-133) AND S.EmployeeID IN(%q) "
// + " ) A "
// + " order by A.Position,A.SequenceNo,A.GCode,A.EmployeeNo",dateTime, sEmpID);
// tempdataset.Tables[0].TableName = "GrossItem";
// rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
// tempdataset = tc.ExecuteDataSet("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.Tables[0].TableName = "TotalGross";
// rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
// 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.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);
// tempdataset.Tables[0].TableName = "DeductItem";
// rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
// 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());
// 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());
// 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());
// 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);
//}
#endregion
try
{
tempdataset = tc.ExecuteDataSet("select A.EmployeeNo, A.Name,A.GName,A.DName,A.GCode,A.CCName,A.SequenceNo,A.ItemGroup,"
+ " A.Description, 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,CC.Description as CCName,G.SequenceNo"
+ " from Grades G,CRG CC,DESIGNATION D,Employee E,SALARYEMPCOSTCENTER SEmpCC ,SALARYMONTHLY S, SalaryMonthlyDetail Sd "
+ " where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID"
+ " AND CC.CRGID=SEmpCC.CostCenterID AND E.EmployeeID=SEmpCC.EmployeeID AND SEmpCC.EmployeeID=S.EmployeeID"
+ " AND Sd.SALARYMONTHLYID=SEmpCC.SALARYMONTHLYID"
+ " 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 "
+ " order by A.ItemGroup,A.Position,A.SequenceNo,A.GCode,A.EmployeeNo", dateTime, sEmpID);
tempdataset.Tables[0].TableName = "GrossItem";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
tempdataset = tc.ExecuteDataSet("select E.EmployeeNo, E.Name,A.GName,A.GCode,A.CCName,A.SequenceNo,A.DName,'Total Gross' as Description, Sum(A.amount) as amount,A.ItemGroup "
+ " from"
+ " (select S.EmployeeID, Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,G.Code as GCode,CC.Description as CCName,G.SequenceNo,D.Name as DName,Sd.ItemGroup "
+ " from SALARYMONTHLY S,Grades G,CRG CC,DESIGNATION D, SALARYEMPCOSTCENTER SEMPCC,SalaryMonthlyDetail Sd "
+ " where S.SalaryMonthlyID=Sd.SalaryMonthlyID "
+ " AND G.GRADEID=S.GRADEID AND D.DESIGNATIONID=S.DESIGNATIONID"
+ " AND CC.CrgID=SEmpCC.CostCenterID AND S.EmployeeID=SEMPCC.EmployeeID AND SEmpCC.EmployeeID=S.EmployeeID"
+ " AND Sd.SALARYMONTHLYID=SEmpCC.SALARYMONTHLYID"
+ " 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,CC.Description,Sd.ItemGroup "
+ " UNION"
+ " select S.EmployeeID, -Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,G.Code as GCode,CC.Description as CCName,G.sequenceNo,D.Name as DName,Sd.ItemGroup"
+ " from GRADES G,CRG CC,DESIGNATION D,SALARYMONTHLY S, SALARYEMPCOSTCENTER SEmpCC,SalaryMonthlyDetail Sd "
+ " where S.SalaryMonthlyID=Sd.SalaryMonthlyID "
+ " AND S.SalaryMonth=%d AND G.GRADEID=S.GRADEID AND D.DESIGNATIONID=S.DESIGNATIONID AND SEmpCC.EmployeeID=S.EmployeeID"
+ " AND Sd.SALARYMONTHLYID=SEmpCC.SALARYMONTHLYID"
+ " and Sd.ItemGroup IN (2) AND S.EmployeeID IN(%q) "
+ " group by S.EmployeeID,G.DESCRIPTION,G.SequenceNo,G.Code,D.Name,CC.Description,Sd.ItemGroup "
+ " ) A, Employee E where A.EmployeeID = E.EmployeeID "
+ " group by E.EmployeeNo, E.Name,A.GName,A.SequenceNo,A.GCode,A.DName,A.CCName,A.ItemGroup ", dateTime, sEmpID, dateTime, sEmpID);
tempdataset.Tables[0].TableName = "TotalGross";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
tempdataset = tc.ExecuteDataSet("select A.EmployeeNo, A.Name,A.GName,A.GCode,A.SequenceNo,A.DName,A.CCName,A.ItemGroup,"
+ " 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,CC.Description as CCName,G.SequenceNo,D.Name as DName "
+ " from Grades G,CRG CC,DESIGNATION D,Employee E,SALARYEMPCOSTCENTER SEmpCC ,SALARYMONTHLY S, SalaryMonthlyDetail Sd "
+ " where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID AND E.employeeID=S.EmployeeID "
+ " AND CC.CrgID=SEmpCC.CostCenterID AND E.EmployeeID=SEmpCC.EmployeeID"
+ " AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d AND SEmpCC.EmployeeID=S.EmployeeID"
+ " AND Sd.SALARYMONTHLYID=SEmpCC.SALARYMONTHLYID"
+ " 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,CC.description as CCName,G.sequenceNo,D.Name as DName"
+ " from Grades G,CRG CC,DESIGNATION D,Employee E,SALARYEMPCOSTCENTER SEmpCC ,SALARYMONTHLY S, SalaryMonthlyDetail Sd "
+ " where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID "
+ " AND CC.CrgID=SEmpCC.CostCenterID AND E.EmployeeID=SEmpCC.EmployeeID"
+ " AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND SEmpCC.EmployeeID=S.EmployeeID"
+ " AND Sd.SALARYMONTHLYID=SEmpCC.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.ItemGroup,A.Description,A.Position,A.CCName"
+ " order by A.Position,A.SequenceNo,A.GCode,A.EmployeeNo",
dateTime, sEmpID, dateTime, sEmpID);
tempdataset.Tables[0].TableName = "DeductItem";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
tempdataset = tc.ExecuteDataSet("select A.EmployeeNo, A.Name,A.GName,A.GCode,A.SequenceNo,A.DName,A.CCName,A.ItemGroup,"
+ " 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,CC.Description as CCName,G.SequenceNo,D.Name as DName"
+ " from Grades G,DESIGNATION D,CRG CC,Employee E,SALARYEMPCOSTCENTER SEMPCC, SALARYMONTHLY S, SalaryMonthlyDetail Sd "
+ " where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID "
+ " AND CC.CrgID=SEmpCC.CostCenterID AND E.EmployeeID=SEmpCC.EmployeeID"
+ " AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND SEmpCC.EmployeeID=S.EmployeeID"
+ " AND Sd.SALARYMONTHLYID=SEmpCC.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,CC.Description as CCName,G.SequenceNo,D.Name as DName "
+ " from Grades G,DESIGNATION D,CRG CC,Employee E,SALARYEMPCOSTCENTER SEMPCC, SALARYMONTHLY S, SalaryMonthlyDetail Sd "
+ " where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID "
+ " AND CC.CrgID=SEmpCC.CostCenterID AND E.EmployeeID=SEmpCC.EmployeeID"
+ " AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND SEmpCC.EmployeeID=S.EmployeeID"
+ " AND Sd.SALARYMONTHLYID=SEmpCC.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.ItemGroup,A.Description,A.Position,A.CCName"
+ " 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());
tempdataset = tc.ExecuteDataSet("select E.EmployeeNo, E.Name,A.GName,A.GCode,A.CCName,A.sequenceNo,A.DName, 'UnAuthorized' as Description, Sum(A.amount) as amount,A.ItemGroup "
+ " from"
+ " (select S.EmployeeID, Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,Sd.ItemGroup,G.Code as GCode,CC.Description as CCName,"
+ " G.SequenceNo,D.Name as DName "
+ " from GRADES G,CRG CC,DESIGNATION D,SALARYEMPCOSTCENTER SEMPCC,SALARYMONTHLY S,SalaryMonthlyDetail Sd "
+ " where S.SalaryMonthlyID=Sd.SalaryMonthlyID "
+ " AND CC.CRGID=SEMPCC.CostCenterID AND S.EmployeeID=SEmpCC.EmployeeID"
+ " AND S.SalaryMonth=%d AND G.GRADEID=S.GRADEID AND SEmpCC.EmployeeID=S.EmployeeID"
+ " AND Sd.SALARYMONTHLYID=SEmpCC.SALARYMONTHLYID"
+ " 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,CC.Description,Sd.ItemGroup"
+ " ) A, Employee E where A.EmployeeID = E.EmployeeID "
+ " group by E.EmployeeNo, E.Name,A.GName,A.SequenceNo,A.GCode,A.DName,A.CCName,A.ItemGroup", dateTime, sEmpID);
tempdataset.Tables[0].TableName = "UnAuthorized";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
tempdataset = tc.ExecuteDataSet("select E.EmployeeNo, E.Name,A.GName,A.GCode,A.CCName,A.SequenceNo,A.DName, 'Total Deduction' as Description, Sum(A.amount) as amount,A.ItemGroup "
+ " from"
+ " (select S.EmployeeID, Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,G.Code as GCode,CC.description as CCName,"
+ " G.SequenceNo,D.Name as DName,Sd.ItemGroup "
+ " from GRADES G,CRG CC,SALARYEMPCOSTCENTER SEMPCC,DESIGNATION D,SALARYMONTHLY S,SalaryMonthlyDetail Sd "
+ " where S.SalaryMonthlyID=Sd.SalaryMonthlyID "
+ " AND CC.CRGID=SEMPCC.CostCenterID and S.EmployeeID=SEmpCC.EmployeeID"
+ " AND S.SalaryMonth=%d AND G.GRADEID=S.GRADEID "
+ " AND D.DESIGNATIONID=S.DESIGNATIONID AND SEmpCC.EmployeeID=S.EmployeeID"
+ " AND Sd.SALARYMONTHLYID=SEmpCC.SALARYMONTHLYID"
+ " and Sd.ItemGroup IN (2,3) AND S.EmployeeID IN(%q) "
+ " group by S.EmployeeID,G.DESCRIPTION,G.SequenceNo,G.Code,D.Name,CC.Description,Sd.ItemGroup"
+ " ) A, Employee E where A.EmployeeID = E.EmployeeID "
+ " group by E.EmployeeNo, E.Name,A.GName,A.SequenceNo,A.GCode,A.DName,A.CCName,A.ItemGroup", dateTime, sEmpID);
tempdataset.Tables[0].TableName = "TotalDeduction";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
tempdataset = tc.ExecuteDataSet("Select E.EMPLOYEENO,E.NAME,G.DESCRIPTION as GName,G.Code as GCode,Sd.ItemGroup,"
+ " G.SequenceNo,D.Name as DName ,CC.Description as CCName,'Net Pay' as Description,SD.CHANGEDAMOUNT as Amount"
+ " from EMPLOYEE as E,GRADES as G,CRG CC,DESIGNATION D,SALARYEMPCOSTCENTER SEMPCC,SALARYMONTHLY as S,SALARYMONTHLYDETAIL as Sd"
+ " where S.SalaryMonthlyID=Sd.SalaryMonthlyID "
+ " AND CC.CRGID=SEMPCC.CostCenterID and E.EmployeeID=SEMPCC.employeeID"
+ " AND S.SalaryMonth=%d"
+ " AND G.GRADEID=S.GRADEID "
+ " AND D.DESIGNATIONID=S.DESIGNATIONID"
+ " AND E.EMPLOYEEID =S.EMPLOYEEID AND SEmpCC.EmployeeID=S.EmployeeID"
+ " AND Sd.SALARYMONTHLYID=SEmpCC.SALARYMONTHLYID"
+ " 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 GetEmpSalaryReconForCurrMonth(TransactionContext tc, DateTime dateTime, string sEmpID)
{
DataSet rootDataset = new DataSet();
DataSet tempdataset = new DataSet();
try
{
tempdataset = tc.ExecuteDataSet("select A.EmployeeNo, A.Name,A.GName,A.DName,A.GCode,A.CCName,A.SequenceNo,A.ItemGroup,"
+ " A.Description, 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,CC.Description as CCName,G.SequenceNo"
+ " from Grades G,CRG CC,DESIGNATION D,Employee E,SALARYEMPCOSTCENTER SEmpCC ,SALARYMONTHLY S, SalaryMonthlyDetail Sd "
+ " where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID"
+ " AND CC.CRGID=SEmpCC.CostCenterID AND E.EmployeeID=SEmpCC.EmployeeID AND SEmpCC.EmployeeID=S.EmployeeID"
+ " AND Sd.SALARYMONTHLYID=SEmpCC.SALARYMONTHLYID"
+ " 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 "
+ " order by A.ItemGroup,A.Position,A.SequenceNo,A.GCode,A.EmployeeNo", dateTime, sEmpID);
tempdataset.Tables[0].TableName = "GrossItem";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
tempdataset = tc.ExecuteDataSet("select A.EmployeeNo, A.Name,A.GName,A.GCode,A.SequenceNo,A.DName,A.CCName,A.ItemGroup,"
+ " 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,CC.Description as CCName,G.SequenceNo,D.Name as DName "
+ " from Grades G,CRG CC,DESIGNATION D,Employee E,SALARYEMPCOSTCENTER SEmpCC ,SALARYMONTHLY S, SalaryMonthlyDetail Sd "
+ " where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID AND E.employeeID=S.EmployeeID "
+ " AND CC.CrgID=SEmpCC.CostCenterID AND E.EmployeeID=SEmpCC.EmployeeID"
+ " AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d AND SEmpCC.EmployeeID=S.EmployeeID"
+ " AND Sd.SALARYMONTHLYID=SEmpCC.SALARYMONTHLYID"
+ " 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,CC.description as CCName,G.sequenceNo,D.Name as DName"
+ " from Grades G,CRG CC,DESIGNATION D,Employee E,SALARYEMPCOSTCENTER SEmpCC ,SALARYMONTHLY S, SalaryMonthlyDetail Sd "
+ " where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID "
+ " AND CC.CrgID=SEmpCC.CostCenterID AND E.EmployeeID=SEmpCC.EmployeeID"
+ " AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND SEmpCC.EmployeeID=S.EmployeeID"
+ " AND Sd.SALARYMONTHLYID=SEmpCC.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.ItemGroup,A.Description,A.Position,A.CCName"
+ " order by A.Position,A.SequenceNo,A.GCode,A.EmployeeNo",
dateTime, sEmpID, dateTime, sEmpID);
tempdataset.Tables[0].TableName = "DeductItem";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
tempdataset = tc.ExecuteDataSet("select A.EmployeeNo, A.Name,A.GName,A.GCode,A.SequenceNo,A.DName,A.CCName,A.ItemGroup,"
+ " 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,CC.Description as CCName,G.SequenceNo,D.Name as DName"
+ " from Grades G,DESIGNATION D,CRG CC,Employee E,SALARYEMPCOSTCENTER SEMPCC, SALARYMONTHLY S, SalaryMonthlyDetail Sd "
+ " where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID "
+ " AND CC.CrgID=SEmpCC.CostCenterID AND E.EmployeeID=SEmpCC.EmployeeID"
+ " AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND SEmpCC.EmployeeID=S.EmployeeID"
+ " AND Sd.SALARYMONTHLYID=SEmpCC.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,CC.Description as CCName,G.SequenceNo,D.Name as DName "
+ " from Grades G,DESIGNATION D,CRG CC,Employee E,SALARYEMPCOSTCENTER SEMPCC, SALARYMONTHLY S, SalaryMonthlyDetail Sd "
+ " where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID "
+ " AND CC.CrgID=SEmpCC.CostCenterID AND E.EmployeeID=SEmpCC.EmployeeID"
+ " AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND SEmpCC.EmployeeID=S.EmployeeID"
+ " AND Sd.SALARYMONTHLYID=SEmpCC.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.ItemGroup,A.Description,A.Position,A.CCName"
+ " 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());
tempdataset = tc.ExecuteDataSet("select E.EmployeeNo, E.Name,A.GName,A.GCode,A.CCName,A.sequenceNo,A.DName, 'UnAuthorized' as Description, Sum(A.amount) as amount,A.ItemGroup "
+ " from"
+ " (select S.EmployeeID, Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,Sd.ItemGroup,G.Code as GCode,CC.Description as CCName,"
+ " G.SequenceNo,D.Name as DName "
+ " from GRADES G,CRG CC,DESIGNATION D,SALARYEMPCOSTCENTER SEMPCC,SALARYMONTHLY S,SalaryMonthlyDetail Sd "
+ " where S.SalaryMonthlyID=Sd.SalaryMonthlyID "
+ " AND CC.CRGID=SEMPCC.CostCenterID AND S.EmployeeID=SEmpCC.EmployeeID"
+ " AND S.SalaryMonth=%d AND G.GRADEID=S.GRADEID AND SEmpCC.EmployeeID=S.EmployeeID"
+ " AND Sd.SALARYMONTHLYID=SEmpCC.SALARYMONTHLYID"
+ " 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,CC.Description,Sd.ItemGroup"
+ " ) A, Employee E where A.EmployeeID = E.EmployeeID "
+ " group by E.EmployeeNo, E.Name,A.GName,A.SequenceNo,A.GCode,A.DName,A.CCName,A.ItemGroup", dateTime, sEmpID);
tempdataset.Tables[0].TableName = "UnAuthorized";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
tempdataset = tc.ExecuteDataSet("Select E.EMPLOYEENO,E.NAME,G.DESCRIPTION as GName,G.Code as GCode,Sd.ItemGroup,"
+ " G.SequenceNo,D.Name as DName ,CC.Description as CCName,'Net Pay' as Description,SD.CHANGEDAMOUNT as Amount"
+ " from EMPLOYEE as E,GRADES as G,CRG CC,DESIGNATION D,SALARYEMPCOSTCENTER SEMPCC,SALARYMONTHLY as S,SALARYMONTHLYDETAIL as Sd"
+ " where S.SalaryMonthlyID=Sd.SalaryMonthlyID "
+ " AND CC.CRGID=SEMPCC.CostCenterID and E.EmployeeID=SEMPCC.employeeID"
+ " AND S.SalaryMonth=%d"
+ " AND G.GRADEID=S.GRADEID "
+ " AND D.DESIGNATIONID=S.DESIGNATIONID"
+ " AND E.EMPLOYEEID =S.EMPLOYEEID AND SEmpCC.EmployeeID=S.EmployeeID"
+ " AND Sd.SALARYMONTHLYID=SEmpCC.SALARYMONTHLYID"
+ " 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 GetEmpSalaryReconForNovertis(TransactionContext tc, DateTime dateTime)
{
DataSet rootDataset = new DataSet();
DataSet tempdataset = new DataSet();
#region Old Code
//try
//{
// tempdataset = tc.ExecuteDataSet("select A.EmployeeNo, A.Name,A.GName,A.DName,A.GCode,A.SequenceNo,A.ItemGroup,"
// + " A.Description, 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,2,8,4) "
// + " AND sd.ItemCode not in(-133) AND S.EmployeeID IN(%q) "
// + " ) A "
// + " order by A.Position,A.SequenceNo,A.GCode,A.EmployeeNo",dateTime, sEmpID);
// tempdataset.Tables[0].TableName = "GrossItem";
// rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
// tempdataset = tc.ExecuteDataSet("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.Tables[0].TableName = "TotalGross";
// rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
// 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.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);
// tempdataset.Tables[0].TableName = "DeductItem";
// rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
// 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());
// 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());
// 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());
// 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);
//}
#endregion
try
{
tempdataset = tc.ExecuteDataSet("select A.EmployeeNo, A.Name,A.GName,A.DName,A.GCode,A.CCName,A.SequenceNo,A.ItemGroup,"
+ " A.Description, 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,CC.Description as CCName,G.SequenceNo"
+ " from Grades G,CRG CC,DESIGNATION D,Employee E,SALARYEMPCOSTCENTER SEmpCC ,SALARYMONTHLY S, SalaryMonthlyDetail Sd "
+ " where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID"
+ " AND CC.CRGID=SEmpCC.CostCenterID AND E.EmployeeID=SEmpCC.EmployeeID AND SEmpCC.EmployeeID=S.EmployeeID"
+ " AND Sd.SALARYMONTHLYID=SEmpCC.SALARYMONTHLYID"
+ " 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) "
+ " ) A "
+ " order by A.ItemGroup,A.Position,A.SequenceNo,A.GCode,A.EmployeeNo", dateTime);
tempdataset.Tables[0].TableName = "GrossItem";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
//tempdataset = tc.ExecuteDataSet("select E.EmployeeNo, E.Name,A.GName,A.GCode,A.CCName,A.SequenceNo,A.DName,'Total Gross' as Description, Sum(A.amount) as amount,A.ItemGroup "
// + " from"
// + " (select S.EmployeeID, Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,G.Code as GCode,CC.Description as CCName,G.SequenceNo,D.Name as DName,Sd.ItemGroup "
// + " from SALARYMONTHLY S,Grades G,CRG CC,DESIGNATION D, SALARYEMPCOSTCENTER SEMPCC,SalaryMonthlyDetail Sd "
// + " where S.SalaryMonthlyID=Sd.SalaryMonthlyID "
// + " AND G.GRADEID=S.GRADEID AND D.DESIGNATIONID=S.DESIGNATIONID"
// + " AND CC.CrgID=SEmpCC.CostCenterID AND S.EmployeeID=SEMPCC.EmployeeID AND SEmpCC.EmployeeID=S.EmployeeID"
// + " AND Sd.SALARYMONTHLYID=SEmpCC.SALARYMONTHLYID"
// + " AND S.SalaryMonth=%d and Sd.ItemGroup IN (1, 8) "
// + " group by S.EmployeeID,G.DESCRIPTION,G.SequenceNo,G.Code,D.Name,CC.Description,Sd.ItemGroup "
// + " UNION"
// + " select S.EmployeeID, -Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,G.Code as GCode,CC.Description as CCName,G.sequenceNo,D.Name as DName,Sd.ItemGroup"
// + " from GRADES G,CRG CC,DESIGNATION D,SALARYMONTHLY S, SALARYEMPCOSTCENTER SEmpCC,SalaryMonthlyDetail Sd "
// + " where S.SalaryMonthlyID=Sd.SalaryMonthlyID "
// + " AND S.SalaryMonth=%d AND G.GRADEID=S.GRADEID AND D.DESIGNATIONID=S.DESIGNATIONID AND SEmpCC.EmployeeID=S.EmployeeID"
// + " AND Sd.SALARYMONTHLYID=SEmpCC.SALARYMONTHLYID"
// + " and Sd.ItemGroup IN (2) "
// + " group by S.EmployeeID,G.DESCRIPTION,G.SequenceNo,G.Code,D.Name,CC.Description,Sd.ItemGroup "
// + " ) A, Employee E where A.EmployeeID = E.EmployeeID "
// + " group by E.EmployeeNo, E.Name,A.GName,A.SequenceNo,A.GCode,A.DName,A.CCName,A.ItemGroup ", 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.GCode,A.SequenceNo,A.DName,A.CCName,A.ItemGroup,"
+ " 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,CC.Description as CCName,G.SequenceNo,D.Name as DName "
+ " from Grades G,CRG CC,DESIGNATION D,Employee E,SALARYEMPCOSTCENTER SEmpCC ,SALARYMONTHLY S, SalaryMonthlyDetail Sd "
+ " where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID AND E.employeeID=S.EmployeeID "
+ " AND CC.CrgID=SEmpCC.CostCenterID AND E.EmployeeID=SEmpCC.EmployeeID"
+ " AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d AND SEmpCC.EmployeeID=S.EmployeeID"
+ " AND Sd.SALARYMONTHLYID=SEmpCC.SALARYMONTHLYID"
+ " 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,CC.description as CCName,G.sequenceNo,D.Name as DName"
+ " from Grades G,CRG CC,DESIGNATION D,Employee E,SALARYEMPCOSTCENTER SEmpCC ,SALARYMONTHLY S, SalaryMonthlyDetail Sd "
+ " where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID "
+ " AND CC.CrgID=SEmpCC.CostCenterID AND E.EmployeeID=SEmpCC.EmployeeID"
+ " AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND SEmpCC.EmployeeID=S.EmployeeID"
+ " AND Sd.SALARYMONTHLYID=SEmpCC.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.ItemGroup,A.Description,A.Position,A.CCName"
+ " order by A.Position,A.SequenceNo,A.GCode,A.EmployeeNo",
dateTime, dateTime);
tempdataset.Tables[0].TableName = "DeductItem";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
tempdataset = tc.ExecuteDataSet("select A.EmployeeNo, A.Name,A.GName,A.GCode,A.SequenceNo,A.DName,A.CCName,A.ItemGroup,"
+ " 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,CC.Description as CCName,G.SequenceNo,D.Name as DName"
+ " from Grades G,DESIGNATION D,CRG CC,Employee E,SALARYEMPCOSTCENTER SEMPCC, SALARYMONTHLY S, SalaryMonthlyDetail Sd "
+ " where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID "
+ " AND CC.CrgID=SEmpCC.CostCenterID AND E.EmployeeID=SEmpCC.EmployeeID"
+ " AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND SEmpCC.EmployeeID=S.EmployeeID"
+ " AND Sd.SALARYMONTHLYID=SEmpCC.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,CC.Description as CCName,G.SequenceNo,D.Name as DName "
+ " from Grades G,DESIGNATION D,CRG CC,Employee E,SALARYEMPCOSTCENTER SEMPCC, SALARYMONTHLY S, SalaryMonthlyDetail Sd "
+ " where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID "
+ " AND CC.CrgID=SEmpCC.CostCenterID AND E.EmployeeID=SEmpCC.EmployeeID"
+ " AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND SEmpCC.EmployeeID=S.EmployeeID"
+ " AND Sd.SALARYMONTHLYID=SEmpCC.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.ItemGroup,A.Description,A.Position,A.CCName"
+ " order by A.Position,A.SequenceNo,A.GCode,A.EmployeeNo", dateTime, dateTime);
tempdataset.Tables[0].TableName = "LeaveDays";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
tempdataset = tc.ExecuteDataSet("select E.EmployeeNo, E.Name,A.GName,A.GCode,A.CCName,A.sequenceNo,A.DName, 'UnAuthorized' as Description, Sum(A.amount) as amount,A.ItemGroup "
+ " from"
+ " (select S.EmployeeID, Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,Sd.ItemGroup,G.Code as GCode,CC.Description as CCName,"
+ " G.SequenceNo,D.Name as DName "
+ " from GRADES G,CRG CC,DESIGNATION D,SALARYEMPCOSTCENTER SEMPCC,SALARYMONTHLY S,SalaryMonthlyDetail Sd "
+ " where S.SalaryMonthlyID=Sd.SalaryMonthlyID "
+ " AND CC.CRGID=SEMPCC.CostCenterID AND S.EmployeeID=SEmpCC.EmployeeID"
+ " AND S.SalaryMonth=%d AND G.GRADEID=S.GRADEID AND SEmpCC.EmployeeID=S.EmployeeID"
+ " AND Sd.SALARYMONTHLYID=SEmpCC.SALARYMONTHLYID"
+ " AND D.DESIGNATIONID=S.DESIGNATIONID and Sd.ItemGroup IN (2) "
+ " group by S.EmployeeID,G.DESCRIPTION,G.SequenceNo,G.Code,D.Name,CC.Description,Sd.ItemGroup"
+ " ) A, Employee E where A.EmployeeID = E.EmployeeID "
+ " group by E.EmployeeNo, E.Name,A.GName,A.SequenceNo,A.GCode,A.DName,A.CCName,A.ItemGroup", dateTime);
tempdataset.Tables[0].TableName = "UnAuthorized";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
//tempdataset = tc.ExecuteDataSet("select E.EmployeeNo, E.Name,A.GName,A.GCode,A.CCName,A.SequenceNo,A.DName, 'Total Deduction' as Description, Sum(A.amount) as amount,A.ItemGroup "
// + " from"
// + " (select S.EmployeeID, Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,G.Code as GCode,CC.description as CCName,"
// + " G.SequenceNo,D.Name as DName,Sd.ItemGroup "
// + " from GRADES G,CRG CC,SALARYEMPCOSTCENTER SEMPCC,DESIGNATION D,SALARYMONTHLY S,SalaryMonthlyDetail Sd "
// + " where S.SalaryMonthlyID=Sd.SalaryMonthlyID "
// + " AND CC.CRGID=SEMPCC.CostCenterID and S.EmployeeID=SEmpCC.EmployeeID"
// + " AND S.SalaryMonth=%d AND G.GRADEID=S.GRADEID "
// + " AND D.DESIGNATIONID=S.DESIGNATIONID AND SEmpCC.EmployeeID=S.EmployeeID"
// + " AND Sd.SALARYMONTHLYID=SEmpCC.SALARYMONTHLYID"
// + " and Sd.ItemGroup IN (2,3) "
// + " group by S.EmployeeID,G.DESCRIPTION,G.SequenceNo,G.Code,D.Name,CC.Description,Sd.ItemGroup"
// + " ) A, Employee E where A.EmployeeID = E.EmployeeID "
// + " group by E.EmployeeNo, E.Name,A.GName,A.SequenceNo,A.GCode,A.DName,A.CCName,A.ItemGroup", 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,G.Code as GCode,Sd.ItemGroup,"
+ " G.SequenceNo,D.Name as DName ,CC.Description as CCName,'Net Pay' as Description,SD.CHANGEDAMOUNT as Amount"
+ " from EMPLOYEE as E,GRADES as G,CRG CC,DESIGNATION D,SALARYEMPCOSTCENTER SEMPCC,SALARYMONTHLY as S,SALARYMONTHLYDETAIL as Sd"
+ " where S.SalaryMonthlyID=Sd.SalaryMonthlyID "
+ " AND CC.CRGID=SEMPCC.CostCenterID and E.EmployeeID=SEMPCC.employeeID"
+ " AND S.SalaryMonth=%d"
+ " AND G.GRADEID=S.GRADEID "
+ " AND D.DESIGNATIONID=S.DESIGNATIONID"
+ " AND E.EMPLOYEEID =S.EMPLOYEEID AND SEmpCC.EmployeeID=S.EmployeeID"
+ " AND Sd.SALARYMONTHLYID=SEmpCC.SALARYMONTHLYID"
+ " and Sd.ItemGroup IN (5) AND Sd.ItemCode IN(-132)"
+ " order by G.SequenceNo,G.Code,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;
}
internal static DataSet GetEmpSalarySheetByCC(TransactionContext tc, DateTime dateTime, string sEmpID)
{
DataSet rootDataset = new DataSet();
DataSet tempdataset = new DataSet();
try
{
string sSQL = SQLParser.MakeSQL(@"select A.EmployeeNo, A.Name,A.AccountNo,A.GName,A.DName,A.GCode,A.CRGDes,A.SequenceNO, A.Description,
SUM(A.changedamount) Amount from
(
select S.EmployeeID, E.EmployeeNo, E.Name,E.AccountNo, 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,CC.DESCRIPTION as CRGDes
from Grades G,CRG as CC,SALARYEMPCOSTCENTER as SEMCC ,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd
where G.GradeID= E.GradeID AND S.EMPLOYEEID=SEMCC.EMPLOYEEID
AND CC.CRGID=SEMCC.COSTCENTERID AND D.DESIGNATIONID=E.DESIGNATIONID
AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID
AND SD.SALARYMONTHLYID=SEMCC.SALARYMONTHLYID AND S.SalaryMonth=%d
and Sd.ItemGroup in(8,4) AND sd.ItemCode not in(-133) AND S.EmployeeID IN(%q)
UNION
select S.EmployeeID, E.EmployeeNo, E.Name,E.AccountNo, 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,CC.DESCRIPTION as CRGDes
from Grades G,CRG as CC,SALARYEMPCOSTCENTER as SEMCC,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd
where G.GradeID= E.GradeID AND S.EMPLOYEEID=SEMCC.EMPLOYEEID
AND CC.CRGID=SEMCC.COSTCENTERID AND D.DESIGNATIONID=E.DESIGNATIONID
AND E.employeeID=S.EmployeeID AND SD.SALARYMONTHLYID=SEMCC.SALARYMONTHLYID
AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d
and Sd.ItemGroup in(1,4) AND sd.ItemCode not in(-133) AND S.EmployeeID IN(%q)
) A
group by A.EmployeeID, A.EmployeeNo, A.Name,A.AccountNo,A.GName,A.DName,A.SequenceNo,A.GCode,A.CRGDes,
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(sSQL);
tempdataset.Tables[0].TableName = "GrossItem";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string sSQL1 = SQLParser.MakeSQL("select E.EmployeeNo, E.Name,E.AccountNo,A.GName,A.GCode,A.DName,'Total Gross' as Description,A.CRGDes,A.SequenceNO, "
+ " 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,CC.DESCRIPTION as CRGDes "
+ " from SALARYMONTHLY S,Grades G,CRG as CC,SALARYEMPCOSTCENTER as SEMCC,DESIGNATION D, SalaryMonthlyDetail Sd "
+ " where S.SalaryMonthlyID=Sd.SalaryMonthlyID"
+ " AND S.EMPLOYEEID=SEMCC.EMPLOYEEID AND CC.CRGID=SEMCC.COSTCENTERID "
+ " AND G.GRADEID=S.GRADEID AND D.DESIGNATIONID=S.DESIGNATIONID "
+ " AND SD.SALARYMONTHLYID=SEMCC.SALARYMONTHLYID"
+ " AND S.SalaryMonth=%d and Sd.ItemGroup IN (1, 8) AND S.EmployeeID IN(%q) "
+ " group by S.EmployeeID,G.DESCRIPTION,D.Name,CC.DESCRIPTION,G.SequenceNo,G.Code "
+ " UNION"
+ " select S.EmployeeID, -Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,G.Code as GCode,G.SequenceNo,D.Name as DName,CC.DESCRIPTION as CRGDes"
+ " from GRADES G,CRG as CC,SALARYEMPCOSTCENTER as SEMCC,DESIGNATION D,SALARYMONTHLY S, SalaryMonthlyDetail Sd "
+ " where S.SalaryMonthlyID=Sd.SalaryMonthlyID "
+ " AND S.EMPLOYEEID=SEMCC.EMPLOYEEID AND CC.CRGID=SEMCC.COSTCENTERID"
+ " AND S.SalaryMonth=%d AND G.GRADEID=S.GRADEID "
+ " AND SD.SALARYMONTHLYID=SEMCC.SALARYMONTHLYID"
+ " AND D.DESIGNATIONID=S.DESIGNATIONID and Sd.ItemGroup IN (2) AND S.EmployeeID IN(%q) "
+ " group by S.EmployeeID,G.DESCRIPTION,D.Name,CC.DESCRIPTION,G.SequenceNo,G.Code "
+ " ) A, Employee E where A.EmployeeID = E.EmployeeID "
+ " group by E.EmployeeNo, E.Name,E.AccountNo,A.GName,A.DName,A.CRGDes,A.SequenceNo,A.GCode ",
dateTime, sEmpID, dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet(sSQL1);
tempdataset.Tables[0].TableName = "TotalGross";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string sSQL2 = SQLParser.MakeSQL(@"select A.EmployeeNo, A.Name,A.AccountNo,A.GName,A.DName,A.CRGDes,A.GCode,A.SequenceNO,
A.Description, SUM(A.changedamount) Amount from (
select S.EmployeeID, E.EmployeeNo, E.Name,E.AccountNo, sd.ItemGroup,sd.ItemCode, sd.ItemID,
sd.Description,sd.Position, sd.changedamount,G.DESCRIPTION as GName,CC.DESCRIPTION as CRGDes,
G.Code as GCode,G.SequenceNo,D.Name as DName
from Grades G,CRG as CC,SALARYEMPCOSTCENTER as SEMCC,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd
where G.GradeID= E.GradeID AND S.EMPLOYEEID=SEMCC.EMPLOYEEID AND CC.CRGID=SEMCC.COSTCENTERID
AND D.DESIGNATIONID=E.DESIGNATIONID AND E.employeeID=S.EmployeeID
AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND SD.SALARYMONTHLYID=SEMCC.SALARYMONTHLYID
AND S.SalaryMonth=%d and Sd.ItemGroup=3 AND S.EmployeeID IN(%q)
union
select S.EmployeeID, E.EmployeeNo, E.Name,E.AccountNo, sd.ItemGroup,sd.ItemCode, sd.ItemID,
sd.Description,sd.Position, -sd.changedamount,G.DESCRIPTION as GName,CC.DESCRIPTION as CRGDes,
G.Code as GCode,G.SequenceNo,D.Name as DName
from Grades G,CRG as CC,SALARYEMPCOSTCENTER as SEMCC ,DESIGNATION D,Employee E, SALARYMONTHLY S,SalaryMonthlyDetail Sd
where G.GradeID= E.GradeID AND S.EMPLOYEEID=SEMCC.EMPLOYEEID AND CC.CRGID=SEMCC.COSTCENTERID
AND D.DESIGNATIONID=E.DESIGNATIONID AND E.employeeID=S.EmployeeID
AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND SD.SALARYMONTHLYID=SEMCC.SALARYMONTHLYID
AND S.SalaryMonth=%d and Sd.ItemGroup=2 AND S.EmployeeID IN(%q) ) A
group by A.EmployeeID, A.EmployeeNo, A.Name,A.AccountNo,A.GName,A.SequenceNo,A.GCode,A.DName,A.CRGDes,
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(sSQL2);
tempdataset.Tables[0].TableName = "DeductItem";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string sSQL3 = SQLParser.MakeSQL(@"select A.EmployeeNo, A.Name,A.AccountNo,A.GName,A.GCode,A.DName,A.CRGDes,A.SequenceNo,
A.Description, SUM(A.changedamount) Amount from (
select S.EmployeeID, E.EmployeeNo, E.Name,E.AccountNo, sd.ItemGroup,sd.ItemCode, sd.ItemID,
sd.Description,sd.Position, sd.changedamount,G.DESCRIPTION as GName,CC.DESCRIPTION as CRGDes,
G.Code as GCode,G.SequenceNo,D.Name as DName
from Grades G,CRG as CC,SALARYEMPCOSTCENTER as SEMCC,DESIGNATION D,Employee E,
SALARYMONTHLY S, SalaryMonthlyDetail Sd
where G.GradeID= E.GradeID AND S.EMPLOYEEID=SEMCC.EMPLOYEEID
AND CC.CRGID=SEMCC.COSTCENTERID AND D.DESIGNATIONID=E.DESIGNATIONID
AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID
AND SD.SALARYMONTHLYID=SEMCC.SALARYMONTHLYID AND S.SalaryMonth=%d
and Sd.ITEMCODE =-133 AND S.EmployeeID IN(%q)
UNION
select S.EmployeeID, E.EmployeeNo, E.Name,E.AccountNo, sd.ItemGroup,sd.ItemCode, sd.ItemID,
sd.Description,sd.Position, sd.changedamount,G.DESCRIPTION as GName,CC.DESCRIPTION as CRGDes,
G.Code as GCode,G.SequenceNo,D.Name as DName
from Grades G,CRG as CC,SALARYEMPCOSTCENTER as SEMCC,DESIGNATION D,Employee E,
SALARYMONTHLY S, SalaryMonthlyDetail Sd
where G.GradeID= E.GradeID AND S.EMPLOYEEID=SEMCC.EMPLOYEEID AND CC.CRGID=SEMCC.COSTCENTERID
AND D.DESIGNATIONID=E.DESIGNATIONID AND E.employeeID=S.EmployeeID
AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND SD.SALARYMONTHLYID=SEMCC.SALARYMONTHLYID
AND S.SalaryMonth=%d and Sd.ITEMCODE =-133 AND S.EmployeeID IN(%q) ) A
group by A.EmployeeID, A.EmployeeNo, A.Name,A.AccountNo,A.GName,A.SequenceNo,A.GCode,A.DName,
A.CRGDes, 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(sSQL3);
tempdataset.Tables[0].TableName = "LeaveDays";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string sSQL4 = SQLParser.MakeSQL(@"select E.EmployeeNo, E.Name,E.AccountNo,A.GName,A.GCode,A.DName, 'UnAuthorized' as Description,
A.CRGDes,A.SequenceNo, Sum(A.amount) as amount
from (
select S.EmployeeID, Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,
CC.DESCRIPTION as CRGDes, G.Code as GCode,G.SequenceNo,D.Name as DName
from GRADES G,CRG as CC,SALARYEMPCOSTCENTER as SEMCC,DESIGNATION D,
SALARYMONTHLY S,SalaryMonthlyDetail Sd
where S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.EMPLOYEEID=SEMCC.EMPLOYEEID
AND CC.CRGID=SEMCC.COSTCENTERID AND S.SalaryMonth=%d
AND G.GRADEID=S.GRADEID AND D.DESIGNATIONID=S.DESIGNATIONID
AND SD.SALARYMONTHLYID=SEMCC.SALARYMONTHLYID and Sd.ItemGroup IN (2)
AND S.EmployeeID IN(%q) group by S.EmployeeID,G.DESCRIPTION,
G.SequenceNo,G.Code,D.Name,CC.DESCRIPTION ) A, Employee E where A.EmployeeID = E.EmployeeID
group by E.EmployeeNo, E.Name,E.AccountNo,A.GName,A.SequenceNo,A.GCode,A.DName,A.CRGDes",
dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet(sSQL4);
tempdataset.Tables[0].TableName = "UnAuthorized";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string sSQL5 = SQLParser.MakeSQL(@"select E.EmployeeNo, E.Name,E.AccountNo,A.GName,A.GCode,A.DName, 'Total Deduction' as Description,
A.CRGDes,A.SequenceNo, Sum(A.amount) as amount
from (
select S.EmployeeID, Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,
CC.DESCRIPTION as CRGDes, G.Code as GCode,G.SequenceNo,D.Name as DName
from GRADES G,CRG as CC,SALARYEMPCOSTCENTER as SEMCC,DESIGNATION D,SALARYMONTHLY S,SalaryMonthlyDetail Sd
where S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d
AND S.EMPLOYEEID=SEMCC.EMPLOYEEID AND CC.CRGID=SEMCC.COSTCENTERID
AND G.GRADEID=S.GRADEID AND D.DESIGNATIONID=S.DESIGNATIONID
AND SD.SALARYMONTHLYID=SEMCC.SALARYMONTHLYID and Sd.ItemGroup IN (2,3)
AND S.EmployeeID IN(%q)
group by S.EmployeeID,G.DESCRIPTION,G.SequenceNo,G.Code,D.Name,CC.DESCRIPTION ) A,
Employee E where A.EmployeeID = E.EmployeeID
group by E.EmployeeNo, E.Name,E.AccountNo,A.GName,A.SequenceNo,A.GCode,A.DName,A.CRGDes", dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet(sSQL5);
tempdataset.Tables[0].TableName = "TotalDeduction";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string sSQL6 = SQLParser.MakeSQL(@"Select E.EMPLOYEENO,E.NAME,E.AccountNo,G.DESCRIPTION as GName,G.Code as GCode,D.Name as DName,
'Net Pay' as Description,CC.DESCRIPTION as CRGDes,G.SequenceNo, SD.CHANGEDAMOUNT as Amount
from EMPLOYEE as E,GRADES as G,CRG as CC,SALARYEMPCOSTCENTER as SEMCC,DESIGNATION D,
SALARYMONTHLY as S,SALARYMONTHLYDETAIL as Sd
where S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d
AND S.EMPLOYEEID=SEMCC.EMPLOYEEID AND CC.CRGID=SEMCC.COSTCENTERID
AND G.GRADEID=S.GRADEID AND D.DESIGNATIONID=S.DESIGNATIONID
AND E.EMPLOYEEID =S.EMPLOYEEID AND SD.SALARYMONTHLYID=SEMCC.SALARYMONTHLYID
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(sSQL6);
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 GetExtendedSalarySheet(TransactionContext tc, DateTime dateTime, string sEmpID)
{
DataSet rootDataset = new DataSet();
DataSet tempdataset = new DataSet();
try
{
tempdataset = tc.ExecuteDataSet("select A.EmployeeNo, A.Name,A.GName,A.DName,A.DGName,A.BIRTHDATE,A.JOININGDATE,A.DATEOFCONFIRMATION,A.CDescription,"
+ " A.Description, SUM(A.changedamount) Amount"
+ " from"
+ " (select S.EmployeeID, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode,E.BIRTHDATE,E.JOININGDATE,E.DATEOFCONFIRMATION,C.Description as CDescription,"
+ " sd.ItemID, sd.Description,sd.Position, sd.changedamount,G.DESCRIPTION as GName,D.DESCRIPTION as DName,S.Designation AS DGName"
+ " from Grades G,Department D,Employee E,Category C ,SALARYMONTHLY S, SalaryMonthlyDetail Sd,Designation DG"
+ " 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 DG.DESIGNATIONID=E.DESIGNATIONID AND S.EmployeeID IN(%q) AND C.CategoryID=S.CategoryID AND Sd.ItemID Not In(13,11,15,16,14)"
//+ " union"
//+ " select S.EmployeeID, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode,E.JOININGDATE,E.DATEOFCONFIRMATION,C.Description as CDescription,"
//+ " sd.ItemID, sd.Description,sd.Position, -sd.changedamount,G.DESCRIPTION as GName,D.DESCRIPTION as DName,DG.NAME AS DGName"
//+ " from Grades G,Department D,Employee E,Category C, SALARYMONTHLY S, SalaryMonthlyDetail Sd,Designation DG"
//+ " 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 DG.DESIGNATIONID=E.DESIGNATIONID AND S.EmployeeID IN(%q) AND C.CategoryID=S.CategoryID AND Sd.ItemID Not In(13,11,15,16,14)"
+ " UNION"
+ " select S.EmployeeID, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode,E.BIRTHDATE,E.JOININGDATE,E.DATEOFCONFIRMATION,C.Description as CDescription,"
+ " sd.ItemID, sd.Description,sd.Position, sd.changedamount,G.DESCRIPTION as GName,D.DESCRIPTION as DName,S.Designation AS DGName"
+ " from Grades G,Department D,Employee E, Category C,SALARYMONTHLY S, SalaryMonthlyDetail Sd ,Designation DG"
+ " 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 DG.DESIGNATIONID=E.DESIGNATIONID AND S.EmployeeID IN(%q) AND C.CategoryID=S.CategoryID AND Sd.ItemID Not In(13,11,15,16,14)"
+ " ) A group by"
+ " A.EmployeeID, A.EmployeeNo, A.Name,A.GName,A.DName,A.DGName,A.BIRTHDATE,A.JOININGDATE,A.DATEOFCONFIRMATION,A.CDescription,"
+ " A.ItemCode, A.ItemID, A.Description,A.Position order by A.EmployeeNo,A.Position", dateTime, sEmpID, dateTime, sEmpID, dateTime, sEmpID);
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,A.DGName,E.BIRTHDATE,E.JOININGDATE,E.DATEOFCONFIRMATION,A.CDescription"
+ " from"
+ " (select S.EmployeeID, Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,D.DESCRIPTION as DName,DG.NAME AS DGName,C.Description as CDescription"
+ " from SALARYMONTHLY S,Grades G,Department D, SalaryMonthlyDetail Sd,Designation AS DG,Category C"
+ " where S.SalaryMonthlyID=Sd.SalaryMonthlyID"
+ " AND G.GRADEID=S.GRADEID AND D.DEPARTMENTID=S.DEPARTMENTID AND S.SalaryMonth=%d AND C.CategoryID=S.CategoryID and Sd.ItemGroup IN (1, 8) AND DG.DESIGNATIONID=S.DESIGNATIONID AND S.EmployeeID IN(%q) AND Sd.ItemID Not In(13,11,15,16,14)"
+ " group by S.EmployeeID,G.DESCRIPTION,D.DESCRIPTION,Dg.NAME,C.Description"
+ " UNION"
+ " select S.EmployeeID, -Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,D.DESCRIPTION as DName,DG.NAME AS DGName,C.Description as CDescription"
+ " from GRADES G,DEPARTMENT D,SALARYMONTHLY S, SalaryMonthlyDetail Sd,Designation AS DG,Category C"
+ " where S.SalaryMonthlyID=Sd.SalaryMonthlyID"
+ " AND S.SalaryMonth=%d AND G.GRADEID=S.GRADEID AND C.CategoryID=S.CategoryID AND D.DEPARTMENTID=S.DEPARTMENTID and Sd.ItemGroup IN (2) AND DG.DESIGNATIONID=S.DESIGNATIONID AND S.EmployeeID IN(%q) AND Sd.ItemID Not In(13,11,15,16,14)"
+ " group by S.EmployeeID,G.DESCRIPTION,D.DESCRIPTION,Dg.NAME,C.Description"
+ " ) A, Employee E where A.EmployeeID = E.EmployeeID"
+ " group by E.EmployeeNo, E.Name,A.GName,A.DName,A.DGName,E.BIRTHDATE,E.JOININGDATE,E.DATEOFCONFIRMATION,A.CDescription ", dateTime, sEmpID, dateTime, sEmpID);
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.DGName,A.BIRTHDATE,A.JOININGDATE,A.DATEOFCONFIRMATION,A.CDescription,"
+ " A.Description, SUM(A.changedamount) Amount"
+ " from"
+ " (select S.EmployeeID, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode,E.BIRTHDATE,E.JOININGDATE,E.DATEOFCONFIRMATION,"
+ " sd.ItemID, sd.Description,sd.Position, sd.changedamount,G.DESCRIPTION as GName,D.DESCRIPTION as DName,DG.NAME AS DGName,C.Description as CDescription"
+ " from Grades G,Department D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd,Designation DG,Category C"
+ " where G.GradeID= E.GradeID AND D.DepartmentID=E.DepartmentID AND C.CategoryID=S.CategoryID AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d and Sd.ItemGroup=8 AND DG.DESIGNATIONID=E.DESIGNATIONID AND S.EmployeeID IN(%q) AND Sd.ItemID In(13,11,15,16,14)"
+ " union"
+ " select S.EmployeeID, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode,E.BIRTHDATE,E.JOININGDATE,E.DATEOFCONFIRMATION,"
+ " sd.ItemID, sd.Description,sd.Position, -sd.changedamount,G.DESCRIPTION as GName,D.DESCRIPTION as DName,DG.NAME AS DGName,C.Description as CDescription"
+ " from Grades G,Department D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd,Designation DG,Category C"
+ " where G.GradeID= E.GradeID AND D.DepartmentID=E.DepartmentID AND E.employeeID=S.EmployeeID AND C.CategoryID=S.CategoryID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d and Sd.ItemGroup=2 AND DG.DESIGNATIONID=E.DESIGNATIONID AND S.EmployeeID IN(%q) AND Sd.ItemID In(13,11,15,16,14)"
+ " UNION"
+ " select S.EmployeeID, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode,E.BIRTHDATE,E.JOININGDATE,E.DATEOFCONFIRMATION,"
+ " sd.ItemID, sd.Description,sd.Position, sd.changedamount,G.DESCRIPTION as GName,D.DESCRIPTION as DName,DG.NAME AS DGName,C.Description as CDescription"
+ " from Grades G,Department D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd ,Designation DG,Category C"
+ " where G.GradeID= E.GradeID AND D.DepartmentID=E.DepartmentID AND E.employeeID=S.EmployeeID AND C.CategoryID=S.CategoryID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d and Sd.ItemGroup=1 AND DG.DESIGNATIONID=E.DESIGNATIONID AND S.EmployeeID IN(%q) AND Sd.ItemID In(13,11,15,16,14)"
+ " ) A group by"
+ " A.EmployeeID, A.EmployeeNo, A.Name,A.GName,A.DName,A.DGName,A.BIRTHDATE,A.JOININGDATE,A.DATEOFCONFIRMATION,A.CDescription,"
+ " A.ItemCode, A.ItemID, A.Description,A.Position order by A.Position,A.EmployeeNo", dateTime, sEmpID, dateTime, sEmpID, dateTime, sEmpID);
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,A.DGName,E.BIRTHDATE,E.JOININGDATE,E.DATEOFCONFIRMATION,A.CDescription"
+ " from"
+ " (select S.EmployeeID, Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,D.DESCRIPTION as DName,DG.NAME AS DGName,C.Description as CDescription"
+ " from SALARYMONTHLY S,Grades G,Department D, SalaryMonthlyDetail Sd,Designation AS DG,Category C"
+ " where S.SalaryMonthlyID=Sd.SalaryMonthlyID"
+ " AND G.GRADEID=S.GRADEID AND D.DEPARTMENTID=S.DEPARTMENTID AND C.CategoryID=S.CategoryID AND S.SalaryMonth=%d and Sd.ItemGroup IN (1, 8) AND DG.DESIGNATIONID=S.DESIGNATIONID AND S.EmployeeID IN(%q)"
+ " group by S.EmployeeID,G.DESCRIPTION,D.DESCRIPTION,Dg.NAME,C.Description"
+ " UNION"
+ " select S.EmployeeID, -Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,D.DESCRIPTION as DName,DG.NAME AS DGName,C.Description as CDescription"
+ " from GRADES G,DEPARTMENT D,SALARYMONTHLY S, SalaryMonthlyDetail Sd,Designation AS DG,Category C"
+ " where S.SalaryMonthlyID=Sd.SalaryMonthlyID"
+ " AND S.SalaryMonth=%d AND G.GRADEID=S.GRADEID AND D.DEPARTMENTID=S.DEPARTMENTID AND C.CategoryID=S.CategoryID and Sd.ItemGroup IN (2) AND DG.DESIGNATIONID=S.DESIGNATIONID AND S.EmployeeID IN(%q)"
+ " group by S.EmployeeID,G.DESCRIPTION,D.DESCRIPTION,Dg.NAME,C.Description"
+ " ) A, Employee E where A.EmployeeID = E.EmployeeID"
+ " group by E.EmployeeNo, E.Name,A.GName,A.DName,A.DGName,E.BIRTHDATE,E.JOININGDATE,E.DATEOFCONFIRMATION,A.CDescription ", dateTime, sEmpID, dateTime, sEmpID);
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,A.DGName,A.BIRTHDATE,A.JOININGDATE,A.DATEOFCONFIRMATION,A.CDescription"
+ " from"
+ " (select S.EmployeeID, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode,E.BIRTHDATE,E.JOININGDATE,E.DATEOFCONFIRMATION,"
+ " sd.ItemID, sd.Description,sd.Position, sd.changedamount,G.DESCRIPTION as GName,D.DESCRIPTION as DName,DG.NAME AS DGName,C.Description as CDescription"
+ " from Grades G,Department D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd,Designation DG,Category C"
+ " where G.GradeID= E.GradeID AND D.DepartmentID=E.DepartmentID AND C.CategoryID=S.CategoryID AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d and Sd.ItemGroup=3 AND DG.DESIGNATIONID=S.DESIGNATIONID AND S.EmployeeID IN(%q)"
+ " union"
+ " select S.EmployeeID, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode,E.BIRTHDATE,E.JOININGDATE,E.DATEOFCONFIRMATION,"
+ " sd.ItemID, sd.Description,sd.Position, -sd.changedamount,G.DESCRIPTION as GName,D.DESCRIPTION as DName,DG.NAME AS DGName,C.Description as CDescription"
+ " from Grades G,Department D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd,Designation DG,Category C"
+ " where G.GradeID= E.GradeID AND D.DepartmentID=E.DepartmentID AND C.CategoryID=S.CategoryID AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d and Sd.ItemGroup=2 AND DG.DESIGNATIONID=S.DESIGNATIONID AND S.EmployeeID IN(%q)"
+ " ) A group by"
+ " A.EmployeeID, A.EmployeeNo, A.Name,A.GName,A.DName,A.DGName,A.BIRTHDATE,A.JOININGDATE,A.DATEOFCONFIRMATION,A.CDescription,"
+ " A.ItemCode, A.ItemID, A.Description,A.Position order by A.EmployeeNo,A.Position",
dateTime, sEmpID, dateTime, sEmpID);
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,A.DGName,E.BIRTHDATE,E.JOININGDATE,E.DATEOFCONFIRMATION,A.CDescription"
+ " from"
+ " (select S.EmployeeID, Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,D.DESCRIPTION as DName,DG.NAME AS DGName,C.Description as CDescription"
+ " from GRADES G,DEPARTMENT D,SALARYMONTHLY S,SalaryMonthlyDetail Sd,Designation DG,Category C"
+ " where S.SalaryMonthlyID=Sd.SalaryMonthlyID"
+ " AND S.SalaryMonth=%d AND G.GRADEID=S.GRADEID AND C.CategoryID=S.CategoryID AND D.DEPARTMENTID=S.DEPARTMENTID and Sd.ItemGroup IN (3) AND DG.DESIGNATIONID=S.DESIGNATIONID AND S.EmployeeID IN(%q)"
+ " group by S.EmployeeID,G.DESCRIPTION,D.DESCRIPTION,DG.NAME,C.Description"
+ " UNION"
+ " select S.EmployeeID, -Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,D.DESCRIPTION as DName,DG.NAME AS DGName,C.Description as CDescription"
+ " from GRADES G,DEPARTMENT D,SALARYMONTHLY S, SalaryMonthlyDetail Sd,Designation AS DG,Category C"
+ " where S.SalaryMonthlyID=Sd.SalaryMonthlyID"
+ " AND S.SalaryMonth=%d AND G.GRADEID=S.GRADEID AND C.CategoryID=S.CategoryID AND D.DEPARTMENTID=S.DEPARTMENTID and Sd.ItemGroup IN (2) AND DG.DESIGNATIONID=S.DESIGNATIONID AND S.EmployeeID IN(%q)"
+ " group by S.EmployeeID,G.DESCRIPTION,D.DESCRIPTION,DG.NAME,C.Description"
+ " ) A, Employee E where A.EmployeeID = E.EmployeeID"
+ " group by E.EmployeeNo, E.Name,A.GName,A.DName,A.DGName,E.BIRTHDATE,E.JOININGDATE,E.DATEOFCONFIRMATION,A.CDescription", dateTime, sEmpID, dateTime, sEmpID);
tempdataset.Tables[0].TableName = "TotalDeduct";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
tempdataset = tc.ExecuteDataSet("select S.EmployeeID, E.EMPLOYEENO,E.NAME,'Net Pay' as Description,sd.changedamount as Amount,G.DESCRIPTION as GName,D.DESCRIPTION as DName,DG.NAME AS DGName,E.BIRTHDATE,E.JOININGDATE,E.DATEOFCONFIRMATION,C.Description as CDescription"
+ " from GRADES G,DEPARTMENT D,SALARYMONTHLY S, SalaryMonthlyDetail Sd,Employee E,Designation AS DG,Category C"
+ " where S.SalaryMonthlyID=Sd.SalaryMonthlyID"
+ " AND S.SalaryMonth=%d"
+ " AND G.GRADEID=S.GRADEID"
+ " AND D.DEPARTMENTID=S.DEPARTMENTID"
+ " AND C.CategoryID=S.CategoryID"
+ " AND E.EMPLOYEEID=S.EMPLOYEEID"
+ " AND DG.DESIGNATIONID=S.DESIGNATIONID"
+ " and Sd.ItemGroup IN (5) AND S.EmployeeID IN(%q)"
+ " order by 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 GetPrvMonthNetSalary(TransactionContext tc, DateTime dateTime, string sEmpID, bool IsNetSum)
{
DataSet oSMonthlys = new DataSet();
try
{
if (IsNetSum)
{
oSMonthlys = tc.ExecuteDataSet("Select S.DEPARTMENTID,D.Description,Sum(SD.CHANGEDAMOUNT) as Amount"
+ " from DEPARTMENT D,SALARYMONTHLY as S,SALARYMONTHLYDETAIL as Sd"
+ " where S.SalaryMonthlyID=Sd.SalaryMonthlyID "
+ " AND S.SalaryMonth=%d"
+ " AND D.DEPARTMENTID=S.DEPARTMENTID "
+ " and Sd.ItemGroup IN (5) AND S.EmployeeID IN(%q)"
+ " group by S.DepartmentID,D.Description", dateTime, sEmpID);
}
else
{
oSMonthlys = tc.ExecuteDataSet("Select E.EmployeeNo,'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) AND S.EmployeeID IN(%q)"
+ " order by E.EMPLOYEENO ", dateTime, sEmpID);
}
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return oSMonthlys;
}
internal static DataSet GetEmpPaySlipIncomeTaxAmount(TransactionContext tc, DateTime dateTime, string sEmpID)
{
DataSet oSMonthlys = new DataSet();
try
{
#region Latest Old Code
oSMonthlys = tc.ExecuteDataSet("SELECT E.NAME Name,E.EMPLOYEENO,G.CODE Grade,SM.Designation 'Designation',L.Description as LName,"
+ " D.DESCRIPTION Department,E.BASICSALARY ActualBasic,E.PAYMENTMODE,"
+ " SM.ACCOUNTNO,SM.SalaryMonth,SMD.DESCRIPTION Description,SMD.ITEMGROUP,"
+ " SMD.CHANGEDAMOUNT,SMD.ItemCode,SMD.ItemID"
+ " FROM SALARYMONTHLY SM,Employee E,Grades G,Department D,Designation DG,Location L,"
+ " SalaryMonthlyDetail SMD"
+ " WHERE SM.EMPLOYEEID=E.EMPLOYEEID"
+ " AND SM.GRADEID=G.GRADEID"
+ " AND SM.DEPARTMENTID=D.DEPARTMENTID"
+ " AND SM.LocationID=L.LocationID"
+ " AND SM.DESIGNATIONID=DG.DESIGNATIONID"
+ " AND SM.SALARYMONTHLYID=SMD.SALARYMONTHLYID"
+ " AND SM.SalaryMonth=%d AND SMD.ITEMGROUP=5 AND SMD.ITEMCODE IN(-129,-132) AND SM.EmployeeID IN(%q) ORDER BY E.EmployeeNo, Position", dateTime, sEmpID);
#endregion
#region Change Old Code
// oSMonthlys = tc.ExecuteDataSet(@"SELECT E.NAME Name,E.EMPLOYEENO,G.CODE Grade,DG.Name 'Designation',L.Description as LName,
// D.DESCRIPTION Department,E.BASICSALARY ActualBasic,E.PAYMENTMODE,
// BAH.ACCOUNTNO,SM.SalaryMonth,SMD.DESCRIPTION Description,SMD.ITEMGROUP,
// SMD.CHANGEDAMOUNT,SMD.ItemCode,SMD.ItemID
// FROM SALARYMONTHLY SM,Employee E,Grades G,Department D,Designation DG,Location L,
// SalaryMonthlyDetail SMD,BANKACCOUNTHISTORY BAH
// WHERE SM.EMPLOYEEID=E.EMPLOYEEID
// AND SM.GRADEID=G.GRADEID
// AND SM.DEPARTMENTID=D.DEPARTMENTID
// AND SM.LocationID=L.LocationID
// AND SM.DESIGNATIONID=DG.DESIGNATIONID
// AND SM.SALARYMONTHLYID=SMD.SALARYMONTHLYID
// AND BAH.CHANGEDATE=(select MAX(ChangeDate) from BANKACCOUNTHISTORY where CHANGEDATE <=%d AND EMPLOYEEID=SM.EMPLOYEEID)
// and BAH.EMPLOYEEID=SM.EmployeeID
// AND SM.SalaryMonth=%d AND SMD.ITEMGROUP=5 AND SMD.ITEMCODE IN(-129,-132) AND SM.EmployeeID IN(%q) ORDER BY E.EmployeeNo, Position
// ", dateTime, dateTime, sEmpID);
#endregion
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return oSMonthlys;
}
internal static DataSet GetCCWiseSalarySheet(TransactionContext tc, DateTime dateTime, string sEmpID)
{
DataSet oSMonthlys = new DataSet();
DataSet rootDataset = new DataSet();
try
{
#region Latest Old Code
// oSMonthlys = tc.ExecuteDataSet(@"Select Emp.EmployeeNo,Emp.Name,CC.Code,Dep.Description,Emp.GrossSalary,SMD.ChangedAmount as 'PFAmount'
// from Employee as Emp,Department as Dep,SalaryMonthly as SM,CRG as CC,
// SalaryMonthlyDetail as SMD,SalaryEmpCostCenter as SEmpCC
// where Emp.EmployeeID=SM.EmployeeID
// and Emp.DepartmentID=SM.DepartmentID
// and SM.SalaryMonthlyID=SMD.SalaryMonthlyID
// and SEmpCC.SalaryMonthlyID=SMD.SalaryMonthlyID
// and Dep.DepartmentID=SM.DepartmentID
// and CC.CRGID=SEmpCC.CostCenterID
// and Emp.EmployeeID=SEmpCC.EmployeeID
// and SM.SalaryMonth=%d
// and SMD.ItemCode=-128 and SMD.ItemGroup=3 and SM.EmployeeId in(%q)
// order by CC.Code", dateTime, sEmpID);
string sSQL = SQLParser.MakeSQL(@"Select CC.Code,SECC.Percentage,
Sum((SMD.ChangedAmount * (SECC.Percentage)/100)) as GrossAmount
from Employee as Emp,Department as Dep,CRG as CC,SalaryMonthly as SM,
SalaryMonthlyDetail as SMD,SalaryEmpCostCenter as SECC
where Emp.DepartmentID=Dep.DepartmentID
and Emp.DepartmentID=SM.DepartmentID
and SM.DepartmentID=Dep.DepartmentID
and Emp.EmployeeID=SM.EmployeeID
and SM.EmployeeID=SECC.EmployeeID
and CC.CrgID=SECC.CostCenterID
and SECC.SalaryMonthlyID=SM.SalaryMonthlyID
and SM.SalaryMonthlyID=SMD.SalaryMonthlyID
and SM.SalaryMonth=%d and SMD.ItemGroup in(1,8) And SMD.CHANGEDAMOUNT<>0
and SM.EmployeeID in(%q)
group by CC.Code,
SECC.Percentage order by CC.Code", dateTime, sEmpID);
oSMonthlys = tc.ExecuteDataSet(sSQL);
oSMonthlys.Tables[0].TableName = "GrossAmount";
rootDataset.Tables.Add(oSMonthlys.Tables[0].Copy());
// string sqlArrear = SQLParser.MakeSQL(@"Select Emp.EmployeeNo,Emp.Name,CC.Code,SECC.Percentage,Dep.Description,SMD.ItemGroup,Sum((SMD.ChangedAmount * (SECC.Percentage)/100)) as GrossArrear
// from Employee as Emp,Department as Dep,CRG as CC,SalaryMonthly as SM,SalaryMonthlyDetail as SMD,SalaryEmpCostCenter as SECC
// where Emp.DepartmentID=Dep.DepartmentID
// and Emp.DepartmentID=SM.DepartmentID
// and SM.DepartmentID=Dep.DepartmentID
// and Emp.EmployeeID=SM.EmployeeID
// and SM.EmployeeID=SECC.EmployeeID
// and CC.CrgID=SECC.CostCenterID
// and SECC.SalaryMonthlyID=SM.SalaryMonthlyID
// and SM.SalaryMonthlyID=SMD.SalaryMonthlyID
// and SM.SalaryMonth=%d and SMD.ItemGroup in(8) and SM.EmployeeID in(%q)
// group by Emp.EmployeeNo,Emp.Name,CC.Code,Dep.Description,SECC.Percentage,SMD.ItemGroup order by Emp.EmployeeNo", dateTime, sEmpID);
// oSMonthlys = tc.ExecuteDataSet(sqlArrear);
// oSMonthlys.Tables[0].TableName = "GrossArrear";
// rootDataset.Tables.Add(oSMonthlys.Tables[0].Copy());
string sSQL1 = SQLParser.MakeSQL(@"Select CC.Code,sum(SMD.ChangedAmount) as 'PFAmount'
from Employee as Emp,Department as Dep,SalaryMonthly as SM,CRG as CC,
SalaryMonthlyDetail as SMD,SalaryEmpCostCenter as SEmpCC
where Emp.EmployeeID=SM.EmployeeID
and Emp.DepartmentID=SM.DepartmentID
and SM.SalaryMonthlyID=SMD.SalaryMonthlyID
and SEmpCC.SalaryMonthlyID=SMD.SalaryMonthlyID
and Dep.DepartmentID=SM.DepartmentID
and CC.CRGID=SEmpCC.CostCenterID
and Emp.EmployeeID=SEmpCC.EmployeeID
and SM.SalaryMonth=%d
and SMD.ItemCode=-128 and SMD.ItemGroup=3
and SM.EmployeeId in(%q) Group by CC.Code
order by CC.Code", dateTime, sEmpID);
oSMonthlys = tc.ExecuteDataSet(sSQL1);
oSMonthlys.Tables[0].TableName = "PFAmount";
rootDataset.Tables.Add(oSMonthlys.Tables[0].Copy());
#endregion
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return rootDataset;
}
internal static DataSet GetCCWiseSalarySummary(TransactionContext tc, DateTime dateTime, string sEmpID)
{
DataSet oSMonthlys = new DataSet();
DataSet rootDataset = new DataSet();
try
{
#region Latest Old Code
// string sSQL = SQLParser.MakeSQL(@"Select CC.CRGID,CC.Code,Sum(Emp.GrossSalary) as 'InvolveAmount' ,Sum(SMD.ChangedAmount) as 'PFAmount'
// from Employee as Emp,SalaryMonthly as SM,CRG as CC,
// SalaryMonthlyDetail as SMD,SalaryEmpCostCenter as SEmpCC
// where Emp.EmployeeID=SM.EmployeeID
// and SM.SalaryMonthlyID=SMD.SalaryMonthlyID
// and SEmpCC.SalaryMonthlyID=SMD.SalaryMonthlyID
// and CC.CRGID=SEmpCC.CostCenterID
// and Emp.EmployeeID=SEmpCC.EmployeeID
// and SM.SalaryMonth=%d
// and SMD.ItemCode=-128 and SMD.ItemGroup=3
// and SM.EmployeeId in(%q)
// group by CC.CRGID,CC.Code
// order by CC.Code
// ", dateTime, sEmpID);
// oSMonthlys = tc.ExecuteDataSet(sSQL);
string sSQL = SQLParser.MakeSQL(@"Select CC.Code,SECC.Percentage,SMD.ItemGroup,Sum((SMD.ChangedAmount * (SECC.Percentage)/100)) as GrossAmount
from Employee as Emp,Department as Dep,CRG as CC,SalaryMonthly as SM,SalaryMonthlyDetail as SMD,SalaryEmpCostCenter as SECC
where Emp.DepartmentID=Dep.DepartmentID
and Emp.DepartmentID=SM.DepartmentID
and SM.DepartmentID=Dep.DepartmentID
and Emp.EmployeeID=SM.EmployeeID
and SM.EmployeeID=SECC.EmployeeID
and CC.CrgID=SECC.CostCenterID
and SECC.SalaryMonthlyID=SM.SalaryMonthlyID
and SM.SalaryMonthlyID=SMD.SalaryMonthlyID
and SM.SalaryMonth=%d and SMD.ItemGroup in(1)
and Emp.EmployeeID in(%q)
group by CC.Code,SECC.Percentage,SMD.ItemGroup order by CC.Code", dateTime, sEmpID);
oSMonthlys = tc.ExecuteDataSet(sSQL);
oSMonthlys.Tables[0].TableName = "GrossAmount";
rootDataset.Tables.Add(oSMonthlys.Tables[0].Copy());
oSMonthlys = tc.ExecuteDataSet(@"Select CC.Code,SECC.Percentage,SMD.ItemGroup,Sum((SMD.ChangedAmount * (SECC.Percentage)/100)) as GrossAmount
from Employee as Emp,Department as Dep,CRG as CC,SalaryMonthly as SM,SalaryMonthlyDetail as SMD,SalaryEmpCostCenter as SECC
where Emp.DepartmentID=Dep.DepartmentID
and Emp.DepartmentID=SM.DepartmentID
and SM.DepartmentID=Dep.DepartmentID
and Emp.EmployeeID=SM.EmployeeID
and SM.EmployeeID=SECC.EmployeeID
and CC.CrgID=SECC.CostCenterID
and SECC.SalaryMonthlyID=SM.SalaryMonthlyID
and SM.SalaryMonthlyID=SMD.SalaryMonthlyID
and SM.SalaryMonth=%d and SMD.ItemGroup in(8)
and Emp.EmployeeID in(%q)
group by CC.Code,SECC.Percentage,SMD.ItemGroup order by CC.Code", dateTime, sEmpID);
oSMonthlys.Tables[0].TableName = "GrossArrear";
rootDataset.Tables.Add(oSMonthlys.Tables[0].Copy());
string sSQL1 = SQLParser.MakeSQL(@"Select CC.Code,SMD.ChangedAmount as 'PFAmount'
from Employee as Emp,Department as Dep,SalaryMonthly as SM,CRG as CC,
SalaryMonthlyDetail as SMD,SalaryEmpCostCenter as SEmpCC
where Emp.EmployeeID=SM.EmployeeID
and Emp.DepartmentID=SM.DepartmentID
and SM.SalaryMonthlyID=SMD.SalaryMonthlyID
and SEmpCC.SalaryMonthlyID=SMD.SalaryMonthlyID
and Dep.DepartmentID=SM.DepartmentID
and CC.CRGID=SEmpCC.CostCenterID
and Emp.EmployeeID=SEmpCC.EmployeeID
and SM.SalaryMonth=%d
and SMD.ItemCode=-128 and SMD.ItemGroup=3 and SM.EmployeeId in(%q)
order by Emp.EmployeeNo", dateTime, sEmpID);
oSMonthlys = tc.ExecuteDataSet(sSQL1);
oSMonthlys.Tables[0].TableName = "PFAmount";
rootDataset.Tables.Add(oSMonthlys.Tables[0].Copy());
#endregion
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return rootDataset;
}
internal static DataSet GetSGSSalarySheet(TransactionContext tc, DateTime dateTime, string sEmpID)
{
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 S.EmployeeID IN(%q) 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=2 AND S.EmployeeID IN(%q) 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 S.EmployeeID IN(%q) 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, sEmpID, dateTime, sEmpID);
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 S.EmployeeID IN(%q) 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 S.EmployeeID IN(%q) 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, sEmpID, dateTime, sEmpID);
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 S.EmployeeID IN(%q) 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 S.EmployeeID IN(%q) 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 S.EmployeeID IN(%q) 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, sEmpID, dateTime, sEmpID, dateTime, sEmpID);
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) AND S.EmployeeID IN(%q)"
+ " 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 S.EmployeeID IN(%q)"
+ " 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, sEmpID, dateTime, sEmpID);
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 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.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 S.EmployeeID IN(%q) "
//+ " 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, sEmpID, dateTime, sEmpID);
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) AND S.EmployeeID IN(%q) "
+ " 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 S.EmployeeID IN(%q) "
+ " 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, sEmpID, dateTime, sEmpID);
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) AND S.EmployeeID IN(%q)"
+ " order by 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 GetEmpSSSummaryByDept(TransactionContext tc, DateTime dateTime, string sEmpID)
{
DataSet oSMonthlys = new DataSet();
try
{
//oSMonthlys = tc.ExecuteDataSet("SELECT SM.DEPARTMENTID,Dep.Description,Count(Distinct SM.EMPLOYEEID) TEmp,"
// + " Basic=Sum(CASE WHEN SMD.ITEMGROUP =1 AND SMD.ITEMCODE=-101 AND SMD.ITEMID=-101 THEN SMD.CHANGEDAMOUNT ELSE 0 END),"
// + " HR=Sum(CASE WHEN SMD.ITEMGROUP =1 AND SMD.ITEMCODE=-113 AND SMD.ITEMID=3 THEN SMD.CHANGEDAMOUNT ELSE 0 END),"
// + " MED=Sum(CASE WHEN SMD.ITEMGROUP =1 AND SMD.ITEMCODE=-113 AND SMD.ITEMID=4 THEN SMD.CHANGEDAMOUNT ELSE 0 END),"
// + " Conv=Sum(CASE WHEN SMD.ITEMGROUP=1 AND SMD.ITEMCODE=-113 AND SMD.ITEMID=5 THEN SMD.CHANGEDAMOUNT ELSE 0 END),"
// + " Arre=Sum(CASE WHEN (SMD.ITEMGROUP=8 AND SMD.ITEMCODE=-101 AND SMD.ITEMID=-101) OR (SMD.ITEMGROUP=8 AND SMD.ITEMCODE=-113 AND SMD.ITEMID=3) OR (SMD.ITEMGROUP=8 AND SMD.ITEMCODE=-113 AND SMD.ITEMID=4) OR (SMD.ITEMGROUP=8 AND SMD.ITEMCODE=-113 AND SMD.ITEMID=5) THEN SMD.CHANGEDAMOUNT ELSE 0 END),"
// + " OT=Sum(CASE WHEN SMD.ITEMGROUP =1 AND SMD.ITEMCODE=-103 AND SMD.ITEMID=1 THEN SMD.CHANGEDAMOUNT ELSE 0 END),"
// + " REMO=Sum(CASE WHEN SMD.ITEMGROUP=1 AND SMD.ITEMCODE=-113 AND SMD.ITEMID=6 THEN SMD.CHANGEDAMOUNT ELSE 0 END),"
// + " LVENCA=Sum(CASE WHEN SMD.ITEMGROUP=1 AND SMD.ITEMCODE=-113 AND SMD.ITEMID=10 THEN SMD.CHANGEDAMOUNT ELSE 0 END),"
// + " OTH=Sum(CASE WHEN SMD.ITEMGROUP =1 AND SMD.ITEMCODE=-113 AND SMD.ITEMID=8 THEN SMD.CHANGEDAMOUNT ELSE 0 END),"
// + " INCTAX=Sum(CASE WHEN SMD.ITEMGROUP=3 AND SMD.ITEMCODE=-129 AND SMD.ITEMID=-129 THEN SMD.CHANGEDAMOUNT ELSE 0 END),"
// + " PF=Sum(CASE WHEN SMD.ITEMGROUP =3 AND SMD.ITEMCODE=-128 AND SMD.ITEMID=-128 THEN SMD.CHANGEDAMOUNT ELSE 0 END),"
// + " LOANADV=Sum(CASE WHEN SMD.ITEMGROUP=3 AND SMD.ITEMCODE=-118 AND SMD.ITEMID=2 THEN SMD.CHANGEDAMOUNT ELSE 0 END),"
// + " WPAY=Sum(CASE WHEN (SMD.ITEMGROUP=2 AND SMD.ITEMCODE=-101 AND SMD.ITEMID=-101) OR (SMD.ITEMGROUP=2 AND SMD.ITEMCODE=-113 AND SMD.ITEMID=3) OR (SMD.ITEMGROUP=2 AND SMD.ITEMCODE=-113 AND SMD.ITEMID=4) OR (SMD.ITEMGROUP=2 AND SMD.ITEMCODE=-113 AND SMD.ITEMID=5) THEN SMD.CHANGEDAMOUNT ELSE 0 END),"
// + " OTHER=Sum(CASE WHEN SMD.ITEMGROUP=3 AND SMD.ITEMCODE=-115 AND SMD.ITEMID=9 THEN SMD.CHANGEDAMOUNT ELSE 0 END)"
// + " FROM SALARYMONTHLY SM "
// + " INNER JOIN SALARYMONTHLYDETAIL SMD"
// + " ON SM.SALARYMONTHLYID=SMD.SALARYMONTHLYID "
// + " AND SM.SalaryMonth=%d"
// + " AND SM.EMPLOYEEID in(%q)"
// + " Inner Join Department as Dep"
// + " On Dep.DEPARTMENTID=SM.DEPARTMENTID"
// + " GROUP by SM.DEPARTMENTID,Dep.Description", dateTime, sEmpID);
string sql =
SQLParser.MakeSQL("SELECT SM.DEPARTMENTID,Dep.Description,Count(Distinct SM.EMPLOYEEID) TEmp,"
+
" Basic=Sum(CASE WHEN SMD.ITEMGROUP =1 AND SMD.ITEMCODE=-101 AND SMD.ITEMID=-101 THEN SMD.CHANGEDAMOUNT ELSE 0 END),"
+
" HR=Sum(CASE WHEN SMD.ITEMGROUP =1 AND SMD.ITEMCODE=-113 AND SMD.ITEMID=3 THEN SMD.CHANGEDAMOUNT ELSE 0 END),"
+
" MED=Sum(CASE WHEN SMD.ITEMGROUP =1 AND SMD.ITEMCODE=-113 AND SMD.ITEMID=4 THEN SMD.CHANGEDAMOUNT ELSE 0 END),"
+
" Conv=Sum(CASE WHEN SMD.ITEMGROUP=1 AND SMD.ITEMCODE=-113 AND SMD.ITEMID=5 THEN SMD.CHANGEDAMOUNT ELSE 0 END),"
+
" Arre=Sum(CASE WHEN (SMD.ITEMGROUP=8 AND SMD.ITEMCODE=-101 AND SMD.ITEMID=-101) OR (SMD.ITEMGROUP=8 AND SMD.ITEMCODE=-113 AND SMD.ITEMID=3) OR (SMD.ITEMGROUP=8 AND SMD.ITEMCODE=-113 AND SMD.ITEMID=4) OR (SMD.ITEMGROUP=8 AND SMD.ITEMCODE=-113 AND SMD.ITEMID=5) THEN SMD.CHANGEDAMOUNT ELSE 0 END),"
+
" OT=Sum(CASE WHEN SMD.ITEMGROUP =1 AND SMD.ITEMCODE=-103 AND SMD.ITEMID = 1 THEN SMD.CHANGEDAMOUNT ELSE 0 END),"
+
" REMO=Sum(CASE WHEN SMD.ITEMGROUP=1 AND SMD.ITEMCODE=-113 AND SMD.ITEMID=6 THEN SMD.CHANGEDAMOUNT ELSE 0 END),"
+
" LVENCA=Sum(CASE WHEN SMD.ITEMGROUP=1 AND SMD.ITEMCODE=-113 AND SMD.ITEMID=10 THEN SMD.CHANGEDAMOUNT ELSE 0 END),"
+
" OTH=Sum(CASE WHEN SMD.ITEMGROUP =1 AND SMD.ITEMCODE=-113 AND SMD.ITEMID=8 THEN SMD.CHANGEDAMOUNT ELSE 0 END),"
+
" INCTAX=Sum(CASE WHEN SMD.ITEMGROUP=3 AND SMD.ITEMCODE=-129 AND SMD.ITEMID=-129 THEN SMD.CHANGEDAMOUNT ELSE 0 END),"
+
" PF=Sum(CASE WHEN SMD.ITEMGROUP =3 AND SMD.ITEMCODE=-128 AND SMD.ITEMID=-128 THEN SMD.CHANGEDAMOUNT ELSE 0 END),"
+
" LOANADV=Sum(CASE WHEN SMD.ITEMGROUP=3 AND SMD.ITEMCODE=-118 AND SMD.ITEMID=2 THEN SMD.CHANGEDAMOUNT ELSE 0 END),"
+
" WPAY=Sum(CASE WHEN (SMD.ITEMGROUP=2 AND SMD.ITEMCODE=-101 AND SMD.ITEMID=-101) OR (SMD.ITEMGROUP=2 AND SMD.ITEMCODE=-113 AND SMD.ITEMID=3) OR (SMD.ITEMGROUP=2 AND SMD.ITEMCODE=-113 AND SMD.ITEMID=4) OR (SMD.ITEMGROUP=2 AND SMD.ITEMCODE=-113 AND SMD.ITEMID=5) THEN SMD.CHANGEDAMOUNT ELSE 0 END),"
+
" OTHER=Sum(CASE WHEN SMD.ITEMGROUP=3 AND SMD.ITEMCODE=-115 AND SMD.ITEMID=9 THEN SMD.CHANGEDAMOUNT ELSE 0 END)"
+ " FROM SALARYMONTHLY SM "
+ " INNER JOIN SALARYMONTHLYDETAIL SMD"
+ " ON SM.SALARYMONTHLYID=SMD.SALARYMONTHLYID "
+ " AND SM.SalaryMonth=%d"
+ " AND SM.EMPLOYEEID in(%q)"
+ " Inner Join Department as Dep"
+ " On Dep.DEPARTMENTID=SM.DEPARTMENTID"
+ " GROUP by SM.DEPARTMENTID,Dep.Description",
dateTime,
sEmpID);
oSMonthlys = tc.ExecuteDataSet("SELECT SM.DEPARTMENTID,Dep.Description,Count(Distinct SM.EMPLOYEEID) TEmp,"
+ " Basic=Sum(CASE WHEN SMD.ITEMGROUP =1 AND SMD.ITEMCODE=-101 AND SMD.ITEMID=-101 THEN SMD.CHANGEDAMOUNT ELSE 0 END),"
+ " HR=Sum(CASE WHEN SMD.ITEMGROUP =1 AND SMD.ITEMCODE=-113 AND SMD.ITEMID=3 THEN SMD.CHANGEDAMOUNT ELSE 0 END),"
+ " MED=Sum(CASE WHEN SMD.ITEMGROUP =1 AND SMD.ITEMCODE=-113 AND SMD.ITEMID=4 THEN SMD.CHANGEDAMOUNT ELSE 0 END),"
+ " Conv=Sum(CASE WHEN SMD.ITEMGROUP=1 AND SMD.ITEMCODE=-113 AND SMD.ITEMID=5 THEN SMD.CHANGEDAMOUNT ELSE 0 END),"
+ " Arre=Sum(CASE WHEN (SMD.ITEMGROUP=8 AND SMD.ITEMCODE=-101 AND SMD.ITEMID=-101) OR (SMD.ITEMGROUP=8 AND SMD.ITEMCODE=-113 AND SMD.ITEMID=3) OR (SMD.ITEMGROUP=8 AND SMD.ITEMCODE=-113 AND SMD.ITEMID=4) OR (SMD.ITEMGROUP=8 AND SMD.ITEMCODE=-113 AND SMD.ITEMID=5) THEN SMD.CHANGEDAMOUNT ELSE 0 END),"
+ " OT=Sum(CASE WHEN SMD.ITEMGROUP =1 AND SMD.ITEMCODE=-103 AND SMD.ITEMID = 1 THEN SMD.CHANGEDAMOUNT ELSE 0 END),"
+ " REMO=Sum(CASE WHEN SMD.ITEMGROUP=1 AND SMD.ITEMCODE=-113 AND SMD.ITEMID=6 THEN SMD.CHANGEDAMOUNT ELSE 0 END),"
+ " LVENCA=Sum(CASE WHEN SMD.ITEMGROUP=1 AND SMD.ITEMCODE=-113 AND SMD.ITEMID=10 THEN SMD.CHANGEDAMOUNT ELSE 0 END),"
+ " OTH=Sum(CASE WHEN SMD.ITEMGROUP =1 AND SMD.ITEMCODE=-113 AND SMD.ITEMID=8 THEN SMD.CHANGEDAMOUNT ELSE 0 END),"
+ " INCTAX=Sum(CASE WHEN SMD.ITEMGROUP=3 AND SMD.ITEMCODE=-129 AND SMD.ITEMID=-129 THEN SMD.CHANGEDAMOUNT ELSE 0 END),"
+ " PF=Sum(CASE WHEN SMD.ITEMGROUP =3 AND SMD.ITEMCODE=-128 AND SMD.ITEMID=-128 THEN SMD.CHANGEDAMOUNT ELSE 0 END),"
+ " LOANADV=Sum(CASE WHEN SMD.ITEMGROUP=3 AND SMD.ITEMCODE=-118 AND SMD.ITEMID=2 THEN SMD.CHANGEDAMOUNT ELSE 0 END),"
+ " WPAY=Sum(CASE WHEN (SMD.ITEMGROUP=2 AND SMD.ITEMCODE=-101 AND SMD.ITEMID=-101) OR (SMD.ITEMGROUP=2 AND SMD.ITEMCODE=-113 AND SMD.ITEMID=3) OR (SMD.ITEMGROUP=2 AND SMD.ITEMCODE=-113 AND SMD.ITEMID=4) OR (SMD.ITEMGROUP=2 AND SMD.ITEMCODE=-113 AND SMD.ITEMID=5) THEN SMD.CHANGEDAMOUNT ELSE 0 END),"
+ " OTHER=Sum(CASE WHEN SMD.ITEMGROUP=3 AND SMD.ITEMCODE=-115 AND SMD.ITEMID=9 THEN SMD.CHANGEDAMOUNT ELSE 0 END)"
+ " FROM SALARYMONTHLY SM "
+ " INNER JOIN SALARYMONTHLYDETAIL SMD"
+ " ON SM.SALARYMONTHLYID=SMD.SALARYMONTHLYID "
+ " AND SM.SalaryMonth=%d"
+ " AND SM.EMPLOYEEID in(%q)"
+ " Inner Join Department as Dep"
+ " On Dep.DEPARTMENTID=SM.DEPARTMENTID"
+ " GROUP by SM.DEPARTMENTID,Dep.Description", dateTime, sEmpID);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return oSMonthlys;
}
internal static IDataReader Get(TransactionContext tc, ID nEmpID, DateTime dateTime)
{
return tc.ExecuteReader("SELECT * FROM SalaryMonthly WHERE EmployeeID=%n AND SalaryMonth=%d", nEmpID.Integer, dateTime);
}
internal static DataSet GetEmpSalaryReconciliationSummary(TransactionContext tc, DateTime dateTime, string sEmpID)
{
DataSet oSMonthlys = new DataSet();
DataSet RootDataSet = new DataSet();
string sSQL = string.Empty;
string sSQLDeduct = string.Empty;
try
{
sSQL = SQLParser.MakeSQL(@"SELECT Y.Description,sum(Y.changedamount) Amount FROM
(Select
CASE sd.ItemCode WHEN -103 THEN 2 else sd.ItemID end ItemID,
CASE sd.ItemCode WHEN -103 THEN 'OT' else sd.Description end Description,
case Sd.ItemGroup WHEN 2 THEN -sd.changedamount ELSE sd.changedamount END changedamount
from SALARYMONTHLY S, SalaryMonthlyDetail Sd
where S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth = %d
and Sd.ItemGroup in(1,2,8) AND sd.ItemCode not in(-133) AND S.EmployeeID in(%q)
AND sd.changedamount<>0 )Y
group by Description ORDER BY Y.[Description]",
dateTime, sEmpID);
oSMonthlys = tc.ExecuteDataSet(sSQL);
oSMonthlys.Tables[0].TableName = "GrossItem";
RootDataSet.Tables.Add(oSMonthlys.Tables[0].Copy());
sSQLDeduct = SQLParser.MakeSQL("Select SMD.DESCRIPTION,SUM(SMD.CHANGEDAMOUNT) as Amount,SMD.ITEMID,SMD.ITEMCODE"
+ " from SALARYMONTHLYDETAIL SMD,SALARYMONTHLY SM"
+ " where SM.EMPLOYEEID in(%q)"
+ " AND SMD.ITEMGROUP IN(3)"
+ " AND SM.SALARYMONTH=%d"
+ " AND SM.SALARYMONTHLYID=SMD.SALARYMONTHLYID"
+ " AND SMD.CHANGEDAMOUNT<>0"
+ " GROUP by SMD.ITEMID,SMD.ITEMCODE,SMD.DESCRIPTION"
+ " order by SMD.ITEMCODE asc", sEmpID, dateTime);
oSMonthlys = tc.ExecuteDataSet(sSQLDeduct);
oSMonthlys.Tables[0].TableName = "TotalDeduction";
RootDataSet.Tables.Add(oSMonthlys.Tables[0].Copy());
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return RootDataSet;
}
#endregion
#region Delete function
internal static void Delete(TransactionContext tc, ID nID)
{
tc.ExecuteNonQuery("DELETE FROM SalaryMonthlyDetail WHERE SalaryMonthlyID=%n", nID.Integer);
tc.ExecuteNonQuery("DELETE FROM SalaryEmpCostCenter WHERE SalaryMonthlyID=%n", nID.Integer);
tc.ExecuteNonQuery("DELETE FROM [SalaryMonthly] WHERE SalaryMonthlyID=%n", nID.Integer);
}
internal static void DeleteSalaryDetail(TransactionContext tc, ID nID)
{
tc.ExecuteNonQuery("DELETE FROM SalaryMonthlyDetail WHERE SalaryMonthlyID=%n", nID.Integer);
}
internal static void DeleteSalaryEmpCC(TransactionContext tc, ID nID)
{
tc.ExecuteNonQuery("DELETE FROM SalaryEmpCostCenter WHERE SalaryMonthlyID=%n", nID.Integer);
}
#endregion
internal static void Insert(TransactionContext tc, TempUnAuthorized tul)
{
tc.ExecuteNonQuery("Delete from UnPaidLeave where employeeid=%n and LeaveID=%n", tul.EmpID, tul.LeaveID);
tc.ExecuteNonQuery("Insert into UnPaidLeave values(%n,%n,%n,%n,%n,%n,%n,%n,%n,%n) ", tul.EmpID, tul.TotalUnAuthorizedDays, tul.BasicPaidDays, tul.OtherPaidDays, tul.BasicCurrentDeduct, tul.OtherCurrentDeduct, tul.BasicUnpaidDays, tul.OtherUnpaidDays, tul.LeaveID,tul.UnPaidLeaveYear);
}
internal static DataSet GetEmpSalarySheet(TransactionContext tc, DateTime dateTime, DateTime dateTime2, string sEmpID)
{
if (dateTime > dateTime2)
{
DateTime temp = dateTime2;
dateTime2 = dateTime;
dateTime = temp;
}
String errStr = string.Empty;
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.JoiningDate,A.SequenceNo,
A.Description,A.Dept ,SUM(A.changedamount) Amount
from
(
select
S.EmployeeID, E.EmployeeNo, E.Name,E.JoiningDate, sd.ItemGroup,sd.ItemCode,
sd.ItemID, sd.Description,sd.Position,G.DESCRIPTION as GName,
D.Name as DName,G.Code as GCode,G.SequenceNo,dep.DESCRIPTION AS Dept,
Sum(sd.changedamount) AS changedamount
from
Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S
, SalaryMonthlyDetail Sd,Department dep
where G.GradeID= E.GradeID
AND D.DESIGNATIONID=E.DESIGNATIONID
AND E.employeeID=S.EmployeeID
AND S.SalaryMonthlyID=Sd.SalaryMonthlyID
AND E.DepartmentID = dep.DEPARTMENTID
AND S.SalaryMonth between %d and %d
AND S.EmployeeID IN(%q)
and Sd.ItemGroup in(8) AND sd.ItemCode not in(-133)
GROUP BY
S.EmployeeID, E.EmployeeNo, E.Name,E.JoiningDate, sd.ItemGroup,sd.ItemCode,
sd.ItemID, sd.Description,sd.Position,G.DESCRIPTION,D.Name,G.Code,G.SequenceNo,dep.DESCRIPTION
UNION
select
S.EmployeeID, E.EmployeeNo, E.Name,E.JoiningDate, sd.ItemGroup,sd.ItemCode,
sd.ItemID, sd.Description,sd.Position,
G.DESCRIPTION as GName,D.Name as DName,G.Code as GCode,G.SequenceNo,
dep.DESCRIPTION AS Dept, Sum(sd.changedamount) AS changedamount
from
Grades G,DESIGNATION D,Employee E,
SALARYMONTHLY S, SalaryMonthlyDetail Sd,Department dep
where
G.GradeID= E.GradeID
AND D.DESIGNATIONID=E.DESIGNATIONID
AND E.employeeID=S.EmployeeID
AND S.SalaryMonthlyID=Sd.SalaryMonthlyID
AND E.DepartmentID = dep.DEPARTMENTID
AND S.SalaryMonth between %d and %d
AND S.EmployeeID IN(%q)
and Sd.ItemGroup in(1) AND sd.ItemCode not in(-133)
GROUP BY
S.EmployeeID, E.EmployeeNo, E.Name,E.JoiningDate, sd.ItemGroup,sd.ItemCode,
sd.ItemID, sd.Description,sd.Position,G.DESCRIPTION,D.Name,G.Code,G.SequenceNo,dep.DESCRIPTION
) 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,A.JoiningDate,A.Dept
order by
A.Position,A.EmployeeNo,A.SequenceNo,A.GCode",
dateTime, dateTime2, sEmpID, dateTime, dateTime2, sEmpID);
errStr = "Error Executing [GrossItem]";
tempdataset = tc.ExecuteDataSet(query1);
tempdataset.Tables[0].TableName = "GrossItem";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
tc.End();
tc = TransactionContext.Begin();
string query2 = SQLParser
.MakeSQL(@"select
A.EmployeeNo, A.Name,A.JoiningDate,A.Description,A.GName,A.GCode,A.SequenceNo,A.DName,
A.Dept,Sum(A.Amount) as amount
from
(
select
E.EmployeeNo, E.Name,E.JoiningDate,'Total Gross' as Description,G.DESCRIPTION as GName,
G.Code as GCode,G.SequenceNo,D.Name as DName,dep.DESCRIPTION AS Dept,Sum(sd.changedamount) as Amount
from
SALARYMONTHLY S,Grades G,DESIGNATION D,SalaryMonthlyDetail Sd,
Employee E, Department dep
where
S.SalaryMonthlyID=Sd.SalaryMonthlyID
AND G.GRADEID=E.GRADEID
AND E.EmployeeID = S.EmployeeID
AND E.DepartmentID = dep.DEPARTMENTID
AND D.DESIGNATIONID=S.DESIGNATIONID
AND S.SalaryMonth between %d and %d
AND S.EmployeeID IN(%q)
and Sd.ItemGroup IN (1, 8)
group by
E.EmployeeNo, E.Name,E.JoiningDate,G.DESCRIPTION,G.SequenceNo,G.Code,D.Name,dep.DESCRIPTION
UNION
select
E.EmployeeNo, E.Name,E.JoiningDate,'Total Gross' as Description,G.DESCRIPTION as GName,
G.Code as GCode,G.SequenceNo,D.Name as DName,dep.DESCRIPTION AS Dept,-Sum(sd.changedamount) as Amount
from
SALARYMONTHLY S,Grades G,DESIGNATION D,SalaryMonthlyDetail Sd,
Employee E, Department dep
where
S.SalaryMonthlyID=Sd.SalaryMonthlyID
AND G.GRADEID=E.GRADEID
AND E.EmployeeID = S.EmployeeID
AND E.DepartmentID = dep.DEPARTMENTID
AND D.DESIGNATIONID=S.DESIGNATIONID
AND S.SalaryMonth between %d and %d
AND S.EmployeeID IN(%q)
and Sd.ItemGroup IN (2)
group by
E.EmployeeNo, E.Name,E.JoiningDate,G.DESCRIPTION,G.SequenceNo
,G.Code,D.Name,dep.DESCRIPTION
) A
group by
A.EmployeeNo, A.Name,A.JoiningDate,A.Description,A.GName,A.GCode
,A.SequenceNo,A.DName,A.Dept",
dateTime, dateTime2, sEmpID, dateTime, dateTime2, sEmpID);
errStr = "Error Executing [TotalGross]";
tempdataset = tc.ExecuteDataSet(query2);
tempdataset.Tables[0].TableName = "TotalGross";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
tc.End();
tc = TransactionContext.Begin();
string query3 = SQLParser
.MakeSQL(@"select A.EmployeeNo, A.Name,A.JoiningDate,A.GName,A.GCode,A.SequenceNo,A.DName,
A.Description, SUM(A.changedamount) Amount,A.ItemCode,A.ItemID,A.Dept
from
(select S.EmployeeID, E.EmployeeNo, E.Name,E.JoiningDate,sd.ItemGroup,sd.ItemCode,
sd.ItemID, sd.Description,sd.Position, SUM(sd.changedamount) as changedamount,G.DESCRIPTION as GName,
G.Code as GCode,G.SequenceNo,D.Name as DName,dep.DESCRIPTION AS Dept
from Grades G,DESIGNATION D,Employee E,Department dep,
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 E.DepartmentID = dep.DEPARTMENTID
AND S.SalaryMonth between %d and %d
AND S.EmployeeID IN(%q)
and Sd.ItemGroup=3
Group By
S.EmployeeID, E.EmployeeNo, E.Name,E.JoiningDate,sd.ItemGroup,sd.ItemCode,
sd.ItemID, sd.Description,sd.Position,G.DESCRIPTION,
G.Code,G.SequenceNo,D.Name,dep.DESCRIPTION
union
select S.EmployeeID, E.EmployeeNo, E.Name,E.JoiningDate,sd.ItemGroup,sd.ItemCode,
sd.ItemID, sd.Description,sd.Position, -SUM(sd.changedamount) as changedamount,G.DESCRIPTION as GName,
G.Code as GCode,G.sequenceNo,D.Name as DName,dep.DESCRIPTION AS Dept
from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd
,Department dep
where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID
AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID
AND E.DepartmentID = dep.DEPARTMENTID
AND S.SalaryMonth between %d and %d
AND S.EmployeeID IN(%q)
and Sd.ItemGroup=2
Group By
S.EmployeeID, E.EmployeeNo, E.Name,E.JoiningDate,sd.ItemGroup,sd.ItemCode,
sd.ItemID, sd.Description,sd.Position,G.DESCRIPTION,
G.Code,G.SequenceNo,D.Name,dep.DESCRIPTION
) 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,A.JoiningDate,A.Dept
order by A.EmployeeNo,A.Position,A.SequenceNo,A.GCode",
dateTime, dateTime2, sEmpID, dateTime, dateTime2, sEmpID);
errStr = "Error Executing [DeductItem]";
tempdataset = tc.ExecuteDataSet(query3);
tempdataset.Tables[0].TableName = "DeductItem";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
tc.End();
tc = TransactionContext.Begin();
string query4 = SQLParser
.MakeSQL(@"select A.EmployeeNo,A.JoiningDate, A.Name,A.GName,A.GCode,A.SequenceNo,A.DName,A.Dept,
A.Description, SUM(A.changedamount) Amount
from(
select S.EmployeeID, E.EmployeeNo, E.Name,E.JoiningDate, sd.ItemGroup,sd.ItemCode,
sd.ItemID, sd.Description,sd.Position, Sum(sd.changedamount) as changedamount,G.DESCRIPTION as GName,
G.Code as GCode,G.SequenceNo,D.Name as DName,dep.DESCRIPTION AS Dept
from
Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S,Department dep
,SalaryMonthlyDetail Sd
where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID
AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID
AND E.DepartmentID = dep.DEPARTMENTID
AND S.SalaryMonth between %d and %d
AND S.EmployeeID IN(%q)
and Sd.ITEMCODE =-133
Group By
S.EmployeeID, E.EmployeeNo,E.JoiningDate, E.Name,E.JoiningDate,sd.ItemGroup,sd.ItemCode,
sd.ItemID, sd.Description,sd.Position,G.DESCRIPTION,
G.Code,G.SequenceNo,D.Name,dep.DESCRIPTION
UNION
select S.EmployeeID, E.EmployeeNo, E.Name,E.JoiningDate, sd.ItemGroup,sd.ItemCode,
sd.ItemID, sd.Description,sd.Position, Sum(sd.changedamount) as changedamount,G.DESCRIPTION as GName,
G.Code as GCode,G.SequenceNo,D.Name as DName,dep.DESCRIPTION AS Dept
from Grades G,DESIGNATION D,Employee E,
SALARYMONTHLY S, SalaryMonthlyDetail Sd ,Department dep
where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID
AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID
and Sd.ITEMCODE =-133
AND S.SalaryMonth between %d and %d
AND E.DepartmentID = dep.DEPARTMENTID
AND S.EmployeeID IN(%q)
Group By
S.EmployeeID, E.EmployeeNo,E.JoiningDate, E.Name,E.JoiningDate,sd.ItemGroup,sd.ItemCode,
sd.ItemID, sd.Description,sd.Position,G.DESCRIPTION,
G.Code,G.SequenceNo,D.Name,dep.DESCRIPTION
) A group by
A.EmployeeID, A.EmployeeNo,A.JoiningDate, A.Name,A.GName,A.SequenceNo,A.GCode,A.DName,A.Dept,
A.ItemCode, A.ItemID, A.Description,A.Position order by A.Position,A.SequenceNo,
A.GCode,A.EmployeeNo", dateTime, dateTime2, sEmpID, dateTime, dateTime2, sEmpID);
errStr = "Error Executing [LeaveDays]";
tempdataset = tc.ExecuteDataSet(query4);
tempdataset.Tables[0].TableName = "LeaveDays";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
tc.End();
tc = TransactionContext.Begin();
string query5 = SQLParser
.MakeSQL(@"select
E.EmployeeNo, E.Name,E.JoiningDate,G.DESCRIPTION as GName,G.Code as GCode,
G.SequenceNo,D.Name as DName ,dep.DESCRIPTION AS Dept,'UnAuthorized' as Description,
Sum(sd.changedamount) as Amount
from
GRADES G,DESIGNATION D,SALARYMONTHLY S
,SalaryMonthlyDetail Sd,Employee E,Department dep
where
S.SalaryMonthlyID=Sd.SalaryMonthlyID
AND G.GRADEID=E.GRADEID
AND D.DESIGNATIONID=E.DESIGNATIONID
AND S.EmployeeID = E.EmployeeID
AND E.DepartmentID = dep.DEPARTMENTID
AND Sd.ItemGroup IN (2)
AND S.SalaryMonth between %d and %d
AND S.EmployeeID IN(%q)
group by
E.EmployeeNo, E.Name,E.JoiningDate,G.DESCRIPTION
,G.SequenceNo,G.Code,D.Name,dep.DESCRIPTION", dateTime, dateTime2, sEmpID);
errStr = "Error Executing [UnAuthorized]";
tempdataset = tc.ExecuteDataSet(query5);
tempdataset.Tables[0].TableName = "UnAuthorized";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
tc.End();
tc = TransactionContext.Begin();
string query6 = SQLParser
.MakeSQL(@"select E.EmployeeNo, E.Name,E.JoiningDate,A.GName,A.GCode,A.SequenceNo,A.DName,
dep.DESCRIPTION AS Dept,'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 G.GRADEID=S.GRADEID
AND D.DESIGNATIONID=S.DESIGNATIONID and Sd.ItemGroup IN (2,3)
AND S.SalaryMonth between %d And %d
AND S.EmployeeID IN(%q)
group by S.EmployeeID,G.DESCRIPTION,G.SequenceNo,G.Code,D.Name
) A, Employee E,Department dep
where
A.EmployeeID = E.EmployeeID
AND E.DepartmentID = dep.DEPARTMENTID
group by E.EmployeeNo, E.Name,A.GName,A.SequenceNo,A.GCode,
A.DName,E.JoiningDate,dep.DESCRIPTION
order by E.EmployeeNo,A.sequenceno,A.GCode", dateTime, dateTime2, sEmpID);
errStr = "Error Executing [TotalDeduction]";
tempdataset = tc.ExecuteDataSet(query6);
tempdataset.Tables[0].TableName = "TotalDeduction";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
tc.End();
tc = TransactionContext.Begin();
string query7 = SQLParser
.MakeSQL(@"Select E.EMPLOYEENO,E.NAME,E.JoiningDate,G.DESCRIPTION as GName,G.Code as GCode,dep.DESCRIPTION AS Dept,
G.SequenceNo,D.Name as DName ,'Net Pay' as Description,SUM(SD.CHANGEDAMOUNT) as Amount
from EMPLOYEE as E,GRADES as G,DESIGNATION D,Department dep,SALARYMONTHLY as S,SALARYMONTHLYDETAIL as Sd
where S.SalaryMonthlyID=Sd.SalaryMonthlyID
AND S.SalaryMonth between %d and %d
AND G.GRADEID=S.GRADEID
AND D.DESIGNATIONID=S.DESIGNATIONID
AND E.EMPLOYEEID =S.EMPLOYEEID
AND E.DepartmentID = dep.DEPARTMENTID
and Sd.ItemGroup IN (5)
AND Sd.ItemCode IN(-132)
AND S.EmployeeID IN(%q)
Group By
E.EMPLOYEENO,E.NAME,E.JoiningDate,G.DESCRIPTION,G.Code,dep.DESCRIPTION,
G.SequenceNo,D.Name
order by E.EMPLOYEENO,G.SequenceNo,G.Code ", dateTime, dateTime2, sEmpID);
errStr = "Error Executing [NetPay]";
tempdataset = tc.ExecuteDataSet(query7);
tempdataset.Tables[0].TableName = "NetPay";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
tc.End();
tc = TransactionContext.Begin();
string query8 = SQLParser
.MakeSQL(@"Select
E.EMPLOYEENO,E.NAME,E.JoiningDate,G.DESCRIPTION as GName,dep.DESCRIPTION AS Dept,
G.Code as GCode,G.SequenceNo,D.Name as DName ,'CPF' as Description,
SUM(SD.CHANGEDAMOUNT) as Amount
from
EMPLOYEE as E,GRADES as G,DESIGNATION D,
Department dep,SALARYMONTHLY as S,SALARYMONTHLYDETAIL as Sd
where
S.SalaryMonthlyID=Sd.SalaryMonthlyID
AND S.SalaryMonth between %d and %d
AND S.EmployeeID IN(%q)
AND G.GRADEID=E.GRADEID
AND D.DESIGNATIONID=E.DESIGNATIONID
AND E.EMPLOYEEID =S.EMPLOYEEID
AND E.DepartmentID = dep.DEPARTMENTID
AND Sd.ItemGroup IN (3) AND Sd.ItemCode IN(-128)
GROUP BY
E.EMPLOYEENO,E.NAME,E.JoiningDate,G.DESCRIPTION,
dep.DESCRIPTION,G.Code,G.SequenceNo,D.Name
order by E.EMPLOYEENO,G.SequenceNo,G.Code ",
dateTime, dateTime2, sEmpID);
errStr = "Error Executing [CPF]";
tempdataset = tc.ExecuteDataSet(query8);
tempdataset.Tables[0].TableName = "CPF";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
tc.End();
tc = TransactionContext.Begin();
string sBonus = SQLParser
.MakeSQL(@"Select
E.EMPLOYEENO,E.NAME,E.JoiningDate,G.DESCRIPTION as GName,dep.DESCRIPTION AS Dept,
G.Code as GCode,G.SequenceNo,D.Name as DName,b.Name AS Description,
Sum(bpd.BonusAmount) AS Amount
from
EMPLOYEE as E,GRADES as G,DESIGNATION D,Department dep,SALARYMONTHLY as S,
BONUSPROCESSDETAIL bpd,Bonus b
where S.SalaryMonth between %d AND %d
AND bpd.DisburseDate BETWEEN %d AND %d
AND S.EmployeeID IN(%q)
AND G.GRADEID=E.GRADEID
AND D.DESIGNATIONID=E.DESIGNATIONID
AND E.EMPLOYEEID =S.EMPLOYEEID
AND bpd.EmployeeID = E.EmployeeID
AND bpd.BonusID = b.BonusID
AND E.DepartmentID = dep.DEPARTMENTID
Group BY E.EMPLOYEENO,E.NAME,E.JoiningDate,G.DESCRIPTION,
G.Code,G.SequenceNo,D.Name,b.Name,dep.DESCRIPTION
order by E.EMPLOYEENO,G.SequenceNo,G.Code",
dateTime, dateTime2, dateTime, dateTime2, sEmpID);
errStr = "Error Executing [Bonus]";
tempdataset = tc.ExecuteDataSet(sBonus);
tempdataset.Tables[0].TableName = "Bonus";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
// tc.End();
// tc = TransactionContext.Begin();
// string sPerformanceBonus = SQLParser
// .MakeSQL(@"select A.EmployeeNo, A.Name,A.GName,A.DName,A.GCode,A.JoiningDate,A.SequenceNo,
// A.Description, SUM(A.changedamount) Amount
// from
// (select S.EmployeeID, E.EmployeeNo, E.Name,E.JoiningDate, 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= S.GradeID
// AND D.DESIGNATIONID=E.DESIGNATIONID AND E.employeeID=S.EmployeeID
// AND S.SalaryMonthlyID=Sd.SalaryMonthlyID
// AND S.SalaryMonth between %d and %d
// AND S.EmployeeID IN(%q)
// and Sd.ItemGroup IN (1, 8) and ITEMID in (4) AND ITEMCODE in(-113)
// UNION
// select S.EmployeeID, E.EmployeeNo, E.Name,E.JoiningDate, 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= S.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID AND E.employeeID=S.EmployeeID
// AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND
// S.SalaryMonth between %d and %d
// AND S.EmployeeID IN(%q)
// and Sd.ItemGroup IN (2) AND ITEMID in (4) AND ITEMCODE in(-113)
// ) 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,A.JoiningDate order by A.Position,
// A.EmployeeNo,A.SequenceNo,A.GCode",
// dateTime,dateTime2, sEmpID, dateTime,dateTime2, sEmpID);
// tempdataset = tc.ExecuteDataSet(sPerformanceBonus);
// tempdataset.Tables[0].TableName = "PerformanceBonus";
// rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
}
catch (Exception ex)
{
throw new Exception(errStr);
}
return rootDataset;
}
internal static double GetAmountOnDateDiffForOverTime(TransactionContext tc, ID employeeId, DateTime fromDate, DateTime toDate, EnumSalaryGroup groupCode, EnumSalaryItemCode itemCode, int itemId, ID payrollTypeID)
{
string sql = SQLParser.MakeSQL(@"SELECT SUM(ChangedAmount) FROM SalaryMonthlyDetail WHERE"
+
" ItemGroup=%n AND ItemCode=%n AND itemId in (select Termid From Term) AND SalaryMonthlyID IN ( SELECT SalaryMonthlyID FROM"
+
" SalaryMonthly WHERE EmployeeID=%n AND SalaryMonth>=%d AND SalaryMonth<=%d AND WithNoDetail=%b and PayrollTypeID=%n) "
, groupCode, itemCode, employeeId.Integer, fromDate, toDate, false,
payrollTypeID.Integer);
object amount2 = tc.ExecuteScalar(sql);
if (amount2 == DBNull.Value)
return 0;
else return Convert.ToDouble(amount2);
}
internal static DataSet GetLastPayDate(TransactionContext tc, int empid)
{
DataSet lastPayDate = new DataSet();
try
{
lastPayDate = tc.ExecuteDataSet("select MAX(salarymonth) from SALARYMONTHLY where EMPLOYEEID=%n", empid);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return lastPayDate;
}
internal static DataSet GetEmpSSSummaryByDeptNew(TransactionContext tc, string str, DateTime dateTime, string sEmpID)
{
DataSet oSMonthlys = new DataSet();
try
{
string sql =
SQLParser.MakeSQL("SELECT SM.DEPARTMENTID,Dep.Description,Count(Distinct SM.EMPLOYEEID) TEmp,"
+
" Basic=Sum(CASE WHEN SMD.ITEMGROUP =1 AND SMD.ITEMCODE=-101 AND SMD.ITEMID=-101 THEN SMD.CHANGEDAMOUNT ELSE 0 END),"
+
" HR=Sum(CASE WHEN SMD.ITEMGROUP =1 AND SMD.ITEMCODE=-113 AND SMD.ITEMID=3 THEN SMD.CHANGEDAMOUNT ELSE 0 END),"
+
" MED=Sum(CASE WHEN SMD.ITEMGROUP =1 AND SMD.ITEMCODE=-113 AND SMD.ITEMID=4 THEN SMD.CHANGEDAMOUNT ELSE 0 END),"
+
" Conv=Sum(CASE WHEN SMD.ITEMGROUP=1 AND SMD.ITEMCODE=-113 AND SMD.ITEMID=5 THEN SMD.CHANGEDAMOUNT ELSE 0 END),"
+
" Arre=Sum(CASE WHEN (SMD.ITEMGROUP=8 AND SMD.ITEMCODE=-101 AND SMD.ITEMID=-101) OR (SMD.ITEMGROUP=8 AND SMD.ITEMCODE=-113 AND SMD.ITEMID=3) OR (SMD.ITEMGROUP=8 AND SMD.ITEMCODE=-113 AND SMD.ITEMID=4) OR (SMD.ITEMGROUP=8 AND SMD.ITEMCODE=-113 AND SMD.ITEMID=5) THEN SMD.CHANGEDAMOUNT ELSE 0 END),"
+
" OT=Sum(CASE WHEN SMD.ITEMGROUP =1 AND SMD.ITEMCODE=-103 AND SMD.ITEMID in" + str + " THEN SMD.CHANGEDAMOUNT ELSE 0 END),"
+
" REMO=Sum(CASE WHEN SMD.ITEMGROUP=1 AND SMD.ITEMCODE=-113 AND SMD.ITEMID=6 THEN SMD.CHANGEDAMOUNT ELSE 0 END),"
+
" LVENCA=Sum(CASE WHEN SMD.ITEMGROUP=1 AND SMD.ITEMCODE=-113 AND SMD.ITEMID=10 THEN SMD.CHANGEDAMOUNT ELSE 0 END),"
+
" OTH=Sum(CASE WHEN SMD.ITEMGROUP =1 AND SMD.ITEMCODE=-113 AND SMD.ITEMID=8 THEN SMD.CHANGEDAMOUNT ELSE 0 END),"
+
" INCTAX=Sum(CASE WHEN SMD.ITEMGROUP=3 AND SMD.ITEMCODE=-129 AND SMD.ITEMID=-129 THEN SMD.CHANGEDAMOUNT ELSE 0 END),"
+
" PF=Sum(CASE WHEN SMD.ITEMGROUP =3 AND SMD.ITEMCODE=-128 AND SMD.ITEMID=-128 THEN SMD.CHANGEDAMOUNT ELSE 0 END),"
+
" LOANADV=Sum(CASE WHEN SMD.ITEMGROUP=3 AND SMD.ITEMCODE=-118 AND SMD.ITEMID=2 THEN SMD.CHANGEDAMOUNT ELSE 0 END),"
+
" WPAY=Sum(CASE WHEN (SMD.ITEMGROUP=2 AND SMD.ITEMCODE=-101 AND SMD.ITEMID=-101) OR (SMD.ITEMGROUP=2 AND SMD.ITEMCODE=-113 AND SMD.ITEMID=3) OR (SMD.ITEMGROUP=2 AND SMD.ITEMCODE=-113 AND SMD.ITEMID=4) OR (SMD.ITEMGROUP=2 AND SMD.ITEMCODE=-113 AND SMD.ITEMID=5) THEN SMD.CHANGEDAMOUNT ELSE 0 END),"
+
" OTHER=Sum(CASE WHEN SMD.ITEMGROUP=3 AND SMD.ITEMCODE=-115 AND SMD.ITEMID=9 THEN SMD.CHANGEDAMOUNT ELSE 0 END)"
+ " FROM SALARYMONTHLY SM "
+ " INNER JOIN SALARYMONTHLYDETAIL SMD"
+ " ON SM.SALARYMONTHLYID=SMD.SALARYMONTHLYID "
+ " AND SM.SalaryMonth=%d"
+ " AND SM.EMPLOYEEID in(%q)"
+ " Inner Join Department as Dep"
+ " On Dep.DEPARTMENTID=SM.DEPARTMENTID"
+ " GROUP by SM.DEPARTMENTID,Dep.Description",
dateTime,
sEmpID);
oSMonthlys = tc.ExecuteDataSet(sql);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return oSMonthlys;
}
internal static DataSet GetSalaryStracture(TransactionContext tc, string SempIds)
{
string sql = SQLParser.MakeSQL(@"
select Emp.EmployeeID,Emp.EmployeeNo as EmpID,Emp.Name as Name,
(select dg.Name From Designation as Dg Where Dg.DesignationID = Emp.DesignationId) as Designation,
(select Ct.Description from Category as Ct Where Ct.CategoryId = Emp.CategoryId) as EmploymentCategory,
EmploymentStatus =
CASE Emp.Status
When 1 then 'Live'
When 2 then 'Discontinued'
When 3 then 'Secondy'
When 4 then 'Suspend'
When 5 then 'Withheld'
When 6 then 'Waitingforjoin'
When 7 then 'Didnotjoin'
When 8 then 'Dismissed'
When 9 then 'Resigned'
When 10 then 'Retired'
When 11 then 'OnDeputation'
When 12 then 'Deceased'
When 13 then 'OnService'
END,
(select Grd.Description From Grades as Grd Where Grd.GradeId = Emp.GradeID) as Grade,
emp.JoiningDate as joinningDate,
Gender =
CASE Emp.Gender
When 0 THEN 'None'
When 1 THEN 'Male'
When 2 THEN 'Female'
When 3 THEN 'Both'
END,
Emp.BirthDate as DOB,
(
select Crg.Description From Crg where Crg.CrgId in (Select EmpCostCenter.CostCenterId from EmpCostCenter
Where EmpCostCenter.CurrentCC = 1 And EmpCostCenter.EmployeeId = Emp.EmployeeId
)
) as CostCenter,
(select dpt.Description from Department as Dpt Where Dpt.DepartmentId = Emp.DepartmentId) as Department,
(select Loc.Description From Location as Loc Where Loc.LocationId = Emp.LocationId) as PostingPlace,
Emp.BasicSalary as BasicSalary,Emp.DepartmentID as DepartmentID
From Employee as Emp Where Emp.EmployeeId in (%q)", SempIds);
return tc.ExecuteDataSet(sql);
}
internal static DataSet GetEmpSalarySheetByYear(TransactionContext tc, DateTime dSalaryMonth, string sEmpID)
{
DataSet rootDataset = new DataSet();
DataSet tempdataset = new DataSet();
DateTime fdy = Global.DateFunctions.FirstDateOfYear(dSalaryMonth);
DateTime ldy = Global.DateFunctions.LastDateOfYear(dSalaryMonth);
try
{
string query1 = SQLParser.MakeSQL(@"select A.SalaryMonth,A.EmployeeNo, A.Name,A.GName,A.DName,A.GCode,A.SequenceNo, A.Description,SUM(A.changedamount)
Amount from(
select S.EmployeeID, E.EmployeeNo,S.SalaryMonth, 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 between %d and %d and Sd.ItemGroup in (8)
AND sd.ItemCode not in(-133) AND S.EmployeeID IN(%q)
UNION
select S.EmployeeID, E.EmployeeNo,S.SalaryMonth,
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 between %d and %d
and Sd.ItemGroup in(1) AND sd.ItemCode not in(-133) AND S.EmployeeID in(%q)
)
A
group by A.SalaryMonth,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.SalaryMonth,A.EmployeeNo,A.Position,A.SequenceNo,A.GCode", fdy, ldy, sEmpID, fdy, ldy, sEmpID);
tempdataset = tc.ExecuteDataSet(query1);
tempdataset.Tables[0].TableName = "GrossItem";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query2 = SQLParser.MakeSQL(@"select A.SalaryMonth,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,S.SalaryMonth,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 between %d and %d and Sd.ItemGroup IN (1, 8)
AND S.EmployeeID IN(%q)
group by S.SalaryMonth,S.EmployeeID,G.DESCRIPTION,G.SequenceNo,G.Code,D.Name
UNION
select S.EmployeeID,S.SalaryMonth, -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 between %d and %d
AND G.GRADEID=S.GRADEID
AND D.DESIGNATIONID=S.DESIGNATIONID and Sd.ItemGroup IN (2) AND S.EmployeeID IN(%q)
group by S.SalaryMonth,S.EmployeeID,G.DESCRIPTION,G.SequenceNo,G.Code,D.Name
) A, Employee E
where A.EmployeeID = E.EmployeeID
group by A.SalaryMonth,E.EmployeeNo, E.Name,A.GName,A.SequenceNo,A.GCode,A.DName", fdy, ldy, sEmpID, fdy, ldy, sEmpID);
tempdataset = tc.ExecuteDataSet(query2);
tempdataset.Tables[0].TableName = "TotalGross";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query3 = SQLParser.MakeSQL(@"select A.SalaryMonth,A.EmployeeNo, A.Name,A.GName,A.GCode,A.SequenceNo,A.DName,
A.Description, SUM(A.changedamount) Amount
from
(
select S.SalaryMonth,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 between %d and %d and Sd.ItemGroup=3 AND S.EmployeeID IN(%q)
union
select
S.SalaryMonth,S.EmployeeID, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode,
sd.ItemID, sd.Description,sd.Position,
-sd.changedamount 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
between %d and %d and Sd.ItemGroup=2
AND S.EmployeeID IN(%q)
) A
group by A.SalaryMonth,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.SalaryMonth,A.Position,A.SequenceNo,A.GCode,A.EmployeeNo", fdy, ldy, sEmpID, fdy, ldy, sEmpID);
tempdataset = tc.ExecuteDataSet(query3);
tempdataset.Tables[0].TableName = "DeductItem";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query4 = SQLParser.MakeSQL(@"select A.SalaryMonth,A.EmployeeNo, A.Name,A.GName,A.GCode,A.SequenceNo,A.DName,
A.Description, SUM(A.changedamount) Amount
from
(
select S.SalaryMonth,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 between %d and %d and Sd.ITEMCODE =-133
AND S.EmployeeID IN(%q)
UNION
select S.SalaryMonth,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 between %d and %d and Sd.ITEMCODE =-133 AND S.EmployeeID IN(%q)
)
A
group by A.SalaryMonth,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.SalaryMonth,A.Position,A.SequenceNo,A.GCode,A.EmployeeNo", fdy, ldy, sEmpID, fdy, ldy, sEmpID);
tempdataset = tc.ExecuteDataSet(query4);
tempdataset.Tables[0].TableName = "LeaveDays";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query5 = SQLParser.MakeSQL(@"select A.SalaryMonth,E.EmployeeNo, E.Name,A.GName,A.GCode,A.sequenceNo,A.DName,
'UnAuthorized' as Description, Sum(A.amount) as amount
from
(
select S.SalaryMonth,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 between %d and %d AND G.GRADEID=S.GRADEID
AND D.DESIGNATIONID=S.DESIGNATIONID and Sd.ItemGroup IN (2) AND S.EmployeeID IN(%q)
group by S.SalaryMonth,S.EmployeeID,G.DESCRIPTION,G.SequenceNo,G.Code,D.Name
) A,Employee E
where A.EmployeeID = E.EmployeeID
group by A.SalaryMonth,E.EmployeeNo,E.Name,A.GName,A.SequenceNo,A.GCode,A.DName", fdy, ldy, sEmpID);
tempdataset = tc.ExecuteDataSet(query5);
tempdataset.Tables[0].TableName = "UnAuthorized";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query6 = SQLParser.MakeSQL(@"select A.SalaryMonth,E.EmployeeNo, E.Name,A.GName,A.GCode,A.SequenceNo,A.DName,
'Total Deduction' as Description,
Sum(A.amount) as amount
from(
select S.SalaryMonth,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 between %d and %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.SalaryMonth,S.EmployeeID,G.DESCRIPTION,G.SequenceNo,G.Code,D.Name
) A,Employee E
where A.EmployeeID = E.EmployeeID
group by A.SalaryMonth,E.EmployeeNo, E.Name,A.GName,A.SequenceNo,A.GCode,A.DName", fdy, ldy, sEmpID);
tempdataset = tc.ExecuteDataSet(query6);
tempdataset.Tables[0].TableName = "TotalDeduction";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query7 = SQLParser.MakeSQL(@"Select S.SalaryMonth,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 between %d and %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 S.SalaryMonth,G.SequenceNo,G.Code,E.EMPLOYEENO", fdy, ldy, sEmpID);
tempdataset = tc.ExecuteDataSet(query7);
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 GetEmpStartDateAndEndDate(TransactionContext tc, DateTime fstDate, DateTime endDate, string sEmpID)
{
DataSet rootDataset = new DataSet();
DataSet tempdataset = new DataSet();
DateTime fdy = Global.DateFunctions.FirstDateOfMonth(fstDate);
DateTime ldy = Global.DateFunctions.LastDateOfMonth(endDate);
try
{
string query1 = SQLParser.MakeSQL(@"select A.SalaryMonth,A.EmployeeNo, A.Name,A.GName,A.DName,A.GCode,A.SequenceNo,A.CostCenter, A.Description,SUM(A.changedamount)
Amount from(
select S.EmployeeID, E.EmployeeNo,S.SalaryMonth, 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,C.DESCRIPTION as CostCenter from SALARYMONTHLY S
LEFT JOIN SALARYMONTHLYDETAIL Sd ON Sd.SALARYMONTHLYID = S.SALARYMONTHLYID
LEFT JOIN SALARYEMPCOSTCENTER SC ON SC.SALARYMONTHLYID = s.SALARYMONTHLYID
LEFT JOIN EMPLOYEE E ON E.EMPLOYEEID = S.EMPLOYEEID
LEFT JOIN GRADES G ON G.GRADEID = E.GRADEID
LEFT JOIN DESIGNATION D ON D.DESIGNATIONID = E.DESIGNATIONID
LEFT JOIN CRG C ON C.CRGID = sc.COSTCENTERID
WHERE
S.SalaryMonth between %d and %d
AND Sd.ItemGroup in (8)
AND sd.ItemCode not in(-133) AND S.EmployeeID IN(%q)
UNION
select S.EmployeeID, E.EmployeeNo,S.SalaryMonth,
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,C.DESCRIPTION as CostCenter
from SALARYMONTHLY S
LEFT JOIN SALARYMONTHLYDETAIL Sd ON Sd.SALARYMONTHLYID = S.SALARYMONTHLYID
LEFT JOIN SALARYEMPCOSTCENTER SC ON SC.SALARYMONTHLYID = s.SALARYMONTHLYID
LEFT JOIN EMPLOYEE E ON E.EMPLOYEEID = S.EMPLOYEEID
LEFT JOIN GRADES G ON G.GRADEID = E.GRADEID
LEFT JOIN DESIGNATION D ON D.DESIGNATIONID = E.DESIGNATIONID
LEFT JOIN CRG C ON C.CRGID = sc.COSTCENTERID
WHERE
S.SalaryMonth between %d and %d
AND Sd.ItemGroup in(1)
AND sd.ItemCode not in(-133) AND S.EmployeeID in(%q))
A
group by A.SalaryMonth,A.EmployeeID, A.EmployeeNo, A.Name,A.GName,A.DName,A.SequenceNo,A.GCode, A.ItemCode, A.ItemID,
A.Description,A.Position,A.CostCenter
order by A.SalaryMonth ASC", fdy, ldy, sEmpID, fdy, ldy, sEmpID);
#region Dead Query1
// string query1 = SQLParser.MakeSQL(@"select A.SalaryMonth,A.EmployeeNo, A.Name,A.GName,A.DName,A.GCode,A.SequenceNo,A.CostCenter, A.Description,SUM(A.changedamount)
// Amount from(
// select S.EmployeeID, E.EmployeeNo,S.SalaryMonth, 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,C.DESCRIPTION as CostCenter from Grades G,DESIGNATION D,Employee E,
// SALARYMONTHLY S, SalaryMonthlyDetail Sd ,CRG C,EMPCOSTCENTER EmpCg
// where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID AND E.employeeID=S.EmployeeID
// And E.employeeID = EmpCg.EMPLOYEEID And EmpCg.COSTCENTERID = C.CRGID
// AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth between %d and %d and Sd.ItemGroup in (8)
// AND sd.ItemCode not in(-133) AND S.EmployeeID IN(%q)
//
// UNION
//
// select S.EmployeeID, E.EmployeeNo,S.SalaryMonth,
// 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,C.DESCRIPTION as CostCenter
// from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd,CRG C,EMPCOSTCENTER EmpCg
// where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID AND E.employeeID=S.EmployeeID
// And E.employeeID = EmpCg.EMPLOYEEID And EmpCg.COSTCENTERID = C.CRGID
// AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth between %d and %d
// and Sd.ItemGroup in(1) AND sd.ItemCode not in(-133) AND S.EmployeeID in(%q)
// )
// A
// group by A.SalaryMonth,A.EmployeeID, A.EmployeeNo, A.Name,A.GName,A.DName,A.SequenceNo,A.GCode, A.ItemCode, A.ItemID,
// A.Description,A.Position,A.CostCenter
// order by A.SalaryMonth asc", fdy, ldy, sEmpID, fdy, ldy, sEmpID);
#endregion
tempdataset = tc.ExecuteDataSet(query1);
tempdataset.Tables[0].TableName = "GrossItem";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query2 = SQLParser.MakeSQL(@"select A.SalaryMonth,E.EmployeeNo, E.Name,A.GName,A.GCode,A.SequenceNo,A.CostCenter,A.DName,'Total Gross' as Description,
Sum(A.amount) as amount
from
(
select S.EmployeeID,S.SalaryMonth,Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,G.Code as GCode,
G.SequenceNo,D.Name as DName,C.DESCRIPTION as CostCenter
FROM SALARYMONTHLY S
LEFT JOIN SALARYMONTHLYDETAIL Sd ON Sd.SALARYMONTHLYID = S.SALARYMONTHLYID
LEFT JOIN SALARYEMPCOSTCENTER SC ON SC.SALARYMONTHLYID = s.SALARYMONTHLYID
LEFT JOIN EMPLOYEE E ON E.EMPLOYEEID = S.EMPLOYEEID
LEFT JOIN GRADES G ON G.GRADEID = E.GRADEID
LEFT JOIN DESIGNATION D ON D.DESIGNATIONID = E.DESIGNATIONID
LEFT JOIN CRG C ON C.CRGID = sc.COSTCENTERID
WHERE
S.SalaryMonth between %d and %d and Sd.ItemGroup IN (1, 8)
AND S.EmployeeID IN(%q)
group by S.SalaryMonth,S.EmployeeID,G.DESCRIPTION,G.SequenceNo,G.Code,D.Name,C.DESCRIPTION
UNION
select S.EmployeeID,S.SalaryMonth, -Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,G.Code as GCode,
G.sequenceNo,D.Name as DName ,C.DESCRIPTION as CostCenter
from SALARYMONTHLY S
LEFT JOIN SALARYMONTHLYDETAIL Sd ON Sd.SALARYMONTHLYID = S.SALARYMONTHLYID
LEFT JOIN SALARYEMPCOSTCENTER SC ON SC.SALARYMONTHLYID = s.SALARYMONTHLYID
LEFT JOIN EMPLOYEE E ON E.EMPLOYEEID = S.EMPLOYEEID
LEFT JOIN GRADES G ON G.GRADEID = E.GRADEID
LEFT JOIN DESIGNATION D ON D.DESIGNATIONID = E.DESIGNATIONID
LEFT JOIN CRG C ON C.CRGID = sc.COSTCENTERID
where
S.SalaryMonth between %d and %d
AND Sd.ItemGroup IN (2) AND S.EmployeeID IN(%q)
group by S.SalaryMonth,S.EmployeeID,G.DESCRIPTION,G.SequenceNo,G.Code,D.Name,C.DESCRIPTION)
A, Employee E
where A.EmployeeID = E.EmployeeID
group by A.SalaryMonth,E.EmployeeNo, E.Name,A.GName,A.SequenceNo,A.GCode,A.DName,A.CostCenter Order By A.SalaryMonth ASC", fdy, ldy, sEmpID, fdy, ldy, sEmpID);
#region Dead Query2
// string query2 = SQLParser.MakeSQL(@"select A.SalaryMonth,E.EmployeeNo, E.Name,A.GName,A.GCode,A.SequenceNo,A.CostCenter,A.DName,'Total Gross' as Description,
// Sum(A.amount) as amount
// from
// (
// select S.EmployeeID,S.SalaryMonth,Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,G.Code as GCode,
// G.SequenceNo,D.Name as DName,C.DESCRIPTION as CostCenter
// from SALARYMONTHLY S,Grades G,DESIGNATION D,
// SalaryMonthlyDetail Sd,CRG C,EMPCOSTCENTER EmpCg
// where S.SalaryMonthlyID=Sd.SalaryMonthlyID AND
// G.GRADEID=S.GRADEID AND D.DESIGNATIONID=S.DESIGNATIONID
// And S.employeeID = EmpCg.EMPLOYEEID And EmpCg.COSTCENTERID = C.CRGID
// AND S.SalaryMonth between %d and %d and Sd.ItemGroup IN (1, 8)
// AND S.EmployeeID IN(%q)
// group by S.SalaryMonth,S.EmployeeID,G.DESCRIPTION,G.SequenceNo,G.Code,D.Name,C.DESCRIPTION
//
// UNION
//
// select S.EmployeeID,S.SalaryMonth, -Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,G.Code as GCode,
// G.sequenceNo,D.Name as DName ,C.DESCRIPTION as CostCenter
// from GRADES G,DESIGNATION D,SALARYMONTHLY S, SalaryMonthlyDetail Sd,CRG C,EMPCOSTCENTER EmpCg
// where S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth between %d and %d
// AND G.GRADEID=S.GRADEID
// AND D.DESIGNATIONID=S.DESIGNATIONID And S.employeeID = EmpCg.EMPLOYEEID And EmpCg.COSTCENTERID = C.CRGID
// and Sd.ItemGroup IN (2) AND S.EmployeeID IN(%q)
// group by S.SalaryMonth,S.EmployeeID,G.DESCRIPTION,G.SequenceNo,G.Code,D.Name,C.DESCRIPTION
//
// ) A, Employee E
// where A.EmployeeID = E.EmployeeID
// group by A.SalaryMonth,E.EmployeeNo, E.Name,A.GName,A.SequenceNo,A.GCode,A.DName,A.CostCenter Order By A.SalaryMonth asc", fdy, ldy, sEmpID, fdy, ldy, sEmpID);
#endregion
tempdataset = tc.ExecuteDataSet(query2);
tempdataset.Tables[0].TableName = "TotalGross";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query3 = SQLParser.MakeSQL(@"select A.SalaryMonth,A.EmployeeNo, A.Name,A.GName,A.GCode,A.SequenceNo,A.DName,A.CostCenter,
A.Description, SUM(A.changedamount) Amount
from
(
select S.SalaryMonth,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,C.DESCRIPTION as CostCenter
from SALARYMONTHLY S
LEFT JOIN SALARYMONTHLYDETAIL Sd ON Sd.SALARYMONTHLYID = S.SALARYMONTHLYID
LEFT JOIN SALARYEMPCOSTCENTER SC ON SC.SALARYMONTHLYID = s.SALARYMONTHLYID
LEFT JOIN EMPLOYEE E ON E.EMPLOYEEID = S.EMPLOYEEID
LEFT JOIN GRADES G ON G.GRADEID = E.GRADEID
LEFT JOIN DESIGNATION D ON D.DESIGNATIONID = E.DESIGNATIONID
LEFT JOIN CRG C ON C.CRGID = sc.COSTCENTERID
where
S.SalaryMonth between %d and %d and Sd.ItemGroup=3 AND S.EmployeeID IN(%q)
union
select
S.SalaryMonth,S.EmployeeID, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode,
sd.ItemID, sd.Description,sd.Position,
-sd.changedamount changedamount,G.DESCRIPTION as GName,G.Code as GCode,
G.sequenceNo,D.Name as DName,C.DESCRIPTION as CostCenter
from SALARYMONTHLY S
LEFT JOIN SALARYMONTHLYDETAIL Sd ON Sd.SALARYMONTHLYID = S.SALARYMONTHLYID
LEFT JOIN SALARYEMPCOSTCENTER SC ON SC.SALARYMONTHLYID = s.SALARYMONTHLYID
LEFT JOIN EMPLOYEE E ON E.EMPLOYEEID = S.EMPLOYEEID
LEFT JOIN GRADES G ON G.GRADEID = E.GRADEID
LEFT JOIN DESIGNATION D ON D.DESIGNATIONID = E.DESIGNATIONID
LEFT JOIN CRG C ON C.CRGID = sc.COSTCENTERID
where
S.SalaryMonth
between %d and %d and Sd.ItemGroup=2
AND S.EmployeeID IN(%q))
A
group by A.SalaryMonth,A.EmployeeID, A.EmployeeNo, A.Name,A.GName,A.SequenceNo,
A.GCode,A.DName, A.ItemCode, A.ItemID, A.Description,A.Position,A.CostCenter
order by A.SalaryMonth asc", fdy, ldy, sEmpID, fdy, ldy, sEmpID);
#region Dead Query3
// string query3 = SQLParser.MakeSQL(@"select A.SalaryMonth,A.EmployeeNo, A.Name,A.GName,A.GCode,A.SequenceNo,A.DName,A.CostCenter,
// A.Description, SUM(A.changedamount) Amount
// from
// (
// select S.SalaryMonth,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,C.DESCRIPTION as CostCenter
// from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S,CRG C,EMPCOSTCENTER EmpCg,
// SalaryMonthlyDetail Sd where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID
// And E.employeeID = EmpCg.EMPLOYEEID And EmpCg.COSTCENTERID = C.CRGID
// AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID
// AND S.SalaryMonth between %d and %d and Sd.ItemGroup=3 AND S.EmployeeID IN(%q)
//
// union
//
// select
//
// S.SalaryMonth,S.EmployeeID, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode,
// sd.ItemID, sd.Description,sd.Position,
// -sd.changedamount changedamount,G.DESCRIPTION as GName,G.Code as GCode,
// G.sequenceNo,D.Name as DName,C.DESCRIPTION as CostCenter
// from
// Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S,CRG C,EMPCOSTCENTER EmpCg, SalaryMonthlyDetail Sd
// where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID
// And E.employeeID = EmpCg.EMPLOYEEID And EmpCg.COSTCENTERID = C.CRGID
// AND E.employeeID=S.EmployeeID
// AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth
// between %d and %d and Sd.ItemGroup=2
// AND S.EmployeeID IN(%q)
// ) A
// group by A.SalaryMonth,A.EmployeeID, A.EmployeeNo, A.Name,A.GName,A.SequenceNo,
// A.GCode,A.DName, A.ItemCode, A.ItemID, A.Description,A.Position,A.CostCenter
// order by A.SalaryMonth asc", fdy, ldy, sEmpID, fdy, ldy, sEmpID);
#endregion
tempdataset = tc.ExecuteDataSet(query3);
tempdataset.Tables[0].TableName = "DeductItem";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query4 = SQLParser.MakeSQL(@"select A.SalaryMonth,A.EmployeeNo, A.Name,A.GName,A.GCode,A.SequenceNo,A.DName,A.CostCenter,
A.Description, SUM(A.changedamount) Amount
from
(
select S.SalaryMonth,S.EmployeeID, E.EmployeeNo, E.Name,C.DESCRIPTION as CostCenter,
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 SALARYMONTHLY S
LEFT JOIN SALARYMONTHLYDETAIL Sd ON Sd.SALARYMONTHLYID = S.SALARYMONTHLYID
LEFT JOIN SALARYEMPCOSTCENTER SC ON SC.SALARYMONTHLYID = s.SALARYMONTHLYID
LEFT JOIN EMPLOYEE E ON E.EMPLOYEEID = S.EMPLOYEEID
LEFT JOIN GRADES G ON G.GRADEID = E.GRADEID
LEFT JOIN DESIGNATION D ON D.DESIGNATIONID = E.DESIGNATIONID
LEFT JOIN CRG C ON C.CRGID = sc.COSTCENTERID
where
S.SalaryMonth between %d and %d and Sd.ITEMCODE =-133
AND S.EmployeeID IN(%q)
UNION
select S.SalaryMonth,S.EmployeeID, E.EmployeeNo, E.Name,C.DESCRIPTION as CostCenter,
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 SALARYMONTHLY S
LEFT JOIN SALARYMONTHLYDETAIL Sd ON Sd.SALARYMONTHLYID = S.SALARYMONTHLYID
LEFT JOIN SALARYEMPCOSTCENTER SC ON SC.SALARYMONTHLYID = s.SALARYMONTHLYID
LEFT JOIN EMPLOYEE E ON E.EMPLOYEEID = S.EMPLOYEEID
LEFT JOIN GRADES G ON G.GRADEID = E.GRADEID
LEFT JOIN DESIGNATION D ON D.DESIGNATIONID = E.DESIGNATIONID
LEFT JOIN CRG C ON C.CRGID = sc.COSTCENTERID
where
S.SalaryMonth between %d and %d and Sd.ITEMCODE =-133 AND S.EmployeeID IN(%q))
A
group by A.SalaryMonth,A.EmployeeID, A.EmployeeNo, A.Name,A.GName,A.SequenceNo,
A.GCode,A.DName,A.ItemCode, A.ItemID, A.Description,A.Position,A.CostCenter
order by A.SalaryMonth asc", fdy, ldy, sEmpID, fdy, ldy, sEmpID);
#region Dead Query4
// string query4 = SQLParser.MakeSQL(@"select A.SalaryMonth,A.EmployeeNo, A.Name,A.GName,A.GCode,A.SequenceNo,A.DName,A.CostCenter,
// A.Description, SUM(A.changedamount) Amount
// from
// (
// select S.SalaryMonth,S.EmployeeID, E.EmployeeNo, E.Name,C.DESCRIPTION as CostCenter,
// 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,CRG C,EMPCOSTCENTER EmpCg
// where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID AND E.employeeID=S.EmployeeID
// And E.employeeID = EmpCg.EMPLOYEEID And EmpCg.COSTCENTERID = C.CRGID
// AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth between %d and %d and Sd.ITEMCODE =-133
// AND S.EmployeeID IN(%q)
// UNION
// select S.SalaryMonth,S.EmployeeID, E.EmployeeNo, E.Name,C.DESCRIPTION as CostCenter,
// 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,CRG C,EMPCOSTCENTER EmpCg
// where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID
// AND E.employeeID=S.EmployeeID And E.employeeID = EmpCg.EMPLOYEEID And EmpCg.COSTCENTERID = C.CRGID
// AND S.SalaryMonthlyID=Sd.SalaryMonthlyID
// AND S.SalaryMonth between %d and %d and Sd.ITEMCODE =-133 AND S.EmployeeID IN(%q)
// )
// A
// group by A.SalaryMonth,A.EmployeeID, A.EmployeeNo, A.Name,A.GName,A.SequenceNo,
// A.GCode,A.DName,A.ItemCode, A.ItemID, A.Description,A.Position,A.CostCenter
// order by A.SalaryMonth asc", fdy, ldy, sEmpID, fdy, ldy, sEmpID);
#endregion
tempdataset = tc.ExecuteDataSet(query4);
tempdataset.Tables[0].TableName = "LeaveDays";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query5 = SQLParser.MakeSQL(@"select A.SalaryMonth,E.EmployeeNo, E.Name,A.GName,A.GCode,A.sequenceNo,A.DName,
A.CostCenter,'UnAuthorized' as Description, Sum(A.amount) as amount
from
(
select S.SalaryMonth,S.EmployeeID, Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,G.Code as GCode,C.DESCRIPTION as CostCenter,
G.SequenceNo,D.Name as DName
from SALARYMONTHLY S
LEFT JOIN SALARYMONTHLYDETAIL Sd ON Sd.SALARYMONTHLYID = S.SALARYMONTHLYID
LEFT JOIN SALARYEMPCOSTCENTER SC ON SC.SALARYMONTHLYID = s.SALARYMONTHLYID
LEFT JOIN EMPLOYEE E ON E.EMPLOYEEID = S.EMPLOYEEID
LEFT JOIN GRADES G ON G.GRADEID = E.GRADEID
LEFT JOIN DESIGNATION D ON D.DESIGNATIONID = E.DESIGNATIONID
LEFT JOIN CRG C ON C.CRGID = sc.COSTCENTERID
where
S.SalaryMonth between %d and %d AND Sd.ItemGroup IN (2) AND S.EmployeeID IN(%q)
group by S.SalaryMonth,S.EmployeeID,G.DESCRIPTION,G.SequenceNo,G.Code,D.Name ,C.DESCRIPTION
) A,Employee E
where A.EmployeeID = E.EmployeeID
group by A.SalaryMonth,E.EmployeeNo,E.Name,A.GName,A.SequenceNo,A.GCode,A.DName,A.CostCenter Order By A.SalaryMonth asc", fdy, ldy, sEmpID);
#region Dead Query5
// string query5 = SQLParser.MakeSQL(@"select A.SalaryMonth,E.EmployeeNo, E.Name,A.GName,A.GCode,A.sequenceNo,A.DName,
// A.CostCenter,'UnAuthorized' as Description, Sum(A.amount) as amount
// from
// (
// select S.SalaryMonth,S.EmployeeID, Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,G.Code as GCode,C.DESCRIPTION as CostCenter,
// G.SequenceNo,D.Name as DName from GRADES G,DESIGNATION D,SALARYMONTHLY S,SalaryMonthlyDetail Sd,CRG C,EMPCOSTCENTER EmpCg
// where S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth between %d and %d AND G.GRADEID=S.GRADEID
// AND D.DESIGNATIONID=S.DESIGNATIONID and Sd.ItemGroup IN (2) AND S.EmployeeID IN(%q)
// And S.employeeID = EmpCg.EMPLOYEEID And EmpCg.COSTCENTERID = C.CRGID
// group by S.SalaryMonth,S.EmployeeID,G.DESCRIPTION,G.SequenceNo,G.Code,D.Name ,C.DESCRIPTION
// ) A,Employee E
// where A.EmployeeID = E.EmployeeID
// group by A.SalaryMonth,E.EmployeeNo,E.Name,A.GName,A.SequenceNo,A.GCode,A.DName,A.CostCenter Order By A.SalaryMonth asc", fdy, ldy, sEmpID);
#endregion
tempdataset = tc.ExecuteDataSet(query5);
tempdataset.Tables[0].TableName = "UnAuthorized";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query6 = SQLParser.MakeSQL(@"select A.SalaryMonth,E.EmployeeNo, E.Name,A.GName,A.GCode,A.SequenceNo,A.DName,
A.CostCenter,'Total Deduction' as Description,
Sum(A.amount) as amount
from(
select S.SalaryMonth,S.EmployeeID, Sum(sd.changedamount) as Amount,C.DESCRIPTION as CostCenter,
G.DESCRIPTION as GName,G.Code as GCode,G.SequenceNo,D.Name as DName
from SALARYMONTHLY S
LEFT JOIN SALARYMONTHLYDETAIL Sd ON Sd.SALARYMONTHLYID = S.SALARYMONTHLYID
LEFT JOIN SALARYEMPCOSTCENTER SC ON SC.SALARYMONTHLYID = s.SALARYMONTHLYID
LEFT JOIN EMPLOYEE E ON E.EMPLOYEEID = S.EMPLOYEEID
LEFT JOIN GRADES G ON G.GRADEID = E.GRADEID
LEFT JOIN DESIGNATION D ON D.DESIGNATIONID = E.DESIGNATIONID
LEFT JOIN CRG C ON C.CRGID = sc.COSTCENTERID
where
S.SalaryMonth between %d and %d AND Sd.ItemGroup IN (2,3) AND S.EmployeeID IN(%q)
group by S.SalaryMonth,S.EmployeeID,G.DESCRIPTION,G.SequenceNo,G.Code,D.Name,C.DESCRIPTION
) A,Employee E
where A.EmployeeID = E.EmployeeID
group by A.SalaryMonth,E.EmployeeNo, E.Name,A.GName,A.SequenceNo,A.GCode,A.DName,A.CostCenter Order By A.SalaryMonth asc", fdy, ldy, sEmpID);
#region Dead Query 6
// string query6 = SQLParser.MakeSQL(@"select A.SalaryMonth,E.EmployeeNo, E.Name,A.GName,A.GCode,A.SequenceNo,A.DName,
// A.CostCenter,'Total Deduction' as Description,
// Sum(A.amount) as amount
// from(
// select S.SalaryMonth,S.EmployeeID, Sum(sd.changedamount) as Amount,C.DESCRIPTION as CostCenter,
// G.DESCRIPTION as GName,G.Code as GCode,G.SequenceNo,D.Name as DName
// from GRADES G,DESIGNATION D,SALARYMONTHLY S,SalaryMonthlyDetail Sd,CRG C,EMPCOSTCENTER EmpCg
// where S.SalaryMonthlyID=Sd.SalaryMonthlyID AND
// S.SalaryMonth between %d and %d AND G.GRADEID=S.GRADEID AND D.DESIGNATIONID=S.DESIGNATIONID
// and Sd.ItemGroup IN (2,3) AND S.EmployeeID IN(%q)
// And S.employeeID = EmpCg.EMPLOYEEID And EmpCg.COSTCENTERID = C.CRGID
// group by S.SalaryMonth,S.EmployeeID,G.DESCRIPTION,G.SequenceNo,G.Code,D.Name,C.DESCRIPTION
// ) A,Employee E
// where A.EmployeeID = E.EmployeeID
// group by A.SalaryMonth,E.EmployeeNo, E.Name,A.GName,A.SequenceNo,A.GCode,A.DName,A.CostCenter Order By A.SalaryMonth asc", fdy, ldy, sEmpID);
#endregion
tempdataset = tc.ExecuteDataSet(query6);
tempdataset.Tables[0].TableName = "TotalDeduction";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query7 = SQLParser.MakeSQL(@"Select S.SalaryMonth,E.EMPLOYEENO,E.NAME,G.DESCRIPTION as GName,G.Code as GCode,C.DESCRIPTION as CostCenter,
G.SequenceNo,D.Name as DName ,'Net Pay' as Description,SD.CHANGEDAMOUNT as Amount
from SALARYMONTHLY as S
LEFT JOIN SALARYMONTHLYDETAIL Sd ON Sd.SALARYMONTHLYID = S.SALARYMONTHLYID
LEFT JOIN SALARYEMPCOSTCENTER SC ON SC.SALARYMONTHLYID = s.SALARYMONTHLYID
LEFT JOIN EMPLOYEE E ON E.EMPLOYEEID = S.EMPLOYEEID
LEFT JOIN GRADES G ON G.GRADEID = E.GRADEID
LEFT JOIN DESIGNATION D ON D.DESIGNATIONID = E.DESIGNATIONID
LEFT JOIN CRG C ON C.CRGID = sc.COSTCENTERID
where S.SalaryMonth between %d and %d
AND Sd.ItemGroup IN (5) AND Sd.ItemCode IN(-132) AND S.EmployeeID IN(%q)
order by S.SalaryMonth asc", fdy, ldy, sEmpID);
#region Dead Query7
// string query7 = SQLParser.MakeSQL(@"Select S.SalaryMonth,E.EMPLOYEENO,E.NAME,G.DESCRIPTION as GName,G.Code as GCode,C.DESCRIPTION as CostCenter,
// 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,CRG C,EMPCOSTCENTER EmpCg,SALARYMONTHLYDETAIL
// as Sd where S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth between %d and %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)
// And E.employeeID = EmpCg.EMPLOYEEID And EmpCg.COSTCENTERID = C.CRGID
// order by S.SalaryMonth asc", fdy, ldy, sEmpID);
#endregion
tempdataset = tc.ExecuteDataSet(query7);
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 GetSalaryForTax(TransactionContext tc, DateTime fstDate, DateTime endDate)
{
DataSet rootDataset = new DataSet();
DataSet tempdataset = new DataSet();
DateTime fdy = Global.DateFunctions.FirstDateOfMonth(fstDate);
DateTime ldy = Global.DateFunctions.LastDateOfMonth(endDate);
try
{
string query = SQLParser.MakeSQL(@"SELECT tab1.EMPLOYEEID, tab1.EMPLOYEENO, tab1.NAME, tab1.Dept, tab1.Amount Basic, tab2.Amount HouseRent, tab3.Amount Conveyance,
ISNULL(tab4.Amount,0) FestivalBonus, ISNULL(tab5.Amount,0) ComputerUsage, ISNULL(tab6.Amount,0) Medical,
ISNULL(tab7.Amount,0) OvertimeAllowance,tab1.SequenceNO FROM
(
--Basic
SELECT e.EMPLOYEEID, e.EMPLOYEENO, e.NAME, d.DESCRIPTION Dept, sd.DESCRIPTION, SUM(sd.CHANGEDAMOUNT) Amount,d.SequenceNO FROM SALARYMONTHLY s
LEFT JOIN SALARYMONTHLYDETAIL sd on s.SALARYMONTHLYID = sd.SALARYMONTHLYID
LEFT JOIN EMPLOYEE e ON s.EMPLOYEEID = e.EMPLOYEEID
LEFT JOIN DEPARTMENT d ON e.DEPARTMENTID = d.DEPARTMENTID
WHERE s.SalaryMonth BETWEEN %d AND %d AND sd.ITEMCODE = -101 AND sd.ITEMGROUP = 1 AND sd.ITEMID = -101
GROUP BY e.EMPLOYEEID, e.EMPLOYEENO, e.NAME, d.DESCRIPTION,d.SequenceNO, sd.DESCRIPTION
) tab1
LEFT JOIN
(
--House Rent
SELECT e.EMPLOYEEID, e.EMPLOYEENO, e.NAME, d.DESCRIPTION Dept, sd.DESCRIPTION, SUM(sd.CHANGEDAMOUNT) Amount,d.SequenceNO FROM SALARYMONTHLY s
LEFT JOIN SALARYMONTHLYDETAIL sd on s.SALARYMONTHLYID = sd.SALARYMONTHLYID
LEFT JOIN EMPLOYEE e ON s.EMPLOYEEID = e.EMPLOYEEID
LEFT JOIN DEPARTMENT d ON e.DEPARTMENTID = d.DEPARTMENTID
WHERE s.SalaryMonth BETWEEN %d AND %d AND sd.ITEMCODE = -113 AND sd.ITEMGROUP = 1 AND sd.ITEMID = 1
GROUP BY e.EMPLOYEEID, e.EMPLOYEENO, e.NAME, d.DESCRIPTION,d.SequenceNO, sd.DESCRIPTION
) tab2
ON tab1.EmployeeID = tab2.EmployeeID
LEFT JOIN
(
--Conveyance
SELECT e.EMPLOYEEID, e.EMPLOYEENO, e.NAME, d.DESCRIPTION Dept, sd.DESCRIPTION, SUM(sd.CHANGEDAMOUNT) Amount,d.SequenceNO FROM SALARYMONTHLY s
LEFT JOIN SALARYMONTHLYDETAIL sd on s.SALARYMONTHLYID = sd.SALARYMONTHLYID
LEFT JOIN EMPLOYEE e ON s.EMPLOYEEID = e.EMPLOYEEID
LEFT JOIN DEPARTMENT d ON e.DEPARTMENTID = d.DEPARTMENTID
WHERE s.SalaryMonth BETWEEN %d AND %d AND sd.ITEMCODE = -113 AND sd.ITEMGROUP = 1 AND sd.ITEMID = 3
GROUP BY e.EMPLOYEEID, e.EMPLOYEENO, e.NAME, d.DESCRIPTION,d.SequenceNO, sd.DESCRIPTION
) tab3
ON tab1.EmployeeID = tab3.EmployeeID
LEFT JOIN
(
--Festival Bonus
SELECT e.EMPLOYEEID, e.EMPLOYEENO, e.NAME, d.DESCRIPTION Dept, 'Festival Bonus' DESCRIPTION, SUM(bpd.ChangeBonusAmount) Amount,d.SequenceNO FROM BONUSPROCESS bp
LEFT JOIN BONUSPROCESSDETAIL bpd ON bpd.BonusProcessID = bp.BONUSPROCESSID
LEFT JOIN EMPLOYEE e ON e.EMPLOYEEID = bpd.EmployeeID
LEFT JOIN DEPARTMENT d ON e.DEPARTMENTID = d.DEPARTMENTID
WHERE BONUSMONTH BETWEEN %d AND %d
GROUP BY e.EMPLOYEEID, e.EMPLOYEENO, e.NAME, d.DESCRIPTION,d.SequenceNO
) tab4
ON tab1.EmployeeID = tab4.EmployeeID
LEFT JOIN
(
--Computer Usage
SELECT e.EMPLOYEEID, e.EMPLOYEENO, e.NAME, d.DESCRIPTION Dept, sd.DESCRIPTION, SUM(sd.CHANGEDAMOUNT) Amount,d.SequenceNO FROM SALARYMONTHLY s
LEFT JOIN SALARYMONTHLYDETAIL sd on s.SALARYMONTHLYID = sd.SALARYMONTHLYID
LEFT JOIN EMPLOYEE e ON s.EMPLOYEEID = e.EMPLOYEEID
LEFT JOIN DEPARTMENT d ON e.DEPARTMENTID = d.DEPARTMENTID
WHERE s.SalaryMonth BETWEEN %d AND %d AND sd.ITEMCODE = -113 AND sd.ITEMGROUP = 1 AND sd.ITEMID = 7
GROUP BY e.EMPLOYEEID, e.EMPLOYEENO, e.NAME, d.DESCRIPTION,d.SequenceNO, sd.DESCRIPTION
) tab5
ON tab1.EmployeeID = tab5.EmployeeID
LEFT JOIN
(
--Medical
SELECT e.EMPLOYEEID, e.EMPLOYEENO, e.NAME, d.DESCRIPTION Dept, sd.DESCRIPTION, SUM(sd.CHANGEDAMOUNT) Amount,d.SequenceNO FROM SALARYMONTHLY s
LEFT JOIN SALARYMONTHLYDETAIL sd on s.SALARYMONTHLYID = sd.SALARYMONTHLYID
LEFT JOIN EMPLOYEE e ON s.EMPLOYEEID = e.EMPLOYEEID
LEFT JOIN DEPARTMENT d ON e.DEPARTMENTID = d.DEPARTMENTID
WHERE s.SalaryMonth BETWEEN %d AND %d AND sd.ITEMCODE = -113 AND sd.ITEMGROUP = 1 AND sd.ITEMID = 2
GROUP BY e.EMPLOYEEID, e.EMPLOYEENO, e.NAME, d.DESCRIPTION,d.SequenceNO, sd.DESCRIPTION
) tab6
ON tab1.EmployeeID = tab6.EmployeeID
LEFT JOIN
(
--Overtime
SELECT e.EMPLOYEEID, e.EMPLOYEENO, e.NAME, d.DESCRIPTION Dept, 'OT' DESCRIPTION, SUM(sd.CHANGEDAMOUNT) Amount,d.SequenceNO FROM SALARYMONTHLY s
LEFT JOIN SALARYMONTHLYDETAIL sd on s.SALARYMONTHLYID = sd.SALARYMONTHLYID
LEFT JOIN EMPLOYEE e ON s.EMPLOYEEID = e.EMPLOYEEID
LEFT JOIN DEPARTMENT d ON e.DEPARTMENTID = d.DEPARTMENTID
WHERE s.SalaryMonth BETWEEN %d AND %d AND sd.ITEMCODE = -103 AND sd.ITEMGROUP = 1 AND sd.ITEMID IN (1,2)
GROUP BY e.EMPLOYEEID, e.EMPLOYEENO, e.NAME, d.DESCRIPTION,d.SequenceNO
) tab7
ON tab1.EmployeeID = tab7.EmployeeID
ORDER BY tab1.SequenceNO,tab1.EmployeeNo", fdy, ldy, fdy, ldy, fdy, ldy, fdy, ldy, fdy, ldy, fdy, ldy, fdy, ldy);
tempdataset = tc.ExecuteDataSet(query);
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return rootDataset;
}
// internal static DataSet GetEmpStartDateAndEndDate(TransactionContext tc, DateTime fstDate,DateTime endDate, string sEmpID)
// {
// DataSet rootDataset = new DataSet();
// DataSet tempdataset = new DataSet();
// DateTime fdy = Global.DateFunctions.FirstDateOfMonth(fstDate);
// DateTime ldy = Global.DateFunctions.LastDateOfMonth(endDate);
// try
// {
// string query1 = SQLParser.MakeSQL(@"select A.SalaryMonth,A.EmployeeNo, A.Name,A.GName,A.DName,A.GCode,A.SequenceNo, A.Description,SUM(A.changedamount)
// Amount from(
// select S.EmployeeID, E.EmployeeNo,S.SalaryMonth, 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 between %d and %d and Sd.ItemGroup in (8)
// AND sd.ItemCode not in(-133) AND S.EmployeeID IN(%q)
//
// UNION
//
// select S.EmployeeID, E.EmployeeNo,S.SalaryMonth,
// 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 between %d and %d
// and Sd.ItemGroup in(1) AND sd.ItemCode not in(-133) AND S.EmployeeID in(%q)
// )
// A
// group by A.SalaryMonth,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.SalaryMonth,A.EmployeeNo,A.Position,A.SequenceNo,A.GCode", fdy, ldy, sEmpID, fdy, ldy, sEmpID);
// tempdataset = tc.ExecuteDataSet(query1);
// tempdataset.Tables[0].TableName = "GrossItem";
// rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
// string query2 = SQLParser.MakeSQL(@"select A.SalaryMonth,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,S.SalaryMonth,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 between %d and %d and Sd.ItemGroup IN (1, 8)
// AND S.EmployeeID IN(%q)
// group by S.SalaryMonth,S.EmployeeID,G.DESCRIPTION,G.SequenceNo,G.Code,D.Name
//
// UNION
//
// select S.EmployeeID,S.SalaryMonth, -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 between %d and %d
// AND G.GRADEID=S.GRADEID
// AND D.DESIGNATIONID=S.DESIGNATIONID and Sd.ItemGroup IN (2) AND S.EmployeeID IN(%q)
// group by S.SalaryMonth,S.EmployeeID,G.DESCRIPTION,G.SequenceNo,G.Code,D.Name
//
// ) A, Employee E
// where A.EmployeeID = E.EmployeeID
// group by A.SalaryMonth,E.EmployeeNo, E.Name,A.GName,A.SequenceNo,A.GCode,A.DName", fdy, ldy, sEmpID, fdy, ldy, sEmpID);
// tempdataset = tc.ExecuteDataSet(query2);
// tempdataset.Tables[0].TableName = "TotalGross";
// rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
// string query3 = SQLParser.MakeSQL(@"select A.SalaryMonth,A.EmployeeNo, A.Name,A.GName,A.GCode,A.SequenceNo,A.DName,
// A.Description, SUM(A.changedamount) Amount
// from
// (
// select S.SalaryMonth,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 between %d and %d and Sd.ItemGroup=3 AND S.EmployeeID IN(%q)
// union
// select
// S.SalaryMonth,S.EmployeeID, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode,
// sd.ItemID, sd.Description,sd.Position,
// -sd.changedamount 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
// between %d and %d and Sd.ItemGroup=2
// AND S.EmployeeID IN(%q)
// ) A
// group by A.SalaryMonth,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.SalaryMonth,A.Position,A.SequenceNo,A.GCode,A.EmployeeNo", fdy, ldy, sEmpID, fdy, ldy, sEmpID);
// tempdataset = tc.ExecuteDataSet(query3);
// tempdataset.Tables[0].TableName = "DeductItem";
// rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
// string query4 = SQLParser.MakeSQL(@"select A.SalaryMonth,A.EmployeeNo, A.Name,A.GName,A.GCode,A.SequenceNo,A.DName,
// A.Description, SUM(A.changedamount) Amount
// from
// (
// select S.SalaryMonth,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 between %d and %d and Sd.ITEMCODE =-133
// AND S.EmployeeID IN(%q)
//
// UNION
//
// select S.SalaryMonth,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 between %d and %d and Sd.ITEMCODE =-133 AND S.EmployeeID IN(%q)
// )
// A
// group by A.SalaryMonth,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.SalaryMonth,A.Position,A.SequenceNo,A.GCode,A.EmployeeNo", fdy, ldy, sEmpID, fdy, ldy, sEmpID);
// tempdataset = tc.ExecuteDataSet(query4);
// tempdataset.Tables[0].TableName = "LeaveDays";
// rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
// string query5 = SQLParser.MakeSQL(@"select A.SalaryMonth,E.EmployeeNo, E.Name,A.GName,A.GCode,A.sequenceNo,A.DName,
// 'UnAuthorized' as Description, Sum(A.amount) as amount
// from
// (
// select S.SalaryMonth,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 between %d and %d AND G.GRADEID=S.GRADEID
// AND D.DESIGNATIONID=S.DESIGNATIONID and Sd.ItemGroup IN (2) AND S.EmployeeID IN(%q)
// group by S.SalaryMonth,S.EmployeeID,G.DESCRIPTION,G.SequenceNo,G.Code,D.Name
// ) A,Employee E
// where A.EmployeeID = E.EmployeeID
// group by A.SalaryMonth,E.EmployeeNo,E.Name,A.GName,A.SequenceNo,A.GCode,A.DName", fdy, ldy, sEmpID);
// tempdataset = tc.ExecuteDataSet(query5);
// tempdataset.Tables[0].TableName = "UnAuthorized";
// rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
// string query6 = SQLParser.MakeSQL(@"select A.SalaryMonth,E.EmployeeNo, E.Name,A.GName,A.GCode,A.SequenceNo,A.DName,
// 'Total Deduction' as Description,
// Sum(A.amount) as amount
// from(
// select S.SalaryMonth,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 between %d and %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.SalaryMonth,S.EmployeeID,G.DESCRIPTION,G.SequenceNo,G.Code,D.Name
// ) A,Employee E
// where A.EmployeeID = E.EmployeeID
// group by A.SalaryMonth,E.EmployeeNo, E.Name,A.GName,A.SequenceNo,A.GCode,A.DName", fdy, ldy, sEmpID);
// tempdataset = tc.ExecuteDataSet(query6);
// tempdataset.Tables[0].TableName = "TotalDeduction";
// rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
// string query7 = SQLParser.MakeSQL(@"Select S.SalaryMonth,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 between %d and %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 S.SalaryMonth,G.SequenceNo,G.Code,E.EMPLOYEENO", fdy, ldy, sEmpID);
// tempdataset = tc.ExecuteDataSet(query7);
// tempdataset.Tables[0].TableName = "NetPay";
// rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
// }
// catch (Exception ex)
// {
// throw new Exception(ex.Message);
// }
// return rootDataset;
// }
internal static IDataReader GetDetail(TransactionContext tc, DateTime startDate, DateTime endDate)
{
string sql = SQLParser.MakeSQL(@"SELECT SD.* FROM SalaryMonthlyDetail SD, SalaryMonthly SM WHERE "
+ " (SM.SalaryMonth between %d AND %d) AND SD.SalaryMonthlyID = SM.SalaryMonthlyID Order by SM.SalaryMonthlyID, SD.Position ", startDate, endDate);
return tc.ExecuteReader(sql);
}
internal static IDataReader GetDetail(TransactionContext tc, ID nEmpID, DateTime startDate, DateTime endDate, ID payrollTypeID)
{
//string sql = SQLParser.MakeSQL(@"SELECT SD.* FROM SalaryMonthlyDetail SD, SalaryMonthly SM WHERE "
// + " (SM.SalaryMonth between %d AND %d) AND SD.SalaryMonthlyID = SM.SalaryMonthlyID Order by SM.SalaryMonthlyID, SD.Position ", startDate, endDate);
string sql = SQLParser.MakeSQL(@"Select * from SalaryMonthlyDetail where SalaryMonthlyID IN(
SELECT SalaryMonthlyID FROM SalaryMonthly where (SalaryMonth between %d And %d) and (payrolltypeid = %n) and EmployeeID=%n) ", startDate, endDate, payrollTypeID.Integer, nEmpID.Integer);
return tc.ExecuteReader(sql);
}
internal static IDataReader Get(TransactionContext tc, DateTime startDate, DateTime endDate, ID payrollTypeID)
{
string sql = SQLParser.MakeSQL(@"SELECT * FROM SalaryMonthly where (SalaryMonth between %d And %d) and (payrolltypeid = %n)", startDate, endDate, payrollTypeID.Integer);
return tc.ExecuteReader(sql);
}
internal static IDataReader Get(TransactionContext tc, ID nEmpID, DateTime startDate, DateTime endDate, ID payrollTypeID)
{
//string sql = SQLParser.MakeSQL(@"SELECT * FROM SalaryMonthly where (SalaryMonth between %d And %d) and (payrolltypeid = %n)", startDate, endDate, SystemInformation.CurrentSysInfo.PayrollTypeID.Integer);
string sql = SQLParser.MakeSQL(@"SELECT * FROM SalaryMonthly where (SalaryMonth between %d And %d) and (payrolltypeid = %n) and EmployeeID=%n", startDate, endDate, payrollTypeID.Integer, nEmpID.Integer);
return tc.ExecuteReader(sql);
}
internal static DataSet GetEmpSalarySheetForIDLC(TransactionContext tc, DateTime dateTime, string sEmpID)
{
DataSet rootDataset = new DataSet();
DataSet tempdataset = new DataSet();
try
{
string query1 = SQLParser.MakeSQL(@"select A.EmployeeNo,A.CIFNo, A.Name,A.GName,A.GCode,A.SequenceNo,A.DName,A.Description,
SUM(A.changedamount) Amount,A.Department,A.Branch,A.DEPARTMENTID
from ( select S.EmployeeID,E.GLOBALID as CIFNo, 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 , DE.DESCRIPTION as Department,L.DESCRIPTION as Branch,DE.DEPARTMENTID
from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd,DEPARTMENT as DE,
LOCATION as L
where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID
AND E.employeeID=S.EmployeeID AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND L.LOCATIONID=S.LOCATIONID
AND S.SalaryMonth=%d and Sd.ItemGroup=8 AND sd.ItemCode not in(-133)
and DE.DEPARTMENTID=S.DEPARTMENTID AND S.EmployeeID IN(%q)
union
select S.EmployeeID,E.GLOBALID as CIFNo, 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,DE.DESCRIPTION as Department,L.DESCRIPTION as Branch,DE.DEPARTMENTID
from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd,DEPARTMENT as DE,
LOCATION as L where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID
AND E.employeeID=S.EmployeeID AND DE.DEPARTMENTID=S.DEPARTMENTID AND L.LOCATIONID=S.LOCATIONID
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.SequenceNo,A.GCode, A.DName,
A.ItemCode, A.ItemID, A.Description,A.Position ,A.Department,A.Branch,A.DEPARTMENTID,
A.CIFNo order by A.Position,A.SequenceNo ,A.EmployeeNo,A.GCode
", dateTime, sEmpID, dateTime, sEmpID);//
tempdataset = tc.ExecuteDataSet(query1);
tempdataset.Tables[0].TableName = "GrossItem";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query2 = SQLParser.MakeSQL("select E.EmployeeNo,E.GLOBALID as CIFNo, E.Name,A.GName,A.GCode,A.SequenceNo,A.DName,DE.DESCRIPTION as Department,"
+ " 'Total Gross' as Description, Sum(A.amount) as amount,L.DESCRIPTION as Branch,DE.DEPARTMENTID "
+ " 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,"
+ " DEPARTMENT DE,LOCATION L where A.EmployeeID = E.EmployeeID AND E.DEPARTMENTID=DE.DEPARTMENTID"
+ " AND E.LOCATIONID=L.LOCATIONID "
+ " group by E.EmployeeNo, E.Name,A.GName,A.SequenceNo,E.GLOBALID ,"
+ " A.GCode,A.DName ,DE.DESCRIPTION,L.DESCRIPTION,DE.DEPARTMENTID ", 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.CIFNo, A.Name,A.GName,A.GCode,A.SequenceNo,A.DName,A.Description, "
+ " SUM(A.changedamount) Amount,A.Department,A.Branch,A.DEPARTMENTID "
+ " from ("
+ " select S.EmployeeID, E.EmployeeNo, E.Name,E.GLOBALID as CIFNo, "
+ " 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 ,"
+ " DE.DESCRIPTION as Department,L.DESCRIPTION as Branch,DE.DEPARTMENTID"
+ " from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd,DEPARTMENT as DE,"
+ " LOCATION as L "
+ " 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 L.LOCATIONID=S.LOCATIONID and DE.DEPARTMENTID=S.DEPARTMENTID"
+ " AND S.EmployeeID IN(%q) "
+ " union "
+ " select S.EmployeeID, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode,E.GLOBALID as CIFNo, "
+ " sd.ItemID, sd.Description,sd.Position, -sd.changedamount,G.DESCRIPTION as GName,"
+ " G.Code as GCode,G.sequenceNo,D.Name as DName,DE.DESCRIPTION as Department,L.DESCRIPTION as Branch,DE.DEPARTMENTID "
+ " from Grades G,DESIGNATION D,Employee E, "
+ " SALARYMONTHLY S, SalaryMonthlyDetail Sd,DEPARTMENT as DE,LOCATION as L "
+ " where G.GradeID= E.GradeID "
+ " AND D.DESIGNATIONID=E.DESIGNATIONID AND E.employeeID=S.EmployeeID "
+ " AND DE.DEPARTMENTID=S.DEPARTMENTID AND L.LOCATIONID=S.LOCATIONID "
+ " 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.CIFNo,"
+ " A.DName, A.ItemCode, A.ItemID, A.Description,A.Position ,A.Department,A.Branch,A.DEPARTMENTID "
+ " order by A.EmployeeNo,A.Position,A.SequenceNo,A.GCode", dateTime, sEmpID, dateTime, sEmpID);
//+ " ", 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.Department,"
+ " A.Description, SUM(A.changedamount) Amount,A.Branch,A.DEPARTMENTID,A.CIFNo "
+ " from "
+ " ( select S.EmployeeID,E.GLOBALID as CIFNo,"
+ " E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode, sd.ItemID, sd.Description,"
+ " sd.Position, sd.changedamount,G.DESCRIPTION as GName,G.Code as GCode,DE.DEPARTMENTID,"
+ " G.SequenceNo,D.Name as DName,DE.DESCRIPTION as Department,L.DESCRIPTION as Branch "
+ " from Grades G,DESIGNATION D,Employee E,DEPARTMENT DE,LOCATION L,"
+ " SALARYMONTHLY S, SalaryMonthlyDetail Sd "
+ " where G.GradeID= E.GradeID "
+ " AND D.DESIGNATIONID=E.DESIGNATIONID AND E.employeeID=S.EmployeeID"
+ " AND E.DEPARTMENTID=DE.DEPARTMENTID AND E.LOCATIONID = L.LOCATIONID "
+ " 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,E.GLOBALID as CIFNo,"
+ " G.DESCRIPTION as GName,G.Code as GCode,G.SequenceNo,D.Name as DName,"
+ " DE.DEPARTMENTID,DE.DESCRIPTION as Department,L.DESCRIPTION as Branch "
+ " from "
+ " Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd,"
+ " DEPARTMENT DE,LOCATION L "
+ " where G.GradeID= E.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID"
+ " AND E.DEPARTMENTID=DE.DEPARTMENTID AND E.LOCATIONID = L.LOCATIONID"
+ " 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,A.Department,A.Branch,A.DEPARTMENTID"
+ " ,A.CIFNo order by A.CIFNo,A.SequenceNo,A.Position,A.GCode,A.EmployeeNo", dateTime, sEmpID, dateTime, sEmpID);
//
tempdataset = tc.ExecuteDataSet(query4);
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,A.Department,"
+ " 'UnAuthorized' as Description, Sum(A.amount) as amount,A.Branch,A.DEPARTMENTID, "
+ " E.GLOBALID as CIFNo from "
+ " ( select S.EmployeeID, Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,"
+ " G.Code as GCode,G.SequenceNo,D.Name as DName,DE.DEPARTMENTID"
+ " ,DE.DESCRIPTION as Department,L.DESCRIPTION as Branch "
+ " from DEPARTMENT DE,LOCATION L,"
+ " GRADES G,DESIGNATION D,SALARYMONTHLY S,SalaryMonthlyDetail Sd"
+ " where S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d"
+ " AND S.DEPARTMENTID=DE.DEPARTMENTID AND S.LOCATIONID = L.LOCATIONID"
+ " 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,DE.DESCRIPTION,"
+ " L.DESCRIPTION,DE.DEPARTMENTID) A, Employee E"
+ " where A.EmployeeID = E.EmployeeID "
+ " group by E.EmployeeNo, E.Name,A.GName,A.SequenceNo,A.GCode,A.DName,A.Department,"
+ " A.Branch,A.DEPARTMENTID,E.GLOBALID", dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet(query5);
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,A.Department,"
+ " 'Total Deduction' as Description, Sum(A.amount) as amount,A.Branch,A.DEPARTMENTID "
+ " ,E.GLOBALID as CIFNo from"
+ " ( select S.EmployeeID, Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,"
+ " G.Code as GCode,G.SequenceNo,D.Name as DName,DE.DEPARTMENTID,"
+ " DE.DESCRIPTION as Department,L.DESCRIPTION as Branch "
+ " from DEPARTMENT DE,LOCATION L,"
+ " GRADES G,DESIGNATION D,SALARYMONTHLY S,SalaryMonthlyDetail Sd"
+ " where S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d"
+ " AND S.DEPARTMENTID=DE.DEPARTMENTID AND S.LOCATIONID = L.LOCATIONID"
+ " 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,DE.DESCRIPTION,"
+ " L.DESCRIPTION,DE.DEPARTMENTID ) A, Employee E "
+ " where A.EmployeeID = E.EmployeeID "
+ " group by E.EmployeeNo, E.Name,A.GName,A.SequenceNo,A.GCode,A.DName ,A.Department,"
+ " A.Branch,A.DEPARTMENTID,E.GLOBALID", dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet(query6);
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,"
+ " DE.DESCRIPTION as Department,L.DESCRIPTION as Branch,DE.DEPARTMENTID"
+ " ,E.GLOBALID as CIFNo from "
+ " EMPLOYEE as E,GRADES as G,DESIGNATION D,SALARYMONTHLY as S,DEPARTMENT DE,LOCATION L,"
+ " SALARYMONTHLYDETAIL as Sd where S.SalaryMonthlyID=Sd.SalaryMonthlyID "
+ " AND S.SalaryMonth=%d AND G.GRADEID=S.GRADEID "
+ " AND E.DEPARTMENTID=DE.DEPARTMENTID AND E.LOCATIONID = L.LOCATIONID"
+ " 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 E.GLOBALID,G.SequenceNo ,G.Code,E.EMPLOYEENO ", dateTime, sEmpID);//
tempdataset = tc.ExecuteDataSet(query7);
tempdataset.Tables[0].TableName = "NetPay";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
// string query8 = SQLParser.MakeSQL(@"Select E.EMPLOYEENO,E.NAME,G.DESCRIPTION as GName,G.Code as GCode,G.SequenceNo,
// D.Name as DName ,'CPF' as Description,SD.CHANGEDAMOUNT as Amount,
// DE.DESCRIPTION as Department,L.DESCRIPTION as Branch,DE.DEPARTMENTID
// ,E.GLOBALID as CIFNo from EMPLOYEE as E,GRADES as G,DESIGNATION D,
// SALARYMONTHLY as S,SALARYMONTHLYDETAIL as Sd,DEPARTMENT DE,LOCATION L
// where S.SalaryMonthlyID=Sd.SalaryMonthlyID
// AND S.SalaryMonth=%d
// AND E.DEPARTMENTID=DE.DEPARTMENTID AND E.LOCATIONID = L.LOCATIONID
// AND G.GRADEID=S.GRADEID
// AND D.DESIGNATIONID=S.DESIGNATIONID
// AND E.EMPLOYEEID =S.EMPLOYEEID
// AND Sd.ItemGroup IN (3) AND Sd.ItemCode IN(-128)
// AND S.EmployeeID IN(%q) order by E.GLOBALID,E.EMPLOYEENO
// ,G.SequenceNo,G.Code", dateTime, sEmpID);//
// tempdataset = tc.ExecuteDataSet(query8);
// tempdataset.Tables[0].TableName = "CPF";
//rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return rootDataset;
}
internal static DataSet GetNewCCWiseSalarySummary(TransactionContext tc, DateTime dateTime, string sEmpID)
{
DataSet oSMonthlys = new DataSet();
try
{
#region Latest Old Code
string sSQL = SQLParser.MakeSQL(@"select C.CRGID as CCID,C.DESCRIPTION as CostCenter,
sum(SMD.CHANGEDAMOUNT)as NetAmount
from SALARYMONTHLY SM
inner join SALARYEMPCOSTCENTER SC on SM.EMPLOYEEID=SC.EMPLOYEEID
inner join CRG C on SC.COSTCENTERID = C.CRGID
inner join SALARYMONTHLYDETAIL SMD on SM.SALARYMONTHLYID=SMD.SALARYMONTHLYID
where SM.SalaryMonth = %d and SC.EMPLOYEEID in(%q)
and SMD.ITEMCODE=-132 And SMD.ITEMGROUP=5 And SMD.ITEMID=-132
group by C.CRGID,C.DESCRIPTION", dateTime, sEmpID);
oSMonthlys = tc.ExecuteDataSet(sSQL);
#endregion
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return oSMonthlys;
}
internal static IDataReader GetHead(TransactionContext tc, int index, DateTime salaryMonth)
{
string sSQL = "";
if (index == 0)
{
sSQL = SQLParser.MakeSQL("select * from SALARYMONTHLYDETAIL Sd,SALARYMONTHLY S where"
+ " S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d"
+ " AND Sd.ItemGroup IN (1, 8)", salaryMonth);
}
else
{
sSQL = SQLParser.MakeSQL("select * from SALARYMONTHLYDETAIL Sd,SALARYMONTHLY S where"
+ " S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d"
+ " AND Sd.ITEMGROUP in(2,3)", salaryMonth);
}
return tc.ExecuteReader(sSQL);
}
internal static IDataReader Get(TransactionContext tc, string sEmpID, DateTime fromdate, DateTime toDate)
{
string Ssql = SQLParser.MakeSQL("SELECT * FROM SalaryMonthly WHERE EmployeeID in(%q) AND SALARYMONTH between %d and %d order by EmployeeID", sEmpID, fromdate, toDate);
return tc.ExecuteReader(Ssql);
}
internal static DataSet GetEmpSalarySheetForManagement(TransactionContext tc, DateTime dateTime, string sEmpID)
{
DataSet rootDataset = new DataSet();
DataSet tempdataset = new DataSet();
try
{
string query1 = SQLParser.MakeSQL(@"select A.SalaryMonth,A.EmployeeNo,A.ItemCode,A.ItemGroup,A.ItemID, A.JOININGDATE, A.Name,A.GName,A.DName,A.GCode,A.SequenceNo, A.Description,A.changedamount
Amount from(
select S.SalaryMonth,S.EmployeeID, E.EmployeeNo, E.JOININGDATE,
E.Name,G.DESCRIPTION as GName,D.Name as DName,G.Code as GCode,G.SequenceNo,CONCAT(sd.Description,' Arrear') Description,sd.changedamount, sd.ItemGroup,sd.ItemCode, sd.ItemID,sd.Position
from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd
where G.GradeID= S.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) AND sd.changedamount<>0
UNION
select S.SalaryMonth, S.EmployeeID, E.EmployeeNo, E.JOININGDATE,
E.Name, G.DESCRIPTION as GName,D.Name as DName,G.Code as GCode, G.SequenceNo,sd.Description,sd.changedamount, sd.ItemGroup,sd.ItemCode, sd.ItemID, sd.Position
from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd
where G.GradeID= S.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) AND sd.changedamount<>0
)
A
order by A.SalaryMonth,A.EmployeeNo, A.Position, A.ItemCode,A.ItemID,A.SequenceNo,A.GCode", dateTime, sEmpID, dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet(query1);
tempdataset.Tables[0].TableName = "GrossItem";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query2 = SQLParser.MakeSQL(@"select A.SalaryMonth,E.EmployeeNo, A.ItemCode,A.ItemGroup,A.ItemID, E.JOININGDATE, E.Name,A.GName,A.GCode,A.SequenceNo,A.DName,'Total Gross' as Description,
Sum(A.amount) as amount
from
(
select S.EmployeeID,S.SalaryMonth,Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,Sd.ItemCode,Sd.ItemGroup,Sd.ItemID,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) AND sd.changedamount<>0
group by S.SalaryMonth,S.EmployeeID,G.DESCRIPTION,G.SequenceNo,G.Code,D.Name,Sd.ItemCode,Sd.ItemGroup,Sd.ItemID
UNION
select S.EmployeeID,S.SalaryMonth, -Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,Sd.ItemCode,Sd.ItemGroup,Sd.ItemID,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) AND sd.changedamount<>0
group by S.SalaryMonth,S.EmployeeID,G.DESCRIPTION,G.SequenceNo,G.Code,D.Name,Sd.ItemCode,Sd.ItemGroup,Sd.ItemID
) A, Employee E
where A.EmployeeID = E.EmployeeID
group by A.SalaryMonth,E.EmployeeNo, E.JOININGDATE, E.Name,A.ItemCode,A.ItemGroup,A.ItemID,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.JoiningDate,A.GName,A.GCode,A.SequenceNo,A.DName,
A.Description, SUM(A.changedamount) Amount,A.ItemCode,A.ItemID,A.ItemGroup
from
(select S.EmployeeID, E.EmployeeNo, E.Name,E.JoiningDate,sd.ItemGroup,sd.ItemCode,
sd.ItemID, sd.Description,sd.Position, sd.changedamount,G.DESCRIPTION GName,G.Code GCode,G.SequenceNo,D.Name DName
from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd
where G.GradeID= S.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) AND sd.changedamount<>0
union
select S.EmployeeID, E.EmployeeNo, E.Name,E.JoiningDate,sd.ItemGroup,sd.ItemCode,
sd.ItemID, sd.Description,sd.Position, -sd.changedamount,G.DESCRIPTION GName,G.Code GCode,G.sequenceNo,D.Name DName
from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd
where G.GradeID= S.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) AND sd.changedamount<>0
) A group by
A.EmployeeID, A.EmployeeNo, A.Name,A.GName,A.SequenceNo,A.GCode,A.DName,
A.ItemCode, A.ItemID,A.ItemGroup, A.Description,A.Position,A.JoiningDate order by A.EmployeeNo,A.Position,A.SequenceNo,A.GCode",
dateTime, sEmpID, dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet(query3);
tempdataset.Tables[0].TableName = "DeductItem";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query6 = SQLParser.MakeSQL(@"select A.SalaryMonth,E.EmployeeNo,A.ItemCode,A.ItemGroup,A.ItemID, E.JOININGDATE, E.Name,A.GName,A.GCode,A.SequenceNo,A.DName,
'Total Deduction' as Description,
Sum(A.amount) as amount
from(
select S.SalaryMonth,S.EmployeeID, Sum(sd.changedamount) as Amount,Sd.ItemCode,Sd.ItemGroup,Sd.ItemID,
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.SalaryMonth,S.EmployeeID,G.DESCRIPTION,G.SequenceNo,G.Code,D.Name ,Sd.ItemCode,Sd.ItemGroup,Sd.ItemID
) A,Employee E
where A.EmployeeID = E.EmployeeID
group by A.SalaryMonth,E.EmployeeNo,A.ItemCode,A.ItemGroup,A.ItemID, E.JOININGDATE, E.Name,A.GName,A.SequenceNo,A.GCode,A.DName", dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet(query6);
tempdataset.Tables[0].TableName = "TotalDeduction";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query7 = SQLParser.MakeSQL(@"Select S.SalaryMonth,E.EMPLOYEENO, Sd.ItemCode,Sd.ItemGroup,Sd.ItemID, E.JOININGDATE,E.NAME,G.DESCRIPTION GName,G.Code GCode,
G.SequenceNo,D.Name DName ,'Net Pay' Description,SD.CHANGEDAMOUNT Amount
from
EMPLOYEE E,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 E.EMPLOYEEID =S.EMPLOYEEID
and Sd.ItemGroup IN (5) AND Sd.ItemCode IN(-132) AND S.EmployeeID IN(%q)
order by S.SalaryMonth,G.SequenceNo,G.Code,E.EMPLOYEENO", dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet(query7);
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 GetCCWiseSalarySheetDetail(TransactionContext tc, DateTime dSMonthDate, string sEmpID)
{
DataSet oSMonthlys = new DataSet();
DataSet rootDataset = new DataSet();
try
{
#region Latest Old Code
string Sql = SQLParser.MakeSQL(@"Select Emp.EmployeeNo,Emp.Name,CC.Code,Dep.Description,
sum(SMD.ChangedAmount * (SEmpCC.Percentage)/100) as 'GrossAmount'
from Employee as Emp,Department as Dep,SalaryMonthly as SM,CRG as CC,
SalaryMonthlyDetail as SMD,SalaryEmpCostCenter as SEmpCC
where Emp.EmployeeID=SM.EmployeeID
and Emp.DepartmentID=SM.DepartmentID
and SM.SalaryMonthlyID=SMD.SalaryMonthlyID
and SEmpCC.SalaryMonthlyID=SMD.SalaryMonthlyID
and Dep.DepartmentID=SM.DepartmentID
and CC.CRGID=SEmpCC.CostCenterID
and Emp.EmployeeID=SEmpCC.EmployeeID
and SM.SalaryMonth=%d
and SMD.ItemGroup=1 and SM.EmployeeId in(%q)
group by Emp.EmployeeNo,Emp.Name,CC.Code,Dep.Description,SEmpCC.Percentage
order by Emp.EmployeeNo", dSMonthDate, sEmpID);
oSMonthlys = tc.ExecuteDataSet(Sql);
oSMonthlys.Tables[0].TableName = "GrossAmount";
rootDataset.Tables.Add(oSMonthlys.Tables[0].Copy());
string sqlArrear = SQLParser.MakeSQL(@"Select Emp.EmployeeNo,Emp.Name,CC.Code,SECC.Percentage,Dep.Description,
SMD.ItemGroup,Sum((SMD.ChangedAmount * (SECC.Percentage)/100)) as GrossArrear
from Employee as Emp,Department as Dep,CRG as CC,SalaryMonthly as SM,
SalaryMonthlyDetail as SMD,SalaryEmpCostCenter as SECC
where Emp.DepartmentID=Dep.DepartmentID
and Emp.DepartmentID=SM.DepartmentID
and SM.DepartmentID=Dep.DepartmentID
and Emp.EmployeeID=SM.EmployeeID
and SM.EmployeeID=SECC.EmployeeID
and CC.CrgID=SECC.CostCenterID
and SECC.SalaryMonthlyID=SM.SalaryMonthlyID
and SM.SalaryMonthlyID=SMD.SalaryMonthlyID
and SM.SalaryMonth=%d and SMD.ItemGroup in(8) and SM.EmployeeID in(%q)
group by Emp.EmployeeNo,Emp.Name,CC.Code,Dep.Description,SECC.Percentage,
SMD.ItemGroup order by Emp.EmployeeNo", dSMonthDate, sEmpID);
oSMonthlys = tc.ExecuteDataSet(sqlArrear);
oSMonthlys.Tables[0].TableName = "GrossArrear";
rootDataset.Tables.Add(oSMonthlys.Tables[0].Copy());
string sSQL1 = SQLParser.MakeSQL(@"Select Emp.EmployeeNo,Emp.Name,CC.Code,Dep.Description,
sum(SMD.ChangedAmount * (SEmpCC.Percentage)/100) as 'PFAmount'
from Employee as Emp,Department as Dep,SalaryMonthly as SM,CRG as CC,
SalaryMonthlyDetail as SMD,SalaryEmpCostCenter as SEmpCC
where Emp.EmployeeID=SM.EmployeeID
and Emp.DepartmentID=SM.DepartmentID
and SM.SalaryMonthlyID=SMD.SalaryMonthlyID
and SEmpCC.SalaryMonthlyID=SMD.SalaryMonthlyID
and Dep.DepartmentID=SM.DepartmentID
and CC.CRGID=SEmpCC.CostCenterID
and Emp.EmployeeID=SEmpCC.EmployeeID
and SM.SalaryMonth=%d
and SMD.ItemCode=-128 and SMD.ItemGroup=3 and SM.EmployeeId in(%q)
group by Emp.EmployeeNo,Emp.Name,CC.Code,Dep.Description,SEmpCC.Percentage
order by Emp.EmployeeNo", dSMonthDate, sEmpID);
oSMonthlys = tc.ExecuteDataSet(sSQL1);
oSMonthlys.Tables[0].TableName = "PFAmount";
rootDataset.Tables.Add(oSMonthlys.Tables[0].Copy());
#endregion
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return rootDataset;
}
internal static DataSet GetSMAndBPForRewardYear(TransactionContext tc, string employeeID, DateTime currentYearFromDate, DateTime currentYearToDate, DateTime previousYearFromDate, DateTime previousYearToDate)
{
DataSet rootDataset = new DataSet();
DataSet dsItems = new DataSet();
try
{
string salaryMonthlySql = SQLParser.MakeSQL(@"Select SUM(SMD.ChangedAmount) As CurrentYearAmount, 0 As PreviousYearAmount, SMD.DESCRIPTION As ItemDescription, SMD.ITEMID, SM.Remarks
From SALARYMONTHLYDETAIL As SMD
Join SalaryMonthly As SM On SM.SALARYMONTHLYID = SMD.SALARYMONTHLYID
Where SM.EMPLOYEEID IN(%s) And SMD.ITEMGROUP IN('1') And SMD.ItemCode IN('-101', '-113') And SM.SalaryMonth Between %d And %d
Group By SMD.ITEMID, SMD.DESCRIPTION, SM.Remarks
Union
Select 0 As CurrentYearAmount, SUM(SMD.ChangedAmount) As PreviousYearAmount, SMD.DESCRIPTION As ItemDescription, SMD.ITEMID, SM.Remarks
From SALARYMONTHLYDETAIL As SMD
Join SalaryMonthly As SM On SM.SALARYMONTHLYID = SMD.SALARYMONTHLYID
Where SM.EMPLOYEEID IN(%s) And SMD.ITEMGROUP IN('1') And SMD.ItemCode IN('-101', '-113') And SM.SalaryMonth Between %d And %d
Group By SMD.ITEMID, SMD.DESCRIPTION, SM.Remarks
Order By SMD.ITEMID", employeeID, currentYearFromDate, currentYearToDate, employeeID, previousYearFromDate, previousYearToDate);
dsItems = tc.ExecuteDataSet(salaryMonthlySql);
dsItems.Tables[0].TableName = "CompensationTable";
rootDataset.Tables.Add(dsItems.Tables[0].Copy());
string bonusProcessSql = SQLParser.MakeSQL(@"Select SUM(BPD.BonusAmount) As CurrentYearAmount, 0 As PreviousYearAmount, B.Code, B.Name as ItemDescription, BP.Remarks
From BONUSPROCESSDETAIL As BPD
Join BONUSPROCESS As BP On BP.BONUSPROCESSID = BPD.BonusProcessID
Join Bonus As B On B.BonusID = BP.BONUSID
Where BPD.EmployeeID In(%s) And B.Code In('002', '003', '005', '006', '007') And BP.BONUSMONTH Between %d And %d
Group By B.Code, BP.BONUSMONTH, B.Name, BP.Remarks
Union
Select 0 As CurrentYearAmount, SUM(BPD.BonusAmount) As PreviousYearAmount, B.Code, B.Name as ItemDescription, BP.Remarks
From BONUSPROCESSDETAIL As BPD
Join BONUSPROCESS As BP On BP.BONUSPROCESSID = BPD.BonusProcessID
Join Bonus As B On B.BonusID = BP.BONUSID
Where BPD.EmployeeID In(%s) And B.Code In('002', '003', '005', '006', '007') And BP.BONUSMONTH Between %d And %d
Group By B.Code, BP.BONUSMONTH, B.Name, BP.Remarks
Order By B.Name", employeeID, currentYearFromDate, currentYearToDate, employeeID, previousYearFromDate, previousYearToDate);
dsItems = tc.ExecuteDataSet(bonusProcessSql);
dsItems.Tables[0].TableName = "VariablePay";
rootDataset.Tables.Add(dsItems.Tables[0].Copy());
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return rootDataset;
}
internal static DataSet CostCenterCount(TransactionContext tc, DateTime dSMonthDate)
{
DataSet oSMonthlys = new DataSet();
try
{
#region Latest Old Code
string Sql = SQLParser.MakeSQL(@"select distinct costcenterid from salaryempcostcenter smd where salarymonthlyid in(select salarymonthlyid from salarymonthly where salarymonth='30 sep 2013')", dSMonthDate);
oSMonthlys = tc.ExecuteDataSet(Sql);
#endregion
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return oSMonthlys;
}
internal static DataSet GetWPPFByGrade(TransactionContext tc, int nYear)
{
DataSet oSMonthlys = new DataSet();
try
{
#region Latest Old Code
string Sql = SQLParser.MakeSQL(@"select * from GradeWPPF where EffectYear=%n", nYear);
oSMonthlys = tc.ExecuteDataSet(Sql);
#endregion
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return oSMonthlys;
}
internal static DataSet GetWPPFFormEmployee(TransactionContext tc, int nYear)
{
DataSet oSMonthlys = new DataSet();
try
{
#region Latest Old Code
string Sql = SQLParser.MakeSQL(@"select * from EmployeeWWF where WWFYear=%n", nYear);
oSMonthlys = tc.ExecuteDataSet(Sql);
#endregion
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return oSMonthlys;
}
internal static DataSet GetBasic(TransactionContext tc)
{
DataSet oSMonthlys = new DataSet();
try
{
#region Latest Old Code
string Sql = SQLParser.MakeSQL(@"WITH cte AS
(
SELECT DISTINCT employeeid,basicsalary,dense_rank()over(partition BY employeeid order by employeeid,basicsalary desc)rownum FROM GRADESALARYASSIGNMENT
)
SELECT employeeid,basicsalary
FROM cte where rownum <= 2 order by employeeid,basicsalary");
oSMonthlys = tc.ExecuteDataSet(Sql);
#endregion
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return oSMonthlys;
}
internal static DataSet GetWPPFClaim(TransactionContext tc, ID empID, int previousYear, int currentYear)
{
string Sql = SQLParser.MakeSQL(@"Select * From WPPFClaim WHERE EmployeeID = %n AND EffectYear >= %n AND EffectYear <= %n", empID.Integer, previousYear, currentYear);
return tc.ExecuteDataSet(Sql);
}
internal static DataSet GetGrade(TransactionContext tc)
{
DataSet oSMonthlys = null;
string Sql = SQLParser.MakeSQL(@"WITH cte AS
(SELECT DISTINCT EmployeeID, GradeID, GradesalaryID, dense_rank()over(partition BY EmployeeID order by GradesalaryID DESC)rownum FROM GRADESALARYASSIGNMENT)
SELECT GradesalaryID, EmployeeID, GradeID
FROM cte where rownum <= 2 order by EmployeeID");
oSMonthlys = tc.ExecuteDataSet(Sql);
return oSMonthlys;
}
internal static DataSet GetCustomDataTable(TransactionContext tc,string sQuery)
{
return tc.ExecuteDataSet(sQuery);
}
internal static DataSet GetGradeWPPF(TransactionContext tc, int previousYear, int currentYear, int gradeID)
{
string Sql = SQLParser.MakeSQL(@"Select * From GradeWPPF WHERE EffectYear >= %n AND EffectYear <= %n AND GradeID = %n", previousYear, currentYear, gradeID);
return tc.ExecuteDataSet(Sql);
}
internal static DataSet GetWPPF(TransactionContext tc, int employeeId, int previousYear, int currentYear)
{
string Sql = SQLParser.MakeSQL(@"Select * From WPPF WHERE EmployeeID = %n AND EffectYear >= %n AND EffectYear <= %n", employeeId, previousYear, currentYear);
return tc.ExecuteDataSet(Sql);
}
internal static DataSet GetWWF(TransactionContext tc, int employeeId, int previousYear, int currentYear)
{
string Sql = SQLParser.MakeSQL(@"Select * From WWF WHERE EmployeeID = %n AND EffectYear >= %n AND EffectYear <= %n", employeeId, previousYear, currentYear);
return tc.ExecuteDataSet(Sql);
}
internal static DataSet GetCalCulatedAmountByAllowDeductID(TransactionContext tc, ID empID, ID allowDeductID, DateTime salaryMonth)
{
string sql = SQLParser.MakeSQL(@"Select SMD.* from SALARYMONTHLYDETAIL As SMD
Left Join SALARYMONTHLY As SM On SM.SALARYMONTHLYID = SMD.SALARYMONTHLYID
Where SM.EMPLOYEEID = %n AND SMD.ITEMID = %n AND SM.SalaryMonth = %d", empID.Integer, allowDeductID.Integer, salaryMonth);
return tc.ExecuteDataSet(sql);
}
internal static IDataReader GetLastSalaryMonthDetails(TransactionContext tc, ID empID)
{
string sql = string.Empty;
sql = SQLParser.MakeSQL(@"SELECT * FROM SALARYMONTHLY WHERE EMPLOYEEID=%n
AND salarymonth=(SELECT max(salarymonth) FROM SALARYMONTHLY WHERE EMPLOYEEID=%n)",empID.Integer,empID.Integer);
return tc.ExecuteReader(sql);
}
internal static DataSet GetWPPF(TransactionContext tc, int empID)
{
string sql = string.Empty;
sql = SQLParser.MakeSQL(@"SELECT * FROM WPPF WHERE employeeID = %n ORDER BY EffectYear", empID);
return tc.ExecuteDataSet(sql);
}
}
#endregion
}