724 lines
29 KiB
C#
724 lines
29 KiB
C#
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 ErtesitesDBHelper : EntityDBHelper<Ertesites>
|
|
{
|
|
private Dictionary<string, string> dynamicColumns = new Dictionary<string, string>()
|
|
{
|
|
{ "ErvenyessegKezdete", "T_ERTESITES_OSSZES.C_ERVENYESSEGKEZDETE" },
|
|
{ "LetrehozasDatum", "T_ERTESITES_OSSZES.C_LETREHOZASDATUM" },
|
|
{ "NavigalasParameter", "T_ERTESITES_OSSZES.C_NAVIGALASPARAMETER" },
|
|
{ "SzinTipus", "T_ERTESITES_OSSZES.C_SZINTIPUS" },
|
|
{ "Tipus", "T_ERTESITES_OSSZES.C_TIPUS" },
|
|
{ "Torolheto", "T_ERTESITES_OSSZES.C_TOROLHETO" },
|
|
{ "Uzenet", "T_ERTESITES_OSSZES.C_UZENET" },
|
|
{ "Globalis", "T_ERTESITES_OSSZES.C_GLOBALIS" },
|
|
{ "GlobalisErvenyessegVege", "T_ERTESITES_OSSZES.C_GLOBALISERVENYESSEGVEGE" },
|
|
};
|
|
|
|
private const string dynamicQueryCommandText =
|
|
"select " +
|
|
"T_ERTESITES_OSSZES.ID, " +
|
|
"{COLUMNS}" +
|
|
// Ertesites betöltése
|
|
// Ertesites kapcsoló mezői
|
|
"T_ERTESITES_OSSZES.C_INTEZMENYID, " + /* Kötelező asszociációs kapcsolómező */
|
|
"T_ERTESITES_OSSZES.C_TANEVID, " + /* Kötelező asszociációs kapcsolómező */
|
|
"T_ERTESITES_OSSZES.TOROLT, " +
|
|
"T_ERTESITES_OSSZES.SERIAL, " +
|
|
"T_ERTESITES_OSSZES.CREATED, " +
|
|
"T_ERTESITES_OSSZES.CREATOR, " +
|
|
"T_ERTESITES_OSSZES.LASTCHANGED, " +
|
|
"T_ERTESITES_OSSZES.MODIFIER " +
|
|
"from " +
|
|
"T_ERTESITES_OSSZES " +
|
|
"where " +
|
|
"(1 = 1) ";
|
|
|
|
private const string emptyQueryCommandText =
|
|
"select " +
|
|
"T_ERTESITES_OSSZES.ID, " +
|
|
// Ertesites betöltése
|
|
// Ertesites mezői
|
|
"T_ERTESITES_OSSZES.C_ERVENYESSEGKEZDETE, " +
|
|
"T_ERTESITES_OSSZES.C_LETREHOZASDATUM, " +
|
|
"T_ERTESITES_OSSZES.C_NAVIGALASPARAMETER, " +
|
|
"T_ERTESITES_OSSZES.C_SZINTIPUS, " +
|
|
"T_ERTESITES_OSSZES.C_TIPUS, " +
|
|
"T_ERTESITES_OSSZES.C_TOROLHETO, " +
|
|
"T_ERTESITES_OSSZES.C_UZENET, " +
|
|
"T_ERTESITES_OSSZES.C_GLOBALIS, " +
|
|
"T_ERTESITES_OSSZES.C_GLOBALISERVENYESSEGVEGE, " +
|
|
// Ertesites kapcsoló mezői
|
|
"T_ERTESITES_OSSZES.C_INTEZMENYID, " + /* Kötelező asszociációs kapcsolómező */
|
|
"T_ERTESITES_OSSZES.C_TANEVID, " + /* Kötelező asszociációs kapcsolómező */
|
|
"T_ERTESITES_OSSZES.TOROLT, " +
|
|
"T_ERTESITES_OSSZES.SERIAL, " +
|
|
"T_ERTESITES_OSSZES.CREATED, " +
|
|
"T_ERTESITES_OSSZES.CREATOR, " +
|
|
"T_ERTESITES_OSSZES.LASTCHANGED, " +
|
|
"T_ERTESITES_OSSZES.MODIFIER " +
|
|
"from " +
|
|
"T_ERTESITES_OSSZES " +
|
|
"where " +
|
|
"(1 = 1) ";
|
|
|
|
public override string EmptyQueryCommandText
|
|
{
|
|
get
|
|
{
|
|
return emptyQueryCommandText;
|
|
}
|
|
}
|
|
|
|
public override string DynamicQueryCommandText
|
|
{
|
|
get
|
|
{
|
|
return dynamicQueryCommandText;
|
|
}
|
|
}
|
|
|
|
public override IDictionary<string, string> DynamicColumns
|
|
{
|
|
get
|
|
{
|
|
return dynamicColumns;
|
|
}
|
|
}
|
|
|
|
protected override Ertesites CreateEntityInstance()
|
|
{
|
|
return Ertesites.GiveAnInstance();
|
|
}
|
|
|
|
#region Lekérdezés
|
|
|
|
public override void LoadEntityFields(Ertesites entity, SDA.DataProvider.SDADataReader reader)
|
|
{
|
|
// Ertesites betöltése
|
|
// Ertesites mezői
|
|
|
|
entity.m_ErvenyessegKezdete = DAUtil.ReadDateTimeAttribute(reader, 1, DateTime.Now /* XXX DateTime */);
|
|
|
|
|
|
entity.m_LetrehozasDatum = DAUtil.ReadDateTimeAttribute(reader, 2, DateTime.Now /* XXX DateTime */);
|
|
|
|
|
|
entity.m_NavigalasParameter = DAUtil.ReadStringAttribute(reader, 3);
|
|
|
|
|
|
entity.m_SzinTipus = DAUtil.ReadIntegerAttribute(reader, 4, -1);
|
|
|
|
|
|
entity.m_Tipus = DAUtil.ReadIntegerAttribute(reader, 5, -1);
|
|
|
|
|
|
entity.m_Torolheto = DAUtil.ReadBooleanAttribute(reader, 6);
|
|
|
|
|
|
entity.m_Uzenet = DAUtil.ReadStringAttribute(reader, 7, "");
|
|
|
|
|
|
entity.m_Globalis = DAUtil.ReadBooleanAttribute(reader, 8);
|
|
|
|
|
|
entity.m_GlobalisErvenyessegVege = DAUtil.ReadDateTimeAttribute(reader, 9);
|
|
|
|
// Ertesites kapcsoló mezői
|
|
DAUtil.ReadIDAttribute(reader, 10, ref entity.m_IntezmenyId, 0);
|
|
DAUtil.ReadIDAttribute(reader, 11, ref entity.m_TanevId, 0);
|
|
}
|
|
|
|
public override void LoadEntityFields(Ertesites entity, SDA.DataProvider.SDADataReader reader, ColumnFilterMode columnFilterMode, IEnumerable<string> columns)
|
|
{
|
|
int index = 1;
|
|
if (columns == null)
|
|
{
|
|
columns = new List<string>(index);
|
|
}
|
|
// Ertesites betöltése
|
|
// Ertesites mezői
|
|
if (((columnFilterMode == ColumnFilterMode.DEFAULT_ALLOWED) ^ (columns.Contains("ErvenyessegKezdete"))))
|
|
{
|
|
entity.m_ErvenyessegKezdete = DAUtil.ReadDateTimeAttribute(reader, index++, DateTime.Now /* XXX DateTime */);
|
|
}
|
|
if (((columnFilterMode == ColumnFilterMode.DEFAULT_ALLOWED) ^ (columns.Contains("LetrehozasDatum"))))
|
|
{
|
|
entity.m_LetrehozasDatum = DAUtil.ReadDateTimeAttribute(reader, index++, DateTime.Now /* XXX DateTime */);
|
|
}
|
|
if (((columnFilterMode == ColumnFilterMode.DEFAULT_ALLOWED) ^ (columns.Contains("NavigalasParameter"))))
|
|
{
|
|
entity.m_NavigalasParameter = DAUtil.ReadStringAttribute(reader, index++);
|
|
}
|
|
if (((columnFilterMode == ColumnFilterMode.DEFAULT_ALLOWED) ^ (columns.Contains("SzinTipus"))))
|
|
{
|
|
entity.m_SzinTipus = DAUtil.ReadIntegerAttribute(reader, index++, -1);
|
|
}
|
|
if (((columnFilterMode == ColumnFilterMode.DEFAULT_ALLOWED) ^ (columns.Contains("Tipus"))))
|
|
{
|
|
entity.m_Tipus = DAUtil.ReadIntegerAttribute(reader, index++, -1);
|
|
}
|
|
if (((columnFilterMode == ColumnFilterMode.DEFAULT_ALLOWED) ^ (columns.Contains("Torolheto"))))
|
|
{
|
|
entity.m_Torolheto = DAUtil.ReadBooleanAttribute(reader, index++);
|
|
}
|
|
if (((columnFilterMode == ColumnFilterMode.DEFAULT_ALLOWED) ^ (columns.Contains("Uzenet"))))
|
|
{
|
|
entity.m_Uzenet = DAUtil.ReadStringAttribute(reader, index++, "");
|
|
}
|
|
if (((columnFilterMode == ColumnFilterMode.DEFAULT_ALLOWED) ^ (columns.Contains("Globalis"))))
|
|
{
|
|
entity.m_Globalis = DAUtil.ReadBooleanAttribute(reader, index++);
|
|
}
|
|
if (((columnFilterMode == ColumnFilterMode.DEFAULT_ALLOWED) ^ (columns.Contains("GlobalisErvenyessegVege"))))
|
|
{
|
|
entity.m_GlobalisErvenyessegVege = DAUtil.ReadDateTimeAttribute(reader, index++);
|
|
}
|
|
// Ertesites kapcsoló mezői
|
|
DAUtil.ReadIDAttribute(reader, index++, ref entity.m_IntezmenyId, 0);
|
|
DAUtil.ReadIDAttribute(reader, index++, ref entity.m_TanevId, 0);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Paraméter kötés
|
|
|
|
public override void BindAttributes(Ertesites entity, SDA.DataProvider.SDACommand command)
|
|
{
|
|
DAUtil.BindParameter(command, "pERVENYESSEGKEZDETE", SDA.DataProvider.SDADBType.DateTime, entity.m_ErvenyessegKezdete, false);
|
|
|
|
DAUtil.BindParameter(command, "pLETREHOZASDATUM", SDA.DataProvider.SDADBType.DateTime, entity.m_LetrehozasDatum, false);
|
|
|
|
DAUtil.BindParameter(command, "pNAVIGALASPARAMETER", SDA.DataProvider.SDADBType.String, 255, entity.m_NavigalasParameter, entity.m_NavigalasParameter == null);
|
|
|
|
DAUtil.BindParameter(command, "pSZINTIPUS", SDA.DataProvider.SDADBType.Int /* DictionaryItem */, 15, entity.m_SzinTipus, false);
|
|
|
|
DAUtil.BindParameter(command, "pTIPUS", SDA.DataProvider.SDADBType.Int /* DictionaryItem */, 15, entity.m_Tipus, false);
|
|
|
|
DAUtil.BindParameter(command, "pTOROLHETO", SDA.DataProvider.SDADBType.Boolean /* Boolean */, 1, entity.m_Torolheto, entity.m_Torolheto == null);
|
|
|
|
DAUtil.BindParameter(command, "pUZENET", SDA.DataProvider.SDADBType.LongString, 2147483647, entity.m_Uzenet, false);
|
|
|
|
DAUtil.BindParameter(command, "pGLOBALIS", SDA.DataProvider.SDADBType.Boolean /* Boolean */, 1, entity.m_Globalis, entity.m_Globalis == null);
|
|
|
|
DAUtil.BindParameter(command, "pGLOBALISERVENYESSEGVEGE", SDA.DataProvider.SDADBType.DateTime, entity.m_GlobalisErvenyessegVege, entity.m_GlobalisErvenyessegVege == null);
|
|
}
|
|
|
|
public override void DynamicBindAttributes(Ertesites entity, SDA.DataProvider.SDACommand command)
|
|
{
|
|
System.Text.StringBuilder sb = new System.Text.StringBuilder();
|
|
if (entity.HasChanged("ErvenyessegKezdete"))
|
|
{
|
|
sb.Append("C_ERVENYESSEGKEZDETE = :pERVENYESSEGKEZDETE,");
|
|
|
|
DAUtil.BindParameter(command, "pERVENYESSEGKEZDETE", SDA.DataProvider.SDADBType.DateTime, entity.m_ErvenyessegKezdete, false);
|
|
|
|
}
|
|
if (entity.HasChanged("LetrehozasDatum"))
|
|
{
|
|
sb.Append("C_LETREHOZASDATUM = :pLETREHOZASDATUM,");
|
|
|
|
DAUtil.BindParameter(command, "pLETREHOZASDATUM", SDA.DataProvider.SDADBType.DateTime, entity.m_LetrehozasDatum, false);
|
|
|
|
}
|
|
if (entity.HasChanged("NavigalasParameter"))
|
|
{
|
|
sb.Append("C_NAVIGALASPARAMETER = :pNAVIGALASPARAMETER,");
|
|
|
|
DAUtil.BindParameter(command, "pNAVIGALASPARAMETER", SDA.DataProvider.SDADBType.String, 255, entity.m_NavigalasParameter, entity.m_NavigalasParameter == null);
|
|
|
|
}
|
|
if (entity.HasChanged("SzinTipus"))
|
|
{
|
|
sb.Append("C_SZINTIPUS = :pSZINTIPUS,");
|
|
|
|
DAUtil.BindParameter(command, "pSZINTIPUS", SDA.DataProvider.SDADBType.Int /* DictionaryItem */, 15, entity.m_SzinTipus, false);
|
|
|
|
}
|
|
if (entity.HasChanged("Tipus"))
|
|
{
|
|
sb.Append("C_TIPUS = :pTIPUS,");
|
|
|
|
DAUtil.BindParameter(command, "pTIPUS", SDA.DataProvider.SDADBType.Int /* DictionaryItem */, 15, entity.m_Tipus, false);
|
|
|
|
}
|
|
if (entity.HasChanged("Torolheto"))
|
|
{
|
|
sb.Append("C_TOROLHETO = :pTOROLHETO,");
|
|
|
|
DAUtil.BindParameter(command, "pTOROLHETO", SDA.DataProvider.SDADBType.Boolean /* Boolean */, 1, entity.m_Torolheto, entity.m_Torolheto == null);
|
|
|
|
}
|
|
if (entity.HasChanged("Uzenet"))
|
|
{
|
|
sb.Append("C_UZENET = :pUZENET,");
|
|
|
|
DAUtil.BindParameter(command, "pUZENET", SDA.DataProvider.SDADBType.LongString, 2147483647, entity.m_Uzenet, false);
|
|
|
|
}
|
|
if (entity.HasChanged("Globalis"))
|
|
{
|
|
sb.Append("C_GLOBALIS = :pGLOBALIS,");
|
|
|
|
DAUtil.BindParameter(command, "pGLOBALIS", SDA.DataProvider.SDADBType.Boolean /* Boolean */, 1, entity.m_Globalis, entity.m_Globalis == null);
|
|
|
|
}
|
|
if (entity.HasChanged("GlobalisErvenyessegVege"))
|
|
{
|
|
sb.Append("C_GLOBALISERVENYESSEGVEGE = :pGLOBALISERVENYESSEGVEGE,");
|
|
|
|
DAUtil.BindParameter(command, "pGLOBALISERVENYESSEGVEGE", SDA.DataProvider.SDADBType.DateTime, entity.m_GlobalisErvenyessegVege, entity.m_GlobalisErvenyessegVege == null);
|
|
|
|
}
|
|
command.CommandText = command.CommandText.Replace("{COLUMNS}", sb.ToString());
|
|
}
|
|
|
|
public override void BindAssociations(Ertesites entity, SDA.DataProvider.SDACommand command)
|
|
{
|
|
DAUtil.BindIdParameter(command, "pINTEZMENYID", entity.InternalIntezmenyId);
|
|
DAUtil.BindIdParameter(command, "pTANEVID", entity.InternalTanevId);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
|
|
internal class ErtesitesDA : EntityDataAccessor<Ertesites>
|
|
{
|
|
private static ErtesitesDBHelper m_dbhelper = new ErtesitesDBHelper();
|
|
|
|
protected override IEntityDBHelper<Ertesites> dbhelper
|
|
{
|
|
get { return m_dbhelper; }
|
|
}
|
|
|
|
#region Load
|
|
|
|
public override bool LoadEntity(Ertesites entity, int entityId)
|
|
{
|
|
return LoadById(entity, entityId);
|
|
}
|
|
|
|
public override bool FilteredLoadEntity(Ertesites entity, int entityId, ColumnFilterMode columnFilterMode, IEnumerable<string> columns)
|
|
{
|
|
return LoadById(entity, entityId, columnFilterMode, columns);
|
|
}
|
|
|
|
public bool LoadById(Ertesites entity, int entityId)
|
|
{
|
|
using (SDA.DataProvider.SDACommand command = dbhelper.CreateEmptyQueryCommand())
|
|
{
|
|
command.CommandText += " and (T_ERTESITES_OSSZES.ID = :pID) ";
|
|
command.Parameters.Add("pID", SDA.DataProvider.SDADBType.Int).Value = entityId;
|
|
return dbhelper.LoadSingleEntity(entity, command);
|
|
}
|
|
}
|
|
|
|
public bool LoadById(Ertesites entity, int entityId, ColumnFilterMode columnFilterMode, IEnumerable<string> columns)
|
|
{
|
|
using (SDA.DataProvider.SDACommand command = dbhelper.CreateDynamicQueryCommand(columnFilterMode, columns))
|
|
{
|
|
command.CommandText += " and (T_ERTESITES_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<Ertesites> collection, string filter, Dictionary<string, object> 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<Ertesites> collection, string filter, ColumnFilterMode columnFilterMode, IEnumerable<string> columns, Dictionary<string, object> 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_ERTESITES_OSSZES (
|
|
C_ERVENYESSEGKEZDETE,
|
|
C_LETREHOZASDATUM,
|
|
C_NAVIGALASPARAMETER,
|
|
C_SZINTIPUS,
|
|
C_TIPUS,
|
|
C_TOROLHETO,
|
|
C_UZENET,
|
|
C_GLOBALIS,
|
|
C_GLOBALISERVENYESSEGVEGE,
|
|
C_INTEZMENYID,
|
|
C_TANEVID,
|
|
TOROLT,
|
|
SERIAL,
|
|
CREATED,
|
|
CREATOR)
|
|
values (
|
|
:pERVENYESSEGKEZDETE,
|
|
:pLETREHOZASDATUM,
|
|
:pNAVIGALASPARAMETER,
|
|
:pSZINTIPUS,
|
|
:pTIPUS,
|
|
:pTOROLHETO,
|
|
:pUZENET,
|
|
:pGLOBALIS,
|
|
:pGLOBALISERVENYESSEGVEGE,
|
|
:pINTEZMENYID,
|
|
:pTANEVID,
|
|
:pTOROLT,
|
|
:pSERIAL,
|
|
:pCREATED,
|
|
:pCREATOR);
|
|
|
|
SELECT SCOPE_IDENTITY() as ID;
|
|
|
|
";
|
|
|
|
public override void InsertEntity(Ertesites 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_ERTESITES_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(Ertesites 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_ERTESITES_OSSZES WHERE (ID = :pID) ";
|
|
private const string m_LogikaiDeleteCommandText = @"
|
|
UPDATE T_ERTESITES_OSSZES
|
|
SET TOROLT = 'T' ,
|
|
SERIAL = SERIAL + 1,
|
|
LASTCHANGED = :pLASTCHANGED,
|
|
MODIFIER = :pMODIFIER
|
|
WHERE (ID = :pID) ";
|
|
|
|
public override void DeleteEntity(Ertesites 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("Ertesites", entity.ID);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region UpdateAssociations
|
|
|
|
private const string m_UpdateAssociationCommandText = @"
|
|
update T_ERTESITES_OSSZES
|
|
set
|
|
C_INTEZMENYID = :pINTEZMENYID,
|
|
C_TANEVID = :pTANEVID,
|
|
SERIAL = ISNULL(SERIAL,0) + 1,
|
|
LASTCHANGED = :pLASTCHANGED,
|
|
MODIFIER = :pMODIFIER
|
|
where
|
|
(ID = :pID) and (ISNULL(SERIAL,0) = :pSERIAL)
|
|
";
|
|
|
|
public override bool UpdateAssociations(Ertesites 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
|
|
|
|
|
|
#endregion
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Az osztály elvégzi az UML modell 'Intezmeny -> Ertesites (Ertesites)'
|
|
/// asszociációjának teljes kezelését.
|
|
/// </summary>
|
|
internal class Intezmeny_Ertesites_DA : EntityCollectionDA<Intezmeny, Ertesites>
|
|
{
|
|
internal protected Intezmeny_Ertesites_DA(Intezmeny owner)
|
|
: base(owner)
|
|
{
|
|
}
|
|
|
|
// Nincs kapcsolótábla
|
|
private const string m_Filter = @" and (T_ERTESITES_OSSZES.C_INTEZMENYID = :pID) ";
|
|
|
|
public override void LoadCollection(IAssociatedEntityCollection<Ertesites> collection)
|
|
{
|
|
new ErtesitesDBHelper().LoadByPartnerId(collection, m_Filter, Owner.ID);
|
|
}
|
|
|
|
private static SDA.DataProvider.SDACommand CreateInsertErtesitesCommand()
|
|
{
|
|
SDA.DataProvider.SDACommand result = new SDA.DataProvider.SDACommand();
|
|
// nincs kapcsolótábla...
|
|
result.CommandText = @"update T_ERTESITES_OSSZES set C_INTEZMENYID = :pINTEZMENYID where (ID = :pERTESITESID)";
|
|
result.Parameters.Add("pINTEZMENYID", SDA.DataProvider.SDADBType.Int);
|
|
result.Parameters.Add("pERTESITESID", SDA.DataProvider.SDADBType.Int);
|
|
return result;
|
|
}
|
|
|
|
private void DoAdd(Intezmeny owner, Ertesites partner)
|
|
{
|
|
using (SDA.DataProvider.SDACommand command = CreateInsertErtesitesCommand())
|
|
{
|
|
command.Connection = UserContext.Instance.SDAConnection;
|
|
command.Transaction = UserContext.Instance.SDATransaction;
|
|
command.Parameters["pINTEZMENYID"].Value = owner.ID;
|
|
command.Parameters["pERTESITESID"].Value = partner.ID;
|
|
command.ExecuteNonQuery();
|
|
}
|
|
}
|
|
|
|
public override void AddItem(Ertesites entity)
|
|
{
|
|
var assochandler = AssociationHandlerManager.Create<Ertesites, Intezmeny>("Ertesites_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 CreateDeleteErtesitesCommand()
|
|
{
|
|
SDA.DataProvider.SDACommand result = new SDA.DataProvider.SDACommand();
|
|
// nincs kapcsolótábla...
|
|
result.CommandText = @"update T_ERTESITES_OSSZES set C_INTEZMENYID = null where (C_INTEZMENYID = :pINTEZMENYID and ID = :pERTESITESID)";
|
|
result.Parameters.Add("pINTEZMENYID", SDA.DataProvider.SDADBType.Int);
|
|
result.Parameters.Add("pERTESITESID", SDA.DataProvider.SDADBType.Int);
|
|
return result;
|
|
}
|
|
|
|
private void DoRemove(Intezmeny owner, Ertesites partner)
|
|
{
|
|
using (SDA.DataProvider.SDACommand command = CreateDeleteErtesitesCommand())
|
|
{
|
|
command.Connection = UserContext.Instance.SDAConnection;
|
|
command.Transaction = UserContext.Instance.SDATransaction;
|
|
command.Parameters["pINTEZMENYID"].Value = owner.ID;
|
|
command.Parameters["pERTESITESID"].Value = partner.ID;
|
|
command.ExecuteNonQuery();
|
|
}
|
|
}
|
|
|
|
public override void DeleteItem(Ertesites entity)
|
|
{
|
|
var assochandler = AssociationHandlerManager.Create<Ertesites, Intezmeny>("Ertesites_Intezmeny");
|
|
assochandler.BeforeDelete(entity, this.Owner);
|
|
entity.Delete(true);
|
|
assochandler.AfterDelete(entity, this.Owner);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Az osztály elvégzi az UML modell 'Tanev -> Ertesites (Ertesites)'
|
|
/// asszociációjának teljes kezelését.
|
|
/// </summary>
|
|
internal class Tanev_Ertesites_DA : EntityCollectionDA<Tanev, Ertesites>
|
|
{
|
|
internal protected Tanev_Ertesites_DA(Tanev owner)
|
|
: base(owner)
|
|
{
|
|
}
|
|
|
|
// Nincs kapcsolótábla
|
|
private const string m_Filter = @" and (T_ERTESITES_OSSZES.C_TANEVID = :pID) ";
|
|
|
|
public override void LoadCollection(IAssociatedEntityCollection<Ertesites> collection)
|
|
{
|
|
new ErtesitesDBHelper().LoadByPartnerId(collection, m_Filter, Owner.ID);
|
|
}
|
|
|
|
private static SDA.DataProvider.SDACommand CreateInsertErtesitesCommand()
|
|
{
|
|
SDA.DataProvider.SDACommand result = new SDA.DataProvider.SDACommand();
|
|
// nincs kapcsolótábla...
|
|
result.CommandText = @"update T_ERTESITES_OSSZES set C_TANEVID = :pTANEVID where (ID = :pERTESITESID)";
|
|
result.Parameters.Add("pTANEVID", SDA.DataProvider.SDADBType.Int);
|
|
result.Parameters.Add("pERTESITESID", SDA.DataProvider.SDADBType.Int);
|
|
return result;
|
|
}
|
|
|
|
private void DoAdd(Tanev owner, Ertesites partner)
|
|
{
|
|
using (SDA.DataProvider.SDACommand command = CreateInsertErtesitesCommand())
|
|
{
|
|
command.Connection = UserContext.Instance.SDAConnection;
|
|
command.Transaction = UserContext.Instance.SDATransaction;
|
|
command.Parameters["pTANEVID"].Value = owner.ID;
|
|
command.Parameters["pERTESITESID"].Value = partner.ID;
|
|
command.ExecuteNonQuery();
|
|
}
|
|
}
|
|
|
|
public override void AddItem(Ertesites entity)
|
|
{
|
|
var assochandler = AssociationHandlerManager.Create<Ertesites, Tanev>("Ertesites_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 CreateDeleteErtesitesCommand()
|
|
{
|
|
SDA.DataProvider.SDACommand result = new SDA.DataProvider.SDACommand();
|
|
// nincs kapcsolótábla...
|
|
result.CommandText = @"update T_ERTESITES_OSSZES set C_TANEVID = null where (C_TANEVID = :pTANEVID and ID = :pERTESITESID)";
|
|
result.Parameters.Add("pTANEVID", SDA.DataProvider.SDADBType.Int);
|
|
result.Parameters.Add("pERTESITESID", SDA.DataProvider.SDADBType.Int);
|
|
return result;
|
|
}
|
|
|
|
private void DoRemove(Tanev owner, Ertesites partner)
|
|
{
|
|
using (SDA.DataProvider.SDACommand command = CreateDeleteErtesitesCommand())
|
|
{
|
|
command.Connection = UserContext.Instance.SDAConnection;
|
|
command.Transaction = UserContext.Instance.SDATransaction;
|
|
command.Parameters["pTANEVID"].Value = owner.ID;
|
|
command.Parameters["pERTESITESID"].Value = partner.ID;
|
|
command.ExecuteNonQuery();
|
|
}
|
|
}
|
|
|
|
public override void DeleteItem(Ertesites entity)
|
|
{
|
|
var assochandler = AssociationHandlerManager.Create<Ertesites, Tanev>("Ertesites_Tanev");
|
|
assochandler.BeforeDelete(entity, this.Owner);
|
|
entity.Delete(true);
|
|
assochandler.AfterDelete(entity, this.Owner);
|
|
}
|
|
}
|
|
|
|
}
|
|
|