157 lines
7.0 KiB
C#
157 lines
7.0 KiB
C#
|
using HRM.BO;
|
|||
|
using Ease.Core.DataAccess;
|
|||
|
using System;
|
|||
|
using System.Data;
|
|||
|
|
|||
|
|
|||
|
namespace HRM.DA
|
|||
|
{
|
|||
|
#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, IsAttachmentNeeded, PayrollTypeID,AttachmentMaxDays,IsLFA,LfaMaxDays," +
|
|||
|
"AllowNegativeBalance,MaxConsequentDays, IsPreApproval, PreApprovalDays, IsSelfCancellation, " +
|
|||
|
"SelfCancellationDays, CancelOnApprovalLeaveEntry, HasMinimumDays, MinimumDays, DescriptionInBangla, BalanceRoundofDigit)" +
|
|||
|
" VALUES(%n, %s, %s,%b,%n,%b,%b, %n, %d, %n, %n,%b,%b,%b,%b,%n,%n,%b,%n,%b,%n, %b, %n, %b, %n, %n, %n, %n, %u, %n)", oItem.ID, oItem.Code,
|
|||
|
oItem.Description, oItem.RemarksNeeded, oItem.ApplicableFor, oItem.IsBalanceCalculationNeeded,
|
|||
|
oItem.AutoLeaveReason, DataReader.GetNullValue(oItem.CreatedBy),
|
|||
|
DataReader.GetNullValue(oItem.CreatedDate), oItem.Sequence, oItem.Status, oItem.IsEarnedLeave,
|
|||
|
oItem.IsHalfDayLeave, oItem.IsCompensatoryLeave, oItem.IsAttachmentNeeded, oItem.PayrollTypeID, oItem.AttachmentMaxDays, oItem.IsLFA, oItem.LfaMaxDays, oItem.AllowNegativeBalance, oItem.MaxConsequentDays,
|
|||
|
oItem.IsPreApproval, oItem.PreApprovalDays, oItem.IsSelfCancellation, oItem.SelfCancellationDays,
|
|||
|
oItem.CancelOnApprovalLeaveEntry, oItem.HasMinimumDays, oItem.MinimumDays, oItem.DescriptionInBangla, oItem.BalanceRoundofDigit);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Update function
|
|||
|
|
|||
|
public static void Update(TransactionContext tc, Leave oItem)
|
|||
|
{
|
|||
|
string sql = SQLParser.MakeSQL("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, " +
|
|||
|
"IsAttachmentNeeded=%b, AttachmentMaxDays=%n,IsLFA=%b,LfaMaxDays=%n,AllowNegativeBalance=%b,MaxConsequentDays=%n, " +
|
|||
|
"IsPreApproval=%b, PreApprovalDays=%n, IsSelfCancellation=%b, SelfCancellationDays=%n, CancelOnApprovalLeaveEntry=%n, HasMinimumDays = %n, " +
|
|||
|
"MinimumDays = %n, DescriptionInBangla=%u, BalanceRoundofDigit=%n " +
|
|||
|
" WHERE LeaveID=%n", oItem.Code, oItem.Description, oItem.RemarksNeeded, oItem.ApplicableFor,
|
|||
|
oItem.IsBalanceCalculationNeeded, oItem.AutoLeaveReason, oItem.ModifiedBy, oItem.ModifiedDate,
|
|||
|
oItem.Sequence, oItem.Status, oItem.IsEarnedLeave, oItem.IsHalfDayLeave, oItem.IsCompensatoryLeave,
|
|||
|
oItem.IsAttachmentNeeded, oItem.AttachmentMaxDays, oItem.IsLFA, oItem.LfaMaxDays, oItem.AllowNegativeBalance,
|
|||
|
oItem.MaxConsequentDays, oItem.IsPreApproval, oItem.PreApprovalDays, oItem.IsSelfCancellation, oItem.SelfCancellationDays,
|
|||
|
oItem.CancelOnApprovalLeaveEntry, oItem.HasMinimumDays, oItem.MinimumDays, oItem.DescriptionInBangla, oItem.BalanceRoundofDigit,
|
|||
|
oItem.ID);
|
|||
|
tc.ExecuteNonQuery(sql);
|
|||
|
}
|
|||
|
|
|||
|
#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, string code, string name,
|
|||
|
int payrollTypeID)
|
|||
|
{
|
|||
|
string sqlClause = string.Empty;
|
|||
|
sqlClause = SQLParser.TagSQL(sqlClause) + SQLParser.MakeSQL("PayrollTypeID = %n", payrollTypeID);
|
|||
|
if (EnumStatus.Active == status || EnumStatus.Inactive == status)
|
|||
|
{
|
|||
|
sqlClause = SQLParser.TagSQL(sqlClause) + SQLParser.MakeSQL("status = %n", status);
|
|||
|
}
|
|||
|
|
|||
|
if (!string.IsNullOrWhiteSpace(code))
|
|||
|
{
|
|||
|
sqlClause = SQLParser.TagSQL(sqlClause) + SQLParser.MakeSQL("Code = %s", code);
|
|||
|
}
|
|||
|
|
|||
|
if (!string.IsNullOrWhiteSpace(name))
|
|||
|
{
|
|||
|
sqlClause = SQLParser.TagSQL(sqlClause) + SQLParser.MakeSQL("Description LIKE %s", ("%" + name + "%"));
|
|||
|
}
|
|||
|
|
|||
|
return tc.ExecuteReader("SELECT * FROM Leave %q order by Description", sqlClause);
|
|||
|
}
|
|||
|
|
|||
|
public static IDataReader Get(TransactionContext tc)
|
|||
|
{
|
|||
|
return tc.ExecuteReader("SELECT * FROM Leave ORDER BY LEAVEID");
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
public static IDataReader Get(TransactionContext tc, string InParameterSQL, int payrollTypeID)
|
|||
|
{
|
|||
|
return tc.ExecuteReader("SELECT * FROM Leave Where LeaveID IN (Select "
|
|||
|
+ " LeaveID From LeavePARAMETER where LEAVEPARAMID IN (%q) ) AND PayrollTypeID=%n ORDER BY LEAVEID",
|
|||
|
InParameterSQL, payrollTypeID);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
public static IDataReader GetEmpApplicableLeave(TransactionContext tc, int empid)
|
|||
|
{
|
|||
|
return tc.ExecuteReader(@"select l.* from LEAVE l , LEAVEPARAMETER lp ,LeaveParameterItem lim, EMPLOYEE e where
|
|||
|
lim.LEAVEPARAMID =lp.LEAVEPARAMID and lim.ItemID = e.GRADEID and e.EMPLOYEEID =%n
|
|||
|
and l.LEAVEID = lp.LEAVEID and (l.APPLICABLEFOR=0 OR e.GENDER = l.APPLICABLEFOR ) order by l.DESCRIPTION",
|
|||
|
empid);
|
|||
|
}
|
|||
|
|
|||
|
public static IDataReader Get(TransactionContext tc, int nLeaveID)
|
|||
|
{
|
|||
|
return tc.ExecuteReader("SELECT * FROM Leave WHERE LeaveID=%n", nLeaveID);
|
|||
|
}
|
|||
|
|
|||
|
public static IDataReader GetAll(TransactionContext tc)
|
|||
|
{
|
|||
|
return tc.ExecuteReader("SELECT * FROM Leave");
|
|||
|
}
|
|||
|
|
|||
|
public static IDataReader GetIDByName(TransactionContext tc, string sLeave, int payrollTypeID)
|
|||
|
{
|
|||
|
return tc.ExecuteReader("SELECT * FROM Leave WHERE Description=%s AND PayrollTypeID=%n", sLeave,
|
|||
|
payrollTypeID);
|
|||
|
}
|
|||
|
|
|||
|
public static IDataReader GetIDByCode(TransactionContext tc, string sLeave, int payrollTypeID)
|
|||
|
{
|
|||
|
return tc.ExecuteReader("SELECT * FROM Leave WHERE CODE=%s AND PayrollTypeID=%n", sLeave, payrollTypeID);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Delete function
|
|||
|
|
|||
|
public static void Delete(TransactionContext tc, int nLeaveID, int payrollTypeID)
|
|||
|
{
|
|||
|
tc.ExecuteNonQuery("DELETE FROM Leave WHERE LeaveID=%n AND PayrollTypeID=%n", nLeaveID, payrollTypeID);
|
|||
|
}
|
|||
|
|
|||
|
internal static IDataReader GetLeaves(TransactionContext tc, int payrollTypeID)
|
|||
|
{
|
|||
|
return tc.ExecuteReader("SELECT * FROM Leave WHERE PayrollTypeID=%n", payrollTypeID);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|