CEL_Payroll/Payroll.Service/Leave/DA/LeaveDA.cs
2024-09-17 14:30:13 +06:00

96 lines
3.9 KiB
C#

using System;
using Payroll.BO;
using System.Data;
using System.Linq;
using Ease.CoreV35.Model;
using System.Data.SqlClient;
using Ease.CoreV35.DataAccess;
using System.Collections.Generic;
using Ease.CoreV35.DataAccess.SQL;
namespace Payroll.Service
{
#region Leave
public class LeaveDA
{
#region Constructor
public LeaveDA() { }
#endregion
#region Insert function
public static void Insert(TransactionContext tc, Leave oItem)
{
tc.ExecuteNonQuery("INSERT INTO Leave(LeaveID, Code, Description,RemarksNeeded,ApplicableFor,IsBalanceCalRequired,AutoLeaveReason,CreatedBy, CreatedDate, SequenceNo, Status,IsEarnedLeave,IsHalfDayLeave,IsCompensatoryLeave)" +
" VALUES(%n, %s, %s,%b,%n,%b,%b, %n, %d, %n, %n,%b,%b,%b)", oItem.ID.Integer, oItem.Code, oItem.Description, oItem.RemarksNeeded, oItem.ApplicableFor, oItem.IsBalanceCalculationNeeded, oItem.AutoLeaveReason, DataReader.GetNullValue(oItem.CreatedBy.Integer), DataReader.GetNullValue(oItem.CreatedDate), oItem.Sequence, oItem.Status, oItem.IsEarnedLeave,oItem.IsHalfDayLeave,oItem.IsCompensatoryLeave);
}
#endregion
#region Update function
public static void Update(TransactionContext tc, Leave oItem)
{
tc.ExecuteNonQuery("UPDATE Leave SET Code=%s, Description=%s,RemarksNeeded=%b,ApplicableFor=%n,IsBalanceCalRequired=%b,AutoLeaveReason=%b, ModifiedBy=%n, ModifiedDate=%d, SequenceNo=%n, Status=%n,IsEarnedLeave=%b,IsHalfDayLeave=%b,IsCompensatoryLeave=%b" +
" WHERE LeaveID=%n", oItem.Code, oItem.Description, oItem.RemarksNeeded, oItem.ApplicableFor, oItem.IsBalanceCalculationNeeded, oItem.AutoLeaveReason, oItem.ModifiedBy.Integer, oItem.ModifiedDate, oItem.Sequence, oItem.Status, oItem.IsEarnedLeave,oItem.IsHalfDayLeave,oItem.IsCompensatoryLeave, oItem.ID.Integer);
}
#endregion
#region ID Generation function
public static int GetNewID(TransactionContext tc)
{
return tc.GenerateID("Leave", "LeaveID");
}
#endregion
#region Get Function
internal static IDataReader Get(TransactionContext tc, EnumStatus status)
{
if (EnumStatus.Active == status || EnumStatus.Inactive == status)
{
return tc.ExecuteReader("SELECT * FROM Leave Where Status=%n Order By SequenceNo", status);
}
else
{
return tc.ExecuteReader("SELECT * FROM Leave Order By SequenceNo");
}
}
public static IDataReader Get(TransactionContext tc)
{
return tc.ExecuteReader("SELECT * FROM Leave ORDER BY LEAVEID");
}
public static IDataReader Get(TransactionContext tc, string InParameterSQL)
{
return tc.ExecuteReader("SELECT * FROM Leave Where LeaveID IN (Select "
+ " LeaveID From LEAVEPARAMETER where LEAVEPARAMID IN (%q) ) ORDER BY LEAVEID", InParameterSQL);
}
public static IDataReader Get(TransactionContext tc, int nLeaveID)
{
return tc.ExecuteReader("SELECT * FROM Leave WHERE LeaveID=%n", nLeaveID);
}
public static IDataReader GetIDByName(TransactionContext tc, string sLeave)
{
return tc.ExecuteReader("SELECT * FROM Leave WHERE Description=%s", sLeave);
}
public static IDataReader GetIDByCode(TransactionContext tc, string sLeave)
{
return tc.ExecuteReader("SELECT * FROM Leave WHERE CODE=%s", sLeave);
}
#endregion
#region Delete function
public static void Delete(TransactionContext tc, int nLeaveID)
{
tc.ExecuteNonQuery("DELETE FROM Leave WHERE LeaveID=%n", nLeaveID);
}
internal static IDataReader GetLeaves(TransactionContext tc)
{
return tc.ExecuteReader("SELECT * FROM Leave");
}
#endregion
}
#endregion
}