using HRM.BO; using Ease.Core.DataAccess; using System; using System.Data; namespace HRM.DA { #region FunctionDA internal class FunctionDA { #region Constructor private FunctionDA() { } #endregion #region Insert function internal static void Insert(TransactionContext tc, Function item) { tc.ExecuteNonQuery( "INSERT INTO [Function] (FunctionID, code, description, CreatedBy, CreatedDate, SequenceNo, Status)" + " VALUES(%n, %s, %s, %n, %d, %n, %n)", item.ID, item.Code, item.Name, item.CreatedBy, item.CreatedDate, item.Sequence, item.Status); } #endregion #region Update Function internal static void Update(TransactionContext tc, Function item) { tc.ExecuteNonQuery( "UPDATE [Function] SET code=%s, description=%s, ModifiedBy=%n, ModifiedDate=%d, SequenceNo=%n, Status=%n" + " WHERE FunctionID=%n", item.Code, item.Name, item.ModifiedBy, item.ModifiedDate, item.Sequence, item.Status, item.ID); } #endregion #region Get Function internal static IDataReader Get(TransactionContext tc, EnumStatus status) { if (EnumStatus.Active == status || EnumStatus.Inactive == status) { return tc.ExecuteReader("SELECT * FROM [Function] where Status=%n Order By SequenceNo", status); } else { return tc.ExecuteReader("SELECT * FROM [Function] Order By SequenceNo"); } } internal static IDataReader Get(TransactionContext tc, int id) { return tc.ExecuteReader("SELECT * FROM [Function] WHERE FunctionID=%n", id); } internal static IDataReader Get(TransactionContext tc, string sCode) { return tc.ExecuteReader("SELECT * FROM [Function] WHERE Code=%s", sCode); } #endregion #region Delete Function internal static void Delete(TransactionContext tc, int id, int UserID) { tc.ExecuteNonQuery("UPDATE [Function] SET CreatedBy=%n,ModifiedBy=%n Where FunctionID=%n", UserID, UserID, id); tc.ExecuteNonQuery("DELETE FROM [Function] WHERE FunctionID=%n", id); } #endregion } #endregion }