HRM-10/HRM.DA/DA/LongServiceAward/LongServiceAwardDA.cs
Mohaimen Hasan 838b8d4480 first commit
2026-11-03 13:06:00 +06:00

162 lines
8.7 KiB
C#

using Ease.Core.DataAccess;
using HRM.BO;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HRM.DA
{
internal class LongServiceAwardDA
{
#region Constructor
public LongServiceAwardDA() { }
#endregion
#region Insert Master
internal static void Insert(Ease.Core.DataAccess.TransactionContext tc, LongServiceAwardMaster oLongServiceAwardMaster)
{
string ssql = SQLParser.MakeSQL("INSERT INTO LongServiceAwardMaster (LongServiceAwardID, AwardName, AwardDescription, AwardType, AwardStatus, AwardDate, AwardYear, CreatedBy, CreatedDate)" +
" VALUES(%n, %s, %s, %n, %n, %d,%d, %n, %d)", oLongServiceAwardMaster.ID,
DataReader.GetNullValue(oLongServiceAwardMaster.AwardName),
DataReader.GetNullValue(oLongServiceAwardMaster.AwardDescription),
(int)oLongServiceAwardMaster.AwardType,
(int)oLongServiceAwardMaster.AwardStatus,
DataReader.GetNullValue(oLongServiceAwardMaster.AwardDate),
DataReader.GetNullValue(oLongServiceAwardMaster.AwardYear),
DataReader.GetNullValue(oLongServiceAwardMaster.CreatedBy),
DataReader.GetNullValue(oLongServiceAwardMaster.CreatedDate));
tc.ExecuteNonQuery(ssql);
}
#endregion
#region Update Master
internal static void Update(Ease.Core.DataAccess.TransactionContext tc, LongServiceAwardMaster oLongServiceAwardMaster)
{
tc.ExecuteNonQuery("UPDATE LongServiceAwardMaster SET " +
"AwardName = %s, " +
"AwardDescription = %s, " +
"AwardType = %n, " +
"AwardStatus = %n, " +
"AwardDate = %d, " +
"AwardYear = %d, " +
"ModifiedBy = %n, " +
"ModifiedDate = %d " +
"WHERE LongServiceAwardID = %n",
DataReader.GetNullValue(oLongServiceAwardMaster.AwardName),
DataReader.GetNullValue(oLongServiceAwardMaster.AwardDescription),
(int)oLongServiceAwardMaster.AwardType,
(int)oLongServiceAwardMaster.AwardStatus,
DataReader.GetNullValue(oLongServiceAwardMaster.AwardDate),
DataReader.GetNullValue(oLongServiceAwardMaster.AwardYear),
DataReader.GetNullValue(oLongServiceAwardMaster.ModifiedBy),
DataReader.GetNullValue(oLongServiceAwardMaster.ModifiedDate),
oLongServiceAwardMaster.ID);
}
#endregion
#region Insert Child
internal static void Insert(Ease.Core.DataAccess.TransactionContext tc, LongServiceAwardChild oLongServiceAwardChild)
{
string sSql = SQLParser.MakeSQL("INSERT INTO LongServiceAwardChild (LongServiceAwardChildID, LongServiceAwardID, EmployeeID, Amount, Gift, IsLMMailDone, LineManagerID, LMComment, LMCommentDate, CreatedBy, CreatedDate)" +
" VALUES(%n, %n, %n, %n, %s, %n, %n, %s, %d, %n, %d)",
oLongServiceAwardChild.ID,
oLongServiceAwardChild.LongServiceAwardID,
oLongServiceAwardChild.EmployeeID,
oLongServiceAwardChild.Amount,
DataReader.GetNullValue(oLongServiceAwardChild.Gift),
DataReader.GetNullValue(oLongServiceAwardChild.IsLMMailDone ? 1 : 0),
oLongServiceAwardChild.LineManagerID,
DataReader.GetNullValue(oLongServiceAwardChild.LMComment),
DataReader.GetNullValue(oLongServiceAwardChild.LMCommentDate),
DataReader.GetNullValue(oLongServiceAwardChild.CreatedBy),
DataReader.GetNullValue(oLongServiceAwardChild.CreatedDate));
tc.ExecuteNonQuery(sSql);
}
#endregion
#region Update Child
internal static void Update(Ease.Core.DataAccess.TransactionContext tc, LongServiceAwardChild oLongServiceAwardChild)
{
tc.ExecuteNonQuery("UPDATE LongServiceAwardChild SET " +
"LongServiceAwardID = %n, " +
"EmployeeID = %n, " +
"Amount = %f, " +
"Gift = %s, " +
"IsLMMailDone = %n, " +
"LineManagerID = %n, " +
"LMComment = %s, " +
"LMCommentDate = %d, " +
"ModifiedBy = %n, " +
"ModifiedDate = %d " +
"WHERE LongServiceAwardChildID = %n",
oLongServiceAwardChild.LongServiceAwardID,
oLongServiceAwardChild.EmployeeID,
oLongServiceAwardChild.Amount,
DataReader.GetNullValue(oLongServiceAwardChild.Gift),
DataReader.GetNullValue(oLongServiceAwardChild.IsLMMailDone ? 1 : 0),
oLongServiceAwardChild.LineManagerID,
DataReader.GetNullValue(oLongServiceAwardChild.LMComment),
DataReader.GetNullValue(oLongServiceAwardChild.LMCommentDate),
DataReader.GetNullValue(oLongServiceAwardChild.ModifiedBy),
DataReader.GetNullValue(oLongServiceAwardChild.ModifiedDate),
oLongServiceAwardChild.ID);
}
#endregion
#region Delete Master
internal static void Delete (Ease.Core.DataAccess.TransactionContext tc, LongServiceAwardMaster oLongServiceAwardMaster)
{
tc.ExecuteNonQuery("DELETE FROM LongServiceAwardMaster Where LongServiceAwardID = %n ", oLongServiceAwardMaster.ID);
}
#endregion
#region Delete Child
internal static void Delete(Ease.Core.DataAccess.TransactionContext tc, LongServiceAwardChild oLongServiceAwardChild)
{
tc.ExecuteNonQuery("DELETE FROM LongServiceAwardChild Where LongServiceAwardChildID = %n ", oLongServiceAwardChild.ID);
}
internal static void Delete(Ease.Core.DataAccess.TransactionContext tc, int parentid)
{
tc.ExecuteNonQuery("DELETE FROM LongServiceAwardChild Where LongServiceAwardID = %n ", parentid);
}
#endregion
internal static IDataReader Get(TransactionContext tc)
{
return tc.ExecuteReader("SELECT * FROM LongServiceAwardMaster");
}
internal static IDataReader GetChildById(TransactionContext tc, int LongServiceAwardID)
{
return tc.ExecuteReader("SELECT * FROM LongServiceAwardChild Where LongServiceAwardID = %n", LongServiceAwardID);
}
internal static IDataReader GetByDateRange(TransactionContext tc, DateTime fromDate, DateTime toDate)
{
return tc.ExecuteReader("SELECT * FROM LongServiceAwardMaster Where AwardDate BETWEEN %d AND %d", fromDate, toDate);
}
internal static DataTable GetEmployeeDataforLongServiceAward(TransactionContext tc, int time, DateTime date)
{
int years = time * 5;
//return tc.ExecuteDataTable(
// @"SELECT e.EMPLOYEEID, e.EMPLOYEENO,e.name, e.LINEMANAGERID, lm.Name AS LineManagerName
// FROM employee e
// LEFT JOIN employee lm ON e.LINEMANAGERID = lm.EMPLOYEEID
// WHERE e.JOININGDATE BETWEEN DATEADD(MONTH, -1, DATEADD(YEAR, - %n, %d))
// AND DATEADD(YEAR, - %n, %d)",
// years, date, years, date);
return tc.ExecuteDataTable(
@"SELECT e.EMPLOYEEID, e.EMPLOYEENO,e.name, e.LINEMANAGERID,
(select CONCAT( e.EMPLOYEENO ,'-',e.Name,'- Email:' , e.EMAILADDRESS)
AS LineManagerName from EMPLOYEE lm where lm.EMPLOYEEID =e.LINEMANAGERID) AS LineManagerName
FROM employee e
WHERE DATEDIFF(YEAR, e.JOININGDATE, %d) =%n",
date,years);
}
}
}