using System; using System.Collections.Generic; using System.Data; using System.Linq; using Kreta.Framework; using Kreta.Framework.Collections; using Kreta.Framework.Collections.Generic; using Kreta.Framework.Entities; using Kreta.Framework.Entities.Associations; using Kreta.Framework.Entities.Generic; namespace SDA.Kreta.Entities { internal sealed class CsoportTipus_FoglalkozasTipusDBHelper : EntityDBHelper { private Dictionary dynamicColumns = new Dictionary() { { "Csoportbontott", "T_CSOPORTTIPUS_FOGLALKOZASTIPU_OSSZES.C_CSOPORTBONTOTT" }, }; private const string dynamicQueryCommandText = "select " + "T_CSOPORTTIPUS_FOGLALKOZASTIPU_OSSZES.ID, " + "{COLUMNS}" + // CsoportTipus_FoglalkozasTipus betöltése // CsoportTipus_FoglalkozasTipus kapcsoló mezői "T_CSOPORTTIPUS_FOGLALKOZASTIPU_OSSZES.C_INTEZMENYID, " + /* Kötelező asszociációs kapcsolómező */ "T_CSOPORTTIPUS_FOGLALKOZASTIPU_OSSZES.C_TANEVID, " + /* Kötelező asszociációs kapcsolómező */ "T_CSOPORTTIPUS_FOGLALKOZASTIPU_OSSZES.C_CSOPORTTIPUSID, " + /* Asszociációs mező */ "T_CSOPORTTIPUS_FOGLALKOZASTIPU_OSSZES.C_FOGLALKOZASTIPUSID, " + /* Asszociációs mező */ "T_CSOPORTTIPUS_FOGLALKOZASTIPU_OSSZES.TOROLT, " + "T_CSOPORTTIPUS_FOGLALKOZASTIPU_OSSZES.SERIAL, " + "T_CSOPORTTIPUS_FOGLALKOZASTIPU_OSSZES.CREATED, " + "T_CSOPORTTIPUS_FOGLALKOZASTIPU_OSSZES.CREATOR, " + "T_CSOPORTTIPUS_FOGLALKOZASTIPU_OSSZES.LASTCHANGED, " + "T_CSOPORTTIPUS_FOGLALKOZASTIPU_OSSZES.MODIFIER " + "from " + "T_CSOPORTTIPUS_FOGLALKOZASTIPU_OSSZES " + "where " + "(1 = 1) "; private const string emptyQueryCommandText = "select " + "T_CSOPORTTIPUS_FOGLALKOZASTIPU_OSSZES.ID, " + // CsoportTipus_FoglalkozasTipus betöltése // CsoportTipus_FoglalkozasTipus mezői "T_CSOPORTTIPUS_FOGLALKOZASTIPU_OSSZES.C_CSOPORTBONTOTT, " + // CsoportTipus_FoglalkozasTipus kapcsoló mezői "T_CSOPORTTIPUS_FOGLALKOZASTIPU_OSSZES.C_INTEZMENYID, " + /* Kötelező asszociációs kapcsolómező */ "T_CSOPORTTIPUS_FOGLALKOZASTIPU_OSSZES.C_TANEVID, " + /* Kötelező asszociációs kapcsolómező */ "T_CSOPORTTIPUS_FOGLALKOZASTIPU_OSSZES.C_CSOPORTTIPUSID, " + /* Asszociációs mező */ "T_CSOPORTTIPUS_FOGLALKOZASTIPU_OSSZES.C_FOGLALKOZASTIPUSID, " + /* Asszociációs mező */ "T_CSOPORTTIPUS_FOGLALKOZASTIPU_OSSZES.TOROLT, " + "T_CSOPORTTIPUS_FOGLALKOZASTIPU_OSSZES.SERIAL, " + "T_CSOPORTTIPUS_FOGLALKOZASTIPU_OSSZES.CREATED, " + "T_CSOPORTTIPUS_FOGLALKOZASTIPU_OSSZES.CREATOR, " + "T_CSOPORTTIPUS_FOGLALKOZASTIPU_OSSZES.LASTCHANGED, " + "T_CSOPORTTIPUS_FOGLALKOZASTIPU_OSSZES.MODIFIER " + "from " + "T_CSOPORTTIPUS_FOGLALKOZASTIPU_OSSZES " + "where " + "(1 = 1) "; public override string EmptyQueryCommandText { get { return emptyQueryCommandText; } } public override string DynamicQueryCommandText { get { return dynamicQueryCommandText; } } public override IDictionary DynamicColumns { get { return dynamicColumns; } } protected override CsoportTipus_FoglalkozasTipus CreateEntityInstance() { return CsoportTipus_FoglalkozasTipus.GiveAnInstance(); } #region Lekérdezés public override void LoadEntityFields(CsoportTipus_FoglalkozasTipus entity, SDA.DataProvider.SDADataReader reader) { // CsoportTipus_FoglalkozasTipus betöltése // CsoportTipus_FoglalkozasTipus mezői entity.m_Csoportbontott = DAUtil.ReadBooleanAttribute(reader, 1); // CsoportTipus_FoglalkozasTipus kapcsoló mezői DAUtil.ReadIDAttribute(reader, 2, ref entity.m_IntezmenyId, 0); DAUtil.ReadIDAttribute(reader, 3, ref entity.m_TanevId, 0); DAUtil.ReadIDAttribute(reader, 4, ref entity.m_CsoportTipusId, 0); DAUtil.ReadIDAttribute(reader, 5, ref entity.m_FoglalkozasTipusId, 0); } public override void LoadEntityFields(CsoportTipus_FoglalkozasTipus entity, SDA.DataProvider.SDADataReader reader, ColumnFilterMode columnFilterMode, IEnumerable columns) { int index = 1; if (columns == null) { columns = new List(index); } // CsoportTipus_FoglalkozasTipus betöltése // CsoportTipus_FoglalkozasTipus mezői if (((columnFilterMode == ColumnFilterMode.DEFAULT_ALLOWED) ^ (columns.Contains("Csoportbontott")))) { entity.m_Csoportbontott = DAUtil.ReadBooleanAttribute(reader, index++); } // CsoportTipus_FoglalkozasTipus kapcsoló mezői DAUtil.ReadIDAttribute(reader, index++, ref entity.m_IntezmenyId, 0); DAUtil.ReadIDAttribute(reader, index++, ref entity.m_TanevId, 0); DAUtil.ReadIDAttribute(reader, index++, ref entity.m_CsoportTipusId, 0); DAUtil.ReadIDAttribute(reader, index++, ref entity.m_FoglalkozasTipusId, 0); } #endregion #region Paraméter kötés public override void BindAttributes(CsoportTipus_FoglalkozasTipus entity, SDA.DataProvider.SDACommand command) { DAUtil.BindParameter(command, "pCSOPORTBONTOTT", SDA.DataProvider.SDADBType.Boolean /* Boolean */, 1, entity.m_Csoportbontott, entity.m_Csoportbontott == null); } public override void DynamicBindAttributes(CsoportTipus_FoglalkozasTipus entity, SDA.DataProvider.SDACommand command) { System.Text.StringBuilder sb = new System.Text.StringBuilder(); if (entity.HasChanged("Csoportbontott")) { sb.Append("C_CSOPORTBONTOTT = :pCSOPORTBONTOTT,"); DAUtil.BindParameter(command, "pCSOPORTBONTOTT", SDA.DataProvider.SDADBType.Boolean /* Boolean */, 1, entity.m_Csoportbontott, entity.m_Csoportbontott == null); } command.CommandText = command.CommandText.Replace("{COLUMNS}", sb.ToString()); } public override void BindAssociations(CsoportTipus_FoglalkozasTipus entity, SDA.DataProvider.SDACommand command) { DAUtil.BindIdParameter(command, "pINTEZMENYID", entity.InternalIntezmenyId); DAUtil.BindIdParameter(command, "pTANEVID", entity.InternalTanevId); DAUtil.BindIdParameter(command, "pFOGLALKOZASTIPUSID", entity.FoglalkozasTipusId); DAUtil.BindIdParameter(command, "pCSOPORTTIPUSID", entity.CsoportTipusId); } #endregion } internal class CsoportTipus_FoglalkozasTipusDA : EntityDataAccessor { private static CsoportTipus_FoglalkozasTipusDBHelper m_dbhelper = new CsoportTipus_FoglalkozasTipusDBHelper(); protected override IEntityDBHelper dbhelper { get { return m_dbhelper; } } #region Load public override bool LoadEntity(CsoportTipus_FoglalkozasTipus entity, int entityId) { return LoadById(entity, entityId); } public override bool FilteredLoadEntity(CsoportTipus_FoglalkozasTipus entity, int entityId, ColumnFilterMode columnFilterMode, IEnumerable columns) { return LoadById(entity, entityId, columnFilterMode, columns); } public bool LoadById(CsoportTipus_FoglalkozasTipus entity, int entityId) { using (SDA.DataProvider.SDACommand command = dbhelper.CreateEmptyQueryCommand()) { command.CommandText += " and (T_CSOPORTTIPUS_FOGLALKOZASTIPU_OSSZES.ID = :pID) "; command.Parameters.Add("pID", SDA.DataProvider.SDADBType.Int).Value = entityId; return dbhelper.LoadSingleEntity(entity, command); } } public bool LoadById(CsoportTipus_FoglalkozasTipus entity, int entityId, ColumnFilterMode columnFilterMode, IEnumerable columns) { using (SDA.DataProvider.SDACommand command = dbhelper.CreateDynamicQueryCommand(columnFilterMode, columns)) { command.CommandText += " and (T_CSOPORTTIPUS_FOGLALKOZASTIPU_OSSZES.ID = :pID) "; command.Parameters.Add("pID", SDA.DataProvider.SDADBType.Int).Value = entityId; return dbhelper.LoadSingleEntity(entity, command, columnFilterMode, columns); } } [Obsolete("Ezt ne használjátok, mert mindenhova bele kellene fogalmazni a tanév szűrést is! Meg fog majd szűnni!")] public override void LoadWithFilter(IEntityCollection collection, string filter, Dictionary commandParameters = null) { using (SDA.DataProvider.SDACommand command = dbhelper.CreateEmptyQueryCommand()) { command.CommandText += filter; dbhelper.CreateParameterBinding(command, commandParameters); dbhelper.LoadEntityCollection(collection, command); } } [Obsolete("Ezt ne használjátok, mert mindenhova bele kellene fogalmazni a tanév szűrést is! Meg fog majd szűnni!")] public override void LoadWithFilter(IEntityCollection collection, string filter, ColumnFilterMode columnFilterMode, IEnumerable columns, Dictionary commandParameters = null) { using (SDA.DataProvider.SDACommand command = dbhelper.CreateDynamicQueryCommand(columnFilterMode, columns)) { command.CommandText += filter; dbhelper.CreateParameterBinding(command, commandParameters); dbhelper.LoadEntityCollection(collection, command, columnFilterMode, columns); } } #endregion #region InsertEntity private const string m_InsertCommandText = @" insert into T_CSOPORTTIPUS_FOGLALKOZASTIPU_OSSZES ( C_CSOPORTBONTOTT, C_INTEZMENYID, C_TANEVID, C_FOGLALKOZASTIPUSID, C_CSOPORTTIPUSID, TOROLT, SERIAL, CREATED, CREATOR) values ( :pCSOPORTBONTOTT, :pINTEZMENYID, :pTANEVID, :pFOGLALKOZASTIPUSID, :pCSOPORTTIPUSID, :pTOROLT, :pSERIAL, :pCREATED, :pCREATOR); SELECT SCOPE_IDENTITY() as ID; "; public override void InsertEntity(CsoportTipus_FoglalkozasTipus entity) { entity.Serial = 0; SetEntityCreator(entity, DateTime.Now, UserContext.Instance.UniqueIdentifier); using (SDA.DataProvider.SDACommand command = DAUtil.CreateCommand(m_InsertCommandText)) { dbhelper.BindAttributes(entity, command); dbhelper.BindAssociations(entity, command); command.Parameters.Add("pTOROLT", SDA.DataProvider.SDADBType.Boolean /* Boolean */).Value = false; command.Parameters.Add("pSERIAL", SDA.DataProvider.SDADBType.Int).Value = 0; command.Parameters.Add("pCREATED", SDA.DataProvider.SDADBType.DateTime).Value = entity.EntityCreated; command.Parameters.Add("pCREATOR", SDA.DataProvider.SDADBType.Int).Value = entity.EntityCreator; entity.ID = Convert.ToInt32(command.ExecuteScalar()); } } #endregion #region UpdateEntity private const string m_UpdateAttributesCommandText = @" update T_CSOPORTTIPUS_FOGLALKOZASTIPU_OSSZES set {COLUMNS} SERIAL = ISNULL(SERIAL,0) + 1, LASTCHANGED = :pLASTCHANGED, MODIFIER = :pMODIFIER, TOROLT = :pTOROLT where (ID = :pID) and (ISNULL(SERIAL,0) = :pSERIAL) "; public override bool UpdateEntity(CsoportTipus_FoglalkozasTipus entity) { using (SDA.DataProvider.SDACommand command = DAUtil.CreateCommand(m_UpdateAttributesCommandText)) { bool result = true; dbhelper.DynamicBindAttributes(entity, command); SetEntityModifier(entity, DateTime.Now, UserContext.Instance.UniqueIdentifier); command.Parameters.Add("pID", SDA.DataProvider.SDADBType.Int).Value = entity.ID; command.Parameters.Add("pSERIAL", SDA.DataProvider.SDADBType.Int).Value = entity.Serial; command.Parameters.Add("pLASTCHANGED", SDA.DataProvider.SDADBType.DateTime).Value = entity.EntityLastChanged; command.Parameters.Add("pMODIFIER", SDA.DataProvider.SDADBType.Int).Value = entity.EntityModifier; command.Parameters.Add("pTOROLT", SDA.DataProvider.SDADBType.Boolean /* Boolean */).Value = entity.Torolt; result = (command.ExecuteNonQuery() == 1); if (result == true) entity.Serial++; return result; } } #endregion #region DeleteEntity private const string m_FizikaiDeleteCommandText = @"DELETE FROM T_CSOPORTTIPUS_FOGLALKOZASTIPU_OSSZES WHERE (ID = :pID) "; private const string m_LogikaiDeleteCommandText = @" UPDATE T_CSOPORTTIPUS_FOGLALKOZASTIPU_OSSZES SET TOROLT = 'T' , SERIAL = SERIAL + 1, LASTCHANGED = :pLASTCHANGED, MODIFIER = :pMODIFIER WHERE (ID = :pID) "; public override void DeleteEntity(CsoportTipus_FoglalkozasTipus entity, bool logikai = true) { var _deleteCommandText = logikai ? m_LogikaiDeleteCommandText : m_FizikaiDeleteCommandText; using (SDA.DataProvider.SDACommand command = DAUtil.CreateCommand(_deleteCommandText)) { command.Parameters.Add("pID", SDA.DataProvider.SDADBType.Int).Value = entity.ID; if (logikai) { DateTime lastchanged = DateTime.Now; var modifier = UserContext.Instance.UniqueIdentifier; command.Parameters.Add("pLASTCHANGED", SDA.DataProvider.SDADBType.DateTime).Value = lastchanged; command.Parameters.Add("pMODIFIER", SDA.DataProvider.SDADBType.Int).Value = modifier; } if (command.ExecuteNonQuery() != 1) { throw new EntityNotFoundException("CsoportTipus_FoglalkozasTipus", entity.ID); } } } private const string m_DeleteByCsoportTipusAndFoglalkozasTipusCommandText = @" delete from T_CSOPORTTIPUS_FOGLALKOZASTIPU_OSSZES where (C_CSOPORTTIPUSID = :pCSOPORTTIPUSID) and (C_FOGLALKOZASTIPUSID = :pFOGLALKOZASTIPUSID) "; public void DeleteByCsoportTipusAndFoglalkozasTipus(int CsoportTipusId, int FoglalkozasTipusId) { using (SDA.DataProvider.SDACommand command = DAUtil.CreateCommand(m_DeleteByCsoportTipusAndFoglalkozasTipusCommandText)) { command.Parameters.Add("pCSOPORTTIPUSID", SDA.DataProvider.SDADBType.Int).Value = CsoportTipusId; command.Parameters.Add("pFOGLALKOZASTIPUSID", SDA.DataProvider.SDADBType.Int).Value = FoglalkozasTipusId; command.ExecuteNonQuery(); } } #endregion #region UpdateAssociations private const string m_UpdateAssociationCommandText = @" update T_CSOPORTTIPUS_FOGLALKOZASTIPU_OSSZES set C_INTEZMENYID = :pINTEZMENYID, C_TANEVID = :pTANEVID, C_FOGLALKOZASTIPUSID = :pFOGLALKOZASTIPUSID, C_CSOPORTTIPUSID = :pCSOPORTTIPUSID, SERIAL = ISNULL(SERIAL,0) + 1, LASTCHANGED = :pLASTCHANGED, MODIFIER = :pMODIFIER where (ID = :pID) and (ISNULL(SERIAL,0) = :pSERIAL) "; public override bool UpdateAssociations(CsoportTipus_FoglalkozasTipus entity) { using (SDA.DataProvider.SDACommand command = DAUtil.CreateCommand(m_UpdateAssociationCommandText)) { dbhelper.BindAssociations(entity, command); DateTime lastchanged = DateTime.Now; var modifier = UserContext.Instance.UniqueIdentifier; command.Parameters.Add("pID", SDA.DataProvider.SDADBType.Int).Value = entity.ID; command.Parameters.Add("pSERIAL", SDA.DataProvider.SDADBType.Int).Value = entity.Serial; command.Parameters.Add("pLASTCHANGED", SDA.DataProvider.SDADBType.DateTime).Value = lastchanged; command.Parameters.Add("pMODIFIER", SDA.DataProvider.SDADBType.Int).Value = modifier; bool result = (command.ExecuteNonQuery() == 1); if (result == true) { entity.Serial++; SetEntityModifier(entity, lastchanged, modifier); } return result; } } #endregion #region Asszociációkkal kapcsolatos adatbázisműveletek (entitásspecifikus) #region Mint asszociációs osztály #endregion public bool LoadByCsoportTipus(CsoportTipus start, FoglalkozasTipus end, CsoportTipus_FoglalkozasTipus entity) { using (SDA.DataProvider.SDACommand command = dbhelper.CreateEmptyQueryCommand()) { command.CommandText += @" and (C_CSOPORTTIPUSID = :pCSOPORTTIPUSID) and (C_FOGLALKOZASTIPUSID = :pFOGLALKOZASTIPUSID) "; command.Parameters.Add("pCSOPORTTIPUSID", SDA.DataProvider.SDADBType.Int).Value = start.ID; command.Parameters.Add("pFOGLALKOZASTIPUSID", SDA.DataProvider.SDADBType.Int).Value = end.ID; return dbhelper.LoadSingleEntity(entity, command); // EntityDA.tdl 457 } } public bool LoadByFoglalkozasTipus(FoglalkozasTipus start, CsoportTipus end, CsoportTipus_FoglalkozasTipus entity) { return this.LoadByCsoportTipus(end, start, entity); } #endregion } internal class FoglalkozasTipus_CsoportTipus_DA : EntityCollectionDA { internal protected FoglalkozasTipus_CsoportTipus_DA(FoglalkozasTipus owner) : base(owner) { } private const string m_Filter = @" and (T_CSOPORTTIPUS_FOGLALKOZASTIPU_OSSZES.C_FOGLALKOZASTIPUSID = :pID) "; public override void LoadCollection(IAssociatedEntityCollection collection) { new CsoportTipus_FoglalkozasTipusDBHelper().LoadByPartnerId(collection, m_Filter, Owner.ID); } public override void AddItem(CsoportTipus_FoglalkozasTipus entity) { entity.FoglalkozasTipusId = Owner.ID; var assochandler = AssociationHandlerManager.Create("CsoportTipus_FoglalkozasTipus"); assochandler.BeforeInsert(entity.CsoportTipus, entity.FoglalkozasTipus); entity.Insert(true); assochandler.AfterInsert(entity.CsoportTipus, entity.FoglalkozasTipus); } public override void DeleteItem(CsoportTipus_FoglalkozasTipus entity) { var assochandler = AssociationHandlerManager.Create("CsoportTipus_FoglalkozasTipus"); assochandler.BeforeDelete(entity.CsoportTipus, entity.FoglalkozasTipus); entity.Delete(true); // egyszeruen töröljük az asszociációs osztályt assochandler.AfterDelete(entity.CsoportTipus, entity.FoglalkozasTipus); } } internal class CsoportTipus_FoglalkozasTipus_DA : EntityCollectionDA { internal protected CsoportTipus_FoglalkozasTipus_DA(CsoportTipus owner) : base(owner) { } private const string m_Filter = @" and (T_CSOPORTTIPUS_FOGLALKOZASTIPU_OSSZES.C_CSOPORTTIPUSID = :pID) "; public override void LoadCollection(IAssociatedEntityCollection collection) { new CsoportTipus_FoglalkozasTipusDBHelper().LoadByPartnerId(collection, m_Filter, Owner.ID); } public override void AddItem(CsoportTipus_FoglalkozasTipus entity) { entity.CsoportTipusId = Owner.ID; var assochandler = AssociationHandlerManager.Create("CsoportTipus_FoglalkozasTipus"); assochandler.BeforeInsert(entity.CsoportTipus, entity.FoglalkozasTipus); entity.Insert(true); assochandler.AfterInsert(entity.CsoportTipus, entity.FoglalkozasTipus); } public override void DeleteItem(CsoportTipus_FoglalkozasTipus entity) { var assochandler = AssociationHandlerManager.Create("CsoportTipus_FoglalkozasTipus"); assochandler.BeforeDelete(entity.CsoportTipus, entity.FoglalkozasTipus); entity.Delete(true); // egyszeruen töröljük az asszociációs osztályt assochandler.AfterDelete(entity.CsoportTipus, entity.FoglalkozasTipus); } } /// /// Az osztály elvégzi az UML modell 'Intezmeny -> CsoportTipus_FoglalkozasTipus (CsoportTipus_FoglalkozasTipus)' /// asszociációjának teljes kezelését. /// internal class Intezmeny_CsoportTipus_FoglalkozasTipus_DA : EntityCollectionDA { internal protected Intezmeny_CsoportTipus_FoglalkozasTipus_DA(Intezmeny owner) : base(owner) { } // Nincs kapcsolótábla private const string m_Filter = @" and (T_CSOPORTTIPUS_FOGLALKOZASTIPU_OSSZES.C_INTEZMENYID = :pID) "; public override void LoadCollection(IAssociatedEntityCollection collection) { new CsoportTipus_FoglalkozasTipusDBHelper().LoadByPartnerId(collection, m_Filter, Owner.ID); } private static SDA.DataProvider.SDACommand CreateInsertCsoportTipus_FoglalkozasTipusCommand() { SDA.DataProvider.SDACommand result = new SDA.DataProvider.SDACommand(); // nincs kapcsolótábla... result.CommandText = @"update T_CSOPORTTIPUS_FOGLALKOZASTIPU_OSSZES set C_INTEZMENYID = :pINTEZMENYID where (ID = :pCSOPORTTIPUS_FOGLALKOZASTIPUS)"; result.Parameters.Add("pINTEZMENYID", SDA.DataProvider.SDADBType.Int); result.Parameters.Add("pCSOPORTTIPUS_FOGLALKOZASTIPUS", SDA.DataProvider.SDADBType.Int); return result; } private void DoAdd(Intezmeny owner, CsoportTipus_FoglalkozasTipus partner) { using (SDA.DataProvider.SDACommand command = CreateInsertCsoportTipus_FoglalkozasTipusCommand()) { command.Connection = UserContext.Instance.SDAConnection; command.Transaction = UserContext.Instance.SDATransaction; command.Parameters["pINTEZMENYID"].Value = owner.ID; command.Parameters["pCSOPORTTIPUS_FOGLALKOZASTIPUS"].Value = partner.ID; command.ExecuteNonQuery(); } } public override void AddItem(CsoportTipus_FoglalkozasTipus entity) { var assochandler = AssociationHandlerManager.Create("CsoportTipus_FoglalkozasTipus_Intezmeny"); assochandler.BeforeInsert(entity, this.Owner); entity.ModifyIntezmeny(this.Owner); if (entity.State == EntityState.Modified) { entity.UpdateAssociations(true); } else { entity.Insert(true); } assochandler.AfterInsert(entity, this.Owner); } private static SDA.DataProvider.SDACommand CreateDeleteCsoportTipus_FoglalkozasTipusCommand() { SDA.DataProvider.SDACommand result = new SDA.DataProvider.SDACommand(); // nincs kapcsolótábla... result.CommandText = @"update T_CSOPORTTIPUS_FOGLALKOZASTIPU_OSSZES set C_INTEZMENYID = null where (C_INTEZMENYID = :pINTEZMENYID and ID = :pCSOPORTTIPUS_FOGLALKOZASTIPUS)"; result.Parameters.Add("pINTEZMENYID", SDA.DataProvider.SDADBType.Int); result.Parameters.Add("pCSOPORTTIPUS_FOGLALKOZASTIPUS", SDA.DataProvider.SDADBType.Int); return result; } private void DoRemove(Intezmeny owner, CsoportTipus_FoglalkozasTipus partner) { using (SDA.DataProvider.SDACommand command = CreateDeleteCsoportTipus_FoglalkozasTipusCommand()) { command.Connection = UserContext.Instance.SDAConnection; command.Transaction = UserContext.Instance.SDATransaction; command.Parameters["pINTEZMENYID"].Value = owner.ID; command.Parameters["pCSOPORTTIPUS_FOGLALKOZASTIPUS"].Value = partner.ID; command.ExecuteNonQuery(); } } public override void DeleteItem(CsoportTipus_FoglalkozasTipus entity) { var assochandler = AssociationHandlerManager.Create("CsoportTipus_FoglalkozasTipus_Intezmeny"); assochandler.BeforeDelete(entity, this.Owner); entity.Delete(true); assochandler.AfterDelete(entity, this.Owner); } } /// /// Az osztály elvégzi az UML modell 'Tanev -> CsoportTipus_FoglalkozasTipus (CsoportTipus_FoglalkozasTipus)' /// asszociációjának teljes kezelését. /// internal class Tanev_CsoportTipus_FoglalkozasTipus_DA : EntityCollectionDA { internal protected Tanev_CsoportTipus_FoglalkozasTipus_DA(Tanev owner) : base(owner) { } // Nincs kapcsolótábla private const string m_Filter = @" and (T_CSOPORTTIPUS_FOGLALKOZASTIPU_OSSZES.C_TANEVID = :pID) "; public override void LoadCollection(IAssociatedEntityCollection collection) { new CsoportTipus_FoglalkozasTipusDBHelper().LoadByPartnerId(collection, m_Filter, Owner.ID); } private static SDA.DataProvider.SDACommand CreateInsertCsoportTipus_FoglalkozasTipusCommand() { SDA.DataProvider.SDACommand result = new SDA.DataProvider.SDACommand(); // nincs kapcsolótábla... result.CommandText = @"update T_CSOPORTTIPUS_FOGLALKOZASTIPU_OSSZES set C_TANEVID = :pTANEVID where (ID = :pCSOPORTTIPUS_FOGLALKOZASTIPUS)"; result.Parameters.Add("pTANEVID", SDA.DataProvider.SDADBType.Int); result.Parameters.Add("pCSOPORTTIPUS_FOGLALKOZASTIPUS", SDA.DataProvider.SDADBType.Int); return result; } private void DoAdd(Tanev owner, CsoportTipus_FoglalkozasTipus partner) { using (SDA.DataProvider.SDACommand command = CreateInsertCsoportTipus_FoglalkozasTipusCommand()) { command.Connection = UserContext.Instance.SDAConnection; command.Transaction = UserContext.Instance.SDATransaction; command.Parameters["pTANEVID"].Value = owner.ID; command.Parameters["pCSOPORTTIPUS_FOGLALKOZASTIPUS"].Value = partner.ID; command.ExecuteNonQuery(); } } public override void AddItem(CsoportTipus_FoglalkozasTipus entity) { var assochandler = AssociationHandlerManager.Create("CsoportTipus_FoglalkozasTipus_Tanev"); assochandler.BeforeInsert(entity, this.Owner); entity.ModifyTanev(this.Owner); if (entity.State == EntityState.Modified) { entity.UpdateAssociations(true); } else { entity.Insert(true); } assochandler.AfterInsert(entity, this.Owner); } private static SDA.DataProvider.SDACommand CreateDeleteCsoportTipus_FoglalkozasTipusCommand() { SDA.DataProvider.SDACommand result = new SDA.DataProvider.SDACommand(); // nincs kapcsolótábla... result.CommandText = @"update T_CSOPORTTIPUS_FOGLALKOZASTIPU_OSSZES set C_TANEVID = null where (C_TANEVID = :pTANEVID and ID = :pCSOPORTTIPUS_FOGLALKOZASTIPUS)"; result.Parameters.Add("pTANEVID", SDA.DataProvider.SDADBType.Int); result.Parameters.Add("pCSOPORTTIPUS_FOGLALKOZASTIPUS", SDA.DataProvider.SDADBType.Int); return result; } private void DoRemove(Tanev owner, CsoportTipus_FoglalkozasTipus partner) { using (SDA.DataProvider.SDACommand command = CreateDeleteCsoportTipus_FoglalkozasTipusCommand()) { command.Connection = UserContext.Instance.SDAConnection; command.Transaction = UserContext.Instance.SDATransaction; command.Parameters["pTANEVID"].Value = owner.ID; command.Parameters["pCSOPORTTIPUS_FOGLALKOZASTIPUS"].Value = partner.ID; command.ExecuteNonQuery(); } } public override void DeleteItem(CsoportTipus_FoglalkozasTipus entity) { var assochandler = AssociationHandlerManager.Create("CsoportTipus_FoglalkozasTipus_Tanev"); assochandler.BeforeDelete(entity, this.Owner); entity.Delete(true); assochandler.AfterDelete(entity, this.Owner); } } }