EchoTex_Payroll/HRM.DA/DA/Bonus/BonusDA.cs

181 lines
7.7 KiB
C#
Raw Permalink Normal View History

2024-10-14 10:01:49 +06:00
using HRM.BO;
using Ease.Core.DataAccess;
using System;
using System.Data;
namespace HRM.DA
{
#region BonusDA
internal class BonusDA
{
#region Constructor
private BonusDA()
{
}
#endregion
#region Insert function
internal static void Insert(TransactionContext tc, Bonus item)
{
tc.ExecuteNonQuery(
"INSERT INTO Bonus(BonusID, code, name, CreatedBy, CreatedDate, SequenceNo, Status,PayrollTypeID, nameinbangla)" +
" VALUES(%n, %s, %s, %n, %d, %n, %n, %n, %u)", item.ID, item.Code, item.Name, item.CreatedBy,
item.CreatedDate, item.Sequence, item.Status, item.PayrollTypeID, item.NameInBangla);
}
#endregion
#region Update function
internal static void Update(TransactionContext tc, Bonus item)
{
tc.ExecuteNonQuery(
"UPDATE Bonus SET code=%s, name=%s, ModifiedBy=%n, ModifiedDate=%d, SequenceNo=%n, Status=%n, PayrollTypeID=%n, nameinbangla=%u" +
" WHERE BonusID=%n", item.Code, item.Name, item.ModifiedBy, item.ModifiedDate, item.Sequence,
item.Status, item.PayrollTypeID, item.NameInBangla, item.ID);
}
#endregion
#region Get Function
internal static IDataReader GetAllBonus(TransactionContext tc, int payrollTypeID, EnumStatus status,
string code, string name)
{
string sqlClause = string.Empty;
sqlClause = SQLParser.TagSQL(sqlClause) + SQLParser.MakeSQL("PayrollTypeID = %n", payrollTypeID);
if (EnumStatus.Active == status || EnumStatus.Inactive == status)
{
sqlClause = SQLParser.TagSQL(sqlClause) + SQLParser.MakeSQL("status = %n", 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 Bonus %q order by SequenceNo", sqlClause);
}
internal static IDataReader Get(TransactionContext tc, EnumStatus status, int payrollTypeID)
{
if (EnumStatus.Active == status || EnumStatus.Inactive == status)
{
return tc.ExecuteReader("SELECT * FROM Bonus where Status=%n AND PAYROLLTYPEID=%n Order By SequenceNo",
status, payrollTypeID);
}
else
{
return tc.ExecuteReader("SELECT * FROM Bonus WHERE PAYROLLTYPEID=%n Order By SequenceNo",
payrollTypeID);
}
}
internal static IDataReader GetParameterizedBonus(TransactionContext tc, EnumStatus status, int payrollTypeID)
{
if (EnumStatus.Regardless != status)
{
return tc.ExecuteReader(
"SELECT * FROM BONUS Where BONUSID in ( SELECT DISTINCT BONUSID FROM BONUSPARAMETER Where Status=%n AND PAYROLLTYPEID=%n) Order by Name ",
status, payrollTypeID);
}
else
{
return tc.ExecuteReader(
"SELECT * FROM BONUS Where BONUSID in ( SELECT DISTINCT BONUSID FROM BONUSPARAMETER Where PAYROLLTYPEID=%n) Order by Name",
payrollTypeID);
}
}
internal static IDataReader GetActiveProccessedBonus(TransactionContext tc, int payrollTypeID,
DateTime bonusMonth)
{
return tc.ExecuteReader(
"SELECT B.*, BP.Bonusmonth FROM BONUS B INNER JOIN BONUSPROCESS BP ON BP.BONUSID = B.BONUSID Where B.Status=%n AND BP.BONUSMONTH=%d AND BP.PAYROLLTYPEID=%n Order by Name",
EnumStatus.Active, bonusMonth, payrollTypeID);
}
internal static IDataReader Get(TransactionContext tc, int nID)
{
return tc.ExecuteReader("SELECT * FROM Bonus WHERE BonusID=%n", nID);
}
#endregion
#region Delete function
internal static void Delete(TransactionContext tc, int nID)
{
tc.ExecuteNonQuery("DELETE FROM Bonus WHERE BonusID=%n", nID);
}
#endregion
#region CC Wise Bonus Summary
internal static DataSet GetCCWiseBonusSummary(TransactionContext tc, DateTime bMonthDate, string bonus)
{
string sql = string.Empty;
DataSet temp = new DataSet();
temp = tc.ExecuteDataSet("SELECT sp.SalaryProcessID FROM salaryprocess sp WHERE sp.SalaryMonth = %d", bMonthDate.LastDateOfMonth());
if (temp.Tables[0].Rows.Count > 0)
{
sql = SQLParser.MakeSQL(@"SELECT cc.DESCRIPTION cc,%s Item, sum(BPD.ChangeBonusAmount) amount
FROM SALARYMONTHLY sm, salaryempcostcenter sc,crg cc, BonusProcessDetail bpd
WHERE sm.SALARYMONTHLYID=sc.SALARYMONTHLYID
AND sc.COSTCENTERID=cc.CRGID
AND bpd.EmployeeID = sm.EMPLOYEEID
AND bpd.BonusID = (Select Distinct BonusID from BONUS WHERE Name = %s)
AND sm.SalaryMonth=%d
AND BPD.DisburseDate between %d and %d
GROUP BY cc.DESCRIPTION", bonus, bonus, bMonthDate, bMonthDate.FirstDateOfMonth(), bMonthDate);
}
else
{
sql = SQLParser.MakeSQL(@"SELECT cc.DESCRIPTION cc,%s Item, sum(BPD.ChangeBonusAmount) amount
FROM BONUSPROCESS sm, Empcostcenter sc,crg cc, BonusProcessDetail bpd
WHERE sm.BONUSPROCESSID=bpd.BonusProcessID
AND sc.COSTCENTERID=cc.CRGID
AND sc.EMPLOYEEID = bpd.EMPLOYEEID AND sc.CurrentCC = 1
AND bpd.BonusID = (Select Distinct BonusID from BONUS WHERE Name = %s)
AND sm.bonusmonth BETWEEN %d AND %d
GROUP BY cc.DESCRIPTION
ORDER BY cc.DESCRIPTION", bonus, bonus, bMonthDate.FirstDateOfMonth(), bMonthDate.LastDateOfMonth());
}
return tc.ExecuteDataSet(sql);
}
#endregion
#region CC Wise Bonus Summary
internal static DataSet GetCCWiseBonus(TransactionContext tc, DateTime bMonthDate, string bonus)
{
string sql = string.Empty;
sql = SQLParser.MakeSQL(@"SELECT cc.DESCRIPTION cc,emp.EMPLOYEENO EmpNo, emp.NAME EmpName, emp.ACCOUNTNO, %s Item, BPD.ChangeBonusAmount amount
FROM SALARYMONTHLY sm,salaryempcostcenter sc,crg cc, EMPLOYEE emp, BonusProcessDetail bpd
WHERE sm.EMPLOYEEID=bpd.EmployeeID
AND emp.EMPLOYEEID = sm.EmployeeID
AND sm.SALARYMONTHLYID=sc.SALARYMONTHLYID
AND sc.COSTCENTERID=cc.CRGID
AND bpd.BonusID = (Select Distinct BonusID from BONUS WHERE Name = %s)
AND sm.SalaryMonth=%d
AND BPD.DisburseDate between %d and %d", bonus, bonus, bMonthDate, bMonthDate.FirstDateOfMonth(), bMonthDate);
return tc.ExecuteDataSet(sql);
}
#endregion
}
#endregion
}