EchoTex_Payroll/HRM.DA/DA/Attendance/AdhocClaimDA.cs

226 lines
18 KiB
C#
Raw Normal View History

2024-10-14 10:01:49 +06:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using HRM.BO;
using Ease.Core.DataAccess;
namespace HRM.DA
{
#region AdhocClaimDA
internal class AdhocClaimDA
{
#region Constructor
private AdhocClaimDA()
{
}
#endregion
#region Insert function
internal static void Insert(TransactionContext tc, AdhocClaim item)
{
//1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
string sql = SQLParser.MakeSQL(
@"INSERT INTO AdhocClaim(AdhocClaimID, EmployeeID, BatchID, ItemType, ItemID, LineManagerID, ClaimDate, SalaryMonth, LMApproveDate, EmployeeValue, LMValue, EmployeeRemarks, LMRemarks, IsLMSubmitted, ClaimValueType, ClaimWFStatus, CreatedBy, CreatedDate, ShiftManagerID, SMApproveDate, ShiftID, WorkPlanGroupID, FromTime, ToTime, IsLMEdited, IsBatchEntry, SystemMode, SeniorTechnicianID, ApproverID, IsSTSubmitted, AdjustmentSalaryMonth)
VALUES( %n, %n, %n, %n, %n, %n, %d, %d, %D, %n, %n, %s, %s, %n, %n, %n, %n, %D, %n, %d, %n, %n, %D, %D, %n, %n, %n, %n, %n, %n, %d)",
item.ID, DataReader.GetNullValue(item.EmployeeID, 0), DataReader.GetNullValue(item.BatchID, 0),
(int)item.ItemType, DataReader.GetNullValue(item.ItemID, 0),
DataReader.GetNullValue(item.LineManagerID, 0), item.ClaimDate, item.SalaryMonth,
DataReader.GetNullValue(item.LMApproveDate), item.EmployeeValue, item.LMValue, item.EmployeeRemarks,
item.LMRemarks, item.IsLMSubmitted, (int)item.ClaimValueType, (int)item.ClaimWFStatus, item.CreatedBy,
item.CreatedDate, DataReader.GetNullValue(item.ShiftManagerID, 0),
DataReader.GetNullValue(item.SMApproveDate), DataReader.GetNullValue(item.ShiftID, 0),
DataReader.GetNullValue(item.WorkPlanGroupID, 0), DataReader.GetNullValue(item.FromTime),
DataReader.GetNullValue(item.ToTime), item.IsLMEdited, item.IsBatchEntry, (int)item.SystemMode,
DataReader.GetNullValue(item.SeniorTechnicianID, 0), DataReader.GetNullValue(item.ApproverID, 0),
item.IsSTSubmitted, DataReader.GetNullValue(item.AdjustmentSalaryMonth));
tc.ExecuteNonQuery(sql);
//var a1 = item.ID;
//var e1 = item.EmployeeID;
//var a2 = DataReader.GetNullValue(item.EmployeeID, 0);
//var a3 = DataReader.GetNullValue(item.BatchID, 0);
//var a4 = item.ItemType;
//var a41 = DataReader.GetNullValue(item.ItemID, 0);
//var a5 = DataReader.GetNullValue(item.LineManagerID, 0);
//var a6 = item.ClaimDate;
//var a7 = item.SalaryMonth;
//var a8 = DataReader.GetNullValue(item.LMApproveDate, DateTime.MinValue);
//var a9 = item.EmployeeValue;
//var a10 = item.LMValue;
//var a11 = item.EmployeeRemarks;
//var a12 = item.LMRemarks;
//var a13 = item.IsLMSubmitted;
//var a14 = item.ClaimValueType;
//var a15 = item.ClaimWFStatus;
//var a16 = item.CreatedBy;
//var a17 = item.CreatedDate;
//var a18 = DataReader.GetNullValue(item.ShiftManagerID, 0);
//var a19 = DataReader.GetNullValue(item.SMApproveDate, DateTime.MinValue);
//var a20 = DataReader.GetNullValue(item.ShiftID, 0);
//var a21 = DataReader.GetNullValue(item.WorkPlanGroupID, 0);
//var a22 = DataReader.GetNullValue(item.FromTime, DateTime.MinValue);
//var a23 = DataReader.GetNullValue(item.ToTime, DateTime.MinValue);
//var a24 = item.IsLMEdited;
//var a25 = item.IsBatchEntry;
//var a26 = item.SystemMode;
//var a27 = DataReader.GetNullValue(item.SeniorTechnicianID, 0);
//var a28 = DataReader.GetNullValue(item.ApproverID, 0);
//var a29 = item.IsSTSubmitted;
//tc.ExecuteNonQuery("INSERT INTO AdhocClaim(AdhocClaimID, EmployeeID, BatchID, ItemType, ItemID, LineManagerID, ClaimDate, SalaryMonth, LMApproveDate, EmployeeValue, LMValue, EmployeeRemarks, LMRemarks, IsLMSubmitted, ClaimValueType, ClaimWFStatus, CreatedBy, CreatedDate, ShiftManagerID, SMApproveDate, ShiftID, WorkPlanGroupID, FromTime, ToTime, IsLMEdited, IsBatchEntry, SystemMode, SeniorTechnicianID, ApproverID, IsSTSubmitted)" +
//" VALUES(%n, %n, %n, %n, %n, %n, %d,%d,%d, %n,%n, %s,%s, %n,%n,%n,%n, %d, %n, %d, %n, %n, %D, %D, %n, %n, %n, %n, %n, %n)", item.ID, DataReader.GetNullValue(item.EmployeeID, 0), DataReader.GetNullValue(item.BatchID, 0), item.ItemType, DataReader.GetNullValue(item.ItemID, 0), DataReader.GetNullValue(item.LineManagerID, 0), item.ClaimDate, item.SalaryMonth, DataReader.GetNullValue(item.LMApproveDate, DateTime.MinValue), item.EmployeeValue, item.LMValue, item.EmployeeRemarks, item.LMRemarks, item.IsLMSubmitted, item.ClaimValueType, item.ClaimWFStatus, item.CreatedBy, item.CreatedDate, DataReader.GetNullValue(item.ShiftManagerID, 0), DataReader.GetNullValue(item.SMApproveDate, DateTime.MinValue), DataReader.GetNullValue(item.ShiftID, 0), DataReader.GetNullValue(item.WorkPlanGroupID, 0), DataReader.GetNullValue(item.FromTime, DateTime.MinValue), DataReader.GetNullValue(item.ToTime, DateTime.MinValue), item.IsLMEdited, item.IsBatchEntry, item.SystemMode, DataReader.GetNullValue(item.SeniorTechnicianID, 0), DataReader.GetNullValue(item.ApproverID, 0), item.IsSTSubmitted);
}
#endregion
#region Update function
internal static void Update(TransactionContext tc, AdhocClaim item)
{
tc.ExecuteNonQuery(
"UPDATE AdhocClaim SET EmployeeID=%n, BatchID=%n, ItemType=%n, ItemID=%n, LineManagerID=%n, ClaimDate=%d, SalaryMonth=%d, LMApproveDate=%D, EmployeeValue=%n, LMValue=%n, EmployeeRemarks=%s, LMRemarks=%s, IsLMSubmitted=%n, ClaimValueType=%n, ClaimWFStatus=%n, ModifiedBy=%n, ModifiedDate=%D, ShiftManagerID=%n, SMApproveDate=%D, ShiftID=%n, WorkPlanGroupID=%n, FromTime=%D, ToTime=%D, IsLMEdited=%n, IsBatchEntry=%n, SystemMode=%n, SeniorTechnicianID=%n, ApproverID=%n, IsSTSubmitted=%n, AdjustmentSalaryMonth=%d" +
" WHERE AdhocClaimID=%n", DataReader.GetNullValue(item.EmployeeID, 0),
DataReader.GetNullValue(item.BatchID, 0), item.ItemType, DataReader.GetNullValue(item.ItemID, 0),
DataReader.GetNullValue(item.LineManagerID, 0), item.ClaimDate, item.SalaryMonth, item.LMApproveDate,
item.EmployeeValue, item.LMValue, item.EmployeeRemarks, item.LMRemarks, item.IsLMSubmitted,
item.ClaimValueType, item.ClaimWFStatus, item.ModifiedBy, item.ModifiedDate,
DataReader.GetNullValue(item.ShiftManagerID, 0), item.SMApproveDate,
DataReader.GetNullValue(item.ShiftID, 0), DataReader.GetNullValue(item.WorkPlanGroupID, 0),
DataReader.GetNullValue(item.FromTime, DateTime.MinValue),
DataReader.GetNullValue(item.ToTime, DateTime.MinValue), item.IsLMEdited, item.IsBatchEntry,
item.SystemMode, DataReader.GetNullValue(item.SeniorTechnicianID, 0),
DataReader.GetNullValue(item.ApproverID, 0), item.IsSTSubmitted,
DataReader.GetNullValue(item.AdjustmentSalaryMonth), item.ID);
}
#endregion
#region Get Function
internal static int GetAdhocClaimDataByWFStatusCount(TransactionContext tc, DateTime fromDate, DateTime toDate,
EnumWFAttnStatus status)
{
string sql = string.Empty;
sql = SQLParser.MakeSQL(@"Select Count(*) from Adhocclaim
where ClaimWFStatus=%n and ClaimDate between %d and %d", (int)status,
fromDate, toDate);
return Convert.ToInt32(tc.ExecuteScalar(sql).ToString());
}
internal static IDataReader Get(TransactionContext tc)
{
return tc.ExecuteReader("SELECT * FROM AdhocClaim Order By ClaimDateTime desc");
}
internal static IDataReader GetByEmployeeID(TransactionContext tc, int employeeID)
{
return tc.ExecuteReader("SELECT * FROM AdhocClaim where employeeID=%n Order By ClaimDateTime desc",
employeeID);
}
internal static IDataReader GetByEmployeeID(TransactionContext tc, string employeeIDs, EnumClaimWFStatus status)
{
return tc.ExecuteReader(
"SELECT * FROM AdhocClaim where employeeID in (%q) and ClaimWFStatus =%n Order By ClaimDateTime desc",
employeeIDs, status);
}
internal static IDataReader GetByShiftManagerID(TransactionContext tc, int employeeID)
{
return tc.ExecuteReader("SELECT * FROM AdhocClaim where ShiftManagerID=%n Order By ClaimDateTime desc",
employeeID);
}
internal static IDataReader GetByEmployeeID(TransactionContext tc, int employeeID, DateTime fromDate,
DateTime toDate)
{
return tc.ExecuteReader(
"SELECT * FROM AdhocClaim where employeeID=%n and CLAIMDATETIME between %d and %d Order By CLAIMDATETIME desc",
employeeID, fromDate, toDate);
}
internal static IDataReader GetByShiftManagerID(TransactionContext tc, int shiftManagerID, DateTime fromDate,
DateTime toDate)
{
return tc.ExecuteReader(
"SELECT * FROM AdhocClaim where ShiftManagerID=%n and ClaimDateTime between %d and %d Order By ClaimDateTime desc",
shiftManagerID, fromDate, toDate);
}
internal static IDataReader GetByApproverID(TransactionContext tc, int shiftManagerID, DateTime fromDate,
DateTime toDate)
{
return tc.ExecuteReader(
"SELECT * FROM AdhocClaim where ApproverID=%n and ClaimDateTime between %d and %d Order By ClaimDateTime desc",
shiftManagerID, fromDate, toDate);
}
internal static IDataReader GetBySeniorTechnicianID(TransactionContext tc, int seniorTechnicianID,
DateTime fromDate, DateTime toDate)
{
return tc.ExecuteReader(
"SELECT * FROM AdhocClaim where SeniorTechnicianID=%n and ClaimDateTime between %d and %d Order By ClaimDateTime desc",
seniorTechnicianID, fromDate, toDate);
}
internal static IDataReader GetByShiftManagerID(TransactionContext tc, int shiftManagerID,
EnumClaimWFStatus status)
{
return tc.ExecuteReader(
"SELECT * FROM AdhocClaim where ShiftManagerID=%n and ClaimWFStatus =%n Order By ClaimDateTime desc",
shiftManagerID, status);
}
internal static IDataReader GetByApprover(TransactionContext tc, int shiftID, int deparetmentID,
EnumClaimWFStatus wfStatus)
{
string sql = SQLParser.MakeSQL(
@"SELECT * FROM ADHOCCLAIM WHERE CLAIMWFSTATUS= %n and EMPLOYEEID IN (SELECT e.EmployeeID FROM EMPLOYEE e
INNER JOIN EMPLOYEEWORKPLANSETUP empwps ON empwps.EMPLOYEEID=e.EMPLOYEEID
INNER JOIN WORKPLANGROUP wpg ON wpg.WORKPLANGROUPID=empwps.WORKPLANGROUPID
WHERE e.departmentID=%n AND wpg.WORKPLANGROUPID=%n AND e.STATUS=%n)",
wfStatus, deparetmentID, shiftID, EnumEmployeeStatus.Live);
return tc.ExecuteReader(sql);
}
internal static IDataReader Get(TransactionContext tc, DateTime claimDate)
{
return tc.ExecuteReader("SELECT * FROM AdhocClaim where ClaimDateTime=%d", claimDate);
}
internal static IDataReader Get(TransactionContext tc, int adhocClaimID)
{
return tc.ExecuteReader("SELECT * FROM AdhocClaim WHERE AdhocClaimID=%n", adhocClaimID);
}
#endregion
#region Delete function
internal static void Delete(TransactionContext tc, int adhocClaimID)
{
tc.ExecuteNonQuery("DELETE FROM AdhocClaim WHERE AdhocClaimID=%n", adhocClaimID);
}
public static long GetMaxBatchID(TransactionContext tc)
{
long batchID = 0;
Object obj = tc.ExecuteScalar("Select Max(BatchID) BatchID FROM AdhocClaim");
if (obj == DBNull.Value)
batchID = 0;
else
batchID = Convert.ToInt64(obj) > 0 ? Convert.ToInt64(obj) : 0;
return batchID;
}
#endregion
}
#endregion
}