using System; using System.Data; using Ease.Core.DataAccess; using HRM.BO; namespace HRM.DA { public class ComponentUploadSetupDA { #region Constructor public ComponentUploadSetupDA() { } #endregion #region Insert function public static void Insert(TransactionContext tc, ComponentUploadSetup oItem) { tc.ExecuteNonQuery( "INSERT INTO ComponentUploadSetup(ComponentUploadSetupID, EmployeeID, ComponentType, ItemID, Description)" + " VALUES(%n, %n, %n,%n, %s)", oItem.ID, oItem.EmployeeID, (EnumComponentType)oItem.ComponentType, oItem.ItemID, oItem.Description); } #endregion #region Update function public static void Update(TransactionContext tc, ComponentUploadSetup oItem) { tc.ExecuteNonQuery( "UPDATE ComponentUploadSetup SET EmployeeID=%n, ComponentType=%n,ItemID=%n, Description=%s" + " WHERE ComponentUploadSetupID=%n", oItem.EmployeeID, (EnumComponentType)oItem.ComponentType, oItem.ItemID, oItem.Description, oItem.ID); } #endregion #region Get function public static IDataReader Get(TransactionContext tc) { return tc.ExecuteReader("SELECT * FROM ComponentUploadSetup ORDER BY EmployeeID"); } public static IDataReader Get(TransactionContext tc, int empid) { return tc.ExecuteReader("SELECT * FROM ComponentUploadSetup WHERE EmployeeID=%n", empid); //return tc.ExecuteReader("SELECT DISTinct EmployeeID, PropductSerial= STUFF((SELECT ', ' + DESCRIPTION From ComponentUploadSetup WHERE employeeid = c.EmployeeID FOR XML PATH(''), TYPE).value('.', 'NVARCHAR(MAX)'), 1, 1, '') From ComponentUploadSetup c where c.employeeid =%n", empid); } #endregion #region Delete function public static void Delete(TransactionContext tc, int id) { tc.ExecuteNonQuery("DELETE FROM ComponentUploadSetup WHERE ComponentUploadSetupID=%n", id); } public static bool IsExist(TransactionContext tc, int empId, EnumComponentType ComponentType, int itemId) { bool Exist = false; Object obj = tc.ExecuteScalar( "Select COUNT (*) FROM ComponentUploadSetup WHERE EmployeeID=%n AND COMPONENTTYPE=%n AND ItemID=%n", empId, ComponentType, itemId); Exist = Convert.ToInt32(obj) > 0 ? true : false; return Exist; } #endregion } }