337 lines
17 KiB
C#
337 lines
17 KiB
C#
using System;
|
|
using System.Data;
|
|
using Ease.Core.DataAccess;
|
|
using HRM.BO;
|
|
|
|
namespace HRM.DA
|
|
{
|
|
internal class AllowanceDeductionDA
|
|
{
|
|
#region Constructor
|
|
|
|
private AllowanceDeductionDA()
|
|
{
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Insert function
|
|
|
|
internal static void Insert(TransactionContext tc, AllowanceDeduction item)
|
|
{
|
|
tc.ExecuteNonQuery(
|
|
"INSERT INTO AllowanceDeduction(ALLOWDEDUCTID, code, name, allowOrDeduct, CreatedBy, CreationDate, SequenceNo, Status, payrolltypeid, nameinbangla)" +
|
|
" VALUES(%n, %s, %s, %n, %n, %d, %n, %n, %n, %u)", item.ID, item.Code, item.Name, item.AllowOrDeductType,
|
|
item.CreatedBy, item.CreatedDate, item.Sequence, item.Status , item.payrolltypeid, item.NameInBangla);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Update function
|
|
|
|
internal static void Update(TransactionContext tc, AllowanceDeduction item)
|
|
{
|
|
tc.ExecuteNonQuery(
|
|
"UPDATE AllowanceDeduction SET code=%s, name=%s, allowOrDeduct=%n, ModifiedBy=%n, ModifiedDate=%d, SequenceNo=%n, Status=%n" +
|
|
" , payrolltypeid=%n, nameinbangla=%u WHERE ALLOWDEDUCTID=%n", item.Code, item.Name, item.AllowOrDeductType, item.ModifiedBy,
|
|
item.ModifiedDate, item.Sequence, item.Status, item.payrolltypeid, item.NameInBangla, item.ID);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Get Function
|
|
|
|
internal static IDataReader Get(TransactionContext tc, EnumStatus status)
|
|
{
|
|
if (EnumStatus.Active == status || EnumStatus.Inactive == status)
|
|
{
|
|
return tc.ExecuteReader(
|
|
"SELECT * FROM AllowanceDeduction Where Status=%n AND ALLOWDEDUCTID>0 order by SequenceNo",
|
|
status);
|
|
}
|
|
else
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM AllowanceDeduction Where ALLOWDEDUCTID>0 order by SequenceNo");
|
|
}
|
|
}
|
|
|
|
internal static IDataReader GetAllowance(TransactionContext tc, EnumStatus status, int payrolltypeid)
|
|
{
|
|
if (EnumStatus.Regardless != status)
|
|
{
|
|
return tc.ExecuteReader(
|
|
"SELECT * FROM AllowanceDeduction Where ALLOWORDEDUCT=%n and payrolltypeid =%n AND Status=%n Order by Name",
|
|
EnumAllowOrDeduct.Allowance, payrolltypeid, status);
|
|
}
|
|
else
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM AllowanceDeduction Where ALLOWORDEDUCT=%n and payrolltypeid =%n Order by Name",
|
|
EnumAllowOrDeduct.Allowance, payrolltypeid);
|
|
}
|
|
//return tc.ExecuteReader("SELECT * FROM AllowanceDeduction Where ALLOWORDEDUCT=%n AND AllowDeductID>0 AND Status=%n Order by SequenceNo", allowanceType, status);
|
|
}
|
|
|
|
internal static IDataReader Get(TransactionContext tc, EnumStatus status, int payrolltypeid)
|
|
{
|
|
if (EnumStatus.Regardless != status)
|
|
{
|
|
return tc.ExecuteReader(
|
|
"SELECT * FROM AllowanceDeduction Where payrolltypeid =%n AND Status=%n Order by Name",
|
|
payrolltypeid, status);
|
|
}
|
|
else
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM AllowanceDeduction Where payrolltypeid =%n Order by Name",
|
|
payrolltypeid);
|
|
}
|
|
//return tc.ExecuteReader("SELECT * FROM AllowanceDeduction Where ALLOWORDEDUCT=%n AND AllowDeductID>0 AND Status=%n Order by SequenceNo", allowanceType, status);
|
|
}
|
|
internal static IDataReader GetADparamAllowance(TransactionContext tc, EnumStatus status, int payrollTypeID)
|
|
{
|
|
if (EnumStatus.Regardless != status)
|
|
{
|
|
return tc.ExecuteReader(
|
|
"SELECT * FROM AllowanceDeduction Where Allowdeductid in ( SELECT DISTINCT allowdeductid FROM ADPARAMETERBASIC Where ALLOWORDEDUCT=%n AND Status=%n AND PAYROLLTYPEID=%n) Order by Name ",
|
|
EnumAllowOrDeduct.Allowance, status, payrollTypeID);
|
|
}
|
|
else
|
|
{
|
|
return tc.ExecuteReader(
|
|
"SELECT * FROM AllowanceDeduction Where Allowdeductid in ( SELECT DISTINCT allowdeductid FROM ADPARAMETERBASIC Where ALLOWORDEDUCT=%n AND PAYROLLTYPEID=%n) Order by Name",
|
|
EnumAllowOrDeduct.Allowance, payrollTypeID);
|
|
}
|
|
//return tc.ExecuteReader("SELECT * FROM AllowanceDeduction Where ALLOWORDEDUCT=%n AND AllowDeductID>0 AND Status=%n Order by SequenceNo", allowanceType, status);
|
|
}
|
|
|
|
internal static IDataReader GetAllowance(TransactionContext tc, EnumPeriodicity periodicity,
|
|
EnumAllowOrDeduct allowOrdeduct)
|
|
{
|
|
string SSQL = string.Empty;
|
|
if (EnumAllowOrDeduct.Allowance == allowOrdeduct)
|
|
{
|
|
SSQL = SQLParser.MakeSQL(
|
|
"Select * from AllowanceDeduction where AllowDeductID IN (Select AllowDeductID from ADParameterBasic where Periodicity=%n) AND AllowORDeduct=%n ",
|
|
periodicity, allowOrdeduct);
|
|
}
|
|
else
|
|
{
|
|
SSQL = SQLParser.MakeSQL(
|
|
"Select * from AllowanceDeduction where AllowDeductID IN (Select AllowDeductID from ADParameterBasic where Periodicity=%n) AND AllowORDeduct=%n ",
|
|
periodicity, allowOrdeduct);
|
|
}
|
|
|
|
return tc.ExecuteReader(SSQL);
|
|
}
|
|
|
|
internal static IDataReader GetAllowance(TransactionContext tc, EnumPeriodicity periodicity,
|
|
EnumEntitleType enumEntitleType, EnumAllowOrDeduct allowOrdeduct)
|
|
{
|
|
string SSQL = string.Empty;
|
|
if (EnumAllowOrDeduct.Allowance == allowOrdeduct)
|
|
{
|
|
SSQL = SQLParser.MakeSQL(
|
|
"Select * from AllowanceDeduction where AllowDeductID IN (Select AllowDeductID from ADParameterBasic where Periodicity=%n and EntitleType=%n) AND AllowORDeduct=%n ",
|
|
periodicity, enumEntitleType, allowOrdeduct);
|
|
}
|
|
else
|
|
{
|
|
SSQL = SQLParser.MakeSQL(
|
|
"Select * from AllowanceDeduction where AllowDeductID IN (Select AllowDeductID from ADParameterBasic where Periodicity=%n and EntitleType=%n) AND AllowORDeduct=%n ",
|
|
periodicity, enumEntitleType, allowOrdeduct);
|
|
}
|
|
|
|
return tc.ExecuteReader(SSQL);
|
|
}
|
|
|
|
internal static IDataReader GetDeduction(TransactionContext tc, EnumStatus status, int payrolltypeid)
|
|
{
|
|
if (EnumStatus.Regardless != status)
|
|
{
|
|
string sSQL =
|
|
SQLParser.MakeSQL(
|
|
"SELECT * FROM AllowanceDeduction Where ALLOWORDEDUCT=%n AND ALLOWDEDUCTID>0 AND Status=%n and Payrolltypeid=%n Order by Name",
|
|
EnumAllowOrDeduct.Deduction, status, payrolltypeid);
|
|
return tc.ExecuteReader(sSQL);
|
|
}
|
|
else
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM AllowanceDeduction Where ALLOWORDEDUCT=%n and Payrolltypeid=%n Order by Name",
|
|
EnumAllowOrDeduct.Deduction, payrolltypeid);
|
|
}
|
|
//return tc.ExecuteReader("SELECT * FROM AllowanceDeduction Where ALLOWORDEDUCT=%n AND AllowDeductID>0 AND Status=%n Order by SequenceNo", allowanceType, status);
|
|
}
|
|
|
|
internal static IDataReader Get(TransactionContext tc, int payrolltypeid, EnumStatus status, EnumAllowOrDeduct nType,
|
|
EnumPeriodicity nPeriodcity)
|
|
{
|
|
return tc.ExecuteReader("Select DISTINCT ALLWD.* from ALLOWANCEDEDUCTION ALLWD,ADParameterBasic ADPB"
|
|
+ " Where ALLWD.ALLOWDEDUCTID=ADPB.ALLOWDEDUCTID"
|
|
+ " AND ALLWD.Status=%n"
|
|
+ " AND ALLWD.ALLOWORDEDUCT=%n"
|
|
+ " AND ADPB.PERIODICITY=%n AND ALLWD.PayrollTypeID=%n",
|
|
status, nType, nPeriodcity, payrolltypeid);
|
|
}
|
|
|
|
internal static IDataReader GetMonthyIndividualAndOneOff(TransactionContext tc, int payrolltypeid, EnumStatus status, EnumAllowOrDeduct nType)
|
|
{
|
|
return tc.ExecuteReader("Select DISTINCT ALLWD.* from ALLOWANCEDEDUCTION ALLWD,ADParameterBasic ADPB"
|
|
+ " Where ALLWD.ALLOWDEDUCTID=ADPB.ALLOWDEDUCTID"
|
|
+ " AND ALLWD.Status=%n"
|
|
+ " AND ALLWD.ALLOWORDEDUCT=%n "
|
|
+ " AND (( ADPB.PERIODICITY =%n ) OR ( ADPB.PERIODICITY =%n " +
|
|
" and ADPB.EntitleType=%n )) AND ALLWD.PayrollTypeID=%n ", status, nType,
|
|
EnumPeriodicity.OneOff, EnumPeriodicity.Monthly, EnumEntitleType.Individual, payrolltypeid);
|
|
}
|
|
|
|
internal static IDataReader Get(TransactionContext tc, EnumStatus status, EnumAllowOrDeduct nType,
|
|
int payrollTypeID)
|
|
{
|
|
if (status != EnumStatus.Regardless)
|
|
{
|
|
return tc.ExecuteReader("Select DISTINCT ALLWD.* from ALLOWANCEDEDUCTION ALLWD,ADParameterBasic ADPB"
|
|
+ " Where ALLWD.ALLOWDEDUCTID=ADPB.ALLOWDEDUCTID"
|
|
+ " AND ALLWD.Status=%n"
|
|
+ " AND ADPB.ADPARAMETERID IN (SELECT ADPARAMETERID FROM ADPARAMETERGRADE WHERE GRADEID IN(SELECT DISTINCT gradeid FROM EMPLOYEE WHERE payrolltypeid=%n))",
|
|
status, nType, payrollTypeID);
|
|
}
|
|
else
|
|
{
|
|
return tc.ExecuteReader("Select DISTINCT ALLWD.* from ALLOWANCEDEDUCTION ALLWD,ADParameterBasic ADPB"
|
|
+ " Where ALLWD.ALLOWDEDUCTID=ADPB.ALLOWDEDUCTID"
|
|
+ " AND ALLWD.ALLOWORDEDUCT=%n"
|
|
+ " AND ADPB.ADPARAMETERID IN (SELECT ADPARAMETERID FROM ADPARAMETERGRADE WHERE GRADEID IN(SELECT DISTINCT gradeid FROM EMPLOYEE WHERE payrolltypeid=%n))",
|
|
nType, payrollTypeID);
|
|
|
|
}
|
|
}
|
|
|
|
internal static IDataReader GetException(TransactionContext tc, EnumStatus status, EnumAllowOrDeduct nType,
|
|
int payrollTypeID)
|
|
{
|
|
return tc.ExecuteReader("Select DISTINCT ALLWD.* from ALLOWANCEDEDUCTION ALLWD,ADParameterBasic ADPB"
|
|
+ " Where ALLWD.ALLOWDEDUCTID=ADPB.ALLOWDEDUCTID"
|
|
+ " AND ALLWD.Status=%n"
|
|
+ " AND ALLWD.ALLOWORDEDUCT=%n"
|
|
+ " AND (ADPB.PERIODICITY=%n"
|
|
+ " OR (ADPB.PERIODICITY=%n AND EntitleType=1))"
|
|
+ " AND ADPB.ADPARAMETERID IN (SELECT ADPARAMETERID FROM ADPARAMETERGRADE WHERE GRADEID IN(SELECT DISTINCT gradeid FROM EMPLOYEE WHERE payrolltypeid=%n))",
|
|
status, nType, (int)EnumPeriodicity.OneOff, (int)EnumPeriodicity.Monthly, payrollTypeID);
|
|
}
|
|
|
|
//internal static IDataReader GetAllDeduType(TransactionContext tc, EnumAllowOrDeduct allowanceType, EnumStatus status)
|
|
//{
|
|
// if (EnumStatus.Active == status)
|
|
// {
|
|
// return tc.ExecuteReader("SELECT * FROM AllowanceDeduction Where ALLOWORDEDUCT=%n AND AllowDeductID>0 AND Status=%n Order by SequenceNo", allowanceType, status);
|
|
// }
|
|
// else
|
|
// {
|
|
// return tc.ExecuteReader("SELECT * FROM AllowanceDeduction Where ALLOWORDEDUCT=%n Order by SequenceNo", allowanceType);
|
|
// }
|
|
// //return tc.ExecuteReader("SELECT * FROM AllowanceDeduction Where ALLOWORDEDUCT=%n AND AllowDeductID>0 AND Status=%n Order by SequenceNo", allowanceType, status);
|
|
//}
|
|
|
|
internal static IDataReader GetAllAllowance(TransactionContext tc, int payrollTypeID, EnumAllowOrDeduct allowOrDeduct, EnumStatus status,
|
|
string code, string name)
|
|
{
|
|
string sqlClause = string.Empty;
|
|
sqlClause = SQLParser.TagSQL(sqlClause) + SQLParser.MakeSQL("PayrollTypeID = %n", payrollTypeID);
|
|
sqlClause = SQLParser.TagSQL(sqlClause) + SQLParser.MakeSQL("ALLOWORDEDUCT = %n", allowOrDeduct);
|
|
if (EnumStatus.Active == status || EnumStatus.Inactive == status)
|
|
{
|
|
sqlClause = SQLParser.TagSQL(sqlClause) + SQLParser.MakeSQL("status = %n", status);
|
|
// return tc.ExecuteReader("SELECT * FROM AllowanceDeduction Where Status=%n AND ALLOWDEDUCTID>0 order by SequenceNo", status);
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(code))
|
|
{
|
|
sqlClause = SQLParser.TagSQL(sqlClause) + SQLParser.MakeSQL("Code = %s", code);
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(name))
|
|
{
|
|
sqlClause = SQLParser.TagSQL(sqlClause) + SQLParser.MakeSQL("Name LIKE %s", ("%" + name + "%"));
|
|
}
|
|
|
|
return tc.ExecuteReader("SELECT * FROM AllowanceDeduction %q AND ALLOWDEDUCTID >0 order by SequenceNo",
|
|
sqlClause);
|
|
}
|
|
|
|
internal static IDataReader GetByGradeID(TransactionContext tc, EnumStatus status, int nGradeID,
|
|
EnumAllowOrDeduct type)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM ALLOWANCEDEDUCTION WHERE ALLOWDEDUCTID IN " +
|
|
"(SELECT ALLOWDEDUCTID FROM ADPARAMETERBASIC WHERE ENTITLETYPE=%n AND ADParameterID IN " +
|
|
"(SELECT Distinct ADPARAMETERID FROM ADPARAMETERGRADE WHERE GRADEID =%n))AND ALLOWORDEDUCT = %n AND Status=%n",
|
|
EnumEntitleType.Individual, nGradeID, type, status);
|
|
}
|
|
|
|
internal static IDataReader Get(TransactionContext tc, int nID)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM AllowanceDeduction WHERE ALLOWDEDUCTID=%n", nID);
|
|
}
|
|
|
|
internal static DataSet GetEmpAllowDeduc(TransactionContext tc, DateTime dEffectDate, int AllowDeducID,
|
|
int payrollTypeID)
|
|
{
|
|
DataSet oEmpHistories = new DataSet();
|
|
try
|
|
{
|
|
oEmpHistories = tc.ExecuteDataSet(
|
|
"Select ADPEmp.employeeid,ADPEmp.adparameterempid, ADPEmp.modifiedBy,ADPEmp.modifiedDate,Emp.EMPLOYEENO,Emp.NAME,Deg.NAME Designation, gr.DESCRIPTION Grade, ADPEmp.MONTHLYAMOUNT Amount"
|
|
+ " from ADPARAMETEREMPLOYEE ADPEmp,EMPLOYEE Emp,GRADES gr,Designation Deg"
|
|
+ " where Emp.EMPLOYEEID=ADPemp.EMPLOYEEID"
|
|
+ " AND Emp.DesignationID=Deg.DesignationID"
|
|
+ " AND Emp.GradeID=gr.GradeID"
|
|
+ " AND ADPEmp.ALLOWDEDUCTID=%n"
|
|
+ " AND ADPEmp.FROMDATE between %d and %d AND Emp.PayrollTypeID=%n"
|
|
+ " order by Emp.EMPLOYEENO ", AllowDeducID,
|
|
PayrollGlobalFunctions.PayrollFirstDateOfMonth(dEffectDate),
|
|
PayrollGlobalFunctions.PayrollLastDateOfMonth(dEffectDate), payrollTypeID);
|
|
}
|
|
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return oEmpHistories;
|
|
}
|
|
|
|
internal static DataSet GetEmpAllowDeduc2(TransactionContext tc, DateTime dEffectDate, DateTime dEffectDate2,
|
|
int AllowDeducID, int payrollTypeID)
|
|
{
|
|
DataSet oEmpHistories = new DataSet();
|
|
try
|
|
{
|
|
string sql = SQLParser.MakeSQL("Select ADPEmp.employeeid,ADPEmp.adparameterempid, ADPEmp.modifiedBy,ADPEmp.modifiedDate,Emp.EMPLOYEENO,Emp.NAME,Deg.NAME Designation, gr.DESCRIPTION Grade, ADPEmp.MONTHLYAMOUNT Amount " +
|
|
" from ADPARAMETEREMPLOYEE ADPEmp,EMPLOYEE Emp,GRADES gr,Designation Deg "
|
|
+ " where Emp.EMPLOYEEID=ADPemp.EMPLOYEEID"
|
|
+ " AND Emp.DesignationID=Deg.DesignationID"
|
|
+ " AND Emp.GradeID=gr.GradeID"
|
|
+ " AND ADPEmp.ALLOWDEDUCTID=%n"
|
|
+ " AND ADPEmp.FROMDATE between %d and %d AND Emp.PayrollTypeID=%n"
|
|
+ " order by Emp.EMPLOYEENO ", AllowDeducID, PayrollGlobalFunctions.PayrollFirstDateOfMonth(dEffectDate), PayrollGlobalFunctions.PayrollLastDateOfMonth(dEffectDate2), payrollTypeID);
|
|
oEmpHistories = tc.ExecuteDataSet(sql);
|
|
}
|
|
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return oEmpHistories;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Delete function
|
|
|
|
internal static void Delete(TransactionContext tc, int nID)
|
|
{
|
|
tc.ExecuteNonQuery("DELETE FROM AllowanceDeduction WHERE ALLOWDEDUCTID=%n", nID);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
} |