using System; using System.Data; using HRM.BO; using Ease.Core.DataAccess; namespace HRM.DA { internal class EmployeeCordinatorDA { public static void Insert(TransactionContext tc, int employeeID, int cordinatorid, bool timeRequest, int userid) { tc.ExecuteNonQuery(@"INSERT INTO EmployeeCordinator (EmployeeID, CordinatorID, ApproveTimeRequest, CreatedDate, CreatedBy) VALUES(%n, %n, %b, %D, %n);", employeeID, cordinatorid, timeRequest, DateTime.Now, userid); } public static void Update(TransactionContext tc, int employeeID, int linemanagerId, int? SecondLineManagerId) { tc.ExecuteNonQuery(@"UPDATE EmployeeCordinator SET CordinatorID = %n WHERE EmployeeID = %n", linemanagerId, employeeID); } public static void DeleteByCordinator(TransactionContext tc, int employeeID) { tc.ExecuteNonQuery(@"DELETE FROM EmployeeCordinator WHERE CordinatorID = %n", employeeID); } public static void Delete(TransactionContext tc, int empcordinatorID) { tc.ExecuteNonQuery(@"DELETE FROM EmployeeCordinator WHERE empCordinatorID = %n", empcordinatorID); } internal static IDataReader Get(TransactionContext tc, int cordinatorid) { return tc.ExecuteReader("SELECT c.*, e.EmployeeNo, e.Name EmployeeName FROM EmployeeCordinator c, Employee e WHERE " + "e.EmployeeId = c.Employeeid and c.CordinatorID = %n", cordinatorid); } internal static IDataReader Get(TransactionContext tc) { return tc.ExecuteReader("SELECT * FROM EmployeeCordinator"); } internal static DataTable GetCoordinatorList(TransactionContext tc) { return tc.ExecuteDataTable("select e.EMPLOYEEID, e.EMPLOYEENO employeeno, e.NAME name, a.total total from EMPLOYEE e inner join" + " (SELECT CordinatorID, Count(*) total FROM EmployeeCordinator group by CordinatorID ) a on " + " e.EMPLOYEEID = a.CordinatorID"); } } }