using HRM.BO; using Ease.Core.DataAccess; using System; using System.Data; using System.Text; namespace HRM.DA { internal class GroupDA { #region Constructor private GroupDA() { } #endregion #region Action Query internal static void Insert(TransactionContext tc, Grouping g) { tc.ExecuteNonQuery("INSERT INTO Grouping(GroupID, Name, Description, IsObjectGroup, ObjectGroupingID)" + " VALUES(%n, %s, %s, %b, %n)", g.ID, g.Name, g.Description, g.IsObjectGroup, g.ObjectGroupingID); } internal static void Update(TransactionContext tc, Grouping g) { tc.ExecuteNonQuery("UPDATE Grouping SET Name=%s, Description=%s, IsObjectGroup=%b, ObjectGroupingID=%n" + " WHERE GroupID=%n", g.Name, g.Description, g.IsObjectGroup, g.ObjectGroupingID, g.ID); } internal static void Delete(TransactionContext tc, int groupID) { tc.ExecuteNonQuery("DELETE FROM Grouping WHERE GroupID=%n", groupID); } #endregion #region Select Query internal static int GenID(TransactionContext tc) { return tc.GenerateID("Grouping", "GroupID"); } internal static IDataReader Get(TransactionContext tc, int groupID) { return tc.ExecuteReader("SELECT * FROM Grouping WHERE GroupID=%n", groupID); } internal static IDataReader Get(TransactionContext tc) { return tc.ExecuteReader("SELECT * FROM Grouping ORDER BY Name"); } internal static IDataReader Get(TransactionContext tc, bool isObjectGroup) { return tc.ExecuteReader("SELECT * FROM Grouping WHERE IsObjectGroup=%n ORDER BY Name", isObjectGroup); } internal static IDataReader GetByParent(TransactionContext tc, int parentID, bool isObjectGroup) { return tc.ExecuteReader( "SELECT * FROM Grouping WHERE ObjectGroupingID=%n AND IsObjectGroup=%n ORDER BY Name", parentID, isObjectGroup); } #endregion } }