EchoTex_Payroll/HRM.DA/DA/Salary/SalaryMonthlyDA.cs

7252 lines
604 KiB
C#
Raw Normal View History

2024-10-14 10:01:49 +06:00
using HRM.BO;
using Ease.Core.DataAccess;
using System;
using System.Data;
using Ease.Core.Utility;
namespace HRM.DA
{
#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,detailid ,salaryWithHeld, EuroRate)"
+ " 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,%n, %n, %n)", item.ID, item.SalaryMonth, item.EmployeeID, item.CategoryID, item.DepartmentID,
item.DesignationID, item.LocationID, item.GradeID, item.IsFinalized, DataReader.GetNullValue(item.PaymentDate),
item.PrevMonthBasic, item.ThisMonthBasic, item.IsConfirmed, item.IsEligibleOT,
DataReader.GetNullValue(item.ReligionID), DataReader.GetNullValue(item.PayrollTypeID), DataReader.GetNullValue(item.OutPayBranchID),
item.OutPayAccountNo, item.Remarks, item.AccountNo, DataReader.GetNullValue(item.BranchID), item.DesignationText,
item.SalaryProcessID, item.PFMembershipType, item.Gender, item.ThisMonthGross, 0, item.salaryWithHeld, item.EuroRate);
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, item.SalaryMonthlyID, item.ItemID, DataReader.GetNullValue(item.SupportID), 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, item.ItemCode,
item.itemGroupCode, item.ItemID);
}
internal static DataTable NotApprovedBonus(TransactionContext tc, int payrollTypeID)
{
DataTable oEmpBasicGrades = new DataTable();
try
{
oEmpBasicGrades = tc.ExecuteDataTable(
@"select distinct e.EMPLOYEENO, e.NAME, bonus.NAME Bonus from bonusprocess b, bonusprocessDetail bp, employee e, BONUS
where b.bonusprocessid =bp.bonusprocessid and bp.EMPLOYEEID = e.EMPLOYEEID and bonus.BONUSID = b.BONUSID
and b.ISTAXPROCESS =1 and b.ISAPPROVE =0 and e.payrolltypeid =%n and e.status =%n",
payrollTypeID, (int)EnumEmployeeStatus.Live);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return oEmpBasicGrades;
}
internal static void Insert(TransactionContext tc, SalaryEmpCostCenter item)
{
tc.ExecuteNonQuery("INSERT INTO SalaryEmpCostCenter(SALARYMONTHLYID, COSTCENTERID, PERCENTAGE, EMPLOYEEID)" +
" VALUES( %n, %n, %n, %n)", item.SalaryMontlyID, item.CostCenterID, item.Percentage, item.EmployeeID);
}
#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, salaryWithHeld=%n, EuroRate=%n"
+ " WHERE SalaryMonthlyID=%n",
item.SalaryMonth, item.EmployeeID, item.CategoryID, item.DepartmentID, item.DesignationID,
item.LocationID, item.GradeID, item.IsFinalized, item.PaymentDate,
item.PrevMonthBasic, item.ThisMonthBasic, item.IsConfirmed,
item.IsEligibleOT, item.ReligionID, item.PayrollTypeID, DataReader.GetNullValue(item.OutPayBranchID),
item.OutPayAccountNo, item.Remarks, item.AccountNo, DataReader.GetNullValue(item.BranchID),
item.SalaryProcessID, item.PFMembershipType, item.Gender, item.salaryWithHeld, item.EuroRate, item.ID);
}
#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 GetbyId(TransactionContext tc, int salarymonthlyID)
{
return tc.ExecuteReader("SELECT * FROM SalaryMonthly where SALARYMONTHLYID=%n", salarymonthlyID);
}
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, int payrollTypeID)
{
string sql = SQLParser.MakeSQL("SELECT * FROM SalaryMonthly where SalaryMonth =%d and payrolltypeid=%n", salaryMonth, payrollTypeID);
return tc.ExecuteReader(sql);
}
internal static IDataReader GetDetail(TransactionContext tc, DateTime salaryMonth, int payrollTypeID)
{
string sSQL = SQLParser.MakeSQL("SELECT SD.* FROM SalaryMonthlyDetail SD, SalaryMonthly SM WHERE "
+ " SD.SalaryMonthlyID=SM.SalaryMonthlyID AND SM.SalaryMonth =%d AND SM.payrolltypeid=%n Order by SM.SalaryMonthlyID, SD.Position ", salaryMonth, payrollTypeID);
return tc.ExecuteReader(sSQL);
}
internal static IDataReader GetDetail(TransactionContext tc, DateTime salaryMonth)
{
string sSQL = SQLParser.MakeSQL("SELECT SD.* FROM SalaryMonthlyDetail SD, SalaryMonthly SM WHERE "
+ " SM.SalaryMonth =%d AND SD.SalaryMonthlyID=SM.SalaryMonthlyID Order by SM.SalaryMonthlyID, SD.Position ", salaryMonth);
return tc.ExecuteReader(sSQL);
}
internal static IDataReader GetHistory(TransactionContext tc, int payrolltypeid, string empIn,
DateTime fromMonth, DateTime toMonth)
{
return tc.ExecuteReader(@"SELECT SM.SalaryMonth, SM.EmployeeID, SD.ITEMID, SD.SUPPORTID, "
+ " SD.CHANGEDAMOUNT Amount, SD.ITEMCODE, SD.ITEMGROUP "
+ " FROM SalaryMonthlyDetail SD, SalaryMonthly SM WHERE "
+ " SM.SalaryMonth BETWEEN %d and %d AND SD.SalaryMonthlyID=SM.SalaryMonthlyID " +
"AND SM.payrolltypeid=%n and SM.EmployeeID IN (%q) Order by SM.EmployeeID, SM.SalaryMonth, SD.Position "
, fromMonth, toMonth, payrolltypeid, empIn);
}
/*internal static IDataReader Get(TransactionContext tc, int nID)
{
return tc.ExecuteReader("SELECT * FROM SalaryMonthly WHERE SalaryMonthlyID=%n", nID);
}*/
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)
{
string sTableName;
sEmpID = IDHelper.GetIDs(tc, sEmpID, out sTableName);
IDataReader dr = tc.ExecuteReader("SELECT * FROM SalaryMonthly WHERE EmployeeID in(%q) AND SALARYMONTH=%d order by DepartmentID,EmployeeID", sEmpID, dMonthDate);
if (sTableName != "")
tc.ExecuteNonQuery("Drop TAble %q", sTableName);
return dr;
}
internal static IDataReader GetForWTP(TransactionContext tc, string sEmpID, DateTime dMonthDate)
{
string sTableName;
sEmpID = IDHelper.GetIDs(tc, sEmpID, out sTableName);
IDataReader dr = tc.ExecuteReader("SELECT * FROM SalaryMonthly WHERE EmployeeID in(%q) AND SALARYMONTH=%d order by EmployeeID", sEmpID, dMonthDate);
if (sTableName != "")
tc.ExecuteNonQuery("Drop TAble %q", sTableName);
return dr;
}
internal static bool IsSalaryProcessed(TransactionContext tc, int employeeId, DateTime salaryMonth)
{
object isprocessed = tc.ExecuteScalar("SELECT count(*) FROM SalaryMonthly WHERE EmployeeID=%n AND SalaryMonth=%d", employeeId, salaryMonth);
if (isprocessed == DBNull.Value)
return false;
if (Convert.ToInt32(isprocessed) == 0) return false;
else return true;
}
internal static bool IsSalaryProcessed(TransactionContext tc, DateTime salaryMonth)
{
object isprocessed = tc.ExecuteScalar("SELECT count(*) FROM SalaryMonthly WHERE SalaryMonth=%d", 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, int payrollTypeID)
{
object isprocessed = tc.ExecuteScalar("SELECT count(*) FROM SALARYPROCESS WHERE SalaryMonth=%d AND ShowINDesktop=1 AND PayrollTypeID=%n", salaryMonth, payrollTypeID);
if (isprocessed == DBNull.Value)
return false;
if (Convert.ToInt32(isprocessed) == 0) return false;
else return true;
}
internal static bool IsPermanentEmp(TransactionContext tc, int employeeId, DateTime salaryMonth, int payrollTypeID)
{
object isprocessed = tc.ExecuteScalar("SELECT count(*) FROM SalaryMonthly WHERE EmployeeID=%n AND SalaryMonth=%d AND PayrollTypeID=%n", employeeId, salaryMonth, payrollTypeID);
if (isprocessed == DBNull.Value)
return false;
if (Convert.ToInt32(isprocessed) == 0) return false;
else return true;
}
internal static int GetUnAuthorizeDays(TransactionContext tc, int 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, salaryMonth,
EnumSalaryGroup.Miscellaneous, EnumSalaryItemCode.Tot_UnauthLeave_Days);
if (leaveDays == DBNull.Value)
return 0;
return Convert.ToInt32(leaveDays);
}
internal static int GetTotalEmp(TransactionContext tc, int SProcessID)
{
int empCount = 0;
object obj = tc.ExecuteScalar("Select COUNT(*) from SALARYMONTHLY where SALARYPROCESSID=%n", SProcessID);
if (obj != null)
{
empCount = Convert.ToInt32(obj);
}
else
{
empCount = 0;
}
return empCount;
}
internal static IDataReader GetByProcessID(TransactionContext tc, int SProcessID)
{
return tc.ExecuteReader("Select * from SALARYMONTHLY where SALARYPROCESSID=%n", SProcessID);
}
internal static bool IsSalaryFinalized(TransactionContext tc, int employeeId, DateTime salaryMonth)
{
object isprocessed = tc.ExecuteScalar("SELECT count(*) FROM SalaryMonthly WHERE EmployeeID=%n AND SalaryMonth=%d AND ISFINALIZED=%b", employeeId, salaryMonth, true);
if (isprocessed == DBNull.Value)
return false;
if (Convert.ToInt32(isprocessed) == 0) return false;
else return true;
}
internal static bool IsSalaryFinalized(TransactionContext tc, DateTime salaryMonth)
{
object isprocessed = tc.ExecuteScalar("SELECT count(*) FROM SalaryMonthly WHERE SalaryMonth=%d AND ISFINALIZED=%b", salaryMonth, true);
if (isprocessed == DBNull.Value)
return false;
if (Convert.ToInt32(isprocessed) == 0) return false;
else return true;
}
internal static IDataReader GetSalaryDetail(TransactionContext tc, int nID)
{
return tc.ExecuteReader("SELECT * FROM SalaryMonthlyDetail WHERE SalaryMonthlyID=%n", nID);
}
internal static IDataReader GetSalaryDetail(TransactionContext tc, string nIDs)
{
string sTableName;
nIDs = IDHelper.GetIDs(tc, nIDs, out sTableName);
IDataReader dr = tc.ExecuteReader("SELECT * FROM SalaryMonthlyDetail WHERE SalaryMonthlyID in (%q)", nIDs);
if (sTableName != "")
tc.ExecuteNonQuery("Drop TAble %q", sTableName);
return dr;
}
internal static IDataReader GetEmpCostCenter(TransactionContext tc, int nID)
{
string sSQL = SQLParser.MakeSQL("SELECT * FROM SalaryEmpCostCenter WHERE SalaryMonthlyID=%n", nID);
return tc.ExecuteReader(sSQL);
}
internal static DataSet GetSumOnRange(TransactionContext tc, string sEmpID, DateTime fromDate, DateTime toDate, EnumSalaryGroup groupCode, EnumSalaryItemCode itemCode, int itemId, int payrollTypeID)
{
DataSet oSMonthlys = new DataSet();
try
{
string sTableName;
sEmpID = IDHelper.GetIDs(tc, sEmpID, out sTableName);
string sql = SQLParser.MakeSQL("SELECT EmployeeID, SUM(sd.ChangedAmount) as Amount FROM SalaryMonthlyDetail sd, SalaryMonthly s WHERE"
+ " sd.ItemGroup=%n AND sd.ItemCode=%n and sd.itemId==%n "
+ " and s.EmployeeID in (%q) AND s.SalaryMonth>=%d AND s.SalaryMonth<=%d AND s.WithNoDetail=%b and s.PayrollTypeID=%n AND s.SalaryMonthlyID=sd.SalaryMonthlyID GROUP BY employeeID"
, groupCode, itemCode, itemId, sEmpID, fromDate, toDate, false, payrollTypeID);
oSMonthlys = tc.ExecuteDataSet(sql);
if (sTableName != "")
tc.ExecuteNonQuery("Drop TAble %q", sTableName);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return oSMonthlys;
}
internal static double GetSumOnRange(TransactionContext tc, int employeeId,
DateTime fromDate, DateTime toDate, EnumSalaryGroup groupCode,
EnumSalaryItemCode itemCode, int itemId, int 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, fromDate, toDate, false, SystemInformation.CurrentSysInfo.PayrollTypeID);
//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, fromDate, toDate, false, SystemInformation.CurrentSysInfo.PayrollTypeID);
string sSQL = SQLParser.MakeSQL("SELECT SUM(sd.ChangedAmount) FROM SalaryMonthlyDetail sd, SalaryMonthly s WHERE"
+ " sd.ItemGroup=%n AND sd.ItemCode=%n and sd.itemId==%n "
+ " and s.EmployeeID=%n AND s.SalaryMonth>=%d AND s.SalaryMonth<=%d AND s.WithNoDetail=%b and s.PayrollTypeID=%n AND s.SalaryMonthlyID=sd.SalaryMonthlyID "
, groupCode, itemCode, itemId, employeeId, fromDate, toDate, false, payrollTypeID);
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);
// amount = tc.ExecuteScalar(sTempSQL);
// return Convert.ToDouble(amount);
//}
//else return Convert.ToDouble(amount);
}
internal static double GetSumOnRangeOnRound(TransactionContext tc, int employeeId,
DateTime fromDate, DateTime toDate, EnumSalaryGroup groupCode,
EnumSalaryItemCode itemCode, int itemId, int 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, fromDate, toDate, false, SystemInformation.CurrentSysInfo.PayrollTypeID);
//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, fromDate, toDate, false, SystemInformation.CurrentSysInfo.PayrollTypeID);
string sSQL = SQLParser.MakeSQL("SELECT SUM(Round(sd.ChangedAmount,0)) FROM SalaryMonthlyDetail sd, SalaryMonthly s WHERE"
+ " sd.ItemGroup=%n AND sd.ItemCode=%n and sd.itemId==%n "
+ " and s.EmployeeID=%n AND s.SalaryMonth>=%d AND s.SalaryMonth<=%d AND s.WithNoDetail=%b and s.PayrollTypeID=%n AND s.SalaryMonthlyID=sd.SalaryMonthlyID "
, groupCode, itemCode, itemId, employeeId, fromDate, toDate, false, payrollTypeID);
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);
// amount = tc.ExecuteScalar(sTempSQL);
// return Convert.ToDouble(amount);
//}
//else return Convert.ToDouble(amount);
}
internal static double GetPrvTaxAmount(TransactionContext tc, EnumIncomeTaxDataFrom dataFrom, int 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);
// 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);
}
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);
}
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);
}
amount = tc.ExecuteScalar(sTempSQL);
return Convert.ToDouble(amount);
}
else return Convert.ToDouble(amount);
}
internal static double GetAmountOnDateDiff(TransactionContext tc, int employeeId,
DateTime fromDate, DateTime toDate, EnumSalaryGroup groupCode,
EnumSalaryItemCode itemCode, int itemId, int 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, fromDate, toDate, false, payrollTypeID);
if (amount == DBNull.Value)
return 0;
else return Convert.ToDouble(amount);
}
internal static double GetThisMonthBasicOnDateDiff(TransactionContext tc, int employeeId,
DateTime fromDate, DateTime toDate, EnumSalaryGroup groupCode,
EnumSalaryItemCode itemCode, int itemId, int payrollTypeID)
{
string sQuary = SQLParser.MakeSQL(@"Select SUM(SM.ThisMonthBasic) from SalaryMonthly SM ,SalaryMonthlyDetail 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, fromDate, toDate, payrollTypeID);
object amount = tc.ExecuteScalar(sQuary);
if (amount == DBNull.Value)
return 0;
else return Convert.ToDouble(amount);
}
////////////////////////////////////////////////////////////////////////////////////////////
internal static double GetAmountOnDateDiffForAll(TransactionContext tc, int employeeId,
DateTime fromDate, DateTime toDate, int 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, fromDate, toDate, false, payrollTypeID);
if (amount == DBNull.Value)
return 0;
else return Convert.ToDouble(amount);
}
///////////////////////////////////////////////////////////////////////////////////////////
internal static double GetUnAuthorizeAmountOnDateRange(TransactionContext tc, int employeeId, DateTime fromDate, DateTime toDate, EnumSalaryGroup groupCode)
{
object amount = tc.ExecuteScalar("Select Sum(ChangedAmount) Amount from SalaryMonthlyDetail SMD"
+ " where SMD.SalaryMonthlyID in("
+ " Select SalaryMonthlyID from SalaryMonthly SM"
+ " where SM.SalaryMonth between %d and %d"
+ " AND SM.EmployeeID=%n) and SMD.ItemGroup=%n", fromDate, toDate, employeeId, groupCode);
if (amount == DBNull.Value)
return 0;
else return Convert.ToDouble(amount);
}
//internal static double GetGrossOnRange(TransactionContext tc, int 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, 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, fromDate, toDate, false);
// if (amount == DBNull.Value)
// return 0;
// else return Convert.ToDouble(amount);
//}
internal static DataSet GetEmpPaySlipGrossForOthersNew(TransactionContext tc, DateTime dateTime, string sEmpID)
{
DataSet oSMonthlys = new DataSet();
try
{
string sSQL = SQLParser.MakeSQL(@"SELECT Distinct E.NAME Name,E.EMPLOYEENO,G.CODE Grade, DG.Name Designation,L.Description LName,
D.DESCRIPTION Department,B.NAME BName,sm.THISMONTHBASIC ActualBasic,CAST(E.PAYMENTMODE as varchar(50)) as PAYMENTMODE ,
SM.ACCOUNTNO,SM.SalaryMonth,cat.DESCRIPTION Category,E.JOININGDATE,E.TINNo,
E.DEPARTMENTID, E.OUTPAYACCOUNTNO OutAccountNo, B2.NAME OutBank
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 LOCATION L on SM.LOCATIONID=L.LOCATIONID
left outer join BRANCHES Br on SM.BRANCHID=Br.BRANCHID
left outer join BANKS B on Br.BANKID=B.BANKID
left outer join BRANCHES Br2 on E.OUTPAYBRANCHID = Br2.BRANCHID
left outer join BANKS B2 on Br2.BANKID=B2.BANKID
inner join CATEGORY cat on E.CATEGORYID=cat.CATEGORYID
inner join SALARYMONTHLYDETAIL SMD on SM.SALARYMONTHLYID=SMD.SALARYMONTHLYID
AND SM.SalaryMonth=%d AND SMD.ITEMGROUP IN(1,2,8)
AND SM.EmployeeID IN(%q) ORDER BY E.EmployeeNo", dateTime, sEmpID);
DataTable dtTemp = tc.ExecuteDataSet(sSQL).Tables[0];
dtTemp.TableName = "PayslipBasic";
oSMonthlys.Tables.Add(dtTemp.Copy());
sSQL = SQLParser.MakeSQL(@"SELECT E.EmployeeID,E.NAME Name,E.EMPLOYEENO,G.CODE Grade, DG.Name Designation,L.Description LName,
D.DESCRIPTION Department,B.NAME BName,sm.THISMONTHBASIC ActualBasic,E.PAYMENTMODE,
SM.ACCOUNTNO,SM.SalaryMonth,SMD.DESCRIPTION Description,SMD.ITEMGROUP,SM.ISFINALIZED,
SMD.CHANGEDAMOUNT,SMD.ItemCode,SMD.ItemID,cat.DESCRIPTION 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 D on SM.DEPARTMENTID=D.DEPARTMENTID
inner join DESIGNATION DG on SM.DESIGNATIONID =DG.DESIGNATIONID
inner join LOCATION L on SM.LOCATIONID=L.LOCATIONID
left outer join BRANCHES Br on SM.BRANCHID=Br.BRANCHID
left outer join BANKS B on Br.BANKID=B.BANKID
inner join CATEGORY cat on E.CATEGORYID=cat.CATEGORYID
inner join SALARYMONTHLYDETAIL SMD on 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);
dtTemp = tc.ExecuteDataSet(sSQL).Tables[0];
dtTemp.TableName = "PayslipGross";
oSMonthlys.Tables.Add(dtTemp.Copy());
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return oSMonthlys;
}
internal static DataSet GetEmpPaySlipGrossForOthers(TransactionContext tc, DateTime dateTime, string sEmpID)
{
DataSet oSMonthlys = new DataSet();
DataTable tempDt = new DataTable();
try
{
string sSQL = SQLParser.MakeSQL(@"SELECT E.EmployeeID,E.NAME Name,E.EMPLOYEENO,G.CODE Grade,DG.[Name] 'Designation',L.Description as LName,
E.CategoryID,D.DESCRIPTION Department,B.NAME as BName,SM.THISMONTHGROSS ActualBasic,CAST(E.PAYMENTMODE as varchar(50)) as 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.TINNo,
E.DEPARTMENTID,E.TINNO
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 E.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) ORDER BY E.EmployeeNo, Position", dateTime, sEmpID);
tempDt = tc.ExecuteDataTable(sSQL);
tempDt.TableName = "PayslipBasic";
oSMonthlys.Tables.Add(tempDt);
sSQL = SQLParser.MakeSQL(@"SELECT E.NAME Name,E.EMPLOYEENO,E.EMPLOYEEID,G.CODE Grade, DG.Name Designation,L.Description LName,
D.DESCRIPTION Department,B.NAME BName,sm.THISMONTHBASIC ActualBasic,E.PAYMENTMODE,
SM.ACCOUNTNO,SM.SalaryMonth,SMD.DESCRIPTION Description,SMD.ITEMGROUP,SM.ISFINALIZED,
SUM(SMD.CHANGEDAMOUNT) CHANGEDAMOUNT,SMD.ItemCode,SMD.ItemID,cat.DESCRIPTION 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 D on SM.DEPARTMENTID=D.DEPARTMENTID
inner join DESIGNATION DG on SM.DESIGNATIONID =DG.DESIGNATIONID
inner join LOCATION L on SM.LOCATIONID=L.LOCATIONID
left outer join BRANCHES Br on SM.BRANCHID=Br.BRANCHID
left outer join BANKS B on Br.BANKID=B.BANKID
inner join CATEGORY cat on E.CATEGORYID=cat.CATEGORYID
inner join SALARYMONTHLYDETAIL SMD on SM.SALARYMONTHLYID=SMD.SALARYMONTHLYID
AND SM.SalaryMonth=%d AND SMD.ITEMGROUP IN(1,2,8)
AND SM.EmployeeID IN(%q) GROUP BY E.NAME,E.EMPLOYEENO,E.EMPLOYEEID,G.CODE, DG.Name ,L.Description,
D.DESCRIPTION,B.NAME ,sm.THISMONTHBASIC,E.PAYMENTMODE,
SM.ACCOUNTNO,SM.SalaryMonth, SMD.DESCRIPTION,SMD.ITEMGROUP,SM.ISFINALIZED,
SMD.ItemCode,SMD.ItemID,cat.DESCRIPTION ,E.JOININGDATE,E.TINNo,
E.DEPARTMENTID", dateTime, sEmpID);
tempDt = tc.ExecuteDataTable(sSQL);
tempDt.TableName = "PayslipGross";
oSMonthlys.Tables.Add(tempDt);
sSQL = SQLParser.MakeSQL(@"SELECT E.NAME Name,E.EMPLOYEENO,E.EMPLOYEEID,G.CODE Grade, DG.Name Designation,L.Description LName,
D.DESCRIPTION Department,B.NAME BName,sm.THISMONTHBASIC ActualBasic,E.PAYMENTMODE,
SM.ACCOUNTNO,SM.SalaryMonth,SMD.Position, SMD.DESCRIPTION Description,SMD.ITEMGROUP,SM.ISFINALIZED,
SMD.CHANGEDAMOUNT,SMD.ItemCode,SMD.ItemID,cat.DESCRIPTION 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 D on SM.DEPARTMENTID=D.DEPARTMENTID
inner join DESIGNATION DG on SM.DESIGNATIONID =DG.DESIGNATIONID
inner join LOCATION L on SM.LOCATIONID=L.LOCATIONID
left outer join BRANCHES Br on SM.BRANCHID=Br.BRANCHID
left outer join BANKS B on Br.BANKID=B.BANKID
inner join CATEGORY cat on E.CATEGORYID=cat.CATEGORYID
inner join SALARYMONTHLYDETAIL SMD on SM.SALARYMONTHLYID=SMD.SALARYMONTHLYID
AND SM.SalaryMonth=%d AND SMD.ITEMGROUP IN(4,5)
AND SM.EmployeeID IN(%q) ORDER BY E.EmployeeNo, Position", dateTime, sEmpID);
tempDt = tc.ExecuteDataTable(sSQL);
tempDt.TableName = "PayslipHours";
oSMonthlys.Tables.Add(tempDt);
}
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.EMPLOYEENO,E.EMPLOYEEID,E.JOININGDATE,E.TINNO,G.CODE Grade,DG.Name as 'Designation',L.Description as LName,
D.DESCRIPTION Department,B.NAME as BName,SM.THISMONTHGROSS 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,E.TINNO
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 GetGrossDeduction(TransactionContext tc, int empID, DateTime salaryMonth)
{
DataSet rootDataset = new DataSet();
DataSet tempdataset = new DataSet();
try
{
string query1 = SQLParser.MakeSQL(@"select Sum(sd.changedamount) as GrossAmount
from SALARYMONTHLY S
INNER JOIN SalaryMonthlyDetail Sd ON S.SalaryMonthlyID=Sd.SalaryMonthlyID
INNER JOIN EMPLOYEE E ON s.EMPLOYEEID = E.EMPLOYEEID
where S.SalaryMonth = %d and Sd.ItemGroup IN (1, 8) AND S.EmployeeID = %n ",
salaryMonth, empID);
tempdataset = tc.ExecuteDataSet(query1);
tempdataset.Tables[0].TableName = "TotalGross";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query2 = SQLParser.MakeSQL(@"select Sum(sd.CHANGEDAMOUNT) as Deductamount
from SALARYMONTHLY S
INNER JOIN SalaryMonthlyDetail Sd on S.SalaryMonthlyID=Sd.SalaryMonthlyID
INNER JOIN EMPLOYEE E ON S.EMPLOYEEID = E.EMPLOYEEID
where S.SalaryMonth = %d
and Sd.ItemGroup IN (2,3) AND S.EmployeeID = %n", salaryMonth, empID);
tempdataset = tc.ExecuteDataSet(query2);
tempdataset.Tables[0].TableName = "TotalDeduction";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return rootDataset;
}
internal static void Updatepayment(TransactionContext tc, DateTime paymentDate, int salarymonthlyid, string chequeNo, string remarks, int userID)
{
string sql = SQLParser.MakeSQL(@"UPDATE SalaryMonthly SET paymentdate=%d, chequeno=%s , remarks=%s, ModifiedDate=%D,Modifiedby=%n where salarymonthlyid=%n", paymentDate, chequeNo, remarks, DateTime.Now, userID, salarymonthlyid) ;
tc.ExecuteNonQuery(sql);
}
internal static DataSet GetEmpPaySlipDeductForCitiOthers(TransactionContext tc, DateTime dateTime, string sEmpID)
{
DataSet oSMonthlys = new DataSet();
try
{
string sTableName;
sEmpID = IDHelper.GetIDs(tc, sEmpID, out sTableName);
string sql = SQLParser.MakeSQL(@"SELECT E.NAME Name,E.EMPLOYEENO,G.CODE Grade,DG.Name Designation,L.Description LName,
D.DESCRIPTION Department,B.NAME BName,SM.THISMONTHGROSS 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);
if (sTableName != "")
tc.ExecuteNonQuery("Drop TAble %q", sTableName);
}
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 sTableName;
sEmpID = IDHelper.GetIDs(tc, sEmpID, out sTableName);
string sql = SQLParser.MakeSQL(@"SELECT E.NAME Name,E.EMPLOYEENO,G.CODE Grade,DG.Name Designation,L.Description LName,
D.DESCRIPTION Department,B.NAME BName,SM.THISMONTHGROSS ActualBasic,E.PAYMENTMODE,
SM.ACCOUNTNO,SM.SalaryMonth,SMD.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
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 LName,
// D.DESCRIPTION Department,B.NAME 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);
if (sTableName != "")
tc.ExecuteNonQuery("Drop TAble %q", sTableName);
}
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
{
string sTableName;
sEmpID = IDHelper.GetIDs(tc, sEmpID, out sTableName);
oSMonthlys = tc.ExecuteDataSet(@"SELECT E.NAME Name,E.EMPLOYEENO,G.CODE Grade,DG.Name Designation,L.Description LName,
D.DESCRIPTION Department,SM.THISMONTHBASIC 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);
if (sTableName != "")
tc.ExecuteNonQuery("Drop TAble %q", sTableName);
}
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
{
string sTableName;
employeeno = IDHelper.GetIDs(tc, employeeno, out sTableName);
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);
if (sTableName != "")
tc.ExecuteNonQuery("Drop TAble %q", sTableName);
}
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 LName,
// D.DESCRIPTION Department,CC.DESCRIPTION RC ,B.NAME 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 L,
// SalaryMonthlyDetail SMD,CRG CC,SALARYEMPCOSTCENTER SEmpCC,BANKS B,BRANCHES 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 sTableName;
sEmpID = IDHelper.GetIDs(tc, sEmpID, out sTableName);
string sSQL = SQLParser.MakeSQL(@"SELECT E.NAME Name,E.EMPLOYEENO,G.CODE Grade,DG.Name Designation,L.Description LName,
D.DESCRIPTION Department,CC.DESCRIPTION RC ,B.NAME 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 Category,E.JOININGDATE,
E.DEPARTMENTID
FROM SALARYMONTHLY SM,Employee E,Grades G,Department D,Designation DG,Location L,
SalaryMonthlyDetail SMD,CRG CC,SALARYEMPCOSTCENTER SEmpCC,BANKS B,BRANCHES 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);
if (sTableName != "")
tc.ExecuteNonQuery("Drop TAble %q", sTableName);
#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
string sTableName;
sEmpID = IDHelper.GetIDs(tc, sEmpID, out sTableName);
oSMonthlys = tc.ExecuteDataSet(@"SELECT E.NAME Name,E.EMPLOYEENO,G.CODE Grade,DG.Name Designation,L.Description LName,
D.DESCRIPTION Department,CC.DESCRIPTION RC ,B.NAME 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);
if (sTableName != "")
tc.ExecuteNonQuery("Drop TAble %q", sTableName);
#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 sTableName;
sEmpID = IDHelper.GetIDs(tc, sEmpID, out sTableName);
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 GName,Deg.Name DegName,D.Description DName, G.Code 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());
if (sTableName != "")
tc.ExecuteNonQuery("Drop TAble %q", sTableName);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return rootDataset;
}
internal static DataSet GetEmpSalarySheetForNonManagement(TransactionContext tc, 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 A.SalaryMonth,A.EmployeeNo,A.THISMONTHBASIC,A.ItemCode,A.ItemGroup,A.ItemID, A.JOININGDATE,A.CCName, A.Name,A.GName,A.DName,A.GCode, A.SequenceNo, A.Description,A.changedamount
Amount from(
select S.SalaryMonth,S.EmployeeID, S.THISMONTHBASIC,E.EmployeeNo, E.JOININGDATE,cc.Code AS CCName,
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,EMPCOSTCENTER ecc, CRG cc
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 E.EMPLOYEEID=ecc.EMPLOYEEID
AND ecc.COSTCENTERID=cc.CRGID
AND ecc.CURRENTCC=1
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, S.THISMONTHBASIC,E.EmployeeNo, E.JOININGDATE,cc.Code AS CCName,
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,EMPCOSTCENTER ecc, CRG cc
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 E.EMPLOYEEID=ecc.EMPLOYEEID
AND ecc.COSTCENTERID=cc.CRGID
AND ecc.CURRENTCC=1
and Sd.ItemGroup in(1) AND sd.ItemCode not in(-133) AND S.EmployeeID in(%q) AND sd.changedamount<>0
Union
select S.SalaryMonth, S.EmployeeID, S.THISMONTHBASIC,E.EmployeeNo, E.JOININGDATE,cc.Code AS CCName,
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,EMPCOSTCENTER ecc, CRG cc
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 E.EMPLOYEEID=ecc.EMPLOYEEID
AND ecc.COSTCENTERID=cc.CRGID
AND ecc.CURRENTCC=1
and Sd.ItemGroup in(4) AND sd.ItemCode in(-101) 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, 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.THISMONTHBASIC,A.ItemGroup, E.JOININGDATE, A.CCName, E.Name,A.GName,A.GCode,A.DName,'Total Gross' as Description,
Sum(A.amount) as amount
from
(
select S.EmployeeID,S.THISMONTHBASIC,S.SalaryMonth,Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,Sd.ItemCode,Sd.ItemGroup,Sd.ItemID,G.Code as GCode,cc.Code AS CCName,
G.SequenceNo,D.Name as DName
from SALARYMONTHLY S,Grades G,DESIGNATION D,
SalaryMonthlyDetail Sd ,EMPCOSTCENTER ecc, CRG cc
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=ecc.EMPLOYEEID
AND ecc.COSTCENTERID=cc.CRGID
AND ecc.CURRENTCC=1
AND S.EmployeeID IN(%q) AND sd.changedamount<>0
group by S.SalaryMonth,S.EmployeeID,S.THISMONTHBASIC,G.DESCRIPTION,G.SequenceNo,G.Code,D.Name,Sd.ItemCode,Sd.ItemGroup,Sd.ItemID,cc.Code
UNION
select S.EmployeeID,S.THISMONTHBASIC,S.SalaryMonth, -Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,Sd.ItemCode,Sd.ItemGroup,Sd.ItemID,G.Code as GCode,cc.Code AS CCName,
G.sequenceNo,D.Name as DName
from GRADES G,DESIGNATION D,SALARYMONTHLY S, SalaryMonthlyDetail Sd ,EMPCOSTCENTER ecc, CRG cc
where S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth =%d
AND S.EmployeeID=ecc.EMPLOYEEID
AND ecc.COSTCENTERID=cc.CRGID
AND ecc.CURRENTCC=1
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,S.THISMONTHBASIC,G.DESCRIPTION,G.SequenceNo,G.Code,D.Name,Sd.ItemCode,Sd.ItemGroup,Sd.ItemID,cc.Code
) A, Employee E
where A.EmployeeID = E.EmployeeID
group by A.SalaryMonth,E.EmployeeNo, A.CCName,A.THISMONTHBASIC, E.JOININGDATE, E.Name,A.ItemGroup,A.GName,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.THISMONTHBASIC, A.Name,A.JoiningDate,A.CCName, A.GName,A.GCode,A.SequenceNo,A.DName,
A.Description, SUM(A.changedamount) Amount,A.ItemCode,A.ItemID,A.ItemGroup
from
(select S.EmployeeID,S.THISMONTHBASIC, E.EmployeeNo, E.Name,E.JoiningDate,cc.Code AS CCName,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 ,EMPCOSTCENTER ecc, CRG cc
where G.GradeID= S.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID AND E.employeeID=S.EmployeeID
AND E.EMPLOYEEID=ecc.EMPLOYEEID
AND ecc.COSTCENTERID=cc.CRGID
AND ecc.CURRENTCC=1
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,S.THISMONTHBASIC, E.EmployeeNo, E.Name,E.JoiningDate,cc.Code AS CCName,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 ,EMPCOSTCENTER ecc, CRG cc
where G.GradeID= S.GradeID
AND E.EMPLOYEEID=ecc.EMPLOYEEID
AND ecc.COSTCENTERID=cc.CRGID
AND ecc.CURRENTCC=1
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.THISMONTHBASIC, A.EmployeeNo, A.Name,A.GName,A.SequenceNo,A.GCode,A.DName,
A.ItemCode, A.ItemID,A.ItemGroup, A.Description,A.Position,A.JoiningDate,A.CCName 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.THISMONTHBASIC,A.ItemGroup, E.JOININGDATE,A.CCName, E.Name,A.GName,A.GCode,A.DName,
'Total Deduction' as Description,
Sum(A.amount) as amount
from(
select S.SalaryMonth,S.EmployeeID,S.THISMONTHBASIC, Sum(sd.changedamount) as Amount,Sd.ItemCode,Sd.ItemGroup,Sd.ItemID,cc.Code AS CCName,
G.DESCRIPTION as GName,G.Code as GCode,G.SequenceNo,D.Name as DName
from GRADES G,DESIGNATION D,SALARYMONTHLY S,SalaryMonthlyDetail Sd,EMPCOSTCENTER ecc, CRG cc
where S.SalaryMonthlyID=Sd.SalaryMonthlyID AND
S.SalaryMonth = %d AND G.GRADEID=S.GRADEID AND D.DESIGNATIONID=S.DESIGNATIONID
AND S.EmployeeID=ecc.EMPLOYEEID
AND ecc.COSTCENTERID=cc.CRGID
AND ecc.CURRENTCC=1
and Sd.ItemGroup IN (3) AND S.EmployeeID IN(%q)
group by S.SalaryMonth,S.EmployeeID,S.THISMONTHBASIC,G.DESCRIPTION,G.SequenceNo,G.Code,D.Name ,Sd.ItemCode,Sd.ItemGroup,Sd.ItemID,cc.Code
) A,Employee E
where A.EmployeeID = E.EmployeeID
group by A.SalaryMonth,E.EmployeeNo,A.THISMONTHBASIC,A.ItemGroup, E.JOININGDATE,A.CCName, E.Name,A.GName,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,S.THISMONTHBASIC, Sd.ItemCode,Sd.ItemGroup,Sd.ItemID, E.JOININGDATE,cc.Code AS CCName,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,EMPCOSTCENTER ecc, CRG cc
where S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth= %d
AND E.EMPLOYEEID=ecc.EMPLOYEEID
AND ecc.COSTCENTERID=cc.CRGID
AND ecc.CURRENTCC=1
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());
if (sTableName != "")
tc.ExecuteNonQuery("Drop TAble %q", sTableName);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return rootDataset;
}
internal static DataSet GetEmpSalarySheetForManagement(TransactionContext tc, 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 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, E.JOININGDATE, E.Name,A.GName,A.GCode,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.GName,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.ItemGroup, E.JOININGDATE, E.Name,A.GName,A.GCode,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 (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.ItemGroup, E.JOININGDATE, E.Name,A.GName,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());
if (sTableName != "")
tc.ExecuteNonQuery("Drop TAble %q", sTableName);
}
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
{
#region Commented by ANIK
// string query1 = SQLParser.MakeSQL(@"select A.EmployeeNo, A.Name,A.GName,A.GCode,A.JoiningDate,
// A.Description, SUM(A.changedamount) Amount,A.ItemGroup,A.ItemCode,A.ItemID
// from
// (
// select S.EmployeeID, E.EmployeeNo, E.Name,E.JoiningDate, sd.ItemGroup,sd.ItemCode,
// sd.ItemID, sd.Description, sd.changedamount,G.DESCRIPTION as GName,G.Code as GCode
// from Grades G,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd
// where G.GradeID= S.GradeID 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.changedamount,G.DESCRIPTION as GName,G.Code as GCode from Grades G,
// Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd
// where G.GradeID= S.GradeID 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.GCode,A.ItemGroup,A.ItemCode,A.ItemID,
// A.ItemCode, A.ItemID, A.Description,A.JoiningDate order by A.EmployeeNo,A.GCode",
// dateTime, sEmpID, dateTime, sEmpID);
// tempdataset = tc.ExecuteDataSet(query1);
#endregion
string query1 = SQLParser.MakeSQL(@"select A.EmployeeNo, A.Name,A.Department, A.DESIGNATION, A.COSTCENTER ,
A.GName,A.GCode,A.JoiningDate,
A.Description, SUM(A.changedamount) Amount,A.ItemGroup,A.ItemCode,A.ItemID
from
(
select S.EmployeeID, E.EmployeeNo, E.Name,dep.DESCRIPTION AS Department,deg.Name AS DESIGNATION,cc.Description AS COSTCENTER,
E.JoiningDate, sd.ItemGroup,sd.ItemCode,
sd.ItemID, sd.Description, sd.changedamount,G.DESCRIPTION as GName,G.Code as GCode
from Grades G,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd, DEPARTMENT dep, DESIGNATION deg, crg cc, salaryempcostcenter scc
where G.GradeID= S.GradeID 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 E.DEPARTMENTID = dep.DEPARTMENTID
AND E.DESIGNATIONID = deg.DESIGNATIONID
AND scc.COSTCENTERID = cc.CRGID
AND scc.SALARYMONTHLYID=s.SALARYMONTHLYID
UNION
select S.EmployeeID, E.EmployeeNo, E.Name,dep.DESCRIPTION AS Department,deg.Name AS DESIGNATION,cc.Description AS COSTCENTER,
E.JoiningDate, sd.ItemGroup,sd.ItemCode,
sd.ItemID, sd.Description, sd.changedamount,G.DESCRIPTION as GName,G.Code as GCode from Grades G,
Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd , DEPARTMENT dep, DESIGNATION deg, crg cc, salaryempcostcenter scc
where G.GradeID= S.GradeID 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 E.DEPARTMENTID = dep.DEPARTMENTID
AND E.DESIGNATIONID = deg.DESIGNATIONID
AND scc.COSTCENTERID = cc.CRGID
AND scc.SALARYMONTHLYID=s.SALARYMONTHLYID
) A group by
A.EmployeeID, A.EmployeeNo, A.Name,A.GName,A.GCode,A.ItemGroup,A.ItemCode,A.ItemID,
A.ItemCode, A.ItemID, A.Description,A.JoiningDate,A.Department, A.DESIGNATION,A.COSTCENTER
order by 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 queryActualGross = SQLParser.MakeSQL(@"select E.EmployeeNo, E.Name, dep.DESCRIPTION AS Department,deg.Name AS DESIGNATION,cc.Description AS COSTCENTER,
E.JoiningDate,A.GName,A.GCode,'Actual 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 , S.SALARYMONTHLYID
from SALARYMONTHLY S,Grades G, SalaryMonthlyDetail Sd
where S.SalaryMonthlyID=Sd.SalaryMonthlyID
AND G.GRADEID=S.GRADEID AND S.SalaryMonth= %d and Sd.ItemGroup IN (1) AND sd.description!='Bonus Arrear' AND S.EmployeeID IN(%q)
group by S.EmployeeID,G.DESCRIPTION,G.Code, S.SALARYMONTHLYID
) A, Employee E ,DEPARTMENT dep, DESIGNATION deg, crg cc,SALARYEMPCOSTCENTER empcc
where A.EmployeeID = E.EmployeeID
AND E.DEPARTMENTID = dep.DEPARTMENTID
AND E.DESIGNATIONID = deg.DESIGNATIONID
AND E.EMPLOYEEID = empcc.EMPLOYEEID
AND empcc.COSTCENTERID = cc.CRGID
AND A.EMPLOYEEID = empcc.EMPLOYEEID
AND A.SALARYMONTHLYID = empcc.SALARYMONTHLYID
group by E.EmployeeNo, E.Name,A.GName,A.GCode,E.JoiningDate ,dep.DESCRIPTION,deg.Name,cc.Description",
dateTime, sEmpID, dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet(queryActualGross);
tempdataset.Tables[0].TableName = "ActualGross";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query2 = SQLParser.MakeSQL(@"select E.EmployeeNo, E.Name,dep.DESCRIPTION AS Department,deg.Name AS DESIGNATION,cc.Description AS COSTCENTER,
E.JoiningDate,A.GName,A.GCode,'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, S.SALARYMONTHLYID
from SALARYMONTHLY S,Grades G, SalaryMonthlyDetail Sd
where S.SalaryMonthlyID=Sd.SalaryMonthlyID
AND G.GRADEID=S.GRADEID AND S.SalaryMonth=%d and Sd.ItemGroup IN (1, 8) AND S.EmployeeID IN(%q)
group by S.EmployeeID,G.DESCRIPTION,G.Code , S.SALARYMONTHLYID
UNION
select S.EmployeeID, -Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,G.Code as GCode, S.SALARYMONTHLYID
from GRADES G,SALARYMONTHLY S, SalaryMonthlyDetail Sd
where S.SalaryMonthlyID=Sd.SalaryMonthlyID
AND S.SalaryMonth=%d AND G.GRADEID=S.GRADEID and Sd.ItemGroup IN (2) AND S.EmployeeID IN(%q)
group by S.EmployeeID,G.DESCRIPTION,G.Code, S.SALARYMONTHLYID
) A, Employee E ,DEPARTMENT dep, DESIGNATION deg, crg cc,SALARYEMPCOSTCENTER empcc
where A.EmployeeID = E.EmployeeID
AND E.DEPARTMENTID = dep.DEPARTMENTID
AND E.DESIGNATIONID = deg.DESIGNATIONID
AND E.EMPLOYEEID = empcc.EMPLOYEEID
AND empcc.COSTCENTERID = cc.CRGID
AND A.EMPLOYEEID = empcc.EMPLOYEEID
AND A.SALARYMONTHLYID = empcc.SALARYMONTHLYID
group by E.EmployeeNo, E.Name,A.GName,A.GCode,E.JoiningDate ,dep.DESCRIPTION,deg.Name,cc.Description",
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.ItemGroup,
// 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.changedamount,G.DESCRIPTION as GName,G.Code as GCode
// from Grades G,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd
// where G.GradeID= S.GradeID AND E.employeeID=S.EmployeeID
// AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth = %d and Sd.ItemGroup in (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.changedamount,G.DESCRIPTION as GName,G.Code as GCode
// from Grades G,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd
// where G.GradeID= S.GradeID 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.GCode, A.ItemGroup,
// A.ItemCode, A.ItemID, A.Description,A.JoiningDate order by A.EmployeeNo,A.GCode",
// dateTime, sEmpID, dateTime, sEmpID);
//string query3 = SQLParser.MakeSQL(@"select A.EmployeeNo, A.Name,A.Department, A.DESIGNATION,-- A.COSTCENTER,
// A.JoiningDate,A.GName,A.GCode,A.ItemGroup,
// A.Description, SUM(A.changedamount) Amount,A.ItemCode,A.ItemID
// from
// (
// select S.EmployeeID, E.EmployeeNo, E.Name, dep.DESCRIPTION AS Department,deg.Name AS DESIGNATION,--cc.Description AS COSTCENTER,
// E.JoiningDate,sd.ItemGroup,sd.ItemCode,
// sd.ItemID, sd.Description, sd.changedamount,G.DESCRIPTION as GName,G.Code as GCode
// from Grades G,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd ,DEPARTMENT dep, DESIGNATION deg--, SALARYEMPCOSTCENTER empcc, crg cc
// where G.GradeID= S.GradeID AND E.employeeID=S.EmployeeID
// AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth = %d and Sd.ItemGroup in (3)
// AND S.EmployeeID IN(%q)
// AND E.DEPARTMENTID = dep.DEPARTMENTID
// AND E.DESIGNATIONID = deg.DESIGNATIONID
// --AND E.EMPLOYEEID = empcc.EMPLOYEEID
// --AND empcc.COSTCENTERID = cc.CRGID
// --AND S.EMPLOYEEID = empcc.EMPLOYEEID
// --AND S.SALARYMONTHLYID = empcc.SALARYMONTHLYID
// Union
// select S.EmployeeID, E.EmployeeNo, E.Name, dep.DESCRIPTION AS Department,deg.Name AS DESIGNATION,--cc.Description AS COSTCENTER,
// E.JoiningDate,sd.ItemGroup,0 ItemCode,
// 0 ItemID, 'LWP' Description, SUM(sd.changedamount) changedamount,G.DESCRIPTION as GName,G.Code as GCode
// from Grades G,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd ,DEPARTMENT dep, DESIGNATION deg--, SALARYEMPCOSTCENTER empcc, crg cc
// where G.GradeID= S.GradeID AND E.employeeID=S.EmployeeID
// AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth = %d and Sd.ItemGroup = 2
// AND S.EmployeeID IN(%q)
// AND E.DEPARTMENTID = dep.DEPARTMENTID
// AND E.DESIGNATIONID = deg.DESIGNATIONID
// --AND E.EMPLOYEEID = empcc.EMPLOYEEID
// --AND empcc.COSTCENTERID = cc.CRGID
// --AND S.EMPLOYEEID = empcc.EMPLOYEEID
// --AND S.SALARYMONTHLYID = empcc.SALARYMONTHLYID
// GROUP BY S.EmployeeID, E.EmployeeNo, E.Name,E.JoiningDate,sd.ItemGroup,G.DESCRIPTION ,G.Code,dep.DESCRIPTION,deg.Name--,cc.Description
// ) A
// group by
// A.EmployeeID, A.EmployeeNo, A.Name,A.GName,A.GCode, A.ItemGroup,
// A.ItemCode, A.ItemID, A.Description,A.JoiningDate , A.Department, A.DESIGNATION--,A.COSTCENTER
// order by A.EmployeeNo,A.GCode",
// dateTime, sEmpID, dateTime, sEmpID);
string query3 = SQLParser.MakeSQL(@"select A.EmployeeNo, A.Name,A.depname Department,A.DName DESIGNATION,A.COSTCENTER, A.JoiningDate,A.GName,A.GCode,A.itemgroup,
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 ,dep.DESCRIPTION depname,cc.Description AS COSTCENTER
from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd ,DEPARTMENT dep, SALARYEMPCOSTCENTER empcc, crg cc
where G.GradeID= S.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID AND E.employeeID=S.EmployeeID AND dep.DEPARTMENTID=S.DEPARTMENTID
AND E.EMPLOYEEID = empcc.EMPLOYEEID
AND empcc.COSTCENTERID = cc.CRGID
AND S.EMPLOYEEID = empcc.EMPLOYEEID
AND S.SALARYMONTHLYID = empcc.SALARYMONTHLYID
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,dep.DESCRIPTION depname,cc.Description AS COSTCENTER
from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd ,DEPARTMENT dep, SALARYEMPCOSTCENTER empcc, crg cc
where G.GradeID= S.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID AND E.employeeID=S.EmployeeID AND dep.DEPARTMENTID=S.DEPARTMENTID
AND E.EMPLOYEEID = empcc.EMPLOYEEID
AND empcc.COSTCENTERID = cc.CRGID
AND S.EMPLOYEEID = empcc.EMPLOYEEID
AND S.SALARYMONTHLYID = empcc.SALARYMONTHLYID
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.depname,A.itemgroup,A.COSTCENTER 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.Department, A.DESIGNATION, A.COSTCENTER,
A.GName,A.GCode,A.JoiningDate,
A.Description, SUM(A.changedamount) Amount
from
(
select S.EmployeeID, E.EmployeeNo, E.Name,dep.DESCRIPTION AS Department,deg.Name AS DESIGNATION,cc.Description AS COSTCENTER,
sd.ItemGroup,sd.ItemCode,E.JoiningDate,
sd.ItemID, sd.Description, sd.changedamount,G.DESCRIPTION as GName,G.Code as GCode
from Grades G,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd ,DEPARTMENT dep, DESIGNATION deg, SALARYEMPCOSTCENTER empcc, crg cc
where G.GradeID = S.GradeID 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)
AND E.DEPARTMENTID = dep.DEPARTMENTID
AND E.DESIGNATIONID = deg.DESIGNATIONID
AND E.EMPLOYEEID = empcc.EMPLOYEEID
AND empcc.COSTCENTERID = cc.CRGID
AND S.EMPLOYEEID = empcc.EMPLOYEEID
AND S.SALARYMONTHLYID = empcc.SALARYMONTHLYID
UNION
select S.EmployeeID, E.EmployeeNo, E.Name, dep.DESCRIPTION AS Department,deg.Name AS DESIGNATION,cc.Description AS COSTCENTER,
sd.ItemGroup,sd.ItemCode,E.JoiningDate,
sd.ItemID, sd.Description, sd.changedamount,G.DESCRIPTION as GName,G.Code as GCode
from Grades G,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd ,DEPARTMENT dep, DESIGNATION deg, SALARYEMPCOSTCENTER empcc, crg cc
where G.GradeID = S.GradeID 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)
AND E.DEPARTMENTID = dep.DEPARTMENTID
AND E.DESIGNATIONID = deg.DESIGNATIONID
AND E.EMPLOYEEID = empcc.EMPLOYEEID
AND empcc.COSTCENTERID = cc.CRGID
AND S.EMPLOYEEID = empcc.EMPLOYEEID
AND S.SALARYMONTHLYID = empcc.SALARYMONTHLYID
) A group by
A.EmployeeID, A.EmployeeNo, A.Name,A.GName,A.GCode,A.JoiningDate,
A.ItemCode, A.ItemID, A.Description ,A.Department, A.DESIGNATION,A.COSTCENTER
order by 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,dep.DESCRIPTION AS Department,deg.Name AS DESIGNATION,cc.Description AS COSTCENTER,
A.GName,A.GCode, 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, S.SALARYMONTHLYID
from GRADES G,SALARYMONTHLY S,SalaryMonthlyDetail Sd
where S.SalaryMonthlyID=Sd.SalaryMonthlyID
AND S.SalaryMonth = %d AND G.GRADEID=S.GRADEID
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.Code, S.SALARYMONTHLYID
) A, Employee E ,DEPARTMENT dep, DESIGNATION deg, crg cc,SALARYEMPCOSTCENTER empcc
where A.EmployeeID = E.EmployeeID
AND E.DEPARTMENTID = dep.DEPARTMENTID
AND E.DESIGNATIONID = deg.DESIGNATIONID
AND E.EMPLOYEEID = empcc.EMPLOYEEID
AND empcc.COSTCENTERID = cc.CRGID
AND A.EMPLOYEEID = empcc.EMPLOYEEID
AND A.SALARYMONTHLYID = empcc.SALARYMONTHLYID
group by E.EmployeeNo, E.Name,A.GName,A.Description,A.GCode,E.JoiningDate ,dep.DESCRIPTION,deg.Name,cc.Description", 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,dep.DESCRIPTION AS Department,deg.Name AS DESIGNATION,cc.Description AS COSTCENTER,
E.JoiningDate,A.GName,A.GCode, '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, S.SALARYMONTHLYID
from GRADES G,SALARYMONTHLY S,SalaryMonthlyDetail Sd
where S.SalaryMonthlyID=Sd.SalaryMonthlyID
AND S.SalaryMonth= %d AND G.GRADEID=S.GRADEID and Sd.ItemGroup IN (3)
AND S.EmployeeID IN(%q)
group by S.EmployeeID,G.DESCRIPTION,G.Code, S.SALARYMONTHLYID
) A, Employee E ,DEPARTMENT dep, DESIGNATION deg, crg cc,SALARYEMPCOSTCENTER empcc
where A.EmployeeID = E.EmployeeID
AND E.DEPARTMENTID = dep.DEPARTMENTID
AND E.DESIGNATIONID = deg.DESIGNATIONID
AND E.EMPLOYEEID = empcc.EMPLOYEEID
AND empcc.COSTCENTERID = cc.CRGID
AND A.EMPLOYEEID = empcc.EMPLOYEEID
AND A.SALARYMONTHLYID = empcc.SALARYMONTHLYID
group by E.EmployeeNo, E.Name,A.GName,A.GCode,E.JoiningDate ,dep.DESCRIPTION,deg.Name,cc.Description
order by E.EmployeeNo,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,dep.DESCRIPTION AS Department,deg.Name AS DESIGNATION,cc.Description AS COSTCENTER,
E.JoiningDate,G.DESCRIPTION as GName,G.Code as GCode,
sd.ItemGroup,sd.ItemCode,sd.ItemID,
'Net Pay' as Description,SD.CHANGEDAMOUNT as Amount
from EMPLOYEE as E,GRADES as G,SALARYMONTHLY as S,SALARYMONTHLYDETAIL as Sd ,DEPARTMENT dep, DESIGNATION deg, crg cc,SALARYEMPCOSTCENTER empcc
where S.SalaryMonthlyID=Sd.SalaryMonthlyID
AND S.SalaryMonth = %d
AND G.GRADEID=S.GRADEID
AND E.EMPLOYEEID = S.EMPLOYEEID
and Sd.ItemGroup IN (5) AND Sd.ItemCode IN(-132)
AND S.EmployeeID IN(%q)
AND E.DEPARTMENTID = dep.DEPARTMENTID
AND E.DESIGNATIONID = deg.DESIGNATIONID
AND E.EMPLOYEEID = empcc.EMPLOYEEID
AND empcc.COSTCENTERID = cc.CRGID
AND S.EMPLOYEEID = empcc.EMPLOYEEID
AND S.SALARYMONTHLYID = empcc.SALARYMONTHLYID
order by E.EMPLOYEENO,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,dep.DESCRIPTION AS Department,deg.Name AS DESIGNATION,cc.Description AS COSTCENTER,
E.JoiningDate,G.DESCRIPTION as GName,G.Code as GCode,
sd.ItemGroup,sd.ItemID,sd.ItemCode,
'CPF' as Description,SD.CHANGEDAMOUNT as Amount
from EMPLOYEE as E,GRADES as G,SALARYMONTHLY as S,SALARYMONTHLYDETAIL as Sd ,DEPARTMENT dep, DESIGNATION deg, crg cc,SALARYEMPCOSTCENTER empcc
where S.SalaryMonthlyID=Sd.SalaryMonthlyID
AND S.SalaryMonth = %d
AND G.GRADEID=S.GRADEID
AND E.EMPLOYEEID =S.EMPLOYEEID
AND Sd.ItemGroup IN (3) AND Sd.ItemCode IN(-128)
AND S.EmployeeID IN(%q)
AND E.DEPARTMENTID = dep.DEPARTMENTID
AND E.DESIGNATIONID = deg.DESIGNATIONID
AND E.EMPLOYEEID = empcc.EMPLOYEEID
AND empcc.COSTCENTERID = cc.CRGID
AND S.EMPLOYEEID = empcc.EMPLOYEEID
AND S.SALARYMONTHLYID = empcc.SALARYMONTHLYID
order by E.EMPLOYEENO,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 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());
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return rootDataset;
}
internal static DataSet GetEmpSalarySheetWithoutCostcenter(TransactionContext tc, DateTime dateTime, string sEmpID)
{
DataSet rootDataset = new DataSet();
DataSet tempdataset = new DataSet();
try
{
#region Commented by ANIK
#endregion
string query1 = SQLParser.MakeSQL(@"select E.EmployeeNo, E.Name,dep.DESCRIPTION AS Department,deg.Name AS DESIGNATION,
G.DESCRIPTION as GName,G.Code as GCode,E.JoiningDate,
A.Description, SUM(A.changedamount) Amount,A.ItemGroup,A.ItemCode,A.ItemID
from
(
select S.EmployeeID, S.GRADEID, S.DEPARTMENTID, S.DESIGNATIONID, sd.ItemGroup, sd.ItemCode,
sd.ItemID, sd.Description, sd.changedamount
from SALARYMONTHLY 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.GRADEID, S.DEPARTMENTID, S.DESIGNATIONID, sd.ItemGroup, sd.ItemCode,
sd.ItemID, sd.Description, sd.changedamount from SALARYMONTHLY 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,Grades G,Employee E, DEPARTMENT dep, DESIGNATION deg
Where G.GradeID = A.GradeID AND E.employeeID = A.EmployeeID
AND A.DEPARTMENTID = dep.DEPARTMENTID
AND A.DESIGNATIONID = deg.DESIGNATIONID
group by E.EmployeeID, E.EmployeeNo, E.Name,G.DESCRIPTION,G.Code,A.ItemGroup,A.ItemCode,A.ItemID,
A.ItemCode, A.ItemID, A.Description,E.JoiningDate,dep.DESCRIPTION, deg.NAME
order by E.EmployeeNo,G.Code",
dateTime, sEmpID, dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet(query1);
tempdataset.Tables[0].TableName = "GrossItem";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string queryActualGross = SQLParser.MakeSQL(@"select E.EmployeeNo, E.Name, dep.DESCRIPTION AS Department,deg.Name AS DESIGNATION,
E.JoiningDate,G.DESCRIPTION as GName,G.Code as GCode ,'Actual Gross' as Description, Sum(A.amount) as amount
from
(select S.EmployeeID, Sum(sd.changedamount) as Amount, S.SALARYMONTHLYID, S.DEPARTMENTID, S.DESIGNATIONID, S.GRADEID
from SALARYMONTHLY S, SalaryMonthlyDetail Sd
where S.SalaryMonthlyID = Sd.SalaryMonthlyID
AND S.SalaryMonth = %d and Sd.ItemGroup IN(1) and sd.description != 'Bonus Arrear' AND S.EmployeeID IN(%q)
group by S.EmployeeID, S.SALARYMONTHLYID, S.DEPARTMENTID, S.DESIGNATIONID, S.GRADEID
) A, Employee E, DEPARTMENT dep, DESIGNATION deg, Grades G
where A.EmployeeID = E.EmployeeID
AND A.DEPARTMENTID = dep.DEPARTMENTID
AND A.DESIGNATIONID = deg.DESIGNATIONID
AND G.GRADEID = A.GRADEID
group by E.EmployeeNo, E.Name,G.DESCRIPTION,G.Code,E.JoiningDate ,dep.DESCRIPTION,deg.Name",
dateTime, sEmpID, dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet(queryActualGross);
tempdataset.Tables[0].TableName = "ActualGross";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query2 = SQLParser.MakeSQL(@"select E.EmployeeNo, E.Name,dep.DESCRIPTION AS Department,deg.Name AS DESIGNATION,G.DESCRIPTION as GName,G.Code as GCode,--cc.Description AS COSTCENTER,
E.JoiningDate,'Total Gross' as Description, Sum(A.amount) as amount
from
( select S.EmployeeID, Sum(sd.changedamount) as Amount,S.GRADEID, S.SALARYMONTHLYID ,S.DEPARTMENTID,S.DESIGNATIONID
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)
group by S.EmployeeID, S.SALARYMONTHLYID ,S.GRADEID,S.DEPARTMENTID,S.DESIGNATIONID
UNION
select S.EmployeeID, -Sum(sd.changedamount) as Amount,S.GRADEID, S.SALARYMONTHLYID,S.DEPARTMENTID,S.DESIGNATIONID
from SALARYMONTHLY 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.SALARYMONTHLYID,S.GRADEID,S.DEPARTMENTID,S.DESIGNATIONID
) A, Employee E ,DEPARTMENT dep, DESIGNATION deg,Grades G--, crg cc,SALARYEMPCOSTCENTER empcc
where A.EmployeeID = E.EmployeeID
AND A.DEPARTMENTID = dep.DEPARTMENTID
AND A.DESIGNATIONID = deg.DESIGNATIONID
AND G.GRADEID=A.GRADEID
group by E.EmployeeNo, E.Name,G.DESCRIPTION ,G.Code,E.JoiningDate ,dep.DESCRIPTION,deg.Name--,cc.Description",
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.ItemGroup,
// 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.changedamount,G.DESCRIPTION as GName,G.Code as GCode
// from Grades G,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd
// where G.GradeID= S.GradeID AND E.employeeID=S.EmployeeID
// AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth = %d and Sd.ItemGroup in (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.changedamount,G.DESCRIPTION as GName,G.Code as GCode
// from Grades G,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd
// where G.GradeID= S.GradeID 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.GCode, A.ItemGroup,
// A.ItemCode, A.ItemID, A.Description,A.JoiningDate order by A.EmployeeNo,A.GCode",
// dateTime, sEmpID, dateTime, sEmpID);
//string query3 = SQLParser.MakeSQL(@"select A.EmployeeNo, A.Name,A.Department, A.DESIGNATION,-- A.COSTCENTER,
// A.JoiningDate,A.GName,A.GCode,A.ItemGroup,
// A.Description, SUM(A.changedamount) Amount,A.ItemCode,A.ItemID
// from
// (
// select S.EmployeeID, E.EmployeeNo, E.Name, dep.DESCRIPTION AS Department,deg.Name AS DESIGNATION,--cc.Description AS COSTCENTER,
// E.JoiningDate,sd.ItemGroup,sd.ItemCode,
// sd.ItemID, sd.Description, sd.changedamount,G.DESCRIPTION as GName,G.Code as GCode
// from Grades G,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd ,DEPARTMENT dep, DESIGNATION deg--, SALARYEMPCOSTCENTER empcc, crg cc
// where G.GradeID= S.GradeID AND E.employeeID=S.EmployeeID
// AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth = %d and Sd.ItemGroup in (3)
// AND S.EmployeeID IN(%q)
// AND E.DEPARTMENTID = dep.DEPARTMENTID
// AND E.DESIGNATIONID = deg.DESIGNATIONID
// --AND E.EMPLOYEEID = empcc.EMPLOYEEID
// --AND empcc.COSTCENTERID = cc.CRGID
// --AND S.EMPLOYEEID = empcc.EMPLOYEEID
// --AND S.SALARYMONTHLYID = empcc.SALARYMONTHLYID
// Union
// select S.EmployeeID, E.EmployeeNo, E.Name, dep.DESCRIPTION AS Department,deg.Name AS DESIGNATION,--cc.Description AS COSTCENTER,
// E.JoiningDate,sd.ItemGroup,0 ItemCode,
// 0 ItemID, 'LWP' Description, SUM(sd.changedamount) changedamount,G.DESCRIPTION as GName,G.Code as GCode
// from Grades G,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd ,DEPARTMENT dep, DESIGNATION deg--, SALARYEMPCOSTCENTER empcc, crg cc
// where G.GradeID= S.GradeID AND E.employeeID=S.EmployeeID
// AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth = %d and Sd.ItemGroup = 2
// AND S.EmployeeID IN(%q)
// AND E.DEPARTMENTID = dep.DEPARTMENTID
// AND E.DESIGNATIONID = deg.DESIGNATIONID
// --AND E.EMPLOYEEID = empcc.EMPLOYEEID
// --AND empcc.COSTCENTERID = cc.CRGID
// --AND S.EMPLOYEEID = empcc.EMPLOYEEID
// --AND S.SALARYMONTHLYID = empcc.SALARYMONTHLYID
// GROUP BY S.EmployeeID, E.EmployeeNo, E.Name,E.JoiningDate,sd.ItemGroup,G.DESCRIPTION ,G.Code,dep.DESCRIPTION,deg.Name--,cc.Description
// ) A
// group by
// A.EmployeeID, A.EmployeeNo, A.Name,A.GName,A.GCode, A.ItemGroup,
// A.ItemCode, A.ItemID, A.Description,A.JoiningDate , A.Department, A.DESIGNATION--,A.COSTCENTER
// order by A.EmployeeNo,A.GCode",
// dateTime, sEmpID, dateTime, sEmpID);
string query3 = SQLParser.MakeSQL(@"select E.EmployeeNo, E.Name,G.DESCRIPTION as GName,G.Code as GCode,D.Name as DESIGNATION ,dep.DESCRIPTION Department, E.JoiningDate,A.itemgroup,
A.Description, SUM(A.changedamount) Amount,A.ItemCode,A.ItemID
from
(select S.EmployeeID,sd.ItemGroup,sd.ItemCode, sd.ItemID, sd.Description,sd.Position,S.GRADEID,S.DEPARTMENTID,S.DESIGNATIONID, sd.changedamount
from SALARYMONTHLY S, SalaryMonthlyDetail Sd
where S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d and Sd.ItemGroup=3 AND S.EmployeeID IN(%q)
union
select S.EmployeeID,sd.ItemGroup,sd.ItemCode, sd.ItemID, sd.Description,sd.Position,S.GRADEID,S.DEPARTMENTID,S.DESIGNATIONID, -sd.changedamount
from SALARYMONTHLY S, SalaryMonthlyDetail Sd
where S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth=%d and Sd.ItemGroup=2 AND S.EmployeeID IN(%q)
) A,Grades G,DESIGNATION D,Employee E,DEPARTMENT dep
Where G.GradeID= A.GradeID AND D.DESIGNATIONID=A.DESIGNATIONID AND E.employeeID=A.EmployeeID AND dep.DEPARTMENTID=A.DEPARTMENTID
group by
A.EmployeeID, E.EmployeeNo, E.Name,G.DESCRIPTION,G.Code,D.Name,
A.ItemCode, A.ItemID, A.Description,A.Position,E.JoiningDate,dep.DESCRIPTION,A.itemgroup order by E.EmployeeNo,A.Position,G.Code", 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 E.EmployeeNo, E.Name,dep.DESCRIPTION AS Department,deg.Name AS DESIGNATION,G.DESCRIPTION as GName,G.Code as GCode,A.Description, SUM(A.changedamount) Amount
// from
// (
// select S.EmployeeID, S.GRADEID, S.SALARYMONTHLYID,S.DEPARTMENTID,S.DESIGNATIONID,--cc.Description AS COSTCENTER,
// sd.ItemGroup,sd.ItemCode,sd.ItemID, sd.Description, sd.changedamount
// from SALARYMONTHLY S, SalaryMonthlyDetail Sd --, SALARYEMPCOSTCENTER empcc, crg cc
// where 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, S.GRADEID, S.SALARYMONTHLYID,S.DEPARTMENTID,S.DESIGNATIONID,--cc.Description AS COSTCENTER,
// sd.ItemGroup,sd.ItemCode,sd.ItemID, sd.Description, sd.changedamount
// from SALARYMONTHLY S, SalaryMonthlyDetail Sd--, SALARYEMPCOSTCENTER empcc, crg cc
// where S.SalaryMonthlyID = Sd.SalaryMonthlyID AND S.SalaryMonth = %d and Sd.ITEMCODE =-139
// AND Sd.ItemGroup IN (4) AND S.EmployeeID IN(%q)
// ) A, Employee E ,DEPARTMENT dep, DESIGNATION deg,Grades G--, crg cc,SALARYEMPCOSTCENTER empcc
// where A.EmployeeID = E.EmployeeID
// AND A.DEPARTMENTID = dep.DEPARTMENTID
// AND A.DESIGNATIONID = deg.DESIGNATIONID
// AND G.GRADEID=A.GRADEID
// group by
// A.DESCRIPTION, E.EmployeeNo, E.Name,G.DESCRIPTION ,G.Code,E.JoiningDate ,dep.DESCRIPTION,deg.Name--,A.COSTCENTER
// order by G.Code,E.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,dep.DESCRIPTION AS Department,deg.Name AS DESIGNATION,--cc.Description AS COSTCENTER,
// G.DESCRIPTION as GName,G.Code as GCode, A.Description, Sum(A.amount) as amount
// ,E.JoiningDate
// from
// ( select S.EmployeeID,Sd.Description, Sum(sd.changedamount) as Amount,
// S.SALARYMONTHLYID ,S.DEPARTMENTID,S.DESIGNATIONID,S.GRADEID
// from SALARYMONTHLY 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,Sd.Description, S.SALARYMONTHLYID,S.DEPARTMENTID,S.DESIGNATIONID,S.GRADEID
// ) A, Employee E ,GRADES G,DEPARTMENT dep, DESIGNATION deg--, crg cc,SALARYEMPCOSTCENTER empcc
// where A.EmployeeID = E.EmployeeID
// AND A.DEPARTMENTID = dep.DEPARTMENTID
// AND A.DESIGNATIONID = deg.DESIGNATIONID
// And G.GRADEID=A.GRADEID
// group by E.EmployeeNo, E.Name,G.DESCRIPTION,G.Code, A.Description,E.JoiningDate ,dep.DESCRIPTION,deg.Name--,cc.Description", 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,dep.DESCRIPTION AS Department,deg.Name AS DESIGNATION,--cc.Description AS COSTCENTER,
E.JoiningDate,G.DESCRIPTION as GName,G.Code as GCode, 'Total Deduction' as Description, Sum(A.amount) as amount
from
( select S.EmployeeID, Sum(sd.changedamount) as Amount,S.GRADEID, S.SALARYMONTHLYID,S.DEPARTMENTID,S.DESIGNATIONID
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.EmployeeID,S.GRADEID, S.SALARYMONTHLYID,S.DEPARTMENTID,S.DESIGNATIONID
) A, GRADES G,Employee E ,DEPARTMENT dep, DESIGNATION deg--, crg cc,SALARYEMPCOSTCENTER empcc
where A.EmployeeID = E.EmployeeID
AND A.DEPARTMENTID = dep.DEPARTMENTID
AND A.DESIGNATIONID = deg.DESIGNATIONID
AND G.GRADEID=A.GRADEID
group by E.EmployeeNo, E.Name,G.DESCRIPTION,G.Code,E.JoiningDate ,dep.DESCRIPTION,deg.Name--,cc.Description
order by E.EmployeeNo,G.Code", dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet(query6);
tempdataset.Tables[0].TableName = "TotalDeduction";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
// string query7 = SQLParser.MakeSQL(@"Select tab1.EMPLOYEENO,tab1.NAME,tab1.Department,tab1.DESIGNATION,--cc.Description AS COSTCENTER,
//tab1.JoiningDate,tab1.GName,tab1.GCode,
//tab1.ItemGroup,tab1.ItemCode,tab1.ItemID,
//tab1.Description,tab1.Amount - ISNULL(tab2.Amount,0) Amount
//from
//(Select E.EMPLOYEENO,E.NAME,dep.DESCRIPTION AS Department,deg.Name AS DESIGNATION,--cc.Description AS COSTCENTER,
//E.JoiningDate,G.DESCRIPTION as GName,G.Code as GCode,
//sd.ItemGroup,sd.ItemCode,sd.ItemID,
//'Net Pay' as Description,SD.CHANGEDAMOUNT as Amount
//from EMPLOYEE as E,GRADES as G,SALARYMONTHLY as S,SALARYMONTHLYDETAIL as Sd ,DEPARTMENT dep, DESIGNATION deg--, crg cc,SALARYEMPCOSTCENTER empcc
//where S.SalaryMonthlyID=Sd.SalaryMonthlyID
//AND S.SalaryMonth = %d
//AND G.GRADEID=S.GRADEID
//AND E.EMPLOYEEID = S.EMPLOYEEID
//and Sd.ItemGroup IN (5) AND Sd.ItemCode IN(-132)
//AND S.EmployeeID IN(%q)
//AND S.DEPARTMENTID = dep.DEPARTMENTID
//AND S.DESIGNATIONID = deg.DESIGNATIONID
//--AND E.EMPLOYEEID = empcc.EMPLOYEEID
//--AND empcc.COSTCENTERID = cc.CRGID
//--AND S.EMPLOYEEID = empcc.EMPLOYEEID
//--AND S.SALARYMONTHLYID = empcc.SALARYMONTHLYID
//) tab1
//left join
//(Select E.EMPLOYEENO,E.NAME,dep.DESCRIPTION AS Department,deg.Name AS DESIGNATION,--cc.Description AS COSTCENTER,
//E.JoiningDate,G.DESCRIPTION as GName,G.Code as GCode,
//sd.ItemGroup,sd.ItemCode,sd.ItemID,
//'Net Pay' as Description,SD.CHANGEDAMOUNT as Amount
//from EMPLOYEE as E,GRADES as G,SALARYMONTHLY as S,SALARYMONTHLYDETAIL as Sd ,DEPARTMENT dep, DESIGNATION deg--, crg cc,SALARYEMPCOSTCENTER empcc
//where S.SalaryMonthlyID=Sd.SalaryMonthlyID
//AND S.SalaryMonth = %d
//AND G.GRADEID=S.GRADEID
//AND E.EMPLOYEEID = S.EMPLOYEEID
//and Sd.ItemGroup IN (1)
//AND S.EmployeeID IN(%q)
//AND S.DEPARTMENTID = dep.DEPARTMENTID
//AND S.DESIGNATIONID = deg.DESIGNATIONID
//--AND E.EMPLOYEEID = empcc.EMPLOYEEID
//--AND empcc.COSTCENTERID = cc.CRGID
//--AND S.EMPLOYEEID = empcc.EMPLOYEEID
//--AND S.SALARYMONTHLYID = empcc.SALARYMONTHLYID
//) tab2
//ON tab1.EMPLOYEENO = tab2.EMPLOYEENO
//order by tab1.EMPLOYEENO,tab1.GCode", dateTime, sEmpID, dateTime, sEmpID);
string query7 = SQLParser.MakeSQL(@"Select E.EMPLOYEENO,E.NAME,dep.DESCRIPTION AS Department,deg.Name AS DESIGNATION,--cc.Description AS COSTCENTER,
E.JoiningDate,G.DESCRIPTION as GName,G.Code as GCode,
sd.ItemGroup,sd.ItemCode,sd.ItemID,
'Net Pay' as Description,SD.CHANGEDAMOUNT as Amount
from EMPLOYEE as E,GRADES as G,SALARYMONTHLY as S,SALARYMONTHLYDETAIL as Sd ,DEPARTMENT dep, DESIGNATION deg--, crg cc,SALARYEMPCOSTCENTER empcc
where S.SalaryMonthlyID=Sd.SalaryMonthlyID
AND S.SalaryMonth = %d
AND G.GRADEID=S.GRADEID
AND E.EMPLOYEEID = S.EMPLOYEEID
and Sd.ItemGroup IN (5) AND Sd.ItemCode IN(-132)
AND S.EmployeeID IN(%q)
AND S.DEPARTMENTID = dep.DEPARTMENTID
AND S.DESIGNATIONID = deg.DESIGNATIONID", 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,dep.DESCRIPTION AS Department,deg.Name AS DESIGNATION,--cc.Description AS COSTCENTER,
E.JoiningDate,G.DESCRIPTION as GName,G.Code as GCode,
sd.ItemGroup,sd.ItemID,sd.ItemCode,
'CPF' as Description,SD.CHANGEDAMOUNT as Amount
from EMPLOYEE as E,GRADES as G,SALARYMONTHLY as S,SALARYMONTHLYDETAIL as Sd ,DEPARTMENT dep, DESIGNATION deg--, crg cc,SALARYEMPCOSTCENTER empcc
where S.SalaryMonthlyID=Sd.SalaryMonthlyID
AND S.SalaryMonth = %d
AND G.GRADEID=S.GRADEID
AND E.EMPLOYEEID =S.EMPLOYEEID
AND Sd.ItemGroup IN (3) AND Sd.ItemCode IN(-128)
AND S.EmployeeID IN(%q)
AND S.DEPARTMENTID = dep.DEPARTMENTID
AND S.DESIGNATIONID = deg.DESIGNATIONID
--AND E.EMPLOYEEID = empcc.EMPLOYEEID
--AND empcc.COSTCENTERID = cc.CRGID
--AND S.EMPLOYEEID = empcc.EMPLOYEEID
--AND S.SALARYMONTHLYID = empcc.SALARYMONTHLYID
order by E.EMPLOYEENO,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 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());
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return rootDataset;
}
internal static DataSet GetEmpSalaryDifference(TransactionContext tc, DateTime fromDate, DateTime toDate, string sEmpID)
{
DataSet rootDataset = new DataSet();
DataSet tempdataset = new DataSet();
try
{
#region Query1
string query1 = SQLParser.MakeSQL(@"
SELECT tab1.EmployeeNo, tab1.Name,tab1.GName,tab1.DName,tab1.GCode,tab1.JoiningDate,tab1.SequenceNo,
tab1.Description, tab1.Amount - ISNULL(tab2.Amount, 0) Amount, tab1.Serial, tab1.SalaryMonth,tab1.ItemCode, tab1.ItemGroup,tab1.ItemID FROM
(select A.EmployeeNo, A.Name,A.GName,A.DName,A.GCode,A.JoiningDate,A.SequenceNo,
A.Description, SUM(A.changedamount) Amount,1 Serial, FORMAT(A.SalaryMonth, 'MMM yy','en-US') SalaryMonth,A.ItemCode, A.ItemGroup,A.ItemID
from
(select S.EmployeeID, E.EmployeeNo, E.Name,E.JoiningDate, sd.ItemGroup,sd.ItemCode, S.SalaryMonth,
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.Salarywithheld<>1 AND S.EmployeeID IN(%q)
UNION
select S.EmployeeID, E.EmployeeNo, E.Name,E.JoiningDate, sd.ItemGroup,sd.ItemCode, S.SalaryMonth,
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.Salarywithheld<>1 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.ItemGroup,A.ItemID, A.Description,A.Position,A.JoiningDate, A.SalaryMonth) tab1
LEFT JOIN
(select A.EmployeeNo, A.Name,A.GName,A.DName,A.GCode,A.JoiningDate,A.SequenceNo,
A.Description, SUM(A.changedamount) Amount,1 Serial, FORMAT(A.SalaryMonth, 'MMM yy','en-US') SalaryMonth,A.ItemCode, A.ItemGroup,A.ItemID
from
(
select S.EmployeeID, E.EmployeeNo, E.Name,E.JoiningDate, sd.ItemGroup,sd.ItemCode, S.SalaryMonth,
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(2) AND sd.ItemCode not in(-133) AND s.Salarywithheld<>1 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.ItemGroup,A.ItemID, A.Description,A.Position,A.JoiningDate, A.SalaryMonth) tab2
ON tab1.EmployeeNo = tab2.EmployeeNo AND tab1.Description = tab2.Description
Union
SELECT tab1.EmployeeNo, tab1.Name,tab1.GName,tab1.DName,tab1.GCode,tab1.JoiningDate,tab1.SequenceNo,
tab1.Description, tab1.Amount - ISNULL(tab2.Amount, 0) Amount, tab1.Serial, tab1.SalaryMonth,tab1.ItemCode, tab1.ItemGroup,tab1.ItemID FROM
(select A.EmployeeNo, A.Name,A.GName,A.DName,A.GCode,A.JoiningDate,A.SequenceNo,
A.Description, SUM(A.changedamount) Amount,1 Serial, FORMAT(A.SalaryMonth, 'MMM yy','en-US') SalaryMonth,A.ItemCode, A.ItemGroup,A.ItemID
from
(select S.EmployeeID, E.EmployeeNo, E.Name,E.JoiningDate, sd.ItemGroup,sd.ItemCode, S.SalaryMonth,
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.Salarywithheld<>1 AND S.EmployeeID IN(%q)
UNION
select S.EmployeeID, E.EmployeeNo, E.Name,E.JoiningDate, sd.ItemGroup,sd.ItemCode, S.SalaryMonth,
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.Salarywithheld<>1 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.ItemGroup,A.ItemID, A.Description,A.Position,A.JoiningDate, A.SalaryMonth) tab1
LEFT JOIN
(select A.EmployeeNo, A.Name,A.GName,A.DName,A.GCode,A.JoiningDate,A.SequenceNo,
A.Description, SUM(A.changedamount) Amount,1 Serial, FORMAT(A.SalaryMonth, 'MMM yy','en-US') SalaryMonth,A.ItemCode, A.ItemGroup,A.ItemID
from
(
select S.EmployeeID, E.EmployeeNo, E.Name,E.JoiningDate, sd.ItemGroup,sd.ItemCode, S.SalaryMonth,
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(2) AND sd.ItemCode not in(-133) AND s.Salarywithheld<>1 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.ItemGroup,A.ItemID, A.Description,A.Position,A.JoiningDate, A.SalaryMonth) tab2
ON tab1.EmployeeNo = tab2.EmployeeNo AND tab1.Description = tab2.Description
UNION
SELECT IsNULL(X.EmployeeNo,Y.EmployeeNo) EmployeeNo, IsNULL(X.Name,Y.Name) Name,IsNULL(X.GName,Y.GName) GName,ISNULL(X.DName,Y.DName) DName,ISNULL(X.GCode,Y.GCode) GCode,ISNULL(X.JoiningDate,Y.JoiningDate) JoiningDate,ISNULL(X.SequenceNo,Y.SequenceNo) SequenceNo,
ISNULL(X.Description,Y.Description) Description, ISNULL(X.Amount,0)-ISNULL(Y.Amount,0) Amount,3 Serial, 'Diff' SalaryMonth,ISNULL(X.ItemCode,Y.ItemCode) ItemCode, ISNULL(X.ItemGroup,Y.ItemGroup) ItemGroup,ISNULL(X.ItemID,Y.ItemID) ItemID
FROM
(
SELECT tab1.EmployeeNo, tab1.Name,tab1.GName,tab1.DName,tab1.GCode,tab1.JoiningDate,tab1.SequenceNo,
tab1.Description, tab1.Amount - ISNULL(tab2.Amount, 0) Amount, tab1.Serial, tab1.SalaryMonth,tab1.ItemCode, tab1.ItemGroup,tab1.ItemID FROM
(select A.EmployeeNo, A.Name,A.GName,A.DName,A.GCode,A.JoiningDate,A.SequenceNo,
A.Description, SUM(A.changedamount) Amount,1 Serial, FORMAT(A.SalaryMonth, 'MMM yy','en-US') SalaryMonth,A.ItemCode, A.ItemGroup,A.ItemID
from
(select S.EmployeeID, E.EmployeeNo, E.Name,E.JoiningDate, sd.ItemGroup,sd.ItemCode, S.SalaryMonth,
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.Salarywithheld<>1 AND S.EmployeeID IN(%q)
UNION
select S.EmployeeID, E.EmployeeNo, E.Name,E.JoiningDate, sd.ItemGroup,sd.ItemCode, S.SalaryMonth,
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.Salarywithheld<>1 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.ItemGroup,A.ItemID, A.Description,A.Position,A.JoiningDate, A.SalaryMonth) tab1
LEFT JOIN
(select A.EmployeeNo, A.Name,A.GName,A.DName,A.GCode,A.JoiningDate,A.SequenceNo,
A.Description, SUM(A.changedamount) Amount,1 Serial, FORMAT(A.SalaryMonth, 'MMM yy','en-US') SalaryMonth,A.ItemCode, A.ItemGroup,A.ItemID
from
(
select S.EmployeeID, E.EmployeeNo, E.Name,E.JoiningDate, sd.ItemGroup,sd.ItemCode, S.SalaryMonth,
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(2) AND sd.ItemCode not in(-133) AND s.Salarywithheld<>1 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.ItemGroup,A.ItemID, A.Description,A.Position,A.JoiningDate, A.SalaryMonth) tab2
ON tab1.EmployeeNo = tab2.EmployeeNo AND tab1.Description = tab2.Description
) X
FULL OUTER JOIN
(
SELECT tab1.EmployeeNo, tab1.Name,tab1.GName,tab1.DName,tab1.GCode,tab1.JoiningDate,tab1.SequenceNo,
tab1.Description, tab1.Amount - ISNULL(tab2.Amount, 0) Amount, tab1.Serial, tab1.SalaryMonth,tab1.ItemCode, tab1.ItemGroup,tab1.ItemID FROM
(select A.EmployeeNo, A.Name,A.GName,A.DName,A.GCode,A.JoiningDate,A.SequenceNo,
A.Description, SUM(A.changedamount) Amount,1 Serial, FORMAT(A.SalaryMonth, 'MMM yy','en-US') SalaryMonth,A.ItemCode, A.ItemGroup,A.ItemID
from
(select S.EmployeeID, E.EmployeeNo, E.Name,E.JoiningDate, sd.ItemGroup,sd.ItemCode, S.SalaryMonth,
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.Salarywithheld<>1 AND S.EmployeeID IN(%q)
UNION
select S.EmployeeID, E.EmployeeNo, E.Name,E.JoiningDate, sd.ItemGroup,sd.ItemCode, S.SalaryMonth,
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.Salarywithheld<>1 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.ItemGroup,A.ItemID, A.Description,A.Position,A.JoiningDate, A.SalaryMonth) tab1
LEFT JOIN
(select A.EmployeeNo, A.Name,A.GName,A.DName,A.GCode,A.JoiningDate,A.SequenceNo,
A.Description, SUM(A.changedamount) Amount,1 Serial, FORMAT(A.SalaryMonth, 'MMM yy','en-US') SalaryMonth,A.ItemCode, A.ItemGroup,A.ItemID
from
(
select S.EmployeeID, E.EmployeeNo, E.Name,E.JoiningDate, sd.ItemGroup,sd.ItemCode, S.SalaryMonth,
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(2) AND sd.ItemCode not in(-133) AND s.Salarywithheld<>1 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.ItemGroup,A.ItemID, A.Description,A.Position,A.JoiningDate, A.SalaryMonth) tab2
ON tab1.EmployeeNo = tab2.EmployeeNo AND tab1.Description = tab2.Description
)
Y
ON
X.EmployeeNo = Y.EmployeeNo and X.Name= Y.Name AND X.GName = Y.GName AND X.DName = Y.DName
AND X.GCode = Y.GCode AND X.JoiningDate = Y.JoiningDate AND X.SequenceNo = Y.SequenceNo
AND X.Description = Y.Description AND X.ItemCode = Y.ItemCode AND X.ItemGroup = Y.ItemGroup AND X.ItemID = Y.ItemID
", fromDate, sEmpID, fromDate, sEmpID, fromDate, sEmpID,
toDate, sEmpID, toDate, sEmpID, toDate, sEmpID,
fromDate, sEmpID, fromDate, sEmpID, fromDate, sEmpID,
toDate, sEmpID, toDate, sEmpID, toDate, sEmpID);
#endregion
tempdataset = tc.ExecuteDataSet(query1);
tempdataset.Tables[0].TableName = "GrossItem";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
#region Query2
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, 1 Serial,
FORMAT(A.SalaryMonth, 'MMM yy','en-US') SalaryMonth
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.Salarywithheld<>1 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.Salarywithheld<>1 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
UNION
select E.EmployeeNo, E.Name,E.JoiningDate,A.GName,A.GCode,A.SequenceNo,A.DName,'Total Gross' as Description, Sum(A.amount) as amount, 2 Serial,
FORMAT(A.SalaryMonth, 'MMM yy','en-US') SalaryMonth
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.Salarywithheld<>1 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.Salarywithheld<>1 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
UNION
SELECT IsNULL(X.EmployeeNo,Y.EmployeeNo) EmployeeNo,
IsNULL(X.Name,Y.Name) Name,
ISNULL(X.JoiningDate,Y.JoiningDate) JoiningDate,
IsNULL(X.GName,Y.GName) GName,
ISNULL(X.GCode,Y.GCode) GCode,
ISNULL(X.SequenceNo,Y.SequenceNo) SequenceNo,
ISNULL(X.DName,Y.DName) DName,
ISNULL(X.Description,Y.Description) Description,
ISNULL(X.Amount,0)-ISNULL(Y.Amount,0) Amount,3 Serial, 'Diff' SalaryMonth
from
(select E.EmployeeNo, E.Name,E.JoiningDate,A.GName,A.GCode,A.SequenceNo,A.DName,'Total Gross' as Description, Sum(A.amount) as amount, A.SalaryMonth
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.Salarywithheld<>1 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.Salarywithheld<>1 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)
X
Full Outer Join
(select E.EmployeeNo, E.Name,E.JoiningDate,A.GName,A.GCode,A.SequenceNo,A.DName,'Total Gross' as Description, Sum(A.amount) as amount, A.SalaryMonth
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.Salarywithheld<>1 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.Salarywithheld<>1 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)
Y
ON X.EmployeeNo = Y.EmployeeNo and X.Name= Y.Name AND X.GName = Y.GName
AND X.GCode = Y.GCode AND X.JoiningDate = Y.JoiningDate
AND X.SequenceNo = Y.SequenceNo
",
fromDate, sEmpID, fromDate, sEmpID,
toDate, sEmpID, toDate, sEmpID,
fromDate, sEmpID, fromDate, sEmpID,
toDate, sEmpID, toDate, sEmpID);
#endregion
tempdataset = tc.ExecuteDataSet(query2);
tempdataset.Tables[0].TableName = "TotalGross";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
#region Query3
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,1 Serial, FORMAT(A.SalaryMonth, 'MMM yy','en-US') SalaryMonth
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.Salarywithheld<>1 AND S.EmployeeID IN(%q)
union
select S.EmployeeID, E.EmployeeNo, E.Name,E.JoiningDate,sd.ItemGroup,0 ItemCode,
0 ItemID, 'LWP' Description,0 Position, SUM(sd.changedamount) 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.Salarywithheld<>1 AND S.EmployeeID IN(%q)
GROUP BY S.EmployeeID, E.EmployeeNo, E.Name,E.JoiningDate,sd.ItemGroup,G.DESCRIPTION,G.Code,G.sequenceNo,D.Name, S.SalaryMonth
) A group by
A.EmployeeID, A.EmployeeNo, A.Name,A.GName,A.SequenceNo,A.GCode,A.DName,
A.ItemCode, A.ItemGroup,A.ItemID, A.Description,A.Position,A.JoiningDate, A.SalaryMonth
UNION
select A.EmployeeNo, A.Name,A.JoiningDate,A.GName,A.GCode,A.SequenceNo,A.DName,
A.Description, SUM(A.changedamount) Amount,2 Serial, FORMAT(A.SalaryMonth, 'MMM yy','en-US') SalaryMonth
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.Salarywithheld<>1 AND S.EmployeeID IN(%q)
union
select S.EmployeeID, E.EmployeeNo, E.Name,E.JoiningDate,sd.ItemGroup,0 ItemCode,
0 ItemID, 'LWP' Description,0 Position, SUM(sd.changedamount) 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.Salarywithheld<>1 AND S.EmployeeID IN(%q)
GROUP BY S.EmployeeID, E.EmployeeNo, E.Name,E.JoiningDate,sd.ItemGroup,G.DESCRIPTION,G.Code,G.sequenceNo,D.Name, S.SalaryMonth
) A group by
A.EmployeeID, A.EmployeeNo, A.Name,A.GName,A.SequenceNo,A.GCode,A.DName,
A.ItemCode, A.ItemGroup,A.ItemID, A.Description,A.Position,A.JoiningDate, A.SalaryMonth
UNION
SELECT IsNULL(X.EmployeeNo,Y.EmployeeNo) EmployeeNo,
IsNULL(X.Name,Y.Name) Name,
ISNULL(X.JoiningDate,Y.JoiningDate) JoiningDate,
IsNULL(X.GName,Y.GName) GName,
ISNULL(X.GCode,Y.GCode) GCode,
ISNULL(X.SequenceNo,Y.SequenceNo) SequenceNo,
ISNULL(X.DName,Y.DName) DName,
ISNULL(X.Description,Y.Description) Description,
ISNULL(X.Amount,0)-ISNULL(Y.Amount,0) Amount,3 Serial, 'Diff' SalaryMonth
From(select A.EmployeeNo, A.Name,A.JoiningDate,A.GName,A.GCode,A.SequenceNo,A.DName,
A.Description, SUM(A.changedamount) Amount, A.SalaryMonth
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.Salarywithheld<>1 AND S.EmployeeID IN(%q)
union
select S.EmployeeID, E.EmployeeNo, E.Name,E.JoiningDate,sd.ItemGroup,0 ItemCode,
0 ItemID, 'LWP' Description,0 Position, SUM(sd.changedamount) 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.Salarywithheld<>1 AND S.EmployeeID IN(%q)
GROUP BY S.EmployeeID, E.EmployeeNo, E.Name,E.JoiningDate,sd.ItemGroup,G.DESCRIPTION,G.Code,G.sequenceNo,D.Name, S.SalaryMonth
) A group by
A.EmployeeID, A.EmployeeNo, A.Name,A.GName,A.SequenceNo,A.GCode,A.DName,
A.ItemCode, A.ItemGroup,A.ItemID, A.Description,A.Position,A.JoiningDate, A.SalaryMonth)
X
Full Outer Join
(
select A.EmployeeNo, A.Name,A.JoiningDate,A.GName,A.GCode,A.SequenceNo,A.DName,
A.Description, SUM(A.changedamount) Amount, A.SalaryMonth
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.Salarywithheld<>1 AND S.EmployeeID IN(%q)
union
select S.EmployeeID, E.EmployeeNo, E.Name,E.JoiningDate,sd.ItemGroup,0 ItemCode,
0 ItemID, 'LWP' Description,0 Position, SUM(sd.changedamount) 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.Salarywithheld<>1 AND S.EmployeeID IN(%q)
GROUP BY S.EmployeeID, E.EmployeeNo, E.Name,E.JoiningDate,sd.ItemGroup,G.DESCRIPTION,G.Code,G.sequenceNo,D.Name, S.SalaryMonth
) A group by
A.EmployeeID, A.EmployeeNo, A.Name,A.GName,A.SequenceNo,A.GCode,A.DName,
A.ItemCode, A.ItemGroup,A.ItemID, A.Description,A.Position,A.JoiningDate, A.SalaryMonth
) Y
ON X.EmployeeNo = Y.EmployeeNo and X.Name= Y.Name AND X.JoiningDate = Y.JoiningDate
AND X.GName = Y.GName AND X.GCode = Y.GCode AND X.DName = Y.DName AND X.Description = Y.Description
AND X.SequenceNo = Y.SequenceNo ",
fromDate, sEmpID, fromDate, sEmpID,
toDate, sEmpID, toDate, sEmpID,
fromDate, sEmpID, fromDate, sEmpID,
toDate, sEmpID, toDate, sEmpID);
#endregion
tempdataset = tc.ExecuteDataSet(query3);
tempdataset.Tables[0].TableName = "DeductItem";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
#region Query6
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,1 Serial , FORMAT(A.SalaryMonth, 'MMM yy','en-US') SalaryMonth
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,Sd.ItemCode, Sd.ItemGroup,Sd.ItemID
from GRADES G,DESIGNATION D,SALARYMONTHLY S,SalaryMonthlyDetail Sd
where S.SalaryMonthlyID=Sd.SalaryMonthlyID AND s.Salarywithheld<>1
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,Sd.ItemCode, Sd.ItemGroup,Sd.ItemID
) 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
UNION
select E.EmployeeNo, E.Name,E.JoiningDate,A.GName,A.GCode,A.SequenceNo,A.DName, 'Total Deduction' as Description, Sum(A.amount) as amount,2 Serial , FORMAT(A.SalaryMonth, 'MMM yy','en-US') SalaryMonth
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,Sd.ItemCode, Sd.ItemGroup,Sd.ItemID
from GRADES G,DESIGNATION D,SALARYMONTHLY S,SalaryMonthlyDetail Sd
where S.SalaryMonthlyID=Sd.SalaryMonthlyID AND s.Salarywithheld<>1
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,Sd.ItemCode, Sd.ItemGroup,Sd.ItemID
) 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
UNION
SELECT IsNULL(X.EmployeeNo,Y.EmployeeNo) EmployeeNo,
IsNULL(X.Name,Y.Name) Name,
ISNULL(X.JoiningDate,Y.JoiningDate) JoiningDate,
IsNULL(X.GName,Y.GName) GName,
ISNULL(X.GCode,Y.GCode) GCode,
ISNULL(X.SequenceNo,Y.SequenceNo) SequenceNo,
ISNULL(X.DName,Y.DName) DName,
ISNULL(X.Description,Y.Description) Description,
ISNULL(X.Amount,0)-ISNULL(Y.Amount,0) Amount,3 Serial, 'Diff' SalaryMonth
From
(
select E.EmployeeNo, E.Name,E.JoiningDate,A.GName,A.GCode,A.SequenceNo,A.DName, 'Total Deduction' as Description, Sum(A.amount) as amount , A.SalaryMonth
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,Sd.ItemCode, Sd.ItemGroup,Sd.ItemID
from GRADES G,DESIGNATION D,SALARYMONTHLY S,SalaryMonthlyDetail Sd
where S.SalaryMonthlyID=Sd.SalaryMonthlyID AND s.Salarywithheld<>1
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,Sd.ItemCode, Sd.ItemGroup,Sd.ItemID
) 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
) X
FULL OUTER JOIN
(
select E.EmployeeNo, E.Name,E.JoiningDate,A.GName,A.GCode,A.SequenceNo,A.DName, 'Total Deduction' as Description, Sum(A.amount) as amount , A.SalaryMonth
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,Sd.ItemCode, Sd.ItemGroup,Sd.ItemID
from GRADES G,DESIGNATION D,SALARYMONTHLY S,SalaryMonthlyDetail Sd
where S.SalaryMonthlyID=Sd.SalaryMonthlyID AND s.Salarywithheld<>1
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,Sd.ItemCode, Sd.ItemGroup,Sd.ItemID
) 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
) Y
ON X.EmployeeNo = Y.EmployeeNo and X.Name= Y.Name AND X.GName = Y.GName
AND X.GCode = Y.GCode AND X.JoiningDate = Y.JoiningDate
AND X.SequenceNo = Y.SequenceNo ", fromDate, sEmpID,
toDate, sEmpID,
fromDate, sEmpID,
toDate, sEmpID);
#endregion
tempdataset = tc.ExecuteDataSet(query6);
tempdataset.Tables[0].TableName = "TotalDeduction";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
#region Query7
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,1 Serial, FORMAT(S.SalaryMonth, 'MMM yy','en-US') 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.Salarywithheld<>1 AND S.EmployeeID IN(%q)
UNION
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,2 Serial, FORMAT(S.SalaryMonth, 'MMM yy','en-US') 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.Salarywithheld<>1 AND S.EmployeeID IN(%q)
UNION
SELECT IsNULL(X.EmployeeNo,Y.EmployeeNo) EmployeeNo,
IsNULL(X.Name,Y.Name) Name,
ISNULL(X.JoiningDate,Y.JoiningDate) JoiningDate,
IsNULL(X.GName,Y.GName) GName,
ISNULL(X.GCode,Y.GCode) GCode,
ISNULL(X.SequenceNo,Y.SequenceNo) SequenceNo,
ISNULL(X.DName,Y.DName) DName,
ISNULL(X.Description,Y.Description) Description,
ISNULL(X.Amount,0)-ISNULL(Y.Amount,0) Amount,3 Serial, 'Diff' SalaryMonth
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.Salarywithheld<>1 AND S.EmployeeID IN(%q)
) X
FULL OUTER JOIN
(
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.Salarywithheld<>1 AND S.EmployeeID IN(%q)
) Y
ON X.EmployeeNo = Y.EmployeeNo and X.Name= Y.Name AND X.GName = Y.GName
AND X.GCode = Y.GCode AND X.JoiningDate = Y.JoiningDate
AND X.SequenceNo = Y.SequenceNo ", fromDate, sEmpID,
toDate, sEmpID,
fromDate, sEmpID,
toDate, 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 GetEmpSalarySheet(TransactionContext tc, DateTime dateTime,string sEmpID)
// {
// DataSet rootDataset = new DataSet();
// DataSet tempdataset = new DataSet();
// try
// {
// string query1 = SQLParser.MakeSQL(@"select A.EmployeeNo, A.Name,A.GName,A.DName,A.GCode,A.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 GName,D.Name DName,G.Code 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 in(-101,-113) AND sd.ItemID IN (-101,1,2,3,4,5,142) 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 GName,D.Name DName,G.Code 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 in(-101,-113) AND sd.ItemID IN (-101,1,2,3,4,5,142) 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 = "BasicGrossItem";
// 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' Description, Sum(A.amount) amount
// from
// ( select S.EmployeeID, Sum(sd.changedamount) Amount,G.DESCRIPTION GName,G.Code GCode,G.SequenceNo,D.Name 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.ItemCode IN (-101,-113) AND sd.ItemID IN (-101,1,2,3,4,5,142) 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) Amount,G.DESCRIPTION GName,G.Code GCode,G.sequenceNo,D.Name 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 sd.ItemCode IN (-101,-113) AND sd.ItemID IN (-101,1,2,3,4,5,142) 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"; //Total Of Basic, House Rent, Medical, Transport, LFA, Medical Interest
// rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
// string query3 = 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 GName,D.Name DName,G.Code 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 in(-107) AND sd.ItemID IN (1,2,3,4) 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 GName,D.Name DName,G.Code 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 in(-107) AND sd.ItemID IN (1,2,3,4) 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(query3);
// tempdataset.Tables[0].TableName = "BonusItem";
// rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
// string query4 = SQLParser.MakeSQL(@"select E.EmployeeNo, E.Name,E.JoiningDate,A.GName,A.GCode,A.SequenceNo,A.DName,'Total Bonus' Description, Sum(A.amount) amount
// from
// ( select S.EmployeeID, Sum(sd.changedamount) Amount,G.DESCRIPTION GName,G.Code GCode,G.SequenceNo,D.Name 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.ItemCode IN (-107) AND sd.ItemID IN (1,2,3,4) 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) Amount,G.DESCRIPTION GName,G.Code GCode,G.sequenceNo,D.Name 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 sd.ItemCode IN (-107) AND sd.ItemID IN (1,2,3,4) 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(query4);
// tempdataset.Tables[0].TableName = "TotalBonus"; //Total Of CS, CM, Ad Sales, KPI Quarterly Bonus
// rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
// string query5 = 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 GName,D.Name DName,G.Code 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 in(-113) AND sd.ItemID IN (9,10,11,12,13,14,15,18) 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 GName,D.Name DName,G.Code 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 in(-113) AND sd.ItemID IN (9,10,11,12,13,14,15,18) 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(query5);
// tempdataset.Tables[0].TableName = "AllowanceItem";
// 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 Allowance' Description, Sum(A.amount) amount
// from
// ( select S.EmployeeID, Sum(sd.changedamount) Amount,G.DESCRIPTION GName,G.Code GCode,G.SequenceNo,D.Name 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.ItemCode IN (-113) AND sd.ItemID IN (9,10,11,12,13,14,15,18) 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) Amount,G.DESCRIPTION GName,G.Code GCode,G.sequenceNo,D.Name 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 sd.ItemCode IN (-113) AND sd.ItemID IN (9,10,11,12,13,14,15,18) 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(query6);
// tempdataset.Tables[0].TableName = "TotalAllowance"; //Total Of Conv, Additional Expence, Off duty/Extra Hour allowance, GV Holiday payment, Eid Day duty Allowance, Internet Exp, Salary Incentive, Pay in leu of Notice
// rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
// string query7 = SQLParser.MakeSQL(@"SELECT t1.EmployeeNo, t1.Name, t1.JoiningDate, t1.GName, t1.GCode, t1.SequenceNo,t1.DName, SUM(t1.amount) Amount, t1.Description
// FROM
// --TotalGross
// ( select E.EmployeeNo, E.Name,E.JoiningDate,A.GName,A.GCode,A.SequenceNo,A.DName, 'Total Income' Description, Sum(A.amount) amount
// from
// ( select S.EmployeeID, Sum(sd.changedamount) Amount,G.DESCRIPTION GName,G.Code GCode,G.SequenceNo,D.Name 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.ItemCode IN (-101,-113) AND sd.ItemID IN (-101,1,2,3,4,5,142) 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) Amount,G.DESCRIPTION GName,G.Code GCode,G.sequenceNo,D.Name 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 sd.ItemCode IN (-101,-113) AND sd.ItemID IN (-101,1,2,3,4,5,142) 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
//
// UNION ALL
//
// --TotalBonus
// select E.EmployeeNo, E.Name,E.JoiningDate,A.GName,A.GCode,A.SequenceNo,A.DName, 'Total Income' Description, Sum(A.amount) amount
// from
// ( select S.EmployeeID, Sum(sd.changedamount) Amount,G.DESCRIPTION GName,G.Code GCode,G.SequenceNo,D.Name 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.ItemCode IN (-107) AND sd.ItemID IN (1,2,3,4) 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) Amount,G.DESCRIPTION GName,G.Code GCode,G.sequenceNo,D.Name 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 sd.ItemCode IN (-107) AND sd.ItemID IN (1,2,3,4) 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
//
// UNION ALL
// --TotalAllowance
// select E.EmployeeNo, E.Name,E.JoiningDate,A.GName,A.GCode,A.SequenceNo,A.DName, 'Total Income' Description, Sum(A.amount) amount
// from
// ( select S.EmployeeID, Sum(sd.changedamount) Amount,G.DESCRIPTION GName,G.Code GCode,G.SequenceNo,D.Name 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.ItemCode IN (-113) AND sd.ItemID IN (9,10,11,12,13,14,15,18) 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) Amount,G.DESCRIPTION GName,G.Code GCode,G.sequenceNo,D.Name 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 sd.ItemCode IN (-113) AND sd.ItemID IN (9,10,11,12,13,14,15,18) 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
// ) t1 GROUP BY t1.EmployeeNo, t1.Name, t1.JoiningDate, t1.GName, t1.GCode, t1.SequenceNo, t1.DName, t1.Description",
// dateTime, sEmpID, dateTime, sEmpID, dateTime, sEmpID, dateTime, sEmpID, dateTime, sEmpID, dateTime, sEmpID);
// tempdataset = tc.ExecuteDataSet(query7);
// tempdataset.Tables[0].TableName = "TotalIncome"; //
// rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
// string query8 = 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 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)
// 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)
// ) 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(query8);
// tempdataset.Tables[0].TableName = "DeductItem";
// rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
// string query9 = 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 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.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 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.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(query9);
// tempdataset.Tables[0].TableName = "LeaveDays";
// rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
// string query10 = SQLParser.MakeSQL(@"
// select E.EmployeeNo, E.Name,A.GName,A.GCode,A.sequenceNo,A.DName, A.Description, Sum(A.amount) amount
// ,E.JoiningDate
// from
// (select S.EmployeeID,Sd.Description, Sum(sd.changedamount) Amount,G.DESCRIPTION GName,G.Code GCode,G.SequenceNo,D.Name 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(query10);
// tempdataset.Tables[0].TableName = "AttendenceDays";
// rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
// string query11 = SQLParser.MakeSQL(@"select E.EmployeeNo, E.Name,E.JoiningDate,A.GName,A.GCode,A.SequenceNo,A.DName, 'Total Deduction' Description, Sum(A.amount) amount
// from
// ( select S.EmployeeID, Sum(sd.changedamount) Amount,G.DESCRIPTION GName,G.Code GCode,G.SequenceNo,D.Name 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(query11);
// tempdataset.Tables[0].TableName = "TotalDeduction";
// rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
// string query12 = SQLParser.MakeSQL(@"Select E.EMPLOYEENO,E.NAME,E.JoiningDate,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 E.EMPLOYEENO,G.SequenceNo,G.Code ", dateTime, sEmpID);
// tempdataset = tc.ExecuteDataSet(query12);
// tempdataset.Tables[0].TableName = "NetPay";
// rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
// string query13 = SQLParser.MakeSQL(@"Select E.EMPLOYEENO,E.NAME,E.JoiningDate,G.DESCRIPTION GName,G.Code GCode,G.SequenceNo,D.Name DName ,'CPF' 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 (3) AND Sd.ItemCode IN(-128) AND S.EmployeeID IN(%q) order by E.EMPLOYEENO,G.SequenceNo,G.Code ", dateTime, sEmpID);
// tempdataset = tc.ExecuteDataSet(query13);
// 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 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 GName,D.Name DName,G.Code 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 GName,D.Name DName,G.Code 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' Description, Sum(A.amount) amount "
+ " from"
+ "( select S.EmployeeID, Sum(sd.changedamount) Amount,G.DESCRIPTION GName,G.Code GCode,G.SequenceNo,D.Name 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) Amount,G.DESCRIPTION GName,G.Code GCode,G.sequenceNo,D.Name 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 GName,G.Code GCode,G.SequenceNo,D.Name 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 GName,G.Code GCode,G.sequenceNo,D.Name 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 GName,G.Code GCode,G.SequenceNo,D.Name 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 GName,G.Code GCode,G.SequenceNo,D.Name 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' Description, Sum(A.amount) amount "
+ " from"
+ " ( select S.EmployeeID, Sum(sd.changedamount) Amount,G.DESCRIPTION GName,G.Code GCode,G.SequenceNo,D.Name 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' Description, Sum(A.amount) amount "
+ " from"
+ "( select S.EmployeeID, Sum(sd.changedamount) Amount,G.DESCRIPTION GName,G.Code GCode,G.SequenceNo,D.Name 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 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)"
+ " 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 GName,D.DESCRIPTION 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 GName,D.DESCRIPTION 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' Description, Sum(A.amount) amount "
// + " from"
// + "( select S.EmployeeID, Sum(sd.changedamount) Amount,G.DESCRIPTION GName,D.DESCRIPTION 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) Amount,G.DESCRIPTION GName,D.DESCRIPTION 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 GName,D.DESCRIPTION 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 GName,D.DESCRIPTION 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 GName,D.DESCRIPTION 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' Description, Sum(A.amount) amount "
// + " from"
// + "( select S.EmployeeID, Sum(sd.changedamount) Amount,G.DESCRIPTION GName,D.DESCRIPTION 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) Amount,G.DESCRIPTION GName,D.DESCRIPTION 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 GName,D.DESCRIPTION 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 GName,D.DESCRIPTION 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' Description, Sum(A.amount) amount "
// + " from"
// + "( select S.EmployeeID, Sum(sd.changedamount) Amount,G.DESCRIPTION GName,D.DESCRIPTION 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) Amount,G.DESCRIPTION GName,D.DESCRIPTION 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 GName,D.DESCRIPTION DName ,'Net Pay' Description,SD.CHANGEDAMOUNT Amount"
// + " from EMPLOYEE E,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 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 GName,"
// + " D.Name DName,G.Code 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' Description, Sum(A.amount) amount "
// + " from"
// + "( select S.EmployeeID, Sum(sd.changedamount) Amount,G.DESCRIPTION GName,G.Code GCode,G.SequenceNo,D.Name 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) Amount,G.DESCRIPTION GName,G.Code GCode,G.sequenceNo,D.Name 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 GName,G.Code GCode,G.SequenceNo,D.Name 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 GName,G.Code GCode,G.sequenceNo,D.Name 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 GName,G.Code GCode,G.SequenceNo,D.Name 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 GName,G.Code GCode,G.SequenceNo,D.Name 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' Description, Sum(A.amount) amount "
// + " from"
// + " ( select S.EmployeeID, Sum(sd.changedamount) Amount,G.DESCRIPTION GName,G.Code GCode,G.SequenceNo,D.Name 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' Description, Sum(A.amount) amount "
// + " from"
// + "( select S.EmployeeID, Sum(sd.changedamount) Amount,G.DESCRIPTION GName,G.Code GCode,G.SequenceNo,D.Name 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 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 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
{
string sTableName;
sEmpID = IDHelper.GetIDs(tc, sEmpID, out sTableName);
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 GName,"
+ " D.Name DName,G.Code GCode,CC.Description 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' Description, Sum(A.amount) amount,A.ItemGroup "
+ " from"
+ " (select S.EmployeeID, Sum(sd.changedamount) Amount,G.DESCRIPTION GName,G.Code GCode,CC.Description CCName,G.SequenceNo,D.Name 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) Amount,G.DESCRIPTION GName,G.Code GCode,CC.Description CCName,G.sequenceNo,D.Name 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 GName,G.Code GCode,CC.Description CCName,G.SequenceNo,D.Name 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 GName,G.Code GCode,CC.description CCName,G.sequenceNo,D.Name 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 GName,G.Code GCode,CC.Description CCName,G.SequenceNo,D.Name 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 GName,G.Code GCode,CC.Description CCName,G.SequenceNo,D.Name 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' Description, Sum(A.amount) amount,A.ItemGroup "
+ " from"
+ " (select S.EmployeeID, Sum(sd.changedamount) Amount,G.DESCRIPTION GName,Sd.ItemGroup,G.Code GCode,CC.Description CCName,"
+ " G.SequenceNo,D.Name 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' Description, Sum(A.amount) amount,A.ItemGroup "
+ " from"
+ " (select S.EmployeeID, Sum(sd.changedamount) Amount,G.DESCRIPTION GName,G.Code GCode,CC.description CCName,"
+ " G.SequenceNo,D.Name 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 GName,G.Code GCode,Sd.ItemGroup,"
+ " G.SequenceNo,D.Name DName ,CC.Description CCName,'Net Pay' Description,SD.CHANGEDAMOUNT Amount"
+ " from EMPLOYEE E,GRADES G,CRG CC,DESIGNATION D,SALARYEMPCOSTCENTER SEMPCC,SALARYMONTHLY S,SALARYMONTHLYDETAIL 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());
if (sTableName != "")
tc.ExecuteNonQuery("Drop TAble %q", sTableName);
}
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
{
string sTableName;
sEmpID = IDHelper.GetIDs(tc, sEmpID, out sTableName);
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 GName,"
+ " D.Name DName,G.Code GCode,CC.Description 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 GName,G.Code GCode,CC.Description CCName,G.SequenceNo,D.Name 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 GName,G.Code GCode,CC.description CCName,G.sequenceNo,D.Name 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 GName,G.Code GCode,CC.Description CCName,G.SequenceNo,D.Name 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 GName,G.Code GCode,CC.Description CCName,G.SequenceNo,D.Name 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' Description, Sum(A.amount) amount,A.ItemGroup "
+ " from"
+ " (select S.EmployeeID, Sum(sd.changedamount) Amount,G.DESCRIPTION GName,Sd.ItemGroup,G.Code GCode,CC.Description CCName,"
+ " G.SequenceNo,D.Name 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 GName,G.Code GCode,Sd.ItemGroup,"
+ " G.SequenceNo,D.Name DName ,CC.Description CCName,'Net Pay' Description,SD.CHANGEDAMOUNT Amount"
+ " from EMPLOYEE E,GRADES G,CRG CC,DESIGNATION D,SALARYEMPCOSTCENTER SEMPCC,SALARYMONTHLY S,SALARYMONTHLYDETAIL 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());
if (sTableName != "")
tc.ExecuteNonQuery("Drop TAble %q", sTableName);
}
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 GName,"
// + " D.Name DName,G.Code 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' Description, Sum(A.amount) amount "
// + " from"
// + "( select S.EmployeeID, Sum(sd.changedamount) Amount,G.DESCRIPTION GName,G.Code GCode,G.SequenceNo,D.Name 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) Amount,G.DESCRIPTION GName,G.Code GCode,G.sequenceNo,D.Name 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 GName,G.Code GCode,G.SequenceNo,D.Name 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 GName,G.Code GCode,G.sequenceNo,D.Name 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 GName,G.Code GCode,G.SequenceNo,D.Name 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 GName,G.Code GCode,G.SequenceNo,D.Name 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' Description, Sum(A.amount) amount "
// + " from"
// + " ( select S.EmployeeID, Sum(sd.changedamount) Amount,G.DESCRIPTION GName,G.Code GCode,G.SequenceNo,D.Name 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' Description, Sum(A.amount) amount "
// + " from"
// + "( select S.EmployeeID, Sum(sd.changedamount) Amount,G.DESCRIPTION GName,G.Code GCode,G.SequenceNo,D.Name 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 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 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 GName,"
+ " D.Name DName,G.Code GCode,CC.Description 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' Description, Sum(A.amount) amount,A.ItemGroup "
// + " from"
// + " (select S.EmployeeID, Sum(sd.changedamount) Amount,G.DESCRIPTION GName,G.Code GCode,CC.Description CCName,G.SequenceNo,D.Name 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) Amount,G.DESCRIPTION GName,G.Code GCode,CC.Description CCName,G.sequenceNo,D.Name 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 GName,G.Code GCode,CC.Description CCName,G.SequenceNo,D.Name 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 GName,G.Code GCode,CC.description CCName,G.sequenceNo,D.Name 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 GName,G.Code GCode,CC.Description CCName,G.SequenceNo,D.Name 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 GName,G.Code GCode,CC.Description CCName,G.SequenceNo,D.Name 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' Description, Sum(A.amount) amount,A.ItemGroup "
+ " from"
+ " (select S.EmployeeID, Sum(sd.changedamount) Amount,G.DESCRIPTION GName,Sd.ItemGroup,G.Code GCode,CC.Description CCName,"
+ " G.SequenceNo,D.Name 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' Description, Sum(A.amount) amount,A.ItemGroup "
// + " from"
// + " (select S.EmployeeID, Sum(sd.changedamount) Amount,G.DESCRIPTION GName,G.Code GCode,CC.description CCName,"
// + " G.SequenceNo,D.Name 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 GName,G.Code GCode,Sd.ItemGroup,"
+ " G.SequenceNo,D.Name DName ,CC.Description CCName,'Net Pay' Description,SD.CHANGEDAMOUNT Amount"
+ " from EMPLOYEE E,GRADES G,CRG CC,DESIGNATION D,SALARYEMPCOSTCENTER SEMPCC,SALARYMONTHLY S,SALARYMONTHLYDETAIL 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 sTableName;
sEmpID = IDHelper.GetIDs(tc, sEmpID, out sTableName);
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 GName,D.Name DName,G.Code GCode,
G.SequenceNo,CC.DESCRIPTION CRGDes
from Grades G,CRG CC,SALARYEMPCOSTCENTER 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 GName, D.Name DName,G.Code GCode,
G.SequenceNo,CC.DESCRIPTION CRGDes
from Grades G,CRG CC,SALARYEMPCOSTCENTER 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' Description,A.CRGDes,A.SequenceNO, "
+ " Sum(A.amount) amount "
+ " from"
+ " ( select S.EmployeeID, Sum(sd.changedamount) Amount,G.DESCRIPTION GName,G.Code GCode,G.SequenceNo,D.Name DName,CC.DESCRIPTION CRGDes "
+ " from SALARYMONTHLY S,Grades G,CRG CC,SALARYEMPCOSTCENTER 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) Amount,G.DESCRIPTION GName,G.Code GCode,G.SequenceNo,D.Name DName,CC.DESCRIPTION CRGDes"
+ " from GRADES G,CRG CC,SALARYEMPCOSTCENTER 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 GName,CC.DESCRIPTION CRGDes,
G.Code GCode,G.SequenceNo,D.Name DName
from Grades G,CRG CC,SALARYEMPCOSTCENTER 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 GName,CC.DESCRIPTION CRGDes,
G.Code GCode,G.SequenceNo,D.Name DName
from Grades G,CRG CC,SALARYEMPCOSTCENTER 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 GName,CC.DESCRIPTION CRGDes,
G.Code GCode,G.SequenceNo,D.Name DName
from Grades G,CRG CC,SALARYEMPCOSTCENTER 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 GName,CC.DESCRIPTION CRGDes,
G.Code GCode,G.SequenceNo,D.Name DName
from Grades G,CRG CC,SALARYEMPCOSTCENTER 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' Description,
A.CRGDes,A.SequenceNo, Sum(A.amount) amount
from (
select S.EmployeeID, Sum(sd.changedamount) Amount,G.DESCRIPTION GName,
CC.DESCRIPTION CRGDes, G.Code GCode,G.SequenceNo,D.Name DName
from GRADES G,CRG CC,SALARYEMPCOSTCENTER 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' Description,
A.CRGDes,A.SequenceNo, Sum(A.amount) amount
from (
select S.EmployeeID, Sum(sd.changedamount) Amount,G.DESCRIPTION GName,
CC.DESCRIPTION CRGDes, G.Code GCode,G.SequenceNo,D.Name DName
from GRADES G,CRG CC,SALARYEMPCOSTCENTER 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 GName,G.Code GCode,D.Name DName,
'Net Pay' Description,CC.DESCRIPTION CRGDes,G.SequenceNo, SD.CHANGEDAMOUNT Amount
from EMPLOYEE E,GRADES G,CRG CC,SALARYEMPCOSTCENTER 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 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());
if (sTableName != "")
tc.ExecuteNonQuery("Drop TAble %q", sTableName);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return rootDataset;
}
internal static DataSet GetExtendedSalarySheet(TransactionContext tc, DateTime dateTime, string sEmpID)
{
#region old-Code
//DataSet rootDataset = new DataSet();
//DataSet tempdataset = new DataSet();
//try
//{
// string sTableName;
// sEmpID = IDHelper.GetIDs(tc, sEmpID, out sTableName);
// 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 CDescription,"
// + " sd.ItemID, sd.Description,sd.Position, sd.changedamount,G.DESCRIPTION GName,D.DESCRIPTION DName,S.Designation 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 CDescription,"
// //+ " sd.ItemID, sd.Description,sd.Position, -sd.changedamount,G.DESCRIPTION GName,D.DESCRIPTION DName,DG.NAME 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 CDescription,"
// + " sd.ItemID, sd.Description,sd.Position, sd.changedamount,G.DESCRIPTION GName,D.DESCRIPTION DName,S.Designation 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' Description, Sum(A.amount) amount,A.DGName,E.BIRTHDATE,E.JOININGDATE,E.DATEOFCONFIRMATION,A.CDescription"
// + " from"
// + " (select S.EmployeeID, Sum(sd.changedamount) Amount,G.DESCRIPTION GName,D.DESCRIPTION DName,DG.NAME DGName,C.Description CDescription"
// + " from SALARYMONTHLY S,Grades G,Department D, SalaryMonthlyDetail Sd,Designation 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) Amount,G.DESCRIPTION GName,D.DESCRIPTION DName,DG.NAME DGName,C.Description 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 (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 GName,D.DESCRIPTION DName,DG.NAME DGName,C.Description 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 GName,D.DESCRIPTION DName,DG.NAME DGName,C.Description 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 GName,D.DESCRIPTION DName,DG.NAME DGName,C.Description 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' Description, Sum(A.amount) amount,A.DGName,E.BIRTHDATE,E.JOININGDATE,E.DATEOFCONFIRMATION,A.CDescription"
// + " from"
// + " (select S.EmployeeID, Sum(sd.changedamount) Amount,G.DESCRIPTION GName,D.DESCRIPTION DName,DG.NAME DGName,C.Description CDescription"
// + " from SALARYMONTHLY S,Grades G,Department D, SalaryMonthlyDetail Sd,Designation 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) Amount,G.DESCRIPTION GName,D.DESCRIPTION DName,DG.NAME DGName,C.Description 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 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 GName,D.DESCRIPTION DName,DG.NAME DGName,C.Description 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 GName,D.DESCRIPTION DName,DG.NAME DGName,C.Description 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' Description, Sum(A.amount) amount,A.DGName,E.BIRTHDATE,E.JOININGDATE,E.DATEOFCONFIRMATION,A.CDescription"
// + " from"
// + " (select S.EmployeeID, Sum(sd.changedamount) Amount,G.DESCRIPTION GName,D.DESCRIPTION DName,DG.NAME DGName,C.Description 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) Amount,G.DESCRIPTION GName,D.DESCRIPTION DName,DG.NAME DGName,C.Description 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 (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' Description,sd.changedamount Amount,G.DESCRIPTION GName,D.DESCRIPTION DName,DG.NAME DGName,E.BIRTHDATE,E.JOININGDATE,E.DATEOFCONFIRMATION,C.Description CDescription"
// + " from GRADES G,DEPARTMENT D,SALARYMONTHLY S, SalaryMonthlyDetail Sd,Employee E,Designation 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());
// if (sTableName != "")
// tc.ExecuteNonQuery("Drop TAble %q", sTableName);
//}
//catch (Exception ex)
//{
// throw new Exception(ex.Message);
//}
#endregion old-Code
DataSet rootDataset = new DataSet();
DataSet tempdataset = new DataSet();
try
{
string sqlGrossItem = SQLParser.MakeSQL(@"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,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 in(8) 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,19) and ItemCode not in(-102,-103)
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,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 in(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,19) and ItemCode not in(-102,-103)
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,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 in(1) 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,19) and ItemCode not in(-102,-103)
) 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, dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet(sqlGrossItem);
tempdataset.Tables[0].TableName = "GrossItem";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string sqlTotalGross = SQLParser.MakeSQL(@"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,19)
and ItemCode not in(-102,-103)
group by S.EmployeeID,G.DESCRIPTION,D.DESCRIPTION,Dg.NAME,C.Description
UNION
select S.EmployeeID, - ISNULL(Sum(sd.changedamount), 0 ) 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 (2) AND DG.DESIGNATIONID=S.DESIGNATIONID AND S.EmployeeID IN(%q) AND Sd.ItemID Not In(13,11,15,16,14,19)
and ItemCode not in(-102,-103)
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,19) and ItemCode not in(-102,-103)
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, dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet(sqlTotalGross);
tempdataset.Tables[0].TableName = "TotalGross";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string SqlOverTime = SQLParser.MakeSQL(@"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,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 in(8) 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) and ItemCode in(-102,-103)
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,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 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) and ItemCode in(-102,-103)
) 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 = tc.ExecuteDataSet(SqlOverTime);
tempdataset.Tables[0].TableName = "OverTime";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string sqlTransport = SQLParser.MakeSQL(@"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,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 in(8) AND DG.DESIGNATIONID=E.DESIGNATIONID AND S.EmployeeID IN(%q)
AND C.CategoryID=S.CategoryID AND Sd.ItemID In(19) and ItemCode in(-113)
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,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 in(1) AND DG.DESIGNATIONID=E.DESIGNATIONID AND S.EmployeeID IN(%q) AND C.CategoryID=S.CategoryID
AND Sd.ItemID In(19) and ItemCode in(-113)
) 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 = tc.ExecuteDataSet(sqlTransport);
tempdataset.Tables[0].TableName = "Transport";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string sqlLumSumItem = SQLParser.MakeSQL("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 = tc.ExecuteDataSet(sqlLumSumItem);
tempdataset.Tables[0].TableName = "LumSumItem";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string sqlGrandTotal = SQLParser.MakeSQL("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 = tc.ExecuteDataSet(sqlGrandTotal);
tempdataset.Tables[0].TableName = "GrandTotal";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string sqlDeductItem = SQLParser.MakeSQL("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);
tempdataset = tc.ExecuteDataSet(sqlDeductItem);
tempdataset.Tables[0].TableName = "DeductItem";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string sqlTotalDeduct = SQLParser.MakeSQL("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);
tempdataset = tc.ExecuteDataSet(sqlTotalDeduct);
tempdataset.Tables[0].TableName = "TotalDeduct";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string sqlNetPay = SQLParser.MakeSQL("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 = tc.ExecuteDataSet(sqlNetPay);
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
{
string sTableName;
sEmpID = IDHelper.GetIDs(tc, sEmpID, out sTableName);
if (IsNetSum)
{
oSMonthlys = tc.ExecuteDataSet("Select S.DEPARTMENTID,D.Description,Sum(SD.CHANGEDAMOUNT) Amount"
+ " from DEPARTMENT D,SALARYMONTHLY S,SALARYMONTHLYDETAIL 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' Description,SD.CHANGEDAMOUNT Amount"
+ " from EMPLOYEE E,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 E.EMPLOYEEID =S.EMPLOYEEID "
+ " and Sd.ItemGroup IN (5) AND S.EmployeeID IN(%q)"
+ " order by E.EMPLOYEENO ", dateTime, sEmpID);
}
if (sTableName != "")
tc.ExecuteNonQuery("Drop TAble %q", sTableName);
}
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
{
string sTableName;
sEmpID = IDHelper.GetIDs(tc, sEmpID, out sTableName);
#region Latest Old Code
oSMonthlys = tc.ExecuteDataSet("SELECT E.NAME Name,E.EMPLOYEENO,G.CODE Grade,SM.Designation 'Designation',L.Description 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);
if (sTableName != "")
tc.ExecuteNonQuery("Drop TAble %q", sTableName);
#endregion
#region Change Old Code
// oSMonthlys = tc.ExecuteDataSet(@"SELECT E.NAME Name,E.EMPLOYEENO,G.CODE Grade,DG.Name 'Designation',L.Description 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
{
string sTableName;
sEmpID = IDHelper.GetIDs(tc, sEmpID, out sTableName);
#region Latest Old Code
// oSMonthlys = tc.ExecuteDataSet(@"Select Emp.EmployeeNo,Emp.Name,CC.Code,Dep.Description,Emp.GrossSalary,SMD.ChangedAmount 'PFAmount'
// from Employee Emp,Department Dep,SalaryMonthly SM,CRG CC,
// SalaryMonthlyDetail SMD,SalaryEmpCostCenter 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)) GrossAmount
from Employee Emp,Department Dep,CRG CC,SalaryMonthly SM,
SalaryMonthlyDetail SMD,SalaryEmpCostCenter 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)) GrossArrear
// from Employee Emp,Department Dep,CRG CC,SalaryMonthly SM,SalaryMonthlyDetail SMD,SalaryEmpCostCenter 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) PFAmount
from Employee Emp,Department Dep,SalaryMonthly SM,CRG CC,
SalaryMonthlyDetail SMD,SalaryEmpCostCenter 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());
if (sTableName != "")
tc.ExecuteNonQuery("Drop TAble %q", sTableName);
#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
{
string sTableName;
sEmpID = IDHelper.GetIDs(tc, sEmpID, out sTableName);
#region Latest Old Code
// string sSQL = SQLParser.MakeSQL(@"Select CC.CRGID,CC.Code,Sum(Emp.GrossSalary) 'InvolveAmount' ,Sum(SMD.ChangedAmount) 'PFAmount'
// from Employee Emp,SalaryMonthly SM,CRG CC,
// SalaryMonthlyDetail SMD,SalaryEmpCostCenter 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)) GrossAmount
from Employee Emp,Department Dep,CRG CC,SalaryMonthly SM,SalaryMonthlyDetail SMD,SalaryEmpCostCenter 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)) GrossAmount
from Employee Emp,Department Dep,CRG CC,SalaryMonthly SM,SalaryMonthlyDetail SMD,SalaryEmpCostCenter 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 'PFAmount'
from Employee Emp,Department Dep,SalaryMonthly SM,CRG CC,
SalaryMonthlyDetail SMD,SalaryEmpCostCenter 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());
if (sTableName != "")
tc.ExecuteNonQuery("Drop TAble %q", sTableName);
#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
{
string sTableName;
if(sEmpID == "")
{
throw new Exception("Salary is not processed");
}
sEmpID = IDHelper.GetIDs(tc, sEmpID, out sTableName);
string sql = SQLParser.MakeSQL("select A.EmployeeNo, A.Name,A.GName,A.DName,"
+ " A.Description, SUM(A.changedamount) Amount, A.Itemid, A.ItemCode, A.ItemGroup"
+ " from"
+ "(select S.EmployeeID, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode, "
+ " sd.ItemID, sd.Description,sd.Position, sd.changedamount,G.DESCRIPTION GName,D.DESCRIPTION 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) AND SD.itemcode NOT IN (-139, -102, -103)"
//+ " union"
//+ " select S.EmployeeID, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode, "
//+ " sd.ItemID, sd.Description,sd.Position, -sd.changedamount,G.DESCRIPTION GName,D.DESCRIPTION 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 GName,D.DESCRIPTION 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) AND SD.itemcode NOT IN (-139, -102, -103)"
+ " ) A group by "
+ " A.EmployeeID, A.EmployeeNo, A.Name,A.GName,A.DName,"
+ " A.ItemCode, A.ItemID, A.Description,A.Position,A.ItemGroup order by A.Position,A.EmployeeNo",
dateTime, sEmpID, dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet(sql);
tempdataset.Tables[0].TableName = "GrossItem";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
sql = SQLParser.MakeSQL("select E.EmployeeNo, E.Name,A.GName,A.DName,'Total Gross' Description, Sum(A.amount) amount "
+ " from"
+ "( select S.EmployeeID, Sum(sd.changedamount) Amount,G.DESCRIPTION GName,D.DESCRIPTION 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,19) and Sd.ITEMCODE Not In(-102,-103) "
+ " group by S.EmployeeID,G.DESCRIPTION,D.DESCRIPTION "
+ " UNION"
+ " select S.EmployeeID, -Sum(sd.changedamount) Amount,G.DESCRIPTION GName,D.DESCRIPTION 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,19) and Sd.ITEMCODE Not In(-102,-103) "
+ " 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 = tc.ExecuteDataSet(sql);
tempdataset.Tables[0].TableName = "TotalGross";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string sqlOverTime = SQLParser.MakeSQL(@"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 ItemCode in(-102,-103) AND S.EmployeeID IN(%q) AND SD.ItemID Not IN(13,11,15,16,14,19)
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 ItemCode in(-102,-103) AND S.EmployeeID IN(%q) AND SD.ItemID Not IN(13,11,15,16,14,19) ) 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 = tc.ExecuteDataSet(sqlOverTime);
tempdataset.Tables[0].TableName = "OverTime";
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 GName,D.DESCRIPTION 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 GName,D.DESCRIPTION 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 GName,D.DESCRIPTION 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' Description, Sum(A.amount) amount "
+ " from"
+ "( select S.EmployeeID, Sum(sd.changedamount) Amount,G.DESCRIPTION GName,D.DESCRIPTION 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) Amount,G.DESCRIPTION GName,D.DESCRIPTION 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 GName,D.DESCRIPTION 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 GName,D.DESCRIPTION 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' Description, Sum(A.amount) amount "
+ " from"
+ "( select S.EmployeeID, Sum(sd.changedamount) Amount,G.DESCRIPTION GName,D.DESCRIPTION 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) Amount,G.DESCRIPTION GName,D.DESCRIPTION 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 GName,D.DESCRIPTION DName ,'Net Pay' Description,SD.CHANGEDAMOUNT Amount"
+ " from EMPLOYEE E,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 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());
if (sTableName != "")
tc.ExecuteNonQuery("Drop TAble %q", sTableName);
}
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
{
string sTableName;
sEmpID = IDHelper.GetIDs(tc, sEmpID, out sTableName);
//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 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 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 Dep"
+ " On Dep.DEPARTMENTID=SM.DEPARTMENTID"
+ " GROUP by SM.DEPARTMENTID,Dep.Description", dateTime, sEmpID);
if (sTableName != "")
tc.ExecuteNonQuery("Drop TAble %q", sTableName);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return oSMonthlys;
}
internal static IDataReader Get(TransactionContext tc, int nEmpID, DateTime dateTime)
{
return tc.ExecuteReader("SELECT * FROM SalaryMonthly WHERE EmployeeID=%n AND SalaryMonth=%d", nEmpID, 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 A.DESCRIPTION,SUM(A.CHANGEDAMOUNT) as Amount,A.ITEMID,A.ITEMCODE from
(Select sm.EmployeeID, SMD.DESCRIPTION,SMD.CHANGEDAMOUNT,SMD.ITEMID,SMD.ITEMCODE from SALARYMONTHLYDETAIL SMD,SALARYMONTHLY SM
where SM.EMPLOYEEID in(%q) AND SMD.ITEMGROUP IN(1,8) AND SM.SALARYMONTH=%d AND SM.SALARYMONTHLYID=SMD.SALARYMONTHLYID
AND SMD.CHANGEDAMOUNT<>0 and sm.Salarywithheld<>1
Union
Select sm.EmployeeID, SMD.DESCRIPTION,-SMD.CHANGEDAMOUNT ,SMD.ITEMID,SMD.ITEMCODE from SALARYMONTHLYDETAIL SMD,SALARYMONTHLY SM
where SM.EMPLOYEEID in(%q) AND SMD.ITEMGROUP IN(2) AND SM.SALARYMONTH=%d AND SM.SALARYMONTHLYID=SMD.SALARYMONTHLYID
AND SMD.CHANGEDAMOUNT<>0 and sm.Salarywithheld<>1)A
GROUP by A.ITEMID,A.ITEMCODE,A.DESCRIPTION order by A.ITEMCODE desc", sEmpID, dateTime, sEmpID, dateTime);
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 and sm.Salarywithheld<>1"
+ " 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, int nID)
{
tc.ExecuteNonQuery("DELETE FROM SalaryMonthlyDetail WHERE SalaryMonthlyID=%n", nID);
tc.ExecuteNonQuery("DELETE FROM SalaryEmpCostCenter WHERE SalaryMonthlyID=%n", nID);
tc.ExecuteNonQuery("DELETE FROM SalaryMonthly WHERE SalaryMonthlyID=%n", nID);
}
internal static void DeleteSalaryDetail(TransactionContext tc, int nID)
{
tc.ExecuteNonQuery("DELETE FROM SalaryMonthlyDetail WHERE SalaryMonthlyID=%n", nID);
}
internal static void DeleteSalaryEmpCC(TransactionContext tc, int nID)
{
tc.ExecuteNonQuery("DELETE FROM SalaryEmpCostCenter WHERE SalaryMonthlyID=%n", nID);
}
#endregion
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 sTableName;
sEmpID = IDHelper.GetIDs(tc, sEmpID, out sTableName);
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 GName,
D.Name DName,G.Code GCode,G.SequenceNo,dep.DESCRIPTION Dept,
Sum(sd.changedamount) 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 GName,D.Name DName,G.Code GCode,G.SequenceNo,
dep.DESCRIPTION Dept, Sum(sd.changedamount) 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) amount
from
(
select
E.EmployeeNo, E.Name,E.JoiningDate,'Total Gross' Description,G.DESCRIPTION GName,
G.Code GCode,G.SequenceNo,D.Name DName,dep.DESCRIPTION Dept,Sum(sd.changedamount) 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' Description,G.DESCRIPTION GName,
G.Code GCode,G.SequenceNo,D.Name DName,dep.DESCRIPTION Dept,-Sum(sd.changedamount) 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) changedamount,G.DESCRIPTION GName,
G.Code GCode,G.SequenceNo,D.Name DName,dep.DESCRIPTION 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) changedamount,G.DESCRIPTION GName,
G.Code GCode,G.sequenceNo,D.Name DName,dep.DESCRIPTION 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) changedamount,G.DESCRIPTION GName,
G.Code GCode,G.SequenceNo,D.Name DName,dep.DESCRIPTION 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) changedamount,G.DESCRIPTION GName,
G.Code GCode,G.SequenceNo,D.Name DName,dep.DESCRIPTION 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 GName,G.Code GCode,
G.SequenceNo,D.Name DName ,dep.DESCRIPTION Dept,'UnAuthorized' Description,
Sum(sd.changedamount) 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 Dept,'Total Deduction' Description, Sum(A.amount) amount
from
(select S.EmployeeID, Sum(sd.changedamount) Amount,G.DESCRIPTION GName,
G.Code GCode,G.SequenceNo,D.Name 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 GName,G.Code GCode,dep.DESCRIPTION Dept,
G.SequenceNo,D.Name DName ,'Net Pay' Description,SUM(SD.CHANGEDAMOUNT) Amount
from EMPLOYEE E,GRADES G,DESIGNATION D,Department dep,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 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 GName,dep.DESCRIPTION Dept,
G.Code GCode,G.SequenceNo,D.Name DName ,'CPF' Description,
SUM(SD.CHANGEDAMOUNT) Amount
from
EMPLOYEE E,GRADES G,DESIGNATION D,
Department dep,SALARYMONTHLY S,SALARYMONTHLYDETAIL 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 GName,dep.DESCRIPTION Dept,
G.Code GCode,G.SequenceNo,D.Name DName,b.Name Description,
Sum(bpd.BonusAmount) Amount
from
EMPLOYEE E,GRADES G,DESIGNATION D,Department dep,SALARYMONTHLY 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());
if (sTableName != "")
tc.ExecuteNonQuery("Drop TAble %q", sTableName);
// 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 GName,
// D.Name DName,G.Code 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 GName,
// D.Name DName,G.Code 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, int employeeId, DateTime fromDate, DateTime toDate, EnumSalaryGroup groupCode, EnumSalaryItemCode itemCode, int itemId, int 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, fromDate, toDate, false,
payrollTypeID);
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 sTableName;
sEmpID = IDHelper.GetIDs(tc, sEmpID, out sTableName);
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 Dep"
+ " On Dep.DEPARTMENTID=SM.DEPARTMENTID"
+ " GROUP by SM.DEPARTMENTID,Dep.Description",
dateTime,
sEmpID);
oSMonthlys = tc.ExecuteDataSet(sql);
if (sTableName != "")
tc.ExecuteNonQuery("Drop TAble %q", sTableName);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return oSMonthlys;
}
internal static DataSet GetSalaryStracture(TransactionContext tc, string SempIds)
{
string sTableName;
SempIds = IDHelper.GetIDs(tc, SempIds, out sTableName);
string sql = SQLParser.MakeSQL(@"
select Emp.EmployeeID,Emp.EmployeeNo EmpID,Emp.Name Name,
(select dg.Name From Designation Dg Where Dg.DesignationID = Emp.DesignationId) Designation,
(select Ct.Description from Category Ct Where Ct.CategoryId = Emp.CategoryId) 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 Grd Where Grd.GradeId = Emp.GradeID) Grade,
emp.JoiningDate joinningDate,
Gender =
CASE Emp.Gender
When 0 THEN 'None'
When 1 THEN 'Male'
When 2 THEN 'Female'
When 3 THEN 'Both'
END,
Emp.BirthDate DOB,
(
select Crg.Description From Crg where Crg.CrgId in (Select EmpCostCenter.CostCenterId from EmpCostCenter
Where EmpCostCenter.CurrentCC = 1 And EmpCostCenter.EmployeeId = Emp.EmployeeId
)
) CostCenter,
(select dpt.Description from Department Dpt Where Dpt.DepartmentId = Emp.DepartmentId) Department,
(select Loc.Description From Location Loc Where Loc.LocationId = Emp.LocationId) PostingPlace,
Emp.BasicSalary BasicSalary,Emp.DepartmentID DepartmentID
From Employee Emp Where Emp.EmployeeId in (%q)", SempIds);
if (sTableName != "")
tc.ExecuteNonQuery("Drop TAble %q", sTableName);
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 sTableName;
sEmpID = IDHelper.GetIDs(tc, sEmpID, out sTableName);
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 GName,D.Name DName,
G.Code 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 GName,D.Name DName,G.Code 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' Description,
Sum(A.amount) amount
from
(
select S.EmployeeID,S.SalaryMonth,Sum(sd.changedamount) Amount,G.DESCRIPTION GName,G.Code GCode,
G.SequenceNo,D.Name 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) Amount,G.DESCRIPTION GName,G.Code GCode,
G.sequenceNo,D.Name 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 GName,
G.Code GCode,G.SequenceNo,D.Name 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 GName,G.Code GCode,G.sequenceNo,D.Name 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 GName,G.Code GCode,G.SequenceNo,D.Name 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 GName,G.Code GCode,G.SequenceNo,D.Name 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' Description, Sum(A.amount) amount
from
(
select S.SalaryMonth,S.EmployeeID, Sum(sd.changedamount) Amount,G.DESCRIPTION GName,G.Code GCode,
G.SequenceNo,D.Name 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' Description,
Sum(A.amount) amount
from(
select S.SalaryMonth,S.EmployeeID, Sum(sd.changedamount) Amount,
G.DESCRIPTION GName,G.Code GCode,G.SequenceNo,D.Name 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 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 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());
if (sTableName != "")
tc.ExecuteNonQuery("Drop TAble %q", sTableName);
}
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.PayrollFirstDateOfMonth(fstDate);
DateTime ldy = Global.DateFunctions.PayrollLastDateOfMonth(endDate);*/
DateTime fdy = new DateTime();
DateTime ldy = new DateTime();
try
{
string sTableName;
sEmpID = IDHelper.GetIDs(tc, sEmpID, out sTableName);
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 GName,D.Name DName,
G.Code 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 GName,D.Name DName,G.Code 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' Description,
Sum(A.amount) amount
from
(
select S.EmployeeID,S.SalaryMonth,Sum(sd.changedamount) Amount,G.DESCRIPTION GName,G.Code GCode,
G.SequenceNo,D.Name 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) Amount,G.DESCRIPTION GName,G.Code GCode,
G.sequenceNo,D.Name 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 GName,
G.Code GCode,G.SequenceNo,D.Name 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 GName,G.Code GCode,G.sequenceNo,D.Name 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 GName,G.Code GCode,G.SequenceNo,D.Name 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 GName,G.Code GCode,G.SequenceNo,D.Name 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' Description, Sum(A.amount) amount
from
(
select S.SalaryMonth,S.EmployeeID, Sum(sd.changedamount) Amount,G.DESCRIPTION GName,G.Code GCode,
G.SequenceNo,D.Name 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' Description,
Sum(A.amount) amount
from(
select S.SalaryMonth,S.EmployeeID, Sum(sd.changedamount) Amount,
G.DESCRIPTION GName,G.Code GCode,G.SequenceNo,D.Name 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 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 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());
if (sTableName != "")
tc.ExecuteNonQuery("Drop TAble %q", sTableName);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return rootDataset;
}
internal static DataSet GetPFForLetterRequest(TransactionContext tc, int empID)
{
DataSet rootDataset = new DataSet();
try
{
//string query1 = SQLParser.MakeSQL(@"select top 1 * from LOANSCHEDULE where EmployeeID=1068 and PAYMENTDATE is null
// empID, empID);
string query1 = SQLParser.MakeSQL(@"; With cte as (
SELECT employeeID, Max(salaryMonth) salaryMonth from SALARYMONTHLY where employeeID=%n group by EMPLOYEEID
)
SELECT E.NAME Name,E.EMPLOYEENO,E.EMPLOYEEID,E.JOININGDATE,
SM.ACCOUNTNO,SM.SalaryMonth, SMD.ITEMGROUP,SMD.DESCRIPTION,
SMD.CHANGEDAMOUNT,SMD.ItemCode,SMD.ItemID,E.TINNO
FROM Employee E Inner join SALARYMONTHLY SM on E.EMPLOYEEID=SM.EMPLOYEEID
inner join SalaryMonthlyDetail SMD on sm.SALARYMONTHLYID=smd.SALARYMONTHLYID
Inner Join cte On cte.EMPLOYEEID=sm.EMPLOYEEID and sm.SALARYMONTH=cte.salaryMonth
Where SMD.ITEMGROUP=3 AND SM.EmployeeID IN(%n) AND SMD.DESCRIPTION='PF Loan'",
empID, empID);
rootDataset = tc.ExecuteDataSet(query1);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return rootDataset;
}
internal static IDataReader GetDetail(TransactionContext tc, DateTime startDate, DateTime endDate, int payrollTypeID)
{
string sql = SQLParser.MakeSQL(@"SELECT SD.* FROM SalaryMonthlyDetail SD, SalaryMonthly SM WHERE "
+ " (SM.SalaryMonth between %d AND %d) AND SD.SalaryMonthlyID = SM.SalaryMonthlyID and payrollTypeID=%n Order by SM.SalaryMonthlyID, SD.Position ", startDate, endDate, payrollTypeID);
return tc.ExecuteReader(sql);
}
internal static IDataReader GetDetail(TransactionContext tc, int nEmpID, DateTime startDate, DateTime endDate, int 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, nEmpID);
return tc.ExecuteReader(sql);
}
internal static IDataReader Get(TransactionContext tc, DateTime startDate, DateTime endDate, int payrollTypeID)
{
string sql = SQLParser.MakeSQL(@"SELECT * FROM SalaryMonthly where (SalaryMonth between %d And %d) and (payrolltypeid = %n) and salarywithheld<>1", startDate, endDate, payrollTypeID);
return tc.ExecuteReader(sql);
}
internal static IDataReader Get(TransactionContext tc, int nEmpID, DateTime startDate, DateTime endDate, int payrollTypeID)
{
//string sql = SQLParser.MakeSQL(@"SELECT * FROM SalaryMonthly where (SalaryMonth between %d And %d) and (payrolltypeid = %n)", startDate, endDate, SystemInformation.CurrentSysInfo.PayrollTypeID);
string sql = SQLParser.MakeSQL(@"SELECT * FROM SalaryMonthly where (SalaryMonth between %d And %d) and (payrolltypeid = %n) and EmployeeID=%n", startDate, endDate, payrollTypeID, nEmpID);
return tc.ExecuteReader(sql);
}
internal static DataSet GetEmpSalarySheetForIDLC(TransactionContext tc, 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 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 CIFNo, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode, sd.ItemID,
sd.Description,sd.Position, sd.changedamount,G.DESCRIPTION GName,G.Code GCode,
G.SequenceNo,D.Name DName , DE.DESCRIPTION Department,L.DESCRIPTION Branch,DE.DEPARTMENTID
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.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 CIFNo, E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode, sd.ItemID,
sd.Description,sd.Position, sd.changedamount,G.DESCRIPTION GName, G.Code GCode,
G.sequenceNo,D.Name DName,DE.DESCRIPTION Department,L.DESCRIPTION Branch,DE.DEPARTMENTID
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.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 CIFNo, E.Name,A.GName,A.GCode,A.SequenceNo,A.DName,DE.DESCRIPTION Department,"
+ " 'Total Gross' Description, Sum(A.amount) amount,L.DESCRIPTION Branch,DE.DEPARTMENTID "
+ " from( select S.EmployeeID, "
+ " Sum(sd.changedamount) Amount,G.DESCRIPTION GName,G.Code GCode,G.SequenceNo,"
+ " D.Name 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) Amount,G.DESCRIPTION GName,"
+ " G.Code GCode,G.sequenceNo,D.Name 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 CIFNo, "
+ " sd.ItemGroup,sd.ItemCode, sd.ItemID, sd.Description,sd.Position, "
+ " sd.changedamount,G.DESCRIPTION GName,G.Code GCode,G.SequenceNo,D.Name DName ,"
+ " DE.DESCRIPTION Department,L.DESCRIPTION Branch,DE.DEPARTMENTID"
+ " 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.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 CIFNo, "
+ " sd.ItemID, sd.Description,sd.Position, -sd.changedamount,G.DESCRIPTION GName,"
+ " G.Code GCode,G.sequenceNo,D.Name DName,DE.DESCRIPTION Department,L.DESCRIPTION Branch,DE.DEPARTMENTID "
+ " 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.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 CIFNo,"
+ " E.EmployeeNo, E.Name, sd.ItemGroup,sd.ItemCode, sd.ItemID, sd.Description,"
+ " sd.Position, sd.changedamount,G.DESCRIPTION GName,G.Code GCode,DE.DEPARTMENTID,"
+ " G.SequenceNo,D.Name DName,DE.DESCRIPTION Department,L.DESCRIPTION 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 CIFNo,"
+ " G.DESCRIPTION GName,G.Code GCode,G.SequenceNo,D.Name DName,"
+ " DE.DEPARTMENTID,DE.DESCRIPTION Department,L.DESCRIPTION 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' Description, Sum(A.amount) amount,A.Branch,A.DEPARTMENTID, "
+ " E.GLOBALID CIFNo from "
+ " ( select S.EmployeeID, Sum(sd.changedamount) Amount,G.DESCRIPTION GName,"
+ " G.Code GCode,G.SequenceNo,D.Name DName,DE.DEPARTMENTID"
+ " ,DE.DESCRIPTION Department,L.DESCRIPTION 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' Description, Sum(A.amount) amount,A.Branch,A.DEPARTMENTID "
+ " ,E.GLOBALID CIFNo from"
+ " ( select S.EmployeeID, Sum(sd.changedamount) Amount,G.DESCRIPTION GName,"
+ " G.Code GCode,G.SequenceNo,D.Name DName,DE.DEPARTMENTID,"
+ " DE.DESCRIPTION Department,L.DESCRIPTION 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 GName,G.Code GCode,"
+ " G.SequenceNo,D.Name DName ,'Net Pay' Description,SD.CHANGEDAMOUNT Amount,"
+ " DE.DESCRIPTION Department,L.DESCRIPTION Branch,DE.DEPARTMENTID"
+ " ,E.GLOBALID CIFNo from "
+ " EMPLOYEE E,GRADES G,DESIGNATION D,SALARYMONTHLY S,DEPARTMENT DE,LOCATION L,"
+ " SALARYMONTHLYDETAIL 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());
if (sTableName != "")
tc.ExecuteNonQuery("Drop TAble %q", sTableName);
// string query8 = SQLParser.MakeSQL(@"Select E.EMPLOYEENO,E.NAME,G.DESCRIPTION GName,G.Code GCode,G.SequenceNo,
// D.Name DName ,'CPF' Description,SD.CHANGEDAMOUNT Amount,
// DE.DESCRIPTION Department,L.DESCRIPTION Branch,DE.DEPARTMENTID
// ,E.GLOBALID CIFNo from EMPLOYEE E,GRADES G,DESIGNATION D,
// SALARYMONTHLY S,SALARYMONTHLYDETAIL 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
{
string sTableName;
sEmpID = IDHelper.GetIDs(tc, sEmpID, out sTableName);
#region Latest Old Code
string sSQL = SQLParser.MakeSQL(@"select C.CRGID CCID,C.DESCRIPTION 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);
if (sTableName != "")
tc.ExecuteNonQuery("Drop TAble %q", sTableName);
#endregion
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return oSMonthlys;
}
internal static DataSet GetOnRange(TransactionContext tc, string sEmpID, DateTime fromDate, DateTime toDate, EnumSalaryGroup groupCode, EnumSalaryItemCode itemCode)
{
DataSet oSMonthlys = new DataSet();
try
{
string sTableName;
sEmpID = IDHelper.GetIDs(tc, sEmpID, out sTableName);
string sql = SQLParser.MakeSQL(@"SELECT SM.EmployeeID,SM.SALARYMONTH, SD.* FROM SalaryMonthlyDetail SD, SalaryMonthly SM WHERE
(SM.SalaryMonth between %d AND %d) AND SM.EmployeeID IN(%q) AND SD.SalaryMonthlyID = SM.SalaryMonthlyID AND ITEMGROUP=%n and itemCode=%n
and sd.changedamount !=0 Order by SD.Position ", fromDate, toDate, sEmpID, (int)groupCode, (int)itemCode);
oSMonthlys = tc.ExecuteDataSet(sql);
if (sTableName != "")
tc.ExecuteNonQuery("Drop TAble %q", sTableName);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return oSMonthlys;
}
internal static DataSet GetOnRange(TransactionContext tc, string sEmpID, DateTime fromDate, DateTime toDate, EnumSalaryGroup groupCode, EnumSalaryItemCode itemCode, int itemId)
{
DataSet oSMonthlys = new DataSet();
try
{
string sTableName;
sEmpID = IDHelper.GetIDs(tc, sEmpID, out sTableName);
string sql = SQLParser.MakeSQL(@"SELECT SM.EmployeeID,SM.SALARYMONTH, SD.* FROM SalaryMonthlyDetail SD, SalaryMonthly SM WHERE
(SM.SalaryMonth between %d AND %d) AND SM.EmployeeID IN(%q) AND SD.SalaryMonthlyID = SM.SalaryMonthlyID AND ITEMGROUP=%n and itemCode=%n AND itemId=%n
and sd.changedamount !=0 Order by SD.Position ", fromDate, toDate, sEmpID, (int)groupCode, (int)itemCode, itemId);
oSMonthlys = tc.ExecuteDataSet(sql);
if (sTableName != "")
tc.ExecuteNonQuery("Drop TAble %q", sTableName);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return oSMonthlys;
}
internal static DataSet GetOTHourByReverseCal(TransactionContext tc, string sEmpID, DateTime fromDate, DateTime toDate, EnumSalaryGroup groupCode, EnumSalaryItemCode itemCode, int itemId)
{
DataSet oSMonthlys = new DataSet();
try
{
string sTableName;
sEmpID = IDHelper.GetIDs(tc, sEmpID, out sTableName);
string sql = SQLParser.MakeSQL(@"SELECT SM.EmployeeID,SM.SALARYMONTH, round(((sd.changedamount/2) * 208)/sm.THISMONTHBASIC,2) changedamount FROM SalaryMonthlyDetail SD, SalaryMonthly SM WHERE
(SM.SalaryMonth between %d AND %d) AND SM.EmployeeID IN(%q) AND SD.SalaryMonthlyID = SM.SalaryMonthlyID AND ITEMGROUP=1 and itemCode=-103 AND Itemid=1
and sd.changedamount !=0 Order by SD.Position ", fromDate, toDate, sEmpID, (int)groupCode, (int)itemCode, itemId);
oSMonthlys = tc.ExecuteDataSet(sql);
if (sTableName != "")
tc.ExecuteNonQuery("Drop TAble %q", sTableName);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return oSMonthlys;
}
internal static DataTable GetNetAmount(TransactionContext tc, DateTime salaryMonth, int payrolltypeid)
{
DataTable oSMonthlys = new DataTable();
try
{
string sql = SQLParser.MakeSQL(@"select count(s.employeeid) Headcount, sum( sd.CHANGEDAMOUNT) CurrentMonth,
(select sum( sd.CHANGEDAMOUNT) from salarymonthly s, SALARYMONTHLYDETAIL sd where s.SALARYMONTHLYID = sd.SALARYMONTHLYID
and s.payrollTypeid =%n and itemcode= -132 and itemid =-132 and s.SALARYMONTH = %d) PrviousMonth
from salarymonthly s, SALARYMONTHLYDETAIL sd where s.SALARYMONTHLYID = sd.SALARYMONTHLYID
and s.payrollTypeid =%n and itemcode= -132 and itemid =-132 and s.SALARYMONTH = %d ",
payrolltypeid, GlobalFunctions.LastDateOfMonth( salaryMonth.AddMonths(-1)), payrolltypeid, salaryMonth);
oSMonthlys = tc.ExecuteDataTable(sql);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return oSMonthlys;
}
internal static DataTable GetWithheldData(TransactionContext tc, DateTime salaryMonth, int payrolltypeid)
{
DataTable oSMonthlys = new DataTable();
try
{
string sql = SQLParser.MakeSQL(@"SELECT s.SALARYMONTHLYID,s.PaymentDate,s.ChequeNo,s.Remarks, s.SALARYMONTH,s.EMPLOYEEID,e.Employeeno,e.Name, d.description Department,dg.Name Designation, sd.CHANGEDAMOUNT NetPay FROM SALARYMONTHLYDETAIL sd,SALARYMONTHLY s, Employee e,Department d, Designation dg
WHERE s.employeeid=e.employeeid and s.salarywithheld=1 and s.SALARYMONTHLYID=sd.SALARYMONTHLYID and e.departmentID=d.DepartmentID and dg.designationID=e.designationid AND s.Paymentdate is null AND s.SALARYMONTH=%d AND s.PayrollTypeid=%n AND sd.ITEMCODE=-132 AND sd.ITEMID=-132 ",
salaryMonth, payrolltypeid);
oSMonthlys = tc.ExecuteDataTable(sql);
}
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 GetByItemCode(TransactionContext tc, int payrolltypeid, string itemCodeIn, DateTime salaryMonth)
{
string sSQL = "";
sSQL = SQLParser.MakeSQL("select SD.EmployeeID, S.DetailID, S.SALARYMONTHLYID, S.ITEMID, S.SUPPORTID, S.POSITION, "
+ " S.CALCULATEDAMOUNT, S.CHANGEDAMOUNT, S.ITEMCODE, S.ITEMGROUP from SALARYMONTHLYDETAIL S,SALARYMONTHLY SD where"
+ " S.SalaryMonthlyID=SD.SalaryMonthlyID AND SD.SalaryMonth=%d AND PayrollTypeID=%n"
+ " AND S.ItemCode IN (%q)", salaryMonth, payrolltypeid, itemCodeIn);
return tc.ExecuteReader(sSQL);
}
internal static IDataReader Get(TransactionContext tc, string sEmpID, DateTime fromdate, DateTime toDate)
{
string sTableName;
sEmpID = IDHelper.GetIDs(tc, sEmpID, out sTableName);
string Ssql = SQLParser.MakeSQL("SELECT * FROM SalaryMonthly WHERE EmployeeID in(%q) AND SALARYMONTH between %d and %d order by EmployeeID", sEmpID, fromdate, toDate);
IDataReader dr = tc.ExecuteReader(Ssql);
if (sTableName != "")
tc.ExecuteNonQuery("Drop TAble %q", sTableName);
return dr;
}
internal static DataSet GetCCWiseSalarySheetDetail(TransactionContext tc, DateTime dSMonthDate, string sEmpID)
{
DataSet oSMonthlys = new DataSet();
DataSet rootDataset = new DataSet();
try
{
string sTableName;
sEmpID = IDHelper.GetIDs(tc, sEmpID, out sTableName);
#region Latest Old Code
string Sql = SQLParser.MakeSQL(@"Select Emp.EmployeeNo,Emp.Name,CC.Code,Dep.Description,
sum(SMD.ChangedAmount * (SEmpCC.Percentage)/100) GrossAmount
from Employee Emp,Department Dep,SalaryMonthly SM,CRG CC,
SalaryMonthlyDetail SMD,SalaryEmpCostCenter 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)) GrossArrear
from Employee Emp,Department Dep,CRG CC,SalaryMonthly SM,
SalaryMonthlyDetail SMD,SalaryEmpCostCenter 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) PFAmount
from Employee Emp,Department Dep,SalaryMonthly SM,CRG CC,
SalaryMonthlyDetail SMD,SalaryEmpCostCenter 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());
if (sTableName != "")
tc.ExecuteNonQuery("Drop TAble %q", sTableName);
#endregion
}
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 GetLTAData(TransactionContext tc, int EmpID)
{
string sql = SQLParser.MakeSQL(@"select a.* from EmpLTA a,Employee e Where a.EmployeeNo=e.EMPLOYEENO AND e.EMPLOYEEID=%n ORDER BY salaryMonth", EmpID);
return tc.ExecuteDataSet(sql);
}
internal static DataSet GetEmpSalarySheetWithoutCostCenterOT(TransactionContext tc, DateTime dateTime, string sEmpID)
{
DataSet rootDataset = new DataSet();
DataSet tempdataset = new DataSet();
try
{
#region Commented by ANIK
// string query1 = SQLParser.MakeSQL(@"select A.EmployeeNo, A.Name,A.GName,A.GCode,A.JoiningDate,
// A.Description, SUM(A.changedamount) Amount,A.ItemGroup,A.ItemCode,A.ItemID
// from
// (
// select S.EmployeeID, E.EmployeeNo, E.Name,E.JoiningDate, sd.ItemGroup,sd.ItemCode,
// sd.ItemID, sd.Description, sd.changedamount,G.DESCRIPTION as GName,G.Code as GCode
// from Grades G,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd
// where G.GradeID= S.GradeID 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.changedamount,G.DESCRIPTION as GName,G.Code as GCode from Grades G,
// Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd
// where G.GradeID= S.GradeID 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.GCode,A.ItemGroup,A.ItemCode,A.ItemID,
// A.ItemCode, A.ItemID, A.Description,A.JoiningDate order by A.EmployeeNo,A.GCode",
// dateTime, sEmpID, dateTime, sEmpID);
// tempdataset = tc.ExecuteDataSet(query1);
#endregion
string query1 = SQLParser.MakeSQL(@"select A.EmployeeNo, A.Name,A.Department, A.DESIGNATION,
A.GName,A.GCode,A.JoiningDate,
A.Description, AVG(A.changedamount) Amount,A.ItemGroup,A.ItemCode,A.ItemID
from
(
select S.EmployeeID, E.EmployeeNo, E.Name,dep.DESCRIPTION AS Department,deg.Name AS DESIGNATION,cc.Description AS COSTCENTER,
E.JoiningDate, sd.ItemGroup,sd.ItemCode,
sd.ItemID, sd.Description, sd.changedamount,G.DESCRIPTION as GName,G.Code as GCode
from Grades G,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd, DEPARTMENT dep, DESIGNATION deg, crg cc, salaryempcostcenter scc
where G.GradeID= S.GradeID 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 E.DEPARTMENTID = dep.DEPARTMENTID
AND E.DESIGNATIONID = deg.DESIGNATIONID
AND scc.COSTCENTERID = cc.CRGID
AND scc.SALARYMONTHLYID=s.SALARYMONTHLYID
UNION
select S.EmployeeID, E.EmployeeNo, E.Name,dep.DESCRIPTION AS Department,deg.Name AS DESIGNATION,cc.Description AS COSTCENTER,
E.JoiningDate, sd.ItemGroup,sd.ItemCode,
sd.ItemID, sd.Description, sd.changedamount,G.DESCRIPTION as GName,G.Code as GCode from Grades G,
Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd , DEPARTMENT dep, DESIGNATION deg, crg cc, salaryempcostcenter scc
where G.GradeID= S.GradeID 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 E.DEPARTMENTID = dep.DEPARTMENTID
AND E.DESIGNATIONID = deg.DESIGNATIONID
AND scc.COSTCENTERID = cc.CRGID
AND scc.SALARYMONTHLYID=s.SALARYMONTHLYID
) A group by
A.EmployeeID, A.EmployeeNo, A.Name,A.GName,A.GCode,A.ItemGroup,A.ItemCode,A.ItemID,
A.ItemCode, A.ItemID, A.Description,A.JoiningDate,A.Department, A.DESIGNATION
order by 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 queryActualGross = SQLParser.MakeSQL(@"select E.EmployeeNo, E.Name, dep.DESCRIPTION AS Department,deg.Name AS DESIGNATION,
E.JoiningDate,A.GName,A.GCode,'Actual Gross' as Description, Avg(A.amount) as amount
from
( select S.EmployeeID, Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,G.Code as GCode , S.SALARYMONTHLYID
from SALARYMONTHLY S,Grades G, SalaryMonthlyDetail Sd
where S.SalaryMonthlyID=Sd.SalaryMonthlyID
AND G.GRADEID=S.GRADEID AND S.SalaryMonth= %d and Sd.ItemGroup IN (1) AND sd.description!='Bonus Arrear' AND S.EmployeeID IN(%q)
group by S.EmployeeID,G.DESCRIPTION,G.Code, S.SALARYMONTHLYID
) A, Employee E ,DEPARTMENT dep, DESIGNATION deg, crg cc,SALARYEMPCOSTCENTER empcc
where A.EmployeeID = E.EmployeeID
AND E.DEPARTMENTID = dep.DEPARTMENTID
AND E.DESIGNATIONID = deg.DESIGNATIONID
AND E.EMPLOYEEID = empcc.EMPLOYEEID
AND empcc.COSTCENTERID = cc.CRGID
AND A.EMPLOYEEID = empcc.EMPLOYEEID
AND A.SALARYMONTHLYID = empcc.SALARYMONTHLYID
group by E.EmployeeNo, E.Name,A.GName,A.GCode,E.JoiningDate ,dep.DESCRIPTION,deg.Name",
dateTime, sEmpID, dateTime, sEmpID);
tempdataset = tc.ExecuteDataSet(queryActualGross);
tempdataset.Tables[0].TableName = "ActualGross";
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
string query2 = SQLParser.MakeSQL(@"select E.EmployeeNo, E.Name,dep.DESCRIPTION AS Department,deg.Name AS DESIGNATION,
E.JoiningDate,A.GName,A.GCode,'Total Gross' as Description, Avg(A.amount) as amount
from
( select S.EmployeeID, Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,G.Code as GCode, S.SALARYMONTHLYID
from SALARYMONTHLY S,Grades G, SalaryMonthlyDetail Sd
where S.SalaryMonthlyID=Sd.SalaryMonthlyID
AND G.GRADEID=S.GRADEID AND S.SalaryMonth=%d and Sd.ItemGroup IN (1, 8) AND S.EmployeeID IN(%q)
group by S.EmployeeID,G.DESCRIPTION,G.Code , S.SALARYMONTHLYID
UNION
select S.EmployeeID, -Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,G.Code as GCode, S.SALARYMONTHLYID
from GRADES G,SALARYMONTHLY S, SalaryMonthlyDetail Sd
where S.SalaryMonthlyID=Sd.SalaryMonthlyID
AND S.SalaryMonth=%d AND G.GRADEID=S.GRADEID and Sd.ItemGroup IN (2) AND S.EmployeeID IN(%q)
group by S.EmployeeID,G.DESCRIPTION,G.Code, S.SALARYMONTHLYID
) A, Employee E ,DEPARTMENT dep, DESIGNATION deg, crg cc,SALARYEMPCOSTCENTER empcc
where A.EmployeeID = E.EmployeeID
AND E.DEPARTMENTID = dep.DEPARTMENTID
AND E.DESIGNATIONID = deg.DESIGNATIONID
AND E.EMPLOYEEID = empcc.EMPLOYEEID
AND empcc.COSTCENTERID = cc.CRGID
AND A.EMPLOYEEID = empcc.EMPLOYEEID
AND A.SALARYMONTHLYID = empcc.SALARYMONTHLYID
group by E.EmployeeNo, E.Name,A.GName,A.GCode,E.JoiningDate ,dep.DESCRIPTION,deg.Name",
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.ItemGroup,
// 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.changedamount,G.DESCRIPTION as GName,G.Code as GCode
// from Grades G,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd
// where G.GradeID= S.GradeID AND E.employeeID=S.EmployeeID
// AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth = %d and Sd.ItemGroup in (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.changedamount,G.DESCRIPTION as GName,G.Code as GCode
// from Grades G,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd
// where G.GradeID= S.GradeID 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.GCode, A.ItemGroup,
// A.ItemCode, A.ItemID, A.Description,A.JoiningDate order by A.EmployeeNo,A.GCode",
// dateTime, sEmpID, dateTime, sEmpID);
//string query3 = SQLParser.MakeSQL(@"select A.EmployeeNo, A.Name,A.Department, A.DESIGNATION,
// A.JoiningDate,A.GName,A.GCode,A.ItemGroup,
// A.Description, SUM(A.changedamount) Amount,A.ItemCode,A.ItemID
// from
// (
// select S.EmployeeID, E.EmployeeNo, E.Name, dep.DESCRIPTION AS Department,deg.Name AS DESIGNATION,--cc.Description AS COSTCENTER,
// E.JoiningDate,sd.ItemGroup,sd.ItemCode,
// sd.ItemID, sd.Description, sd.changedamount,G.DESCRIPTION as GName,G.Code as GCode
// from Grades G,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd ,DEPARTMENT dep, DESIGNATION deg--, SALARYEMPCOSTCENTER empcc, crg cc
// where G.GradeID= S.GradeID AND E.employeeID=S.EmployeeID
// AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth = %d and Sd.ItemGroup in (3)
// AND S.EmployeeID IN(%q)
// AND E.DEPARTMENTID = dep.DEPARTMENTID
// AND E.DESIGNATIONID = deg.DESIGNATIONID
// --AND E.EMPLOYEEID = empcc.EMPLOYEEID
// --AND empcc.COSTCENTERID = cc.CRGID
// --AND S.EMPLOYEEID = empcc.EMPLOYEEID
// --AND S.SALARYMONTHLYID = empcc.SALARYMONTHLYID
// Union
// select S.EmployeeID, E.EmployeeNo, E.Name, dep.DESCRIPTION AS Department,deg.Name AS DESIGNATION,--cc.Description AS COSTCENTER,
// E.JoiningDate,sd.ItemGroup,0 ItemCode,
// 0 ItemID, 'LWP' Description, SUM(sd.changedamount) changedamount,G.DESCRIPTION as GName,G.Code as GCode
// from Grades G,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd ,DEPARTMENT dep, DESIGNATION deg--, SALARYEMPCOSTCENTER empcc, crg cc
// where G.GradeID= S.GradeID AND E.employeeID=S.EmployeeID
// AND S.SalaryMonthlyID=Sd.SalaryMonthlyID AND S.SalaryMonth = %d and Sd.ItemGroup = 2
// AND S.EmployeeID IN(%q)
// AND E.DEPARTMENTID = dep.DEPARTMENTID
// AND E.DESIGNATIONID = deg.DESIGNATIONID
// --AND E.EMPLOYEEID = empcc.EMPLOYEEID
// --AND empcc.COSTCENTERID = cc.CRGID
// --AND S.EMPLOYEEID = empcc.EMPLOYEEID
// --AND S.SALARYMONTHLYID = empcc.SALARYMONTHLYID
// GROUP BY S.EmployeeID, E.EmployeeNo, E.Name,E.JoiningDate,sd.ItemGroup,G.DESCRIPTION ,G.Code,dep.DESCRIPTION,deg.Name--,cc.Description
// ) A
// group by
// A.EmployeeID, A.EmployeeNo, A.Name,A.GName,A.GCode, A.ItemGroup,
// A.ItemCode, A.ItemID, A.Description,A.JoiningDate , A.Department, A.DESIGNATION--
// order by A.EmployeeNo,A.GCode",
// dateTime, sEmpID, dateTime, sEmpID);
string query3 = SQLParser.MakeSQL(@"select A.EmployeeNo, A.Name,A.depname Department,A.DName DESIGNATION, A.JoiningDate,A.GName,A.GCode,A.itemgroup,
A.Description, avg(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 ,dep.DESCRIPTION depname,cc.Description AS COSTCENTER
from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd ,DEPARTMENT dep, SALARYEMPCOSTCENTER empcc, crg cc
where G.GradeID= S.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID AND E.employeeID=S.EmployeeID AND dep.DEPARTMENTID=S.DEPARTMENTID
AND E.EMPLOYEEID = empcc.EMPLOYEEID
AND empcc.COSTCENTERID = cc.CRGID
AND S.EMPLOYEEID = empcc.EMPLOYEEID
AND S.SALARYMONTHLYID = empcc.SALARYMONTHLYID
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,dep.DESCRIPTION depname,cc.Description AS COSTCENTER
from Grades G,DESIGNATION D,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd ,DEPARTMENT dep, SALARYEMPCOSTCENTER empcc, crg cc
where G.GradeID= S.GradeID AND D.DESIGNATIONID=E.DESIGNATIONID AND E.employeeID=S.EmployeeID AND dep.DEPARTMENTID=S.DEPARTMENTID
AND E.EMPLOYEEID = empcc.EMPLOYEEID
AND empcc.COSTCENTERID = cc.CRGID
AND S.EMPLOYEEID = empcc.EMPLOYEEID
AND S.SALARYMONTHLYID = empcc.SALARYMONTHLYID
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.depname,A.itemgroup 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.Department, A.DESIGNATION,
A.GName,A.GCode,A.JoiningDate,
A.Description, avg(A.changedamount) Amount
from
(
select S.EmployeeID, E.EmployeeNo, E.Name,dep.DESCRIPTION AS Department,deg.Name AS DESIGNATION,cc.Description AS COSTCENTER,
sd.ItemGroup,sd.ItemCode,E.JoiningDate,
sd.ItemID, sd.Description, sd.changedamount,G.DESCRIPTION as GName,G.Code as GCode
from Grades G,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd ,DEPARTMENT dep, DESIGNATION deg, SALARYEMPCOSTCENTER empcc, crg cc
where G.GradeID = S.GradeID 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)
AND E.DEPARTMENTID = dep.DEPARTMENTID
AND E.DESIGNATIONID = deg.DESIGNATIONID
AND E.EMPLOYEEID = empcc.EMPLOYEEID
AND empcc.COSTCENTERID = cc.CRGID
AND S.EMPLOYEEID = empcc.EMPLOYEEID
AND S.SALARYMONTHLYID = empcc.SALARYMONTHLYID
UNION
select S.EmployeeID, E.EmployeeNo, E.Name, dep.DESCRIPTION AS Department,deg.Name AS DESIGNATION,cc.Description AS COSTCENTER,
sd.ItemGroup,sd.ItemCode,E.JoiningDate,
sd.ItemID, sd.Description, sd.changedamount,G.DESCRIPTION as GName,G.Code as GCode
from Grades G,Employee E, SALARYMONTHLY S, SalaryMonthlyDetail Sd ,DEPARTMENT dep, DESIGNATION deg, SALARYEMPCOSTCENTER empcc, crg cc
where G.GradeID = S.GradeID 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)
AND E.DEPARTMENTID = dep.DEPARTMENTID
AND E.DESIGNATIONID = deg.DESIGNATIONID
AND E.EMPLOYEEID = empcc.EMPLOYEEID
AND empcc.COSTCENTERID = cc.CRGID
AND S.EMPLOYEEID = empcc.EMPLOYEEID
AND S.SALARYMONTHLYID = empcc.SALARYMONTHLYID
) A group by
A.EmployeeID, A.EmployeeNo, A.Name,A.GName,A.GCode,A.JoiningDate,
A.ItemCode, A.ItemID, A.Description ,A.Department, A.DESIGNATION
order by 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,dep.DESCRIPTION AS Department,deg.Name AS DESIGNATION,cc.Description AS COSTCENTER,
A.GName,A.GCode, A.Description, avg(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, S.SALARYMONTHLYID
from GRADES G,SALARYMONTHLY S,SalaryMonthlyDetail Sd
where S.SalaryMonthlyID=Sd.SalaryMonthlyID
AND S.SalaryMonth = %d AND G.GRADEID=S.GRADEID
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.Code, S.SALARYMONTHLYID
) A, Employee E ,DEPARTMENT dep, DESIGNATION deg, crg cc,SALARYEMPCOSTCENTER empcc
where A.EmployeeID = E.EmployeeID
AND E.DEPARTMENTID = dep.DEPARTMENTID
AND E.DESIGNATIONID = deg.DESIGNATIONID
AND E.EMPLOYEEID = empcc.EMPLOYEEID
AND empcc.COSTCENTERID = cc.CRGID
AND A.EMPLOYEEID = empcc.EMPLOYEEID
AND A.SALARYMONTHLYID = empcc.SALARYMONTHLYID
group by E.EmployeeNo, E.Name,A.GName,A.Description,A.GCode,E.JoiningDate ,dep.DESCRIPTION,deg.Name,cc.Description", 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,dep.DESCRIPTION AS Department,deg.Name AS DESIGNATION,
E.JoiningDate,A.GName,A.GCode, 'Total Deduction' as Description, avg(A.amount) as amount
from
( select S.EmployeeID, Sum(sd.changedamount) as Amount,G.DESCRIPTION as GName,G.Code as GCode, S.SALARYMONTHLYID
from GRADES G,SALARYMONTHLY S,SalaryMonthlyDetail Sd
where S.SalaryMonthlyID=Sd.SalaryMonthlyID
AND S.SalaryMonth= %d AND G.GRADEID=S.GRADEID and Sd.ItemGroup IN (3)
AND S.EmployeeID IN(%q)
group by S.EmployeeID,G.DESCRIPTION,G.Code, S.SALARYMONTHLYID
) A, Employee E ,DEPARTMENT dep, DESIGNATION deg, crg cc,SALARYEMPCOSTCENTER empcc
where A.EmployeeID = E.EmployeeID
AND E.DEPARTMENTID = dep.DEPARTMENTID
AND E.DESIGNATIONID = deg.DESIGNATIONID
AND E.EMPLOYEEID = empcc.EMPLOYEEID
AND empcc.COSTCENTERID = cc.CRGID
AND A.EMPLOYEEID = empcc.EMPLOYEEID
AND A.SALARYMONTHLYID = empcc.SALARYMONTHLYID
group by E.EmployeeNo, E.Name,A.GName,A.GCode,E.JoiningDate ,dep.DESCRIPTION,deg.Name
order by E.EmployeeNo,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 distinct E.EMPLOYEENO,E.NAME,dep.DESCRIPTION AS Department,deg.Name AS DESIGNATION,
E.JoiningDate,G.DESCRIPTION as GName,G.Code as GCode,
sd.ItemGroup,sd.ItemCode,sd.ItemID,
'Net Pay' as Description,SD.CHANGEDAMOUNT as Amount
from EMPLOYEE as E,GRADES as G,SALARYMONTHLY as S,SALARYMONTHLYDETAIL as Sd ,DEPARTMENT dep, DESIGNATION deg, crg cc,SALARYEMPCOSTCENTER empcc
where S.SalaryMonthlyID=Sd.SalaryMonthlyID
AND S.SalaryMonth = %d
AND G.GRADEID=S.GRADEID
AND E.EMPLOYEEID = S.EMPLOYEEID
and Sd.ItemGroup IN (5) AND Sd.ItemCode IN(-132)
AND S.EmployeeID IN(%q)
AND E.DEPARTMENTID = dep.DEPARTMENTID
AND E.DESIGNATIONID = deg.DESIGNATIONID
AND E.EMPLOYEEID = empcc.EMPLOYEEID
AND empcc.COSTCENTERID = cc.CRGID
AND S.EMPLOYEEID = empcc.EMPLOYEEID
AND S.SALARYMONTHLYID = empcc.SALARYMONTHLYID
order by E.EMPLOYEENO,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 distinct E.EMPLOYEENO,E.NAME,dep.DESCRIPTION AS Department,deg.Name AS DESIGNATION,
E.JoiningDate,G.DESCRIPTION as GName,G.Code as GCode,
sd.ItemGroup,sd.ItemID,sd.ItemCode,
'CPF' as Description,SD.CHANGEDAMOUNT as Amount
from EMPLOYEE as E,GRADES as G,SALARYMONTHLY as S,SALARYMONTHLYDETAIL as Sd ,DEPARTMENT dep, DESIGNATION deg, crg cc,SALARYEMPCOSTCENTER empcc
where S.SalaryMonthlyID=Sd.SalaryMonthlyID
AND S.SalaryMonth = %d
AND G.GRADEID=S.GRADEID
AND E.EMPLOYEEID =S.EMPLOYEEID
AND Sd.ItemGroup IN (3) AND Sd.ItemCode IN(-128)
AND S.EmployeeID IN(%q)
AND E.DEPARTMENTID = dep.DEPARTMENTID
AND E.DESIGNATIONID = deg.DESIGNATIONID
AND E.EMPLOYEEID = empcc.EMPLOYEEID
AND empcc.COSTCENTERID = cc.CRGID
AND S.EMPLOYEEID = empcc.EMPLOYEEID
AND S.SALARYMONTHLYID = empcc.SALARYMONTHLYID
order by E.EMPLOYEENO,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 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());
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return rootDataset;
}
internal static DataSet GetCCWiseOPISummary(TransactionContext tc, DateTime dSMonthDate, int nID)
{
string sql = string.Empty;
sql = SQLParser.MakeSQL(@"SELECT cc.DESCRIPTION cc,oi.Name Item, sum(oitem.ChangeNetAmount) amount
FROM OPIProcess op, opiprocessdetail opd,OPIProcessDetailItem oitem,employee emp,crg cc, empcostcenter empcc,opiitem oi
WHERE op.OPIProcessID=opd.OPIProcessID
AND opd.OPIProcessDetailID=oitem.OPIProcessDetailID
AND opd.EmployeeID=emp.EMPLOYEEID
AND cc.CRGID=empcc.COSTCENTERID
AND empcc.currentcc=1
AND empcc.EMPLOYEEID=emp.EMPLOYEEID
AND oitem.OPIItemID=oi.OpiItemID
AND op.OPIMonth=%d AND oi.OpiItemID=%n
GROUP BY cc.DESCRIPTION ,oi.Name", dSMonthDate, nID);
return tc.ExecuteDataSet(sql);
}
internal static DataSet GetCCWiseOPI(TransactionContext tc, DateTime dSMonthDate, int nID)
{
string sql = string.Empty;
sql = SQLParser.MakeSQL(@"SELECT cc.DESCRIPTION cc,emp.EMPLOYEENO EmpNo, emp.NAME EmpName, emp.ACCOUNTNO, oi.Name Item, oitem.ChangeNetAmount amount
FROM OPIProcess op, opiprocessdetail opd,OPIProcessDetailItem oitem,employee emp,crg cc, opiitem oi,
Salarymonthly sm,salaryempcostcenter scc
WHERE op.OPIProcessID=opd.OPIProcessID
AND opd.OPIProcessDetailID=oitem.OPIProcessDetailID
AND opd.EmployeeID=emp.EMPLOYEEID
AND emp.EmployeeID=sm.EMPLOYEEID
AND sm.SALARYMONTHLYID=scc.SALARYMONTHLYID
AND sm.SalaryMonth=op.OPIMonth
AND cc.CRGID=scc.COSTCENTERID
AND oitem.OPIItemID=oi.OpiItemID
AND op.OPIMonth=%d AND oi.OpiItemID=%n", dSMonthDate, nID);
return tc.ExecuteDataSet(sql);
}
}
#endregion
}