EchoTex_Payroll/HRM.DA/DA/Attendance/DailyAttendanceAllowanceDA.cs
2024-10-14 10:01:49 +06:00

181 lines
6.9 KiB
C#

using Ease.Core.DataAccess;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HRM.BO;
using System.Data;
namespace HRM.DA
{
#region SettlmentAdvice
public class DailyAttendanceAllowanceDA
{
#region Constructor
public DailyAttendanceAllowanceDA()
{
}
#endregion
#region Insert function
//public EnumattnBeniftsType BenifitsType { get; set; }
//public int? OtherBenifitItemID { get; set; }
//public double OtherBenifitValue { get; set; }
//public DateTime SalaryMonth { get; set; }
//public bool IsArrear { get; set; }
public static void Insert(TransactionContext tc, DailyAttendanceAllowance item)
{
string sql = SQLParser.MakeSQL(@"
INSERT INTO DailyAttendanceAllowance(DailyAttendanceProcessID, AttnDate, EmployeeID, ShiftID,
PayrollTypeID, BenifitsType, OtherBenifitItemID, OtherBenifitValue, SalaryMonth, IsArrear, CreatedBy, CreatedDate)
VALUES(%n, %d, %n, %n, %n, %n, %n, %n, %d, %n %n, %d)",
item.DailyAttendanceProcessID, item.AttnDate, item.EmployeeID, item.ShiftID,
DataReader.GetNullValue(item.PayrollTypeID), item.BenifitsType, item.OtherBenifitItemID, item.OtherBenifitValue
, item.SalaryMonth, item.IsArrear, item.CreatedBy, DataReader.GetNullValue(item.CreatedDate));
tc.ExecuteNonQuery(sql);
}
#endregion
#region Update function
public static void Update(TransactionContext tc, DailyAttendanceAllowance item)
{
string sql = SQLParser.MakeSQL(@"
UPDATE DailyAttendanceAllowance
SET DailyAttendanceProcessID=%n, AttnDate=%d, EmployeeID=%n, ShiftID=%n,
PayrollTypeID=%n,
BenifitsType=%n, OtherBenifitItemID =%n, OtherBenifitValue=%n, SalaryMonth=%d, IsArrear=%n
ModifiedBy=%n, ModifiedDate=%d)
WHERE DailyAttendanceAllowanceID=%n",
item.DailyAttendanceProcessID, item.AttnDate, item.EmployeeID, item.ShiftID,
DataReader.GetNullValue(item.PayrollTypeID), item.BenifitsType, item.OtherBenifitItemID, item.OtherBenifitValue
, item.SalaryMonth, item.IsArrear, item.ModifiedBy, DataReader.GetNullValue(item.ModifiedDate),
item.ID);
tc.ExecuteNonQuery(sql);
}
internal static IDataReader GetByPayrollType(TransactionContext tc, int payrollTypeID)
{
string sql = SQLParser.MakeSQL(@"
SELECT * FROM DailyAttendanceAllowance
WHERE PayrollTypeID = %n",
payrollTypeID);
return tc.ExecuteReader(sql);
}
internal static IDataReader GetById(TransactionContext tc, int id)
{
string sql = SQLParser.MakeSQL(@"
SELECT * FROM DailyAttendanceAllowance
WHERE DailyAttendanceAllowanceID = %n",
id);
return tc.ExecuteReader(sql);
}
internal static IDataReader GetByAttnDate(TransactionContext tc, DateTime attnDate)
{
string sql = SQLParser.MakeSQL(@"
SELECT * FROM DailyAttendanceAllowance
WHERE AttnDate = %d ",
attnDate, true);
return tc.ExecuteReader(sql);
}
internal static IDataReader Get(TransactionContext tc, string empids, DateTime attnDate)
{
string sql = SQLParser.MakeSQL(@"
SELECT * FROM DailyAttendanceAllowance
WHERE AttnDate = %d and Employeeid in (%q)",
attnDate, empids);
return tc.ExecuteReader(sql);
}
internal static IDataReader GetEditedItems(TransactionContext tc, DateTime attnDate)
{
string sql = SQLParser.MakeSQL(@"
SELECT * FROM DailyAttendanceAllowance
WHERE AttnDate = %d and ManualEdited=%n",
attnDate, true);
return tc.ExecuteReader(sql);
}
internal static IDataReader GetByAttnDateRange(TransactionContext tc, DateTime attnFromDate, DateTime attnToDate)
{
string sql = SQLParser.MakeSQL(@"
SELECT * FROM DailyAttendanceAllowance
WHERE AttnDate BETWEEN %d AND %d",
attnFromDate, attnToDate);
return tc.ExecuteReader(sql);
}
internal static IDataReader GetByAttnDateRangePayrollType(TransactionContext tc, DateTime attnFromDate, DateTime attnToDate, int payrollTypeid)
{
string sql = SQLParser.MakeSQL(@"
SELECT * FROM DailyAttendanceAllowance
WHERE PayrollTypeID = %n AND AttnDate BETWEEN %d AND %d",
payrollTypeid, attnFromDate, attnToDate);
return tc.ExecuteReader(sql);
}
internal static DataTable GetByAttnDateRangePayrollTypedt(TransactionContext tc, DateTime attnFromDate, DateTime attnToDate, int payrollTypeid)
{
string sql = SQLParser.MakeSQL(@"
SELECT d.EmployeeID, d.ShiftID, SUM(d.NightAllowance) AS NightAllowance, SUM(d.HolidayAllowance) AS HolidayAllowance, SUM(d.OtherAllowance) AS OtherAllowance, SUM(d.ExtraHour) AS ExtraHour, SUM(d.RegularOverTime) AS RegularOverTime, SUM(d.HolidayOverTime) AS HolidayOverTime
FROM DailyAttendanceAllowance d
JOIN EMPLOYEE e ON d.EmployeeID = e.EMPLOYEEID
WHERE e.PayrollTypeID = %n AND d.AttnDate BETWEEN %d AND %d
GROUP BY d.EmployeeID, d.ShiftID",
payrollTypeid, attnFromDate, attnToDate);
return tc.ExecuteDataTable(sql);
}
internal static DataTable GetByAttnbySalaryMonth(TransactionContext tc, DateTime salarymonth, int payrollTypeid)
{
string sql = SQLParser.MakeSQL(@"
SELECT d.EmployeeID, d.BenifitsType type, d.OtherBenifitItemID ItemID, SUM(d.OtherBenifitValue) AS value
FROM DailyAttendanceAllowance d
JOIN EMPLOYEE e ON d.EmployeeID = e.EMPLOYEEID
WHERE e.PayrollTypeID = %n AND d.SalaryMonth =%d
GROUP BY d.EmployeeID, d.OtherBenifitItemID, d.BenifitsType",
payrollTypeid, salarymonth);
return tc.ExecuteDataTable(sql);
}
internal static void Delete(TransactionContext tc, int id)
{
string sql = SQLParser.MakeSQL(@"
DELETE DailyAttendanceAllowance
WHERE DailyAttendanceAllowanceID = %n",
id);
tc.ExecuteNonQuery(sql);
}
internal static void Delete(TransactionContext tc, string empIDs, DateTime attnDate , bool edited)
{
tc.ExecuteNonQuery("DELETE FROM DailyAttendanceAllowance WHERE EmployeeID in(%q) AND AttnDate=%d and ManualEdited =%n", empIDs, attnDate, edited);
}
#endregion
#region Update function
#endregion
}
#endregion
}