using HRM.BO; using Ease.Core.DataAccess; using System; using System.Data; using System.Text; namespace HRM.DA { internal class RelationTableDA { #region Constructor public RelationTableDA() { } #endregion #region Action Query internal static void Insert(TransactionContext tc, RelationTable g) { tc.ExecuteNonQuery(@"INSERT INTO RelationTable(RelationTableId, RelationId, RelationName, MasterTableName, MasterColumn1Name,LinkTableName,LinkColumn1Name,JoinSql,LinkColumn2Name, LinkColumn3Name, LinkColumn4Name,MasterColumn2Name,MasterColumn3Name,MasterColumn4Name)" + " VALUES(%n,%n,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)", g.ID, g.RelationId, g.RelationName, g.MasterTableName , g.MasterColumn1Name, g.LinkTableName, g.LinkColumn1Name, g.JoinSql, g.LinkColumn2Name, g.LinkColumn3Name, g.LinkColumn4Name, g.MasterColumn2Name, g.MasterColumn3Name, g.MasterColumn4Name); } internal static void Update(TransactionContext tc, RelationTable g) { tc.ExecuteNonQuery(@"UPDATE RelationTable SET RelationId=%n, RelationName=%s, MasterTableName=%s, MasterColumn1Name=%s,LinkTableName=%s,LinkColumn1Name=%s,JoinSql=%s,LinkColumn2Name=%s, LinkColumn3Name=%s, LinkColumn4Name=%s,MasterColumn2Name=%s,MasterColumn3Name=%s,MasterColumn4Name=%s WHERE RelationTableID=%n", g.RelationId, g.RelationName, g.MasterTableName , g.MasterColumn1Name, g.LinkTableName, g.LinkColumn1Name, g.JoinSql, g.LinkColumn2Name, g.LinkColumn3Name, g.LinkColumn4Name, g.MasterColumn2Name, g.MasterColumn3Name, g.MasterColumn4Name, g.ID); } internal static void Delete(TransactionContext tc, int groupID) { tc.ExecuteNonQuery("DELETE FROM RelationTable WHERE RelationTableID=%n", groupID); } #endregion #region Select Query internal static int GenID(TransactionContext tc) { return tc.GenerateID("RelationTable", "RelationTableID"); } internal static IDataReader Get(TransactionContext tc, int groupID) { return tc.ExecuteReader("SELECT * FROM RelationTable WHERE RelationTableID=%n", groupID); } internal static IDataReader Get(TransactionContext tc) { return tc.ExecuteReader("SELECT * FROM RelationTable ORDER BY Name"); } internal static IDataReader Get(TransactionContext tc, bool isObjectGroup) { return tc.ExecuteReader("SELECT * FROM RelationTable WHERE IsObjectGroup=%n ORDER BY Name", isObjectGroup); } internal static IDataReader GetByParent(TransactionContext tc, int parentID, bool isObjectGroup) { return tc.ExecuteReader( "SELECT * FROM RelationTable WHERE ObjectRelationTableID=%n AND IsObjectGroup=%n ORDER BY Name", parentID, isObjectGroup); } #endregion } }