229 lines
9.1 KiB
C#
229 lines
9.1 KiB
C#
|
using System;
|
|||
|
using Ease.Core.Model;
|
|||
|
using Ease.Core.DataAccess;
|
|||
|
using HRM.BO;
|
|||
|
using Ease.Core.Utility;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Data;
|
|||
|
using NPOI.SS.Formula.Functions;
|
|||
|
using static iTextSharp.text.pdf.PdfDocument;
|
|||
|
|
|||
|
|
|||
|
namespace HRM.DA
|
|||
|
{
|
|||
|
internal class EmployeeTaxInvestmentDA
|
|||
|
{
|
|||
|
#region Constructor
|
|||
|
|
|||
|
private EmployeeTaxInvestmentDA()
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Insert function
|
|||
|
|
|||
|
internal static void Insert(TransactionContext tc, EmployeeTaxInvestment item)
|
|||
|
{
|
|||
|
|
|||
|
|
|||
|
|
|||
|
tc.ExecuteNonQuery(
|
|||
|
"INSERT INTO ITINVESTMENT(InvestmentID, employeeID, amount, taxParamID, typeID, CreatedBy, CreationDate, SequenceNo, Status, EntryFrom, taxeffectDone)" +
|
|||
|
" VALUES(%n, %n, %n, %n, %n, %n, %d, %n, %n, %n, %n)", item.ID, item.EmployeeID, item.Amount,
|
|||
|
item.TaxparameterId, item.TypeID, item.CreatedBy, item.CreatedDate,
|
|||
|
item.Sequence, item.Status, item.EntryFrom, item.submitStatus);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Update function
|
|||
|
|
|||
|
internal static void Update(TransactionContext tc, EmployeeTaxInvestment item)
|
|||
|
{
|
|||
|
tc.ExecuteNonQuery(
|
|||
|
"UPDATE ITINVESTMENT SET employeeID=%n, amount=%n, taxParamID=%n, typeID=%n, ModifiedBy=%n, ModifiedDate=%d, SequenceNo=%n, Status=%n" +
|
|||
|
" , EntryFrom=%n, taxeffectDone=%n WHERE InvestmentID=%n", item.EmployeeID, item.Amount, item.TaxparameterId, item.TypeID,
|
|||
|
item.ModifiedBy, item.ModifiedDate, item.Sequence, item.Status, item.EntryFrom, item.submitStatus, item.ID);
|
|||
|
}
|
|||
|
|
|||
|
internal static void Approve(TransactionContext tc, EmployeeTaxInvestment item)
|
|||
|
{
|
|||
|
tc.ExecuteNonQuery(
|
|||
|
"UPDATE ITINVESTMENT SET ModifiedBy=%n, ModifiedDate=%d" +
|
|||
|
" ,taxeffectDone=%n WHERE InvestmentID=%n", item.ModifiedBy, item.ModifiedDate,
|
|||
|
item.submitStatus, item.ID);
|
|||
|
}
|
|||
|
|
|||
|
internal static DataTable getSummaryView(TransactionContext tc, int taxparamid)
|
|||
|
{
|
|||
|
return tc.ExecuteDataTable(
|
|||
|
@"select e.employeeNo employeeno, e.NAME name, d.NAME designation, ISNULL(a.ess, 0) fromess,
|
|||
|
ISNULL(b.admin, 0) fromadmin,
|
|||
|
ISNULL(a.ess, 0) + ISNULL(b.admin, 0) total , Round(ISNULL(c.investmentallowed , 0 ) -ISNULL(f.pfAmount , 0 ) *2,0) investmentallowed from
|
|||
|
Employee e left outer join
|
|||
|
(
|
|||
|
select EMPLOYEEID, sum(Amount) ess from ITINVESTMENT where entryFrom = 1 and TAXPARAMID = %n
|
|||
|
and taxeffectDone=%n group by EMPLOYEEID) a on e.EMPLOYEEID = a.EMPLOYEEID
|
|||
|
left outer join
|
|||
|
(
|
|||
|
select EMPLOYEEID, sum(Amount) admin from ITINVESTMENT where entryFrom = 2 and TAXPARAMID = %n
|
|||
|
and taxeffectDone=%n group by EMPLOYEEID) b on b.EMPLOYEEID = e.EMPLOYEEID
|
|||
|
left outer join DESIGNATION d on e.DESIGNATIONID = d.DESIGNATIONID
|
|||
|
left outer join
|
|||
|
(
|
|||
|
select EMPLOYEEID, ISNULL( sum(THISYEARTOTAL), 0 ) investmentallowed from INCOMETAXTEMP where ITEMCODE =-220
|
|||
|
group by EMPLOYEEID ) c on c.EMPLOYEEID = e.EMPLOYEEID
|
|||
|
left outer join
|
|||
|
(
|
|||
|
select EMPLOYEEID, ISNULL( sum(THISYEARTOTAL), 0 ) pfAmount from INCOMETAXTEMP where ITEMCODE =-207
|
|||
|
group by EMPLOYEEID ) f on f.EMPLOYEEID = e.EMPLOYEEID
|
|||
|
where e.STATUS = 1
|
|||
|
", taxparamid, EnumTaxInvestmentStatus.Approve, taxparamid, EnumTaxInvestmentStatus.Approve);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
internal static void Reject(TransactionContext tc, EmployeeTaxInvestment item)
|
|||
|
{
|
|||
|
tc.ExecuteNonQuery(
|
|||
|
"UPDATE ITINVESTMENT SET rejectReason=%s, ModifiedBy=%n, ModifiedDate=%d" +
|
|||
|
" ,taxeffectDone=%n WHERE InvestmentID=%n", item.rejectReason, item.ModifiedBy, item.ModifiedDate,
|
|||
|
item.submitStatus, item.ID);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Get Function
|
|||
|
|
|||
|
internal static IDataReader Get(TransactionContext tc)
|
|||
|
{
|
|||
|
return tc.ExecuteReader("SELECT * FROM ITINVESTMENT");
|
|||
|
}
|
|||
|
|
|||
|
internal static IDataReader Get(TransactionContext tc, int nID)
|
|||
|
{
|
|||
|
return tc.ExecuteReader("SELECT * FROM ITINVESTMENT WHERE InvestmentID=%n", nID);
|
|||
|
}
|
|||
|
|
|||
|
internal static double GetAmount(TransactionContext tc, int nTaxParamID, int nEmployeeID)
|
|||
|
{
|
|||
|
object InvestAmount =
|
|||
|
tc.ExecuteScalar("SELECT Sum(amount) Amount FROM ITINVESTMENT WHERE taxParamID=%n AND employeeID=%n"
|
|||
|
+ " AND taxeffectDone=%n ", nTaxParamID, nEmployeeID, EnumTaxInvestmentStatus.Approve);
|
|||
|
if (InvestAmount == DBNull.Value)
|
|||
|
return 0.0;
|
|||
|
return Convert.ToDouble(InvestAmount);
|
|||
|
}
|
|||
|
|
|||
|
public static IDataReader GetFile(TransactionContext tc, int referenceId, EnumTaxAttachment type)
|
|||
|
{
|
|||
|
string sql =
|
|||
|
SQLParser.MakeSQL(
|
|||
|
"select * from TaxAttachment where referenceId = %n and fileType = %n",
|
|||
|
referenceId, (int)type);
|
|||
|
return tc.ExecuteReader(sql);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Delete function
|
|||
|
|
|||
|
internal static void Delete(TransactionContext tc, int nID)
|
|||
|
{
|
|||
|
tc.ExecuteNonQuery("DELETE FROM ITINVESTMENT WHERE InvestmentID=%n", nID);
|
|||
|
}
|
|||
|
|
|||
|
internal static void DeleteAttachment(TransactionContext tc, int referenceId, EnumTaxAttachment type)
|
|||
|
{
|
|||
|
tc.ExecuteNonQuery("DELETE FROM TaxAttachment WHERE referenceId=%n and fileType = %n", referenceId, (int)type);
|
|||
|
}
|
|||
|
|
|||
|
internal static void DeleteAdmin(TransactionContext tc, int taxparamId, int emplioyeeid, int typeID)
|
|||
|
{
|
|||
|
tc.ExecuteNonQuery("DELETE FROM ITINVESTMENT WHERE taxParamID=%n AND employeeID=%n AND typeID=%n " +
|
|||
|
"AND EntryFrom =%n",
|
|||
|
taxparamId, emplioyeeid, typeID, EnumTaxInvestment.Admin);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
internal static IDataReader GetAllUsersInfo(TransactionContext tc, int taxparid)
|
|||
|
{
|
|||
|
return tc.ExecuteReader(
|
|||
|
@"select employeeid ,MAX(INVESTMENTID) INVESTMENTID, SUM(AMOUNT) AMOUNT ,MAX(TYPEID) TYPEID , MAX(INVDATE) INVDATE ,
|
|||
|
MAX(USERID) USERID,
|
|||
|
MAX(TAXPARAMID) TAXPARAMID,
|
|||
|
MAX(SequenceNO) SequenceNO,
|
|||
|
MAX(Status) Status,
|
|||
|
MAX(CreatedBy) CreatedBy,
|
|||
|
MAX(CreationDate) CreationDate,
|
|||
|
MAX(ModifiedBy) ModifiedBy,
|
|||
|
MAX(ModifiedDate) ModifiedDate
|
|||
|
from ITINVESTMENT where TAXPARAMID = %n and
|
|||
|
TYPEID in (select TYPEID from ITINVESTMENT) group by EMPLOYEEID", taxparid);
|
|||
|
}
|
|||
|
|
|||
|
internal static IDataReader GetAllUsersInfoNew(TransactionContext tc, int taxparid)
|
|||
|
{
|
|||
|
return tc.ExecuteReader(
|
|||
|
@"SELECT
|
|||
|
employeeid,
|
|||
|
INVESTMENTID,
|
|||
|
AMOUNT,
|
|||
|
TYPEID,
|
|||
|
INVDATE,
|
|||
|
USERID,
|
|||
|
TAXPARAMID,
|
|||
|
SequenceNO,
|
|||
|
Status,
|
|||
|
CreatedBy,
|
|||
|
CreationDate,
|
|||
|
ModifiedBy,
|
|||
|
ModifiedDate
|
|||
|
FROM
|
|||
|
ITINVESTMENT
|
|||
|
WHERE
|
|||
|
TAXPARAMID = %n
|
|||
|
AND TYPEID IN (SELECT TYPEID FROM ITINVESTMENT)", taxparid);
|
|||
|
}
|
|||
|
internal static IDataReader GetEmpByTaxparam(TransactionContext tc, int taxparid)
|
|||
|
{
|
|||
|
return tc.ExecuteReader(
|
|||
|
@"select e.EmployeeNo, e.Name as EmployeeName, ITINVESTMENT.*
|
|||
|
from ITINVESTMENT, Employee e
|
|||
|
where ITINVESTMENT.TAXPARAMID = %n and e.Employeeid =ITINVESTMENT.Employeeid
|
|||
|
", taxparid);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
internal static IDataReader GetSingleEmpsInfo(TransactionContext tc, int id, int taxparamid)
|
|||
|
{
|
|||
|
return tc.ExecuteReader(
|
|||
|
"Select * from ITINVESTMENT where EMPLOYEEID = %n and TAXPARAMID=%n",
|
|||
|
id, taxparamid);
|
|||
|
}
|
|||
|
internal static IDataReader GetbyTaxParamID(TransactionContext tc, int taxparamid)
|
|||
|
{
|
|||
|
return tc.ExecuteReader(
|
|||
|
"Select * from ITINVESTMENT where TAXPARAMID=%n",
|
|||
|
taxparamid);
|
|||
|
}
|
|||
|
|
|||
|
#region Other function
|
|||
|
|
|||
|
public static bool IsExist(TransactionContext tc, int empId, int taxParamId, int typeId)
|
|||
|
{
|
|||
|
bool Exist = false;
|
|||
|
Object obj =
|
|||
|
tc.ExecuteScalar(
|
|||
|
"Select COUNT (*) FROM ITINVESTMENT WHERE employeeID=%n AND taxParamID=%n AND typeID=%n", empId,
|
|||
|
taxParamId, typeId);
|
|||
|
Exist = Convert.ToInt32(obj) > 0 ? true : false;
|
|||
|
return Exist;
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|