126 lines
5.1 KiB
C#
126 lines
5.1 KiB
C#
using HRM.BO;
|
|
using Ease.Core.DataAccess;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
|
|
|
|
namespace HRM.DA
|
|
{
|
|
public class DelegateResponsibilityDA
|
|
{
|
|
#region Constructor
|
|
|
|
public DelegateResponsibilityDA()
|
|
{
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Insert function
|
|
|
|
public static void Insert(TransactionContext tc, DelegateResponsibility oItem)
|
|
{
|
|
tc.ExecuteNonQuery(
|
|
"INSERT INTO DelegateResponsibility(DelegateResponsibilityID, FromEmployeeID, ToEmployeeID, FromDate, ToDate, IsLeave, IsLoan, IsAttendance, IsAccepted,IsUnlimited,IsRead,Remarks,Status,AcceptDate, CreatedBy, CreationDate)" +
|
|
" VALUES(%n, %n, %n,%d, %d, %b, %b,%b,%b,%b,%b,%s,%b,%d, %n,%d)", oItem.ID, oItem.FromEmployeeID,
|
|
oItem.ToEmployeeID, oItem.FromDate, oItem.ToDate, oItem.IsLeave, oItem.IsLoan, oItem.IsAttendance,
|
|
oItem.IsAccepted, oItem.IsUnlimited, oItem.IsRead, oItem.Remarks, oItem.Status, oItem.AcceptDate,
|
|
oItem.CreatedBy, oItem.CreatedDate);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Update function
|
|
|
|
public static void Update(TransactionContext tc, DelegateResponsibility oItem)
|
|
{
|
|
tc.ExecuteNonQuery(
|
|
"UPDATE DelegateResponsibility SET FromEmployeeID=%n,ToEmployeeID=%n, FromDate=%d, ToDate=%d,AcceptDate=%d, IsLeave=%b,IsLoan=%b,IsAttendance=%b,IsAccepted=%b,IsUnlimited=%b,Remarks=%s,IsRead=%b,Status=%b, ModifiedBy=%n, ModifiedDate=%d" +
|
|
" WHERE DelegateResponsibilityID=%n", oItem.FromEmployeeID, oItem.ToEmployeeID, oItem.FromDate,
|
|
oItem.ToDate, oItem.AcceptDate, oItem.IsLeave, oItem.IsLoan, oItem.IsAttendance, oItem.IsAccepted,
|
|
oItem.IsUnlimited, oItem.Remarks, oItem.IsRead, oItem.Status, oItem.ModifiedBy, oItem.ModifiedDate,
|
|
oItem.ID);
|
|
}
|
|
|
|
internal static void UpdateReadStatus(TransactionContext tc, int objID, bool isRead)
|
|
{
|
|
tc.ExecuteNonQuery("UPDATE DelegateResponsibility SET IsRead=%b " +
|
|
" WHERE DelegateResponsibilityID=%n", isRead, objID);
|
|
}
|
|
|
|
internal static void UpdateStatus(TransactionContext tc, int objID, EnumStatus status)
|
|
{
|
|
tc.ExecuteNonQuery("UPDATE DelegateResponsibility SET Status=%n " +
|
|
" WHERE DelegateResponsibilityID=%n", (int)status, objID);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Get function
|
|
|
|
public static IDataReader GetWithPayrollType(TransactionContext tc, int payrollTypeID)
|
|
{
|
|
return tc.ExecuteReader(
|
|
"SELECT b.* FROM DelegateResponsibility b LEFT JOIN EMPLOYEE e ON e.EMPLOYEEID=b.EMPLOYEEID WHERE e.PAYROLLTYPEID=%n and e.status=%n ORDER BY e.EmployeeNo asc",
|
|
payrollTypeID, EnumStatus.Active);
|
|
}
|
|
|
|
internal static IDataReader GetByEmployeeID(TransactionContext tc, int empID)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM DelegateResponsibility where FromEmployeeID=%n and Status=%n", empID,
|
|
EnumStatus.Active);
|
|
}
|
|
|
|
internal static IDataReader GetByToEmployeeID(TransactionContext tc, int empID)
|
|
{
|
|
return tc.ExecuteReader(
|
|
"SELECT * FROM DelegateResponsibility where ToEmployeeID=%n and IsAccepted=%n AND Status=%n", empID, 1,
|
|
EnumStatus.Active);
|
|
}
|
|
|
|
internal static IDataReader Get(TransactionContext tc, int id)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM DelegateResponsibility where DelegateResponsibilityID=%n", id);
|
|
}
|
|
|
|
public static IDataReader Get(TransactionContext tc, int EmployeeID, int payrollTypeID)
|
|
{
|
|
return tc.ExecuteReader(
|
|
"SELECT b.* FROM DelegateResponsibility b LEFT JOIN EMPLOYEE e ON e.EMPLOYEEID=b.EMPLOYEEID WHERE b.EmployeeID =%n AND e.PAYROLLTYPEID=%n and e.status=%n",
|
|
EmployeeID, payrollTypeID, EnumStatus.Active);
|
|
}
|
|
|
|
public static IDataReader Get(TransactionContext tc, string ids, int payrollTypeID)
|
|
{
|
|
return tc.ExecuteReader(
|
|
"SELECT b.* FROM DelegateResponsibility b LEFT JOIN EMPLOYEE e ON e.EMPLOYEEID=b.EMPLOYEEID where b.EmployeeID in (%q) AND e.PAYROLLTYPEID=%n and e.status=%n",
|
|
ids, payrollTypeID, EnumStatus.Active);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Other function
|
|
|
|
public static bool IsExist(TransactionContext tc, int empId)
|
|
{
|
|
bool Exist = false;
|
|
Object obj = tc.ExecuteScalar("Select COUNT(*) FROM DelegateResponsibility WHERE EmployeeID=%n ", empId);
|
|
Exist = Convert.ToInt32(obj) > 0 ? true : false;
|
|
return Exist;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Delete Function
|
|
|
|
public static void Delete(TransactionContext tc, string empID)
|
|
{
|
|
string sSql = SQLParser.MakeSQL("Delete FROM DelegateResponsibility where EmployeeID in (%q)", empID);
|
|
tc.ExecuteNonQuery(sSql);
|
|
//return tc.ExecuteNonQuery(sSql);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
} |