234 lines
14 KiB
C#
234 lines
14 KiB
C#
|
using System;
|
|||
|
using Payroll.BO;
|
|||
|
using System.Data;
|
|||
|
using System.Linq;
|
|||
|
using Ease.CoreV35.Model;
|
|||
|
using System.Data.SqlClient;
|
|||
|
using Ease.CoreV35.DataAccess;
|
|||
|
using System.Collections.Generic;
|
|||
|
using Ease.CoreV35.DataAccess.SQL;
|
|||
|
|
|||
|
namespace Payroll.Service
|
|||
|
{
|
|||
|
#region ADParameterEmployeeDA
|
|||
|
|
|||
|
internal class ADParameterEmployeeDA
|
|||
|
{
|
|||
|
#region Constructor
|
|||
|
|
|||
|
private ADParameterEmployeeDA() { }
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Insert function
|
|||
|
|
|||
|
internal static void Insert(TransactionContext tc, ADParameterEmployee item)
|
|||
|
{
|
|||
|
//, ModifiedBy, ModifiedDate
|
|||
|
//,%n,%d
|
|||
|
//, item.CreatedBy.Integer, DataReader.GetNullValue(item.CreatedDate)
|
|||
|
tc.ExecuteNonQuery("INSERT INTO ADParameterEmployee(ADPARAMETEREMPID, ADParameterID, AllowDeductID, Periodicity, EmployeeID, FROMDATE, TillDate, MonthlyAmount, TotalAmount, ARREARINFO, ADEMPTYPE, ValueType, DISBURSEDAMOUNT, ENTRYDATE,TracNo, CreatedBy,CreatedDate)" +
|
|||
|
" VALUES(%n, %n, %n, %n, %n, %d, %d, %n, %n, %n, %n, %n, %n, %d,%s,%n,%d)", item.ID.Integer, item.ADParameterID.Integer, item.AllowDeductID.Integer, item.Periodicity, item.EmployeeID.Integer, item.FormDate, DataReader.GetNullValue(item.TillDate), item.MonthlyAmount, item.TotalAmount, item.Arreartype, item.ADEmpType, item.ValueType, item.DisburseAmount, DateTime.Now, DataReader.GetNullValue(item.TracNo), item.CreatedBy.Integer, item.CreatedDate);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Update function
|
|||
|
|
|||
|
internal static void Update(TransactionContext tc, ADParameterEmployee item)
|
|||
|
{
|
|||
|
tc.ExecuteNonQuery("UPDATE ADParameterEmployee SET aDParameterID=%n, allowDeductID=%n, periodicity=%n, employeeID=%n, FROMDATE=%d, tillDate=%d, monthlyAmount=%n, totalAmount=%n, ARREARINFO=%n, ModifiedBy=%n, ModifiedDate=%d, ADEMPTYPE=%n, ValueType=%n, DISBURSEDAMOUNT=%n,TracNo=%s" +
|
|||
|
" WHERE ADPARAMETEREMPID=%n", item.ADParameterID.Integer, item.AllowDeductID.Integer, item.Periodicity, item.EmployeeID.Integer, item.FormDate, DataReader.GetNullValue(item.TillDate), item.MonthlyAmount, item.TotalAmount, item.Arreartype, item.ModifiedBy.Integer, item.ModifiedDate, item.ADEmpType, item.ValueType, item.DisburseAmount, item.TracNo, item.ID.Integer);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Get Function
|
|||
|
|
|||
|
internal static IDataReader GetByEmployee(TransactionContext tc, ID nEmpID, EnumAllowOrDeduct adType, EnumADEmpType adEmpType, DateTime nextPayProcessDate, ID PayrolltypeID)
|
|||
|
{
|
|||
|
|
|||
|
return tc.ExecuteReader("SELECT * FROM ADParameterEmployee Where EmployeeID = %n AND ADEMPTYPE = %n " +
|
|||
|
" AND ADPARAMETERID IN (SELECT ADPARAMETERID FROM ADParameterBasic WHERE PayrollTypeID=%n AND AllowORDeduct = %n AND IsCurrentlyActive <> 0)"
|
|||
|
+ " AND ( (TillDate >= %d OR TillDate IS Null) AND "
|
|||
|
+ " (FromDate <= %d) OR ArrearInfo =%n )", nEmpID.Integer, adEmpType, PayrolltypeID.Integer, adType,
|
|||
|
GlobalFunctions.FirstDateOfMonth( nextPayProcessDate), nextPayProcessDate, EnumArrearType.ToCalculate);
|
|||
|
}
|
|||
|
|
|||
|
internal static IDataReader GetByEmployee(TransactionContext tc, ID nEmpID, ID nAllowDeductID, ID PayrolltypeID)
|
|||
|
{
|
|||
|
return tc.ExecuteReader("Select AD.* from ADPARAMETEREMPLOYEE AD, ADParameterBasic AB WHERE AB.PayrollTypeID=%n AND AB.ADParameterID=AD.ADParameterID AND AD.EMPLOYEEID=%n AND AD.ALLOWDEDUCTID=%n", PayrolltypeID.Integer, nEmpID.Integer, nAllowDeductID.Integer);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
internal static IDataReader Get(TransactionContext tc, DateTime fromDate, DateTime toDate, ID PayrolltypeID)
|
|||
|
{
|
|||
|
return tc.ExecuteReader("SELECT ADE.* FROM ADParameterBasic ADB, ADParameterEmployee ADE "
|
|||
|
+ " WHERE ADB.PayrollTypeID=%n AND ADB.ADParameterID=ADE.ADParameterID AND ADE.ADEMPType=%n AND ADB.IsCurrentlyActive <> 0 "
|
|||
|
+ " AND ( (ADE.TillDate >= %d OR ADE.TillDate IS Null) AND "
|
|||
|
+ " (ADE.FromDate <= %d) OR ADE.ArrearInfo =%n )", PayrolltypeID.Integer,
|
|||
|
EnumADEmpType.AppliedToIndividual, fromDate, toDate, EnumArrearType.ToCalculate);
|
|||
|
}
|
|||
|
|
|||
|
internal static IDataReader Get(TransactionContext tc, ID AllowDeductID, DateTime fromDate, DateTime toDate, ID PayrolltypeID)
|
|||
|
{
|
|||
|
string sql =
|
|||
|
SQLParser.MakeSQL(
|
|||
|
@"Select * from ADPARAMETEREMPLOYEE where FROMDATE between %d and %d
|
|||
|
AND ADPARAMETERID IN(Select ADPARAMETERID from ADPARAMETERBASIC where PAYROLLTYPEID=%n and ALLOWDEDUCTID=%n)",
|
|||
|
fromDate, GlobalFunctions.LastDateOfMonth(toDate),
|
|||
|
PayrolltypeID.Integer, AllowDeductID.Integer);
|
|||
|
return tc.ExecuteReader(@"Select * from ADPARAMETEREMPLOYEE where FROMDATE between %d and %d
|
|||
|
AND ADPARAMETERID IN(Select ADPARAMETERID from ADPARAMETERBASIC where PAYROLLTYPEID=%n and ALLOWDEDUCTID=%n)", fromDate, GlobalFunctions.LastDateOfMonth(toDate), PayrolltypeID.Integer, AllowDeductID.Integer);
|
|||
|
}
|
|||
|
|
|||
|
internal static IDataReader GetForApproval(TransactionContext tc, ID AllowDeductID, DateTime fromDate, DateTime toDate, ID PayrolltypeID)
|
|||
|
{
|
|||
|
string sql = SQLParser.MakeSQL(@"Select * from ADPARAMETEREMPLOYEE where FROMDATE between %d and %d AND ADPARAMETERID IN(Select ADPARAMETERID from ADPARAMETERBASIC where ALLOWDEDUCTID in
|
|||
|
(Select ALLOWDEDUCTID from ADPARAMETERBASIC where PAYROLLTYPEID=%n and ALLOWDEDUCTID in(select ALLOWDEDUCTID from ALLOWANCEDEDUCTION where ALLOWORDEDUCT=%n))) ORDER BY Modifieddate", fromDate, GlobalFunctions.LastDateOfMonth(toDate), PayrolltypeID.Integer, AllowDeductID.Integer);
|
|||
|
|
|||
|
return tc.ExecuteReader(sql);
|
|||
|
}
|
|||
|
|
|||
|
internal static IDataReader Get(TransactionContext tc, ID nEmpID,ID AllowDeductID,DateTime fromDate, DateTime toDate)
|
|||
|
{
|
|||
|
return tc.ExecuteReader(@"Select * from ADPARAMETEREMPLOYEE where EMPLOYEEID=%n AND FROMDATE between %d and %d AND ALLOWDEDUCTID=%n",nEmpID.Integer,fromDate,GlobalFunctions.LastDateOfMonth(toDate),AllowDeductID.Integer );
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
internal static IDataReader GetbyParameter(TransactionContext tc, ID nADPAramID, EnumADEmpType type)
|
|||
|
{
|
|||
|
return tc.ExecuteReader("SELECT * FROM ADParameterEmployee WHERE ADPARAMETERID=%n AND ADEMPTYPE=%n", nADPAramID.Integer,type);
|
|||
|
}
|
|||
|
|
|||
|
//internal static IDataReader GetByEmployee(TransactionContext tc, ID nEmpID, EnumAllowOrDeduct adType, string sTypes)
|
|||
|
//{
|
|||
|
// return tc.ExecuteReader("SELECT * FROM ADParameterEmployee Where EmployeeID = %n AND ADEMPTYPE IN (%q) " +
|
|||
|
// " AND ADPARAMETERID IN (SELECT ADPARAMETERID FROM ADParameterBasic WHERE AllowORDeduct = %n AND AND ADB.IsCurrentlyActive <> 0)"
|
|||
|
// + " AND ( (TillDate >= %d OR TillDate IS Null) AND (FromDate <= %d) OR ArrearInfo =%b )",
|
|||
|
// nEmpID.Integer, sTypes, adType);
|
|||
|
//}
|
|||
|
|
|||
|
internal static IDataReader Get(TransactionContext tc,EnumStatus status)
|
|||
|
{
|
|||
|
if(EnumStatus.Active==status || EnumStatus.Inactive==status)
|
|||
|
{
|
|||
|
//return tc.ExecuteReader("SELECT * FROM ADParameterEmployee where Status=%n Order by SequenceNo",status);
|
|||
|
return tc.ExecuteReader("SELECT * FROM ADParameterEmployee");
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
return tc.ExecuteReader("SELECT * FROM ADParameterEmployee");
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
internal static IDataReader Get(TransactionContext tc, ID nID)
|
|||
|
{
|
|||
|
return tc.ExecuteReader("SELECT * FROM ADParameterEmployee WHERE ADPARAMETEREMPID=%n", nID.Integer);
|
|||
|
}
|
|||
|
|
|||
|
internal static IDataReader GetbyParameter(TransactionContext tc, ID nID, DateTime nextPayProcessDate)
|
|||
|
{
|
|||
|
return tc.ExecuteReader("SELECT * FROM ADParameterEmployee WHERE ADPARAMETERID=%n AND ((TillDate >= %d OR TillDate IS NULL) AND (FromDate <= %d) OR ArrearInfo=%n)", nID.Integer,
|
|||
|
GlobalFunctions.FirstDateOfMonth(nextPayProcessDate),
|
|||
|
nextPayProcessDate, EnumArrearType.ToCalculate);
|
|||
|
}
|
|||
|
|
|||
|
internal static IDataReader GetByAllow(TransactionContext tc, ID nID)
|
|||
|
{
|
|||
|
return tc.ExecuteReader("SELECT * FROM ADParameterEmployee WHERE AllowDeductID=%n", nID.Integer);
|
|||
|
}
|
|||
|
|
|||
|
internal static IDataReader GetByCreatedBy(TransactionContext tc, ID nID, DateTime nextPayProcessDate)
|
|||
|
{
|
|||
|
return tc.ExecuteReader("SELECT * FROM ADParameterEmployee WHERE CreatedBy=%n AND FromDate=%d and TillDate=%d", nID.Integer, GlobalFunctions.FirstDateOfMonth(nextPayProcessDate), GlobalFunctions.LastDateOfMonth(nextPayProcessDate));
|
|||
|
}
|
|||
|
|
|||
|
internal static IDataReader GetByAllowForApproval(TransactionContext tc, ID nID, ID PayrolltypeID)
|
|||
|
{
|
|||
|
return tc.ExecuteReader(@"Select * from ADPARAMETEREMPLOYEE where ADPARAMETERID IN(Select ADPARAMETERID from ADPARAMETERBASIC where ALLOWDEDUCTID in
|
|||
|
(Select ALLOWDEDUCTID from ADPARAMETERBASIC where PAYROLLTYPEID=%n and ALLOWDEDUCTID in(select ALLOWDEDUCTID from ALLOWANCEDEDUCTION where ALLOWORDEDUCT=%n))) ORDER BY Modifieddate", PayrolltypeID.Integer, nID.Integer);
|
|||
|
}
|
|||
|
|
|||
|
internal static IDataReader Get(TransactionContext tc, ID nEmpID, ID nAllowDeductID, ID nADParamID)
|
|||
|
{
|
|||
|
return tc.ExecuteReader("SELECT * FROM ADParameterEmployee WHERE EMPLOYEEID=%n AND ADPARAMETERID = %n AND ALLOWDEDUCTID =%n ", nEmpID.Integer, nADParamID.Integer, nAllowDeductID.Integer);
|
|||
|
}
|
|||
|
|
|||
|
internal static IDataReader Get(TransactionContext tc, ID nEmpID, ID nAllowDeductID, ID nADParamID,EnumArrearType nArrearType)
|
|||
|
{
|
|||
|
return tc.ExecuteReader("SELECT * FROM ADParameterEmployee WHERE EMPLOYEEID=%n AND ADPARAMETERID = %n AND ALLOWDEDUCTID =%n AND ARREARINFO=%n", nEmpID.Integer, nADParamID.Integer, nAllowDeductID.Integer,(int)nArrearType);
|
|||
|
}
|
|||
|
|
|||
|
internal static DataSet GetByEmployee(TransactionContext tc, ID payrollTypeID, EnumAllowOrDeduct allowOrDeduct, ID empID, EnumADEmpType adEmpType)
|
|||
|
{
|
|||
|
string sql = SQLParser.MakeSQL(@"Select ADPARAMETEREMPLOYEE.*, ALLOWANCEDEDUCTION.NAME From ADPARAMETEREMPLOYEE
|
|||
|
Left Join ALLOWANCEDEDUCTION On ALLOWANCEDEDUCTION.ALLOWDEDUCTID = ADPARAMETEREMPLOYEE.ALLOWDEDUCTID
|
|||
|
Where ADPARAMETEREMPLOYEE.ADPARAMETERID IN (SELECT ADPARAMETERID FROM ADParameterBasic WHERE PayrollTypeID=%n AND AllowORDeduct = %n AND IsCurrentlyActive <> 0)
|
|||
|
And ADPARAMETEREMPLOYEE.EMPLOYEEID = %n AND ADPARAMETEREMPLOYEE.ADEMPTYPE = %n
|
|||
|
Order By ADPARAMETEREMPID Desc", payrollTypeID.Integer, (int)allowOrDeduct, empID.Integer, (int)adEmpType);
|
|||
|
return tc.ExecuteDataSet(sql);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Delete function
|
|||
|
|
|||
|
internal static void Delete(TransactionContext tc, ID nID)
|
|||
|
{
|
|||
|
tc.ExecuteNonQuery("DELETE FROM ADParameterEmployee WHERE ADPARAMETEREMPID=%n", nID.Integer);
|
|||
|
}
|
|||
|
|
|||
|
internal static void DeletebyAdParamid(TransactionContext tc, ID nID)
|
|||
|
{
|
|||
|
tc.ExecuteNonQuery("DELETE FROM ADParameterEmployee WHERE ADParameterID=%n", nID.Integer);
|
|||
|
}
|
|||
|
|
|||
|
internal static void DeleteByAllo(TransactionContext tc, ID nAllowDeductID)
|
|||
|
{
|
|||
|
tc.ExecuteNonQuery("DELETE FROM ADParameterEmployee WHERE AllowDeductID=%n", nAllowDeductID.Integer);
|
|||
|
}
|
|||
|
|
|||
|
internal static void DeleteByEmpID(TransactionContext tc, ID nEmpID,ID nADParameterID)
|
|||
|
{
|
|||
|
tc.ExecuteNonQuery("DELETE FROM ADParameterEmployee WHERE EmployeeID=%n AND ADParameterID=%n", nEmpID.Integer,nADParameterID.Integer);
|
|||
|
}
|
|||
|
|
|||
|
internal static void DeleteByAllowDeductMonth(TransactionContext tc, ID nEmpID, ID nAllowDeductID, DateTime dAllowDeductMonht)
|
|||
|
{
|
|||
|
tc.ExecuteNonQuery("Delete from ADPARAMETEREMPLOYEE where FromDate between %d and %d and EmployeeID=%n and AllowDeductID=%n", GlobalFunctions.FirstDateOfMonth(dAllowDeductMonht),GlobalFunctions.LastDateOfMonth(dAllowDeductMonht),nEmpID.Integer,nAllowDeductID.Integer);
|
|||
|
}
|
|||
|
|
|||
|
internal static void DeleteByEmpIDAndSalaryMonth(TransactionContext tc, ID nCreatedBy, DateTime nextPayProcessDate)
|
|||
|
{
|
|||
|
tc.ExecuteNonQuery("Delete from ADPARAMETEREMPLOYEE where CreatedBy= %n AND FromDate= %d AND TillDate= %d", nCreatedBy.Integer, GlobalFunctions.FirstDateOfMonth(nextPayProcessDate), GlobalFunctions.LastDateOfMonth(nextPayProcessDate));
|
|||
|
}
|
|||
|
|
|||
|
public static void Delete(TransactionContext tc, ADParameterEmployee adParamEmp)
|
|||
|
{
|
|||
|
tc.ExecuteNonQuery("DELETE FROM ADParameterEmployee WHERE EMPLOYEEID=%n AND AllowDeductID=%n AND Periodicity=%n", adParamEmp.EmployeeID.Integer, adParamEmp.AllowDeductID.Integer, adParamEmp.Periodicity);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
|
|||
|
#region Other function
|
|||
|
public static bool IsExist(TransactionContext tc, int empId, int allowDeduct, int adParamid, DateTime? tillDate, EnumPeriodicity status)
|
|||
|
{
|
|||
|
bool Exist = false;
|
|||
|
Object obj;
|
|||
|
if(tillDate == DateTime.MinValue)
|
|||
|
obj = tc.ExecuteScalar("Select Count(*) FROM ADParameterEmployee WHERE EMPLOYEEID=%n AND AllowDeductID=%n AND ADPARAMETERID=%n AND TillDate is Null AND Periodicity=%n", empId, allowDeduct, adParamid, EnumPeriodicity.Monthly);
|
|||
|
else
|
|||
|
obj = tc.ExecuteScalar("Select Count(*) FROM ADParameterEmployee WHERE EMPLOYEEID=%n AND AllowDeductID=%n AND ADPARAMETERID=%n AND TillDate =%d AND Periodicity=%n", empId, allowDeduct, adParamid, tillDate, EnumPeriodicity.Monthly);
|
|||
|
Exist = Convert.ToInt32(obj) > 0 ? true : false;
|
|||
|
return Exist;
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|