492 lines
39 KiB
C#
492 lines
39 KiB
C#
using HRM.BO;
|
|
using Ease.Core.DataAccess;
|
|
using System;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
|
|
|
|
namespace HRM.DA
|
|
{
|
|
#region FSTranDA
|
|
|
|
internal class FSTranDA
|
|
{
|
|
#region Constructor
|
|
|
|
private FSTranDA()
|
|
{
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Insert function
|
|
|
|
internal static void Insert(TransactionContext tc, FSTran item)
|
|
{
|
|
tc.ExecuteNonQuery(
|
|
"INSERT INTO FSTran(FSTranID, ChangeTaxAmount, EmployeeID, LastSalaryPaidMonth, NetAmount, NoticeDate, Remarks,SettlementDate,TaxAmount,CreatedBy,CreationDate,ShortNoticePeriod,DiscontinueDate)" +
|
|
" VALUES(%n, %n,%n, %d, %n, %d, %s, %d, %n,%n,%D, %n, %d)", item.ID, item.ChangeTaxAmount,
|
|
item.EmployeeID, item.LastSalaryPaidMonth, item.NetAmount, item.NoticeDate, item.Remarks,
|
|
item.SettlementDate, item.TaxAmount, item.CreatedBy, item.CreatedDate, item.ShortNoticePeriod,
|
|
item.DiscontinueDate );
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Update function
|
|
|
|
internal static void Update(TransactionContext tc, FSTran item)
|
|
{
|
|
tc.ExecuteNonQuery(
|
|
"UPDATE FSTran SET ChangeTaxAmount=%n,EmployeeID=%n, LastSalaryPaidMonth=%d, NetAmount=%n, NoticeDate=%d, Remarks=%s,SettlementDate=%d,TaxAmount=%n,ShortNoticePeriod=%n,DiscontinueDate=%d" +
|
|
"WHERE FSTranID=%n", item.ChangeTaxAmount, item.EmployeeID,
|
|
item.LastSalaryPaidMonth, item.NetAmount, item.NoticeDate, item.Remarks, item.SettlementDate,
|
|
item.TaxAmount, item.ShortNoticePeriod, item.DiscontinueDate, item.ID);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Get Function
|
|
|
|
internal static IDataReader Get(TransactionContext tc)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM FSTran Order By FSTranID");
|
|
}
|
|
|
|
internal static IDataReader Get(TransactionContext tc, EnumStatus status)
|
|
{
|
|
if (EnumStatus.Active == status)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM FSTran where Status=%n order by FSTranID", status);
|
|
}
|
|
else
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM FSTran order by FSTranID");
|
|
}
|
|
}
|
|
|
|
internal static IDataReader Get(TransactionContext tc, string sEmpIDs)
|
|
{
|
|
string sTableName;
|
|
sEmpIDs = IDHelper.GetIDs(tc, sEmpIDs, out sTableName);
|
|
|
|
IDataReader dr = tc.ExecuteReader("SELECT * FROM FSTran Where EmployeeID in(%q)", sEmpIDs);
|
|
if (sTableName != "")
|
|
tc.ExecuteNonQuery("Drop TAble %q", sTableName);
|
|
return dr;
|
|
}
|
|
|
|
internal static IDataReader Get(TransactionContext tc, int nID)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM FSTran Where FSTranID=%n", nID);
|
|
}
|
|
|
|
internal static IDataReader GetByEmpdId(TransactionContext tc, int nEmpID)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM FSTran Where EmployeeID=%n", nEmpID);
|
|
}
|
|
|
|
internal static IDataReader GetByEmpIdForRegEmployee(TransactionContext tc, int nEmpID)
|
|
{
|
|
return tc.ExecuteReader("SELECT e.EmployeeNo, e.Name EmployeeName, FSTran.* FROM FSTran, Employee e Where e.EmployeeID=%n", nEmpID);
|
|
}
|
|
|
|
internal static IDataReader Get(TransactionContext tc, DateTime dFromDate, DateTime dToDate)
|
|
{
|
|
return tc.ExecuteReader("SELECT e.EmployeeNo, e.Name EmployeeName, FSTran.* FROM FSTran, Employee e Where e.EmployeeID=FSTran.EmployeeID and" +
|
|
" SettlementDate between %d AND %d", dFromDate, dToDate);
|
|
}
|
|
|
|
internal static DataSet GetEmpPaymentAdvice(TransactionContext tc,int settlementAdviceId)
|
|
{
|
|
DataSet rootDataset = new DataSet();
|
|
DataSet tempdataset = new DataSet();
|
|
try
|
|
{
|
|
|
|
string query1 = SQLParser.MakeSQL(@"select A.EmployeeID, A.EmployeeNo, A.Name,A.designation,A.Department,A.JoiningDate,A.LOCATION,
|
|
A.Description,SUM(A.changedamount) Amount,A.STATUS,A.GROSSSALARY ctc,calenderDays=30,A.workDays,A.TranDate,T.ACCOUNTNO,T.Bank,A.Remarks
|
|
from
|
|
(
|
|
SELECT e.EMPLOYEEID,e.EMPLOYEENO,e.Name,e.joiningDate,d.Name designation,dpt.[DESCRIPTION] Department,ftd.ITEMCODE,ftd.ITEMID,
|
|
ftd.[DESCRIPTION],loc.[DESCRIPTION] location,e.[STATUS],e.GROSSSALARY,DATEDIFF(day, err.ResignationDate, err.LastWorkingDate) + 1 AS workDays,
|
|
SUM(ftd.CHANGEDVALUE) changedamount,sa.TranDate,ft.Remarks
|
|
FROM fstran ft
|
|
INNER JOIN FSTRANDETAIL AS ftd ON ft.FSTRANID=ftd.TRANID
|
|
INNER JOIN EMPLOYEE AS e ON e.EMPLOYEEID = ft.EMPLOYEEID
|
|
INNER JOIN EmpResignationRequest AS err ON e.EMPLOYEEID=err.EmployeeID
|
|
INNER JOIN DESIGNATION AS d ON e.DESIGNATIONID=d.DESIGNATIONID
|
|
INNER JOIN department AS dpt ON e.DEPARTMENTID=dpt.DEPARTMENTID
|
|
INNER JOIN location AS loc ON e.LOCATIONID=loc.LOCATIONID
|
|
INNER JOIN SettlmentAdviceItem AS sai ON sai.EmpResignID = err.ResignationRequestId
|
|
INNER JOIN SettlmentAdvice AS sa ON sa.SettlementAdviceID = sai.SettlmentAdviceID
|
|
WHERE amounttype=1 AND sa.SettlementAdviceID=%n AND ftd.ITEMCODE IN (6,7) AND ftd.FSTRANTYPE=1
|
|
GROUP BY e.EMPLOYEEID,e.EMPLOYEENO,e.Name,e.joiningDate,d.Name,dpt.[DESCRIPTION],ftd.ITEMCODE,ftd.ITEMCODE,ftd.ITEMID,ftd.[DESCRIPTION],
|
|
loc.[DESCRIPTION],e.[STATUS],e.GROSSSALARY, err.LastWorkingDate, err.ResignationDate,sa.TranDate,ft.Remarks
|
|
|
|
UNION ALL
|
|
|
|
SELECT e.EMPLOYEEID,e.EMPLOYEENO,e.Name,e.joiningDate,d.Name designation,dpt.[DESCRIPTION] Department,ftd.ITEMCODE,ftd.ITEMID,
|
|
ftd.[DESCRIPTION],loc.[DESCRIPTION] location,e.[STATUS],e.GROSSSALARY,DATEDIFF(day, err.ResignationDate, err.LastWorkingDate) + 1 AS workDays,
|
|
-SUM(ftd.CHANGEDVALUE) changedamount,sa.TranDate,ft.Remarks
|
|
FROM fstran ft
|
|
INNER JOIN FSTRANDETAIL AS ftd ON ft.FSTRANID=ftd.TRANID
|
|
INNER JOIN EMPLOYEE AS e ON e.EMPLOYEEID = ft.EMPLOYEEID
|
|
INNER JOIN EmpResignationRequest AS err ON e.EMPLOYEEID=err.EmployeeID
|
|
INNER JOIN DESIGNATION AS d ON e.DESIGNATIONID=d.DESIGNATIONID
|
|
INNER JOIN department AS dpt ON e.DEPARTMENTID=dpt.DEPARTMENTID
|
|
INNER JOIN location AS loc ON e.LOCATIONID=loc.LOCATIONID
|
|
INNER JOIN SettlmentAdviceItem AS sai ON sai.EmpResignID = err.ResignationRequestId
|
|
INNER JOIN SettlmentAdvice AS sa ON sa.SettlementAdviceID = sai.SettlmentAdviceID
|
|
WHERE amounttype=1 AND sa.SettlementAdviceID=%n AND ftd.ITEMCODE IN (6,7) AND ftd.FSTRANTYPE=2
|
|
GROUP BY e.EMPLOYEEID,e.EMPLOYEENO,e.Name,e.joiningDate,d.Name,dpt.[DESCRIPTION],ftd.ITEMCODE,ftd.ITEMCODE,ftd.ITEMID,ftd.[DESCRIPTION],
|
|
loc.[DESCRIPTION],e.[STATUS],e.GROSSSALARY, err.LastWorkingDate, err.ResignationDate,sa.TranDate,ft.Remarks
|
|
) A
|
|
LEFT JOIN (
|
|
SELECT ba.employeeID,ba.ACCOUNTNO,bk.NAME bank
|
|
FROM
|
|
BANKACCOUNTHISTORY ba
|
|
INNER JOIN BRANCHES AS bran ON bran.BRANCHID = ba.BRANCHID
|
|
INNER JOIN BANKS AS bk ON bk.BankID = bran.BankID
|
|
INNER JOIN (SELECT MAX(EMPBANKACCOUNTID) accountId FROM BANKACCOUNTHISTORY GROUP BY employeeID) T ON T.accountId=ba.EMPBANKACCOUNTID) T ON T.employeeID=A.EMPLOYEEID
|
|
group by
|
|
A.EmployeeNo, A.Name,A.designation,A.Department,A.JoiningDate,
|
|
A.Description,A.[STATUS],A.GROSSSALARY,A.workDays,A.LOCATION,A.TRANDATE,T.ACCOUNTNO,T.Bank,A.EMPLOYEEID,A.Remarks
|
|
Order by A.TranDate",
|
|
settlementAdviceId, settlementAdviceId);
|
|
|
|
tempdataset = tc.ExecuteDataSet(query1);
|
|
|
|
tempdataset.Tables[0].TableName = "GrossItem";
|
|
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
|
|
|
|
|
|
string query2 = SQLParser.MakeSQL(@"Select A.EMPLOYEEID, A.EmployeeNo, A.Name,A.designation,A.Department,A.JoiningDate,A.LOCATION,
|
|
DESCRIPTION='Total Gross Payable',SUM(A.changedamount) Amount,A.STATUS,A.GROSSSALARY ctc,calenderDays=30,A.workDays,A.TranDate,T.ACCOUNTNO,T.Bank,A.Remarks
|
|
from
|
|
(
|
|
SELECT e.EMPLOYEEID,e.EMPLOYEENO,e.Name,e.joiningDate,d.Name designation,dpt.[DESCRIPTION] Department,loc.[DESCRIPTION] location,e.[STATUS],e.GROSSSALARY,DATEDIFF(day, err.ResignationDate, err.LastWorkingDate) + 1 AS workDays,
|
|
SUM(ftd.CHANGEDVALUE) changedamount,sa.TranDate,ft.Remarks
|
|
FROM fstran ft
|
|
INNER JOIN FSTRANDETAIL AS ftd ON ft.FSTRANID=ftd.TRANID
|
|
INNER JOIN EMPLOYEE AS e ON e.EMPLOYEEID = ft.EMPLOYEEID
|
|
INNER JOIN EmpResignationRequest AS err ON e.EMPLOYEEID=err.EmployeeID
|
|
INNER JOIN DESIGNATION AS d ON e.DESIGNATIONID=d.DESIGNATIONID
|
|
INNER JOIN department AS dpt ON e.DEPARTMENTID=dpt.DEPARTMENTID
|
|
INNER JOIN SettlmentAdviceItem AS sai ON sai.EmpResignID = err.ResignationRequestId
|
|
INNER JOIN SettlmentAdvice AS sa ON sa.SettlementAdviceID = sai.SettlmentAdviceID
|
|
INNER JOIN location AS loc ON e.LOCATIONID=loc.LOCATIONID
|
|
WHERE amounttype=1 AND sa.SettlementAdviceID=%n AND ftd.ITEMCODE IN (6,7) AND ftd.FSTRANTYPE=1 AND ftd.side=1
|
|
GROUP BY e.EMPLOYEEID,e.EMPLOYEENO,e.Name,e.joiningDate,d.Name,dpt.[DESCRIPTION],loc.[DESCRIPTION],e.[STATUS],e.GROSSSALARY, err.LastWorkingDate, err.ResignationDate,sa.TranDate,ft.Remarks
|
|
UNION
|
|
SELECT e.EMPLOYEEID,e.EMPLOYEENO,e.Name,e.joiningDate,d.Name designation,dpt.[DESCRIPTION] Department,loc.[DESCRIPTION] location,e.[STATUS],e.GROSSSALARY,DATEDIFF(day, err.ResignationDate, err.LastWorkingDate) + 1 AS workDays,
|
|
-SUM(ftd.CHANGEDVALUE) changedamount,sa.TranDate,ft.Remarks
|
|
FROM fstran ft
|
|
INNER JOIN FSTRANDETAIL AS ftd ON ft.FSTRANID=ftd.TRANID
|
|
INNER JOIN EMPLOYEE AS e ON e.EMPLOYEEID = ft.EMPLOYEEID
|
|
INNER JOIN EmpResignationRequest AS err ON e.EMPLOYEEID=err.EmployeeID
|
|
INNER JOIN DESIGNATION AS d ON e.DESIGNATIONID=d.DESIGNATIONID
|
|
INNER JOIN department AS dpt ON e.DEPARTMENTID=dpt.DEPARTMENTID
|
|
INNER JOIN SettlmentAdviceItem AS sai ON sai.EmpResignID = err.ResignationRequestId
|
|
INNER JOIN SettlmentAdvice AS sa ON sa.SettlementAdviceID = sai.SettlmentAdviceID
|
|
INNER JOIN location AS loc ON e.LOCATIONID=loc.LOCATIONID
|
|
WHERE amounttype=1 AND sa.SettlementAdviceID=%n AND ftd.ITEMCODE IN (6,7) AND ftd.FSTRANTYPE=2
|
|
GROUP BY e.EMPLOYEEID,e.EMPLOYEENO,e.Name,e.joiningDate,d.Name,dpt.[DESCRIPTION],loc.[DESCRIPTION],e.[STATUS],e.GROSSSALARY, err.LastWorkingDate, err.ResignationDate,sa.TranDate,ft.Remarks
|
|
|
|
) A
|
|
LEFT JOIN (
|
|
SELECT ba.employeeID,ba.ACCOUNTNO,bk.NAME bank
|
|
FROM
|
|
BANKACCOUNTHISTORY ba
|
|
INNER JOIN BRANCHES AS bran ON bran.BRANCHID = ba.BRANCHID
|
|
INNER JOIN BANKS AS bk ON bk.BankID = bran.BankID
|
|
INNER JOIN (SELECT MAX(EMPBANKACCOUNTID) accountId FROM BANKACCOUNTHISTORY GROUP BY employeeID) T ON T.accountId=ba.EMPBANKACCOUNTID) T ON T.employeeID=A.EMPLOYEEID
|
|
group by
|
|
A.EmployeeNo, A.Name,A.designation,A.Department,A.JoiningDate,A.[STATUS],A.GROSSSALARY,A.workDays,A.LOCATION,A.TranDate,T.ACCOUNTNO,T.Bank,A.EMPLOYEEID,A.Remarks",
|
|
settlementAdviceId, settlementAdviceId);
|
|
|
|
tempdataset = tc.ExecuteDataSet(query2);
|
|
|
|
tempdataset.Tables[0].TableName = "TotalGross";
|
|
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
|
|
|
|
string query7 = SQLParser.MakeSQL(@"Select A.EMPLOYEEID,A.EmployeeNo, A.Name,A.designation,A.Department,A.JoiningDate,A.LOCATION,
|
|
A.Description,SUM(A.changedamount) Amount,A.STATUS,A.GROSSSALARY ctc,calenderDays=30,A.workDays,a.TranDate,T.ACCOUNTNO,T.Bank,A.Remarks
|
|
from
|
|
(
|
|
SELECT e.EMPLOYEEID,e.EMPLOYEENO,e.Name,e.joiningDate,d.Name designation,dpt.[DESCRIPTION] Department,ftd.ITEMCODE,ftd.ITEMID,
|
|
'Compensation Basic' AS DESCRIPTION,loc.[DESCRIPTION] location,e.[STATUS],e.GROSSSALARY,DATEDIFF(day, err.ResignationDate, err.LastWorkingDate) + 1 AS workDays,
|
|
SUM(ftd.CHANGEDVALUE) changedamount,sa.TranDate,ft.Remarks
|
|
FROM fstran ft
|
|
INNER JOIN FSTRANDETAIL AS ftd ON ft.FSTRANID=ftd.TRANID
|
|
INNER JOIN EMPLOYEE AS e ON e.EMPLOYEEID = ft.EMPLOYEEID
|
|
INNER JOIN EmpResignationRequest AS err ON e.EMPLOYEEID=err.EmployeeID
|
|
INNER JOIN DESIGNATION AS d ON e.DESIGNATIONID=d.DESIGNATIONID
|
|
INNER JOIN department AS dpt ON e.DEPARTMENTID=dpt.DEPARTMENTID
|
|
INNER JOIN SettlmentAdviceItem AS sai ON sai.EmpResignID = err.ResignationRequestId
|
|
INNER JOIN SettlmentAdvice AS sa ON sa.SettlementAdviceID = sai.SettlmentAdviceID
|
|
INNER JOIN location AS loc ON e.LOCATIONID=loc.LOCATIONID
|
|
WHERE amounttype=1 AND sa.SettlementAdviceID=%n AND ftd.ITEMCODE IN (31) AND ftd.FSTRANTYPE=1
|
|
GROUP BY e.EMPLOYEEID,e.EMPLOYEENO,e.Name,e.joiningDate,d.Name,dpt.[DESCRIPTION],ftd.ITEMCODE,ftd.ITEMCODE,ftd.ITEMID,ftd.[DESCRIPTION],loc.[DESCRIPTION],e.[STATUS],e.GROSSSALARY, err.LastWorkingDate, err.ResignationDate,sa.TranDate,ft.Remarks
|
|
) A
|
|
LEFT JOIN (
|
|
SELECT ba.employeeID,ba.ACCOUNTNO,bk.NAME bank
|
|
FROM
|
|
BANKACCOUNTHISTORY ba
|
|
INNER JOIN BRANCHES AS bran ON bran.BRANCHID = ba.BRANCHID
|
|
INNER JOIN BANKS AS bk ON bk.BankID = bran.BankID
|
|
INNER JOIN (SELECT MAX(EMPBANKACCOUNTID) accountId FROM BANKACCOUNTHISTORY GROUP BY employeeID) T ON T.accountId=ba.EMPBANKACCOUNTID) T ON T.employeeID=A.EMPLOYEEID
|
|
group by
|
|
A.EmployeeNo, A.Name,A.designation,A.Department,A.JoiningDate,
|
|
A.Description,A.[STATUS],A.GROSSSALARY,A.workDays,A.LOCATION,a.TranDate,T.ACCOUNTNO,T.Bank,A.EMPLOYEEID,A.Remarks
|
|
", settlementAdviceId);
|
|
|
|
tempdataset = tc.ExecuteDataSet(query7);
|
|
|
|
tempdataset.Tables[0].TableName = "BasicItem";
|
|
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
|
|
|
|
string query3 = SQLParser.MakeSQL(@"Select A.EMPLOYEEID,A.EmployeeNo, A.Name,A.designation,A.Department,A.JoiningDate,A.LOCATION,
|
|
A.Description,SUM(A.changedamount) Amount,A.STATUS,A.GROSSSALARY ctc,calenderDays=30,A.workDays,a.TranDate,T.ACCOUNTNO,T.Bank,A.Remarks
|
|
from
|
|
(
|
|
SELECT e.EMPLOYEEID,e.EMPLOYEENO,e.Name,e.joiningDate,d.Name designation,dpt.[DESCRIPTION] Department,ftd.ITEMCODE,ftd.ITEMID,
|
|
ftd.[DESCRIPTION],loc.[DESCRIPTION] location,e.[STATUS],e.GROSSSALARY,DATEDIFF(day, err.ResignationDate, err.LastWorkingDate) + 1 AS workDays,
|
|
SUM(ftd.CHANGEDVALUE) changedamount,sa.TranDate,ft.Remarks
|
|
FROM fstran ft
|
|
INNER JOIN FSTRANDETAIL AS ftd ON ft.FSTRANID=ftd.TRANID
|
|
INNER JOIN EMPLOYEE AS e ON e.EMPLOYEEID = ft.EMPLOYEEID
|
|
INNER JOIN EmpResignationRequest AS err ON e.EMPLOYEEID=err.EmployeeID
|
|
INNER JOIN DESIGNATION AS d ON e.DESIGNATIONID=d.DESIGNATIONID
|
|
INNER JOIN department AS dpt ON e.DEPARTMENTID=dpt.DEPARTMENTID
|
|
INNER JOIN SettlmentAdviceItem AS sai ON sai.EmpResignID = err.ResignationRequestId
|
|
INNER JOIN SettlmentAdvice AS sa ON sa.SettlementAdviceID = sai.SettlmentAdviceID
|
|
INNER JOIN location AS loc ON e.LOCATIONID=loc.LOCATIONID
|
|
WHERE amounttype=1 AND sa.SettlementAdviceID=%n AND ftd.ITEMCODE IN (1,2,3,10,8,10,20,12,32) AND ftd.FSTRANTYPE=1
|
|
GROUP BY e.EMPLOYEEID,e.EMPLOYEENO,e.Name,e.joiningDate,d.Name,dpt.[DESCRIPTION],ftd.ITEMCODE,ftd.ITEMCODE,ftd.ITEMID,ftd.[DESCRIPTION],loc.[DESCRIPTION],e.[STATUS],e.GROSSSALARY, err.LastWorkingDate, err.ResignationDate,sa.TranDate,ft.Remarks
|
|
) A
|
|
LEFT JOIN (
|
|
SELECT ba.employeeID,ba.ACCOUNTNO,bk.NAME bank
|
|
FROM
|
|
BANKACCOUNTHISTORY ba
|
|
INNER JOIN BRANCHES AS bran ON bran.BRANCHID = ba.BRANCHID
|
|
INNER JOIN BANKS AS bk ON bk.BankID = bran.BankID
|
|
INNER JOIN (SELECT MAX(EMPBANKACCOUNTID) accountId FROM BANKACCOUNTHISTORY GROUP BY employeeID) T ON T.accountId=ba.EMPBANKACCOUNTID) T ON T.employeeID=A.EMPLOYEEID
|
|
group by
|
|
A.EmployeeNo, A.Name,A.designation,A.Department,A.JoiningDate,
|
|
A.Description,A.[STATUS],A.GROSSSALARY,A.workDays,A.LOCATION,a.TranDate,T.ACCOUNTNO,T.Bank,A.EMPLOYEEID,A.Remarks
|
|
", settlementAdviceId);
|
|
|
|
tempdataset = tc.ExecuteDataSet(query3);
|
|
|
|
tempdataset.Tables[0].TableName = "OtherItems";
|
|
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
|
|
|
|
|
|
string query4 = SQLParser.MakeSQL(@"Select A.EMPLOYEEID, A.EmployeeNo, A.Name,A.designation,A.Department,A.JoiningDate,A.LOCATION,
|
|
A.Description,SUM(A.changedamount) Amount,A.STATUS,A.GROSSSALARY ctc,calenderDays=30,A.workDays,A.TranDate,T.ACCOUNTNO,T.Bank,A.Remarks
|
|
from
|
|
(
|
|
SELECT e.EMPLOYEEID,e.EMPLOYEENO,e.Name,e.joiningDate,d.Name designation,dpt.[DESCRIPTION] Department,ftd.ITEMCODE,ftd.ITEMID,
|
|
ftd.[DESCRIPTION],loc.[DESCRIPTION] location,e.[STATUS],e.GROSSSALARY,DATEDIFF(day, err.ResignationDate, err.LastWorkingDate) + 1 AS workDays,
|
|
SUM(ftd.CHANGEDVALUE) changedamount,sa.TranDate,ft.Remarks
|
|
FROM fstran ft
|
|
INNER JOIN FSTRANDETAIL AS ftd ON ft.FSTRANID=ftd.TRANID
|
|
INNER JOIN EMPLOYEE AS e ON e.EMPLOYEEID = ft.EMPLOYEEID
|
|
INNER JOIN EmpResignationRequest AS err ON e.EMPLOYEEID=err.EmployeeID
|
|
INNER JOIN DESIGNATION AS d ON e.DESIGNATIONID=d.DESIGNATIONID
|
|
INNER JOIN department AS dpt ON e.DEPARTMENTID=dpt.DEPARTMENTID
|
|
INNER JOIN SettlmentAdviceItem AS sai ON sai.EmpResignID = err.ResignationRequestId
|
|
INNER JOIN SettlmentAdvice AS sa ON sa.SettlementAdviceID = sai.SettlmentAdviceID
|
|
INNER JOIN location AS loc ON e.LOCATIONID=loc.LOCATIONID
|
|
WHERE amounttype=1 AND sa.SettlementAdviceID=%n AND ftd.ITEMCODE IN (1,2,3,10,8,10,20,12,27) AND ftd.FSTRANTYPE=2
|
|
GROUP BY e.EMPLOYEEID,e.EMPLOYEENO,e.Name,e.joiningDate,d.Name,dpt.[DESCRIPTION],ftd.ITEMCODE,ftd.ITEMCODE,ftd.ITEMID,ftd.[DESCRIPTION],loc.[DESCRIPTION],e.[STATUS],e.GROSSSALARY, err.LastWorkingDate, err.ResignationDate,sa.TranDate,ft.Remarks
|
|
) A
|
|
LEFT JOIN (
|
|
SELECT ba.employeeID,ba.ACCOUNTNO,bk.NAME bank
|
|
FROM
|
|
BANKACCOUNTHISTORY ba
|
|
INNER JOIN BRANCHES AS bran ON bran.BRANCHID = ba.BRANCHID
|
|
INNER JOIN BANKS AS bk ON bk.BankID = bran.BankID
|
|
INNER JOIN (SELECT MAX(EMPBANKACCOUNTID) accountId FROM BANKACCOUNTHISTORY GROUP BY employeeID) T ON T.accountId=ba.EMPBANKACCOUNTID) T ON T.employeeID=A.EMPLOYEEID
|
|
group by
|
|
A.EmployeeNo, A.Name,A.designation,A.Department,A.JoiningDate,
|
|
A.Description, A.Description,A.[STATUS],A.GROSSSALARY,A.workDays,A.LOCATION,A.TranDate,T.ACCOUNTNO,T.Bank,A.EMPLOYEEID,A.Remarks", settlementAdviceId);
|
|
tempdataset = tc.ExecuteDataSet(query4);
|
|
|
|
tempdataset.Tables[0].TableName = "DeductItem";
|
|
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
|
|
|
|
|
|
|
|
string query5 = SQLParser.MakeSQL(@" ;WITH cte AS (Select A.EmployeeID, A.EmployeeNo, A.Name,A.designation,A.Department,A.JoiningDate,A.LOCATION,
|
|
DESCRIPTION='Total Deduction',SUM(A.changedamount) Amount,A.STATUS,A.GROSSSALARY ctc,calenderDays=30,A.workDays,A.TranDate,T.ACCOUNTNO,T.Bank,A.Remarks
|
|
from
|
|
(
|
|
SELECT e.EMPLOYEEID,e.EMPLOYEENO,e.Name,e.joiningDate,d.Name designation,dpt.[DESCRIPTION] Department,
|
|
SUM(ftd.CHANGEDVALUE) changedamount,loc.[DESCRIPTION] location,e.[STATUS],e.GROSSSALARY,DATEDIFF(day, err.ResignationDate, err.LastWorkingDate) + 1 AS workDays,sa.TranDate,ft.Remarks
|
|
FROM fstran ft
|
|
INNER JOIN FSTRANDETAIL AS ftd ON ft.FSTRANID=ftd.TRANID
|
|
INNER JOIN EMPLOYEE AS e ON e.EMPLOYEEID = ft.EMPLOYEEID
|
|
INNER JOIN EmpResignationRequest AS err ON e.EMPLOYEEID=err.EmployeeID
|
|
INNER JOIN DESIGNATION AS d ON e.DESIGNATIONID=d.DESIGNATIONID
|
|
INNER JOIN department AS dpt ON e.DEPARTMENTID=dpt.DEPARTMENTID
|
|
INNER JOIN SettlmentAdviceItem AS sai ON sai.EmpResignID = err.ResignationRequestId
|
|
INNER JOIN SettlmentAdvice AS sa ON sa.SettlementAdviceID = sai.SettlmentAdviceID
|
|
INNER JOIN location AS loc ON e.LOCATIONID=loc.LOCATIONID
|
|
WHERE amounttype=1 AND sa.SettlementAdviceID=%n AND ((ftd.ITEMCODE IN (1,2,3,10,8,10,20,12,6,7,27) AND ftd.FSTRANTYPE=2) OR (ftd.ITEMCODE IN (7) AND ftd.FSTRANTYPE=1 AND side=-1))
|
|
GROUP BY e.EMPLOYEEID,e.EMPLOYEENO,e.Name,e.joiningDate,d.Name,dpt.[DESCRIPTION],loc.[DESCRIPTION],e.[STATUS],e.GROSSSALARY, err.LastWorkingDate, err.ResignationDate,sa.TranDate,ft.Remarks
|
|
) A
|
|
LEFT JOIN (
|
|
SELECT ba.employeeID,ba.ACCOUNTNO,bk.NAME bank
|
|
FROM
|
|
BANKACCOUNTHISTORY ba
|
|
INNER JOIN BRANCHES AS bran ON bran.BRANCHID = ba.BRANCHID
|
|
INNER JOIN BANKS AS bk ON bk.BankID = bran.BankID
|
|
INNER JOIN (SELECT MAX(EMPBANKACCOUNTID) accountId FROM BANKACCOUNTHISTORY GROUP BY employeeID) T ON T.accountId=ba.EMPBANKACCOUNTID) T ON T.employeeID=A.EMPLOYEEID
|
|
group by
|
|
A.EmployeeNo, A.Name,A.designation,A.Department,A.JoiningDate,A.[STATUS],A.GROSSSALARY,A.workDays,A.LOCATION,A.TranDate,T.ACCOUNTNO,T.Bank,A.EMPLOYEEID,A.Remarks)
|
|
SELECT * FROM cte
|
|
UNION ALL
|
|
SELECT e.EmployeeID, e.EMPLOYEENO,e.Name,d.Name designation,dpt.[DESCRIPTION] Department,e.JoiningDate,loc.[DESCRIPTION] LOCATION, [DESCRIPTION]='Total Deduction', amount=0, e.STATUS,e.GROSSSALARY ctc,calenderDays=30,
|
|
DATEDIFF(day, err.ResignationDate, err.LastWorkingDate) + 1 AS workDays,
|
|
sa.TranDate,T.ACCOUNTNO,T.Bank,Remarks=''
|
|
FROM EmpResignationRequest AS err
|
|
INNER JOIN EMPLOYEE AS e ON e.EMPLOYEEID=err.EmployeeID
|
|
INNER JOIN DESIGNATION AS d ON e.DESIGNATIONID=d.DESIGNATIONID
|
|
INNER JOIN department AS dpt ON e.DEPARTMENTID=dpt.DEPARTMENTID
|
|
INNER JOIN SettlmentAdviceItem AS sai ON sai.EmpResignID = err.ResignationRequestId
|
|
INNER JOIN SettlmentAdvice AS sa ON sa.SettlementAdviceID = sai.SettlmentAdviceID
|
|
INNER JOIN location AS loc ON e.LOCATIONID=loc.LOCATIONID
|
|
LEFT JOIN (
|
|
SELECT ba.employeeID,ba.ACCOUNTNO,bk.NAME bank
|
|
FROM
|
|
BANKACCOUNTHISTORY ba
|
|
INNER JOIN BRANCHES AS bran ON bran.BRANCHID = ba.BRANCHID
|
|
INNER JOIN BANKS AS bk ON bk.BankID = bran.BankID
|
|
INNER JOIN (SELECT MAX(EMPBANKACCOUNTID) accountId FROM BANKACCOUNTHISTORY GROUP BY employeeID) T ON T.accountId=ba.EMPBANKACCOUNTID) T ON T.employeeID=e.EMPLOYEEID
|
|
WHERE sa.SettlementAdviceID=%n AND (select count(*) from cte) =0", settlementAdviceId, settlementAdviceId);
|
|
|
|
tempdataset = tc.ExecuteDataSet(query5);
|
|
|
|
tempdataset.Tables[0].TableName = "TotalDeduction";
|
|
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
|
|
|
|
string query6 = SQLParser.MakeSQL(@"Select A.EMPLOYEEID, A.EmployeeNo, A.Name,A.designation,A.Department,A.JoiningDate,A.LOCATION,
|
|
A.Description,SUM(A.changedamount) Amount,A.STATUS,A.GROSSSALARY ctc,calenderDays=30,A.workDays,A.TranDate,T.ACCOUNTNO,T.Bank,A.Remarks
|
|
from
|
|
(
|
|
SELECT e.EMPLOYEEID,e.EMPLOYEENO,e.Name,e.joiningDate,d.Name designation,dpt.[DESCRIPTION] Department,
|
|
'Tax Amount' Description,loc.[DESCRIPTION] location,e.[STATUS],e.GROSSSALARY,DATEDIFF(day, err.ResignationDate, err.LastWorkingDate) + 1 AS workDays,
|
|
ft.TAXAMOUNT changedamount,sa.TranDate,ft.Remarks
|
|
FROM fstran ft
|
|
INNER JOIN EMPLOYEE AS e ON e.EMPLOYEEID = ft.EMPLOYEEID
|
|
INNER JOIN EmpResignationRequest AS err ON e.EMPLOYEEID=err.EmployeeID
|
|
INNER JOIN DESIGNATION AS d ON e.DESIGNATIONID=d.DESIGNATIONID
|
|
INNER JOIN department AS dpt ON e.DEPARTMENTID=dpt.DEPARTMENTID
|
|
INNER JOIN SettlmentAdviceItem AS sai ON sai.EmpResignID = err.ResignationRequestId
|
|
INNER JOIN SettlmentAdvice AS sa ON sa.SettlementAdviceID = sai.SettlmentAdviceID
|
|
INNER JOIN location AS loc ON e.LOCATIONID=loc.LOCATIONID
|
|
WHERE sa.SettlementAdviceID=%n
|
|
GROUP BY e.EMPLOYEEID,e.EMPLOYEENO,e.Name,e.joiningDate,d.Name,dpt.[DESCRIPTION],loc.[DESCRIPTION],e.[STATUS],e.GROSSSALARY, err.LastWorkingDate, err.ResignationDate,sa.TranDate,ft.Remarks,ft.TAXAMOUNT
|
|
) A
|
|
LEFT JOIN (
|
|
SELECT ba.employeeID,ba.ACCOUNTNO,bk.NAME bank
|
|
FROM
|
|
BANKACCOUNTHISTORY ba
|
|
INNER JOIN BRANCHES AS bran ON bran.BRANCHID = ba.BRANCHID
|
|
INNER JOIN BANKS AS bk ON bk.BankID = bran.BankID
|
|
INNER JOIN (SELECT MAX(EMPBANKACCOUNTID) accountId FROM BANKACCOUNTHISTORY GROUP BY employeeID) T ON T.accountId=ba.EMPBANKACCOUNTID) T ON T.employeeID=A.EMPLOYEEID
|
|
group by
|
|
A.EmployeeNo, A.Name,A.designation,A.Department,A.JoiningDate,
|
|
A.Description,A.[STATUS],A.GROSSSALARY,A.workDays,A.LOCATION,a.TranDate,T.ACCOUNTNO,T.Bank,A.EMPLOYEEID,A.Remarks", settlementAdviceId);
|
|
|
|
tempdataset = tc.ExecuteDataSet(query6);
|
|
|
|
tempdataset.Tables[0].TableName = "TaxAmount";
|
|
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
|
|
|
|
string query8 = SQLParser.MakeSQL(@"Select A.EMPLOYEEID, A.EmployeeNo, A.Name,A.designation,A.Department,A.JoiningDate,A.LOCATION,
|
|
DESCRIPTION='Net Pay',(SUM(A.changedamount) - A.TAXAMOUNT) Amount,A.STATUS,A.GROSSSALARY ctc,calenderDays=30,A.workDays,A.TranDate,T.ACCOUNTNO,T.Bank,A.Remarks
|
|
from
|
|
(
|
|
SELECT e.EMPLOYEEID,e.EMPLOYEENO,e.Name,e.joiningDate,d.Name designation,dpt.[DESCRIPTION] Department,
|
|
SUM(ftd.CHANGEDVALUE) changedamount,loc.[DESCRIPTION] location,e.[STATUS],e.GROSSSALARY,DATEDIFF(day, err.ResignationDate, err.LastWorkingDate) + 1 AS workDays,sa.TranDate,ft.Remarks,ft.TAXAMOUNT
|
|
FROM fstran ft
|
|
INNER JOIN FSTRANDETAIL AS ftd ON ft.FSTRANID=ftd.TRANID
|
|
INNER JOIN EMPLOYEE AS e ON e.EMPLOYEEID = ft.EMPLOYEEID
|
|
INNER JOIN EmpResignationRequest AS err ON e.EMPLOYEEID=err.EmployeeID
|
|
INNER JOIN DESIGNATION AS d ON e.DESIGNATIONID=d.DESIGNATIONID
|
|
INNER JOIN department AS dpt ON e.DEPARTMENTID=dpt.DEPARTMENTID
|
|
INNER JOIN location AS loc ON e.LOCATIONID=loc.LOCATIONID
|
|
INNER JOIN SettlmentAdviceItem AS sai ON sai.EmpResignID = err.ResignationRequestId
|
|
INNER JOIN SettlmentAdvice AS sa ON sa.SettlementAdviceID = sai.SettlmentAdviceID
|
|
WHERE amounttype=1 AND sa.SettlementAdviceID=%n AND ftd.ITEMCODE IN (6,7,1,2,3,10,8,10,20,12,31,27,32) AND ftd.FSTRANTYPE=1
|
|
GROUP BY e.EMPLOYEEID,e.EMPLOYEENO,e.Name,e.joiningDate,d.Name,dpt.[DESCRIPTION],loc.[DESCRIPTION],e.[STATUS],e.GROSSSALARY, err.LastWorkingDate, err.ResignationDate,sa.TranDate,ft.Remarks,ft.TAXAMOUNT
|
|
|
|
UNION
|
|
|
|
SELECT e.EMPLOYEEID,e.EMPLOYEENO,e.Name,e.joiningDate,d.Name designation,dpt.[DESCRIPTION] Department,
|
|
-SUM(ftd.CHANGEDVALUE) changedamount,loc.[DESCRIPTION] location,e.[STATUS],e.GROSSSALARY,DATEDIFF(day, err.ResignationDate, err.LastWorkingDate) + 1 AS workDays,sa.TranDate,ft.Remarks,ft.TAXAMOUNT
|
|
FROM fstran ft
|
|
INNER JOIN FSTRANDETAIL AS ftd ON ft.FSTRANID=ftd.TRANID
|
|
INNER JOIN EMPLOYEE AS e ON e.EMPLOYEEID = ft.EMPLOYEEID
|
|
INNER JOIN EmpResignationRequest AS err ON e.EMPLOYEEID=err.EmployeeID
|
|
INNER JOIN DESIGNATION AS d ON e.DESIGNATIONID=d.DESIGNATIONID
|
|
INNER JOIN department AS dpt ON e.DEPARTMENTID=dpt.DEPARTMENTID
|
|
INNER JOIN location AS loc ON e.LOCATIONID=loc.LOCATIONID
|
|
INNER JOIN SettlmentAdviceItem AS sai ON sai.EmpResignID = err.ResignationRequestId
|
|
INNER JOIN SettlmentAdvice AS sa ON sa.SettlementAdviceID = sai.SettlmentAdviceID
|
|
WHERE amounttype=1 AND sa.SettlementAdviceID=%n AND ((ftd.ITEMCODE IN (6,7,1,2,3,10,8,10,20,12,31,27,32) AND ftd.FSTRANTYPE=2) OR (ftd.ITEMCODE IN (7) AND ftd.FSTRANTYPE=1 AND side=-1))
|
|
GROUP BY e.EMPLOYEEID,e.EMPLOYEENO,e.Name,e.joiningDate,d.Name,dpt.[DESCRIPTION],loc.[DESCRIPTION],e.[STATUS],e.GROSSSALARY, err.LastWorkingDate, err.ResignationDate,sa.TranDate,ft.Remarks,ft.TAXAMOUNT
|
|
) A
|
|
LEFT JOIN (
|
|
SELECT ba.employeeID,ba.ACCOUNTNO,bk.NAME bank
|
|
FROM
|
|
BANKACCOUNTHISTORY ba
|
|
INNER JOIN BRANCHES AS bran ON bran.BRANCHID = ba.BRANCHID
|
|
INNER JOIN BANKS AS bk ON bk.BankID = bran.BankID
|
|
INNER JOIN (SELECT MAX(EMPBANKACCOUNTID) accountId FROM BANKACCOUNTHISTORY GROUP BY employeeID) T ON T.accountId=ba.EMPBANKACCOUNTID) T ON T.employeeID=A.EMPLOYEEID
|
|
group by
|
|
A.EmployeeNo, A.Name,A.designation,A.Department,A.JoiningDate,A.[STATUS],A.GROSSSALARY,A.workDays,A.LOCATION,A.TranDate,T.ACCOUNTNO,T.Bank,A.EMPLOYEEID,A.Remarks,A.TAXAMOUNT", settlementAdviceId,settlementAdviceId);
|
|
|
|
tempdataset = tc.ExecuteDataSet(query8);
|
|
|
|
tempdataset.Tables[0].TableName = "NetPay";
|
|
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
|
|
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
return rootDataset;
|
|
}
|
|
|
|
|
|
//internal static double GetPFAmount(SqlConnection connection, string sEmpNo)
|
|
//{
|
|
// object ob;
|
|
// SqlCommand command = new SqlCommand("SELECT TotalPayment " +
|
|
// " FROM FinalSettlement" +
|
|
// " WHERE EmpCode=@ID", connection);
|
|
// command.Parameters.Add("@ID", SqlDbType.VarChar).Value = sEmpNo;
|
|
// ob= command.ExecuteScalar();
|
|
// return ob == DBNull.Value ? 0 : Convert.ToDouble(ob);
|
|
//}
|
|
|
|
#endregion
|
|
|
|
#region Delete function
|
|
|
|
internal static void Delete(TransactionContext tc, int nID)
|
|
{
|
|
tc.ExecuteNonQuery("DELETE FROM FSTran Where FSTranID=%n", nID);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
|
|
#endregion
|
|
} |