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

89 lines
3.1 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
{
public class EmployeeShortLeaveDA
{
#region Constructor
public EmployeeShortLeaveDA() { }
#endregion
#region Insert function
public static void Insert(TransactionContext tc, EmployeeShortLeave oItem)
{
tc.ExecuteNonQuery("INSERT INTO ShortLeave(ShortLeaveID, EmployeeID, DESCRIPTION, FromDate, ToDate, ShortLeaveType, WillReturn)" +
" VALUES(%n, %n, %s,%D,%D,%n,%n)", oItem.ID.Integer, oItem.EmployeeID, oItem.Description, oItem.FromDate, oItem.ToDate, oItem.ShortLeaveType, oItem.WillReturn);
}
#endregion
#region Update function
public static void Update(TransactionContext tc, EmployeeShortLeave oItem)
{
tc.ExecuteNonQuery("UPDATE ShortLeave SET EmployeeID=%n, Description=%s,FromDate=%D,ToDate=%D,ShortLeaveType=%n,WillReturn=%n" +
" WHERE ShortLeaveID=%n", oItem.EmployeeID, oItem.Description, oItem.FromDate, oItem.ToDate, oItem.ShortLeaveType, oItem.WillReturn, oItem.ID.Integer);
}
#endregion
#region Get function
public static IDataReader Get(TransactionContext tc)
{
return tc.ExecuteReader("SELECT * FROM ShortLeave ORDER BY ShortLeaveID");
}
public static IDataReader Get(TransactionContext tc, int sLeaveID)
{
return tc.ExecuteReader("SELECT * FROM ShortLeave WHERE ShortLeaveID=%n", sLeaveID);
}
public static IDataReader GetByType(TransactionContext tc, int sLType)
{
return tc.ExecuteReader("SELECT * FROM ShortLeave WHERE ShortLeaveType=%n", sLType);
}
public static IDataReader GetByEmpID(TransactionContext tc, int employeeID)
{
return tc.ExecuteReader("SELECT * FROM ShortLeave WHERE EmployeeID=%n", employeeID);
}
public static IDataReader GetByEmp(TransactionContext tc, int employeeID)
{
return tc.ExecuteReader("SELECT * FROM ShortLeave WHERE EmployeeID=%n", employeeID);
}
public static DataSet GetEmployeeWiseShortLeaveReport(TransactionContext tc, int employeeID)
{
string query = string.Empty;
DataSet dataSet = null;
query = "SELECT e.[NAME] EmployeeName, e.EMPLOYEENO EmployeeNo, d.[NAME] Designation, sl.* "
+ "FROM ShortLeave sl INNER JOIN EMPLOYEE e ON e.EMPLOYEEID = sl.EmployeeID INNER JOIN DESIGNATION d ON d.DESIGNATIONID = e.DESIGNATIONID"
+ "WHERE sl.EmployeeID=%d";
dataSet = tc.ExecuteDataSet(query, employeeID);
return dataSet;
}
#endregion
#region Delete function
public static void Delete(TransactionContext tc, int sLeaveID)
{
tc.ExecuteNonQuery("DELETE FROM ShortLeave WHERE ShortLeaveID=%n", sLeaveID);
}
#endregion
}
}