143 lines
5.2 KiB
C#
143 lines
5.2 KiB
C#
|
using HRM.BO;
|
|||
|
using Ease.Core.DataAccess;
|
|||
|
using System;
|
|||
|
using System.Data;
|
|||
|
|
|||
|
namespace HRM.DA
|
|||
|
{
|
|||
|
#region CategoryDA
|
|||
|
|
|||
|
internal class CategoryDA
|
|||
|
{
|
|||
|
#region Constructor
|
|||
|
|
|||
|
private CategoryDA()
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Insert function
|
|||
|
|
|||
|
internal static void Insert(TransactionContext tc, Category item)
|
|||
|
{
|
|||
|
tc.ExecuteNonQuery(
|
|||
|
"INSERT INTO Category(CategoryID, code, description, CreatedBy, CreationDate, SequenceNo, Status, WagesType,PayrollTypeID, descriptionInBangla)" +
|
|||
|
" VALUES(%n, %s, %s, %n, %d, %n, %n, %n,%n, %u)", item.ID, item.Code, item.Name, item.CreatedBy,
|
|||
|
item.CreatedDate, item.Sequence, item.Status, item.WagesType, item.PayrollTypeID, item.NameInBangla);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Update function
|
|||
|
|
|||
|
internal static void Update(TransactionContext tc, Category item)
|
|||
|
{
|
|||
|
tc.ExecuteNonQuery(
|
|||
|
"UPDATE Category SET code=%s, description=%s, ModifiedBy=%n, ModifiedDate=%d, SequenceNo=%n, Status=%n, WagesType=%n, PayrollTypeID=%n, descriptionInBangla=%u" +
|
|||
|
" WHERE CategoryID=%n", item.Code, item.Name, item.ModifiedBy, item.ModifiedDate, item.Sequence,
|
|||
|
item.Status, item.WagesType, item.PayrollTypeID, item.NameInBangla, item.ID);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Get Function
|
|||
|
|
|||
|
internal static IDataReader GetAllCategory(TransactionContext tc, int payrollTypeID, EnumStatus status,
|
|||
|
string code, string name)
|
|||
|
{
|
|||
|
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("Name LIKE %s", ("%" + name + "%"));
|
|||
|
}
|
|||
|
|
|||
|
return tc.ExecuteReader("SELECT * FROM Category %q Order By SequenceNo", sqlClause);
|
|||
|
}
|
|||
|
|
|||
|
internal static IDataReader Get(TransactionContext tc, EnumStatus status, int payrollTypeID)
|
|||
|
{
|
|||
|
if (EnumStatus.Active == status || EnumStatus.Inactive == status)
|
|||
|
{
|
|||
|
return tc.ExecuteReader(
|
|||
|
"SELECT * FROM Category where Status=%n AND PayRollTypeID=%n Order By SequenceNo", status,
|
|||
|
payrollTypeID);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
return tc.ExecuteReader("SELECT * FROM Category WHERE PayRollTypeID=%n Order By SequenceNo",
|
|||
|
payrollTypeID);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
internal static IDataReader Get(TransactionContext tc, EnumWagesType wageType, EnumStatus status,
|
|||
|
int payrollTypeID)
|
|||
|
{
|
|||
|
return tc.ExecuteReader(
|
|||
|
"SELECT * FROM Category where Status=%n AND PayRollTypeID=%n and WagesType=%n Order By SequenceNo",
|
|||
|
status, payrollTypeID, wageType);
|
|||
|
}
|
|||
|
|
|||
|
internal static IDataReader Get(TransactionContext tc, int ID)
|
|||
|
{
|
|||
|
return tc.ExecuteReader("SELECT * FROM Category WHERE CategoryID=%n", ID);
|
|||
|
}
|
|||
|
internal static IDataReader GetAll(TransactionContext tc)
|
|||
|
{
|
|||
|
return tc.ExecuteReader("SELECT * FROM Category ");
|
|||
|
}
|
|||
|
internal static IDataReader GetByPayrollTypeID(TransactionContext tc, int payrollTypeID)
|
|||
|
{
|
|||
|
return tc.ExecuteReader("SELECT * FROM Category WHERE PayRollTypeID=%n", payrollTypeID);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Delete function
|
|||
|
|
|||
|
internal static void Delete(TransactionContext tc, int ID)
|
|||
|
{
|
|||
|
tc.ExecuteNonQuery("DELETE FROM Category WHERE CategoryID=%n", ID);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
internal static DataSet GetAgeRange(TransactionContext tc, int fromyear, int toyear)
|
|||
|
{
|
|||
|
DataSet rootDataset = new DataSet();
|
|||
|
DataSet tempdataset = new DataSet();
|
|||
|
try
|
|||
|
{
|
|||
|
string query = SQLParser.MakeSQL(@"Select Count(EmployeeID)as ManagementStaff,(Select Count(EmployeeID)
|
|||
|
from Employee where CategoryID=2 and DATEDIFF(YEAR,BIRTHDATE,GETDATE()) between %n and %n)as NonManagementStaff
|
|||
|
from Employee
|
|||
|
where CategoryID=1 and DATEDIFF(YEAR,BIRTHDATE,GETDATE()) between %n and %n ",
|
|||
|
fromyear, toyear, fromyear, toyear);
|
|||
|
|
|||
|
tempdataset = tc.ExecuteDataSet(query);
|
|||
|
|
|||
|
tempdataset.Tables[0].TableName = "AgeRange";
|
|||
|
rootDataset.Tables.Add(tempdataset.Tables[0].Copy());
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
throw new Exception(ex.Message);
|
|||
|
}
|
|||
|
|
|||
|
return rootDataset;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|