EchoTex_Payroll/HRM.DA/DA/Recruitement/HeadCountApprovalRequestDA.cs

169 lines
8.7 KiB
C#
Raw 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
{
public class HeadCountApprovalRequestDA
{
public HeadCountApprovalRequestDA()
{
}
internal static void Delete(TransactionContext tc, int id)
{
string sql = SQLParser.MakeSQL(@"DELETE FROM HeadCountApprovalRequest WHERE HeadCountApprovalRequestID = %n", id);
tc.ExecuteNonQuery(sql);
}
internal static void Insert(TransactionContext tc, HeadCountApprovalRequest ob)
{
string sql = SQLParser.MakeSQL(@"INSERT INTO dbo.HeadCountApprovalRequest
(
HeadCountApprovalRequestID, RcID, RequestDate,
RequestType, Reason, DepartmentID,
BudgetedManPower,AdditionalManPower, WfStatus,
CREATEDBY, CreationDate,
Remarks,
IsMonthly,
Month1,
Month2,
Month3,
Month4,
Month5,
Month6,
Month7,
Month8,
Month9,
Month10,
Month11,
Month12,
YearToal,
BudgetYear,
Position,CategoryID,Designation,Year,DesignationID
)
VALUES
(
%n, %n, %d,
%n, %s, %n,
%n,%n, %n,
%n, %d,%s,%b,
%n,%n,%n,%n,
%n,%n,%n,%n,
%n,%n,%n,%n,
%n,%n,%s,%n,%s,%n,%n)",
ob.ID, ob.RcID, ob.RequestDate,
ob.RequestType, ob.Reason, ob.UnitID,
ob.BudgetedManPower, ob.AdditionalManPower, ob.WfStatus,
ob.CreatedBy, ob.CreatedDate,ob.Remarks,ob.IsMonthly,
ob.Month1, ob.Month2, ob.Month3, ob.Month4, ob.Month5,
ob.Month6, ob.Month7, ob.Month8, ob.Month9, ob.Month10,
ob.Month11, ob.Month12, ob.YearTotal, ob.BudgetedYaer,
ob.Position,ob.CategoryID,ob.Designation,ob.Year,DataReader.GetNullValue(ob.DesignationID));
tc.ExecuteNonQuery(sql);
}
internal static void Update(TransactionContext tc, HeadCountApprovalRequest ob)
{
string sql = SQLParser.MakeSQL(@"UPDATE HeadCountApprovalRequest
SET
RcID = %n,
RequestDate = %d,
RequestType = %n,
Reason = %s,
DepartmentID = %n,
BudgetedManPower = %n,
WfStatus = %n,
MODIFIEDBY = %n,
ModificationDate = %d,
AdditionalManPower = %n,
Remarks = %s,
IsMonthly = %b,
Month1 = %n,
Month2 = %n,
Month3 = %n,
Month4 = %n,
Month5 = %n,
Month6 = %n,
Month7 = %n,
Month8 = %n,
Month9 = %n,
Month10 = %n,
Month11 = %n,
Month12 = %n,
YearToal = %n,
BudgetYear = %n,Position =%s,CategoryID = %n,Designation = %s, Year = %n, DesignationID = %n
WHERE HeadCountApprovalRequestID = %n",
ob.RcID, ob.RequestDate, ob.RequestType,
ob.Reason, ob.UnitID, ob.BudgetedManPower,
ob.WfStatus, ob.ModifiedBy, ob.ModifiedDate,
ob.AdditionalManPower,ob.Remarks,ob.IsMonthly,
ob.Month1,ob.Month2,ob.Month3,ob.Month4,
ob.Month5, ob.Month6, ob.Month7, ob.Month8,
ob.Month9, ob.Month10, ob.Month11, ob.Month12,
ob.YearTotal, ob.BudgetedYaer,ob.Position,ob.CategoryID,ob.Designation,ob.Year,DataReader.GetNullValue(ob.DesignationID),
ob.ID);
tc.ExecuteNonQuery(sql);
}
internal static IDataReader Get(TransactionContext tc, int id)
{
string sql = SQLParser.MakeSQL(@"SELECT * FROM HeadCountApprovalRequest WHERE HeadCountApprovalRequestID = %n", id);
return tc.ExecuteReader(sql);
}
internal static IDataReader Get(TransactionContext tc, int year,int departmentID)
{
DateTime date = new DateTime(year, 12, 31);
string sql = SQLParser.MakeSQL(@"SELECT * FROM HeadCountApprovalRequest WHERE RequestDate = %d AND DepartmentID = %n", date,departmentID);
return tc.ExecuteReader(sql);
}
internal static IDataReader Get(TransactionContext tc)
{
string sql = SQLParser.MakeSQL(@"SELECT * FROM HeadCountApprovalRequest");
return tc.ExecuteReader(sql);
}
internal static IDataReader GetChilds(TransactionContext tc, int id)
{
string sql = SQLParser.MakeSQL(@"SELECT * FROM HeadCountRequestEmp WHERE HeadCountApprovalRequestID = %n", id);
return tc.ExecuteReader(sql);
}
internal static IDataReader GetBudgetedHeadCount(TransactionContext tc, int departmentId, int designationId, int positionYear)
{
string sSearch = string.Empty;
if (departmentId > 0)
{
sSearch = SQLParser.TagSQL(sSearch) + SQLParser.MakeSQL("em.DEPARTMENTID=%n", departmentId);
}
if (designationId > 0)
{
sSearch = SQLParser.TagSQL(sSearch) + SQLParser.MakeSQL("em.DESIGNATIONID=%n", designationId);
}
sSearch = SQLParser.TagSQL(sSearch) + SQLParser.MakeSQL("em.YEAR=%n", positionYear);
return tc.ExecuteReader("SELECT * FROM HeadCountApprovalRequest em %q", sSearch);
}
internal static IDataReader GetBudgetedHeadCountByPositionYear(TransactionContext tc, int positionYear)
{
string sSearch = string.Empty;
//if (departmentId > 0)
//{
// sSearch = SQLParser.TagSQL(sSearch) + SQLParser.MakeSQL("em.DEPARTMENTID=%n", departmentId);
//}
//if (designationId > 0)
//{
// sSearch = SQLParser.TagSQL(sSearch) + SQLParser.MakeSQL("em.DESIGNATIONID=%n", designationId);
//}
sSearch = SQLParser.TagSQL(sSearch) + SQLParser.MakeSQL("em.YEAR=%n", positionYear);
return tc.ExecuteReader("SELECT * FROM HeadCountApprovalRequest em %q", sSearch);
}
internal static void DeleteChild(TransactionContext tc, int id)
{
string sql = SQLParser.MakeSQL(@"DELETE FROM HeadCountRequestEmp WHERE HeadCountApprovalRequestID = %n", id);
tc.ExecuteNonQuery(sql);
}
}
}