1060 lines
45 KiB
C#
1060 lines
45 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 FoglalkozasDBHelper : EntityDBHelper<Foglalkozas>
|
|
{
|
|
private Dictionary<string, string> dynamicColumns = new Dictionary<string, string>()
|
|
{
|
|
{ "FoglalkozasTipusa", "T_FOGLALKOZAS_OSSZES.C_FOGLALKOZASTIPUSA" },
|
|
{ "Oraszam", "T_FOGLALKOZAS_OSSZES.C_ORASZAM" },
|
|
{ "Nev", "T_FOGLALKOZAS_OSSZES.C_NEV" },
|
|
{ "ErtekelesKell", "T_FOGLALKOZAS_OSSZES.C_ERTEKELESKELL" },
|
|
{ "MulasztasKell", "T_FOGLALKOZAS_OSSZES.C_MULASZTASKELL" },
|
|
{ "TanarFelveheti", "T_FOGLALKOZAS_OSSZES.C_TANARFELVEHETI" },
|
|
{ "Importalt", "T_FOGLALKOZAS_OSSZES.C_IMPORTALT" },
|
|
{ "IsOsszevontOra", "T_FOGLALKOZAS_OSSZES.C_ISOSSZEVONTORA" },
|
|
{ "IsNemzetisegi", "T_FOGLALKOZAS_OSSZES.C_ISNEMZETISEGI" },
|
|
{ "TuloraSzam", "T_FOGLALKOZAS_OSSZES.C_TULORASZAM" },
|
|
{ "MegbizasiOraszam", "T_FOGLALKOZAS_OSSZES.C_MEGBIZASIORASZAM" },
|
|
};
|
|
|
|
private const string dynamicQueryCommandText =
|
|
"select " +
|
|
"T_FOGLALKOZAS_OSSZES.ID, " +
|
|
"{COLUMNS}" +
|
|
// Foglalkozas betöltése
|
|
// Foglalkozas kapcsoló mezői
|
|
"T_FOGLALKOZAS_OSSZES.C_TANTARGYID, " + /* Opcionális asszociációs kapcsolómező */
|
|
"T_FOGLALKOZAS_OSSZES.C_OSZTALYCSOPORTID, " + /* Opcionális asszociációs kapcsolómező */
|
|
"T_FOGLALKOZAS_OSSZES.C_TANARID, " + /* Kötelező asszociációs kapcsolómező */
|
|
"T_FOGLALKOZAS_OSSZES.C_INTEZMENYID, " + /* Kötelező asszociációs kapcsolómező */
|
|
"T_FOGLALKOZAS_OSSZES.C_TANEVID, " + /* Kötelező asszociációs kapcsolómező */
|
|
"T_FOGLALKOZAS_OSSZES.TOROLT, " +
|
|
"T_FOGLALKOZAS_OSSZES.SERIAL, " +
|
|
"T_FOGLALKOZAS_OSSZES.CREATED, " +
|
|
"T_FOGLALKOZAS_OSSZES.CREATOR, " +
|
|
"T_FOGLALKOZAS_OSSZES.LASTCHANGED, " +
|
|
"T_FOGLALKOZAS_OSSZES.MODIFIER " +
|
|
"from " +
|
|
"T_FOGLALKOZAS_OSSZES " +
|
|
"where " +
|
|
"(1 = 1) ";
|
|
|
|
private const string emptyQueryCommandText =
|
|
"select " +
|
|
"T_FOGLALKOZAS_OSSZES.ID, " +
|
|
// Foglalkozas betöltése
|
|
// Foglalkozas mezői
|
|
"T_FOGLALKOZAS_OSSZES.C_FOGLALKOZASTIPUSA, " +
|
|
"T_FOGLALKOZAS_OSSZES.C_ORASZAM, " +
|
|
"T_FOGLALKOZAS_OSSZES.C_NEV, " +
|
|
"T_FOGLALKOZAS_OSSZES.C_ERTEKELESKELL, " +
|
|
"T_FOGLALKOZAS_OSSZES.C_MULASZTASKELL, " +
|
|
"T_FOGLALKOZAS_OSSZES.C_TANARFELVEHETI, " +
|
|
"T_FOGLALKOZAS_OSSZES.C_IMPORTALT, " +
|
|
"T_FOGLALKOZAS_OSSZES.C_ISOSSZEVONTORA, " +
|
|
"T_FOGLALKOZAS_OSSZES.C_ISNEMZETISEGI, " +
|
|
"T_FOGLALKOZAS_OSSZES.C_TULORASZAM, " +
|
|
"T_FOGLALKOZAS_OSSZES.C_MEGBIZASIORASZAM, " +
|
|
// Foglalkozas kapcsoló mezői
|
|
"T_FOGLALKOZAS_OSSZES.C_TANTARGYID, " + /* Opcionális asszociációs kapcsolómező */
|
|
"T_FOGLALKOZAS_OSSZES.C_OSZTALYCSOPORTID, " + /* Opcionális asszociációs kapcsolómező */
|
|
"T_FOGLALKOZAS_OSSZES.C_TANARID, " + /* Kötelező asszociációs kapcsolómező */
|
|
"T_FOGLALKOZAS_OSSZES.C_INTEZMENYID, " + /* Kötelező asszociációs kapcsolómező */
|
|
"T_FOGLALKOZAS_OSSZES.C_TANEVID, " + /* Kötelező asszociációs kapcsolómező */
|
|
"T_FOGLALKOZAS_OSSZES.TOROLT, " +
|
|
"T_FOGLALKOZAS_OSSZES.SERIAL, " +
|
|
"T_FOGLALKOZAS_OSSZES.CREATED, " +
|
|
"T_FOGLALKOZAS_OSSZES.CREATOR, " +
|
|
"T_FOGLALKOZAS_OSSZES.LASTCHANGED, " +
|
|
"T_FOGLALKOZAS_OSSZES.MODIFIER " +
|
|
"from " +
|
|
"T_FOGLALKOZAS_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 Foglalkozas CreateEntityInstance()
|
|
{
|
|
return Foglalkozas.GiveAnInstance();
|
|
}
|
|
|
|
#region Lekérdezés
|
|
|
|
public override void LoadEntityFields(Foglalkozas entity, SDA.DataProvider.SDADataReader reader)
|
|
{
|
|
// Foglalkozas betöltése
|
|
// Foglalkozas mezői
|
|
|
|
entity.m_FoglalkozasTipusa = DAUtil.ReadIntegerAttribute(reader, 1, -1);
|
|
|
|
|
|
entity.m_Oraszam = DAUtil.ReadDoubleAttribute(reader, 2, 0);
|
|
|
|
|
|
entity.m_Nev = DAUtil.ReadStringAttribute(reader, 3);
|
|
|
|
|
|
entity.m_ErtekelesKell = DAUtil.ReadBooleanAttribute(reader, 4);
|
|
|
|
|
|
entity.m_MulasztasKell = DAUtil.ReadBooleanAttribute(reader, 5);
|
|
|
|
|
|
entity.m_TanarFelveheti = DAUtil.ReadBooleanAttribute(reader, 6);
|
|
|
|
|
|
entity.m_Importalt = DAUtil.ReadBooleanAttribute(reader, 7, false);
|
|
|
|
|
|
entity.m_IsOsszevontOra = DAUtil.ReadBooleanAttribute(reader, 8, false);
|
|
|
|
|
|
entity.m_IsNemzetisegi = DAUtil.ReadBooleanAttribute(reader, 9, false);
|
|
|
|
|
|
entity.m_TuloraSzam = DAUtil.ReadDoubleAttribute(reader, 10, 0);
|
|
|
|
|
|
entity.m_MegbizasiOraszam = DAUtil.ReadDoubleAttribute(reader, 11, 0);
|
|
|
|
// Foglalkozas kapcsoló mezői
|
|
DAUtil.ReadIDAttribute(reader, 12, ref entity.m_TantargyId, -1);
|
|
DAUtil.ReadIDAttribute(reader, 13, ref entity.m_OsztalyCsoportId, -1);
|
|
DAUtil.ReadIDAttribute(reader, 14, ref entity.m_TanarId, 0);
|
|
DAUtil.ReadIDAttribute(reader, 15, ref entity.m_IntezmenyId, 0);
|
|
DAUtil.ReadIDAttribute(reader, 16, ref entity.m_TanevId, 0);
|
|
}
|
|
|
|
public override void LoadEntityFields(Foglalkozas entity, SDA.DataProvider.SDADataReader reader, ColumnFilterMode columnFilterMode, IEnumerable<string> columns)
|
|
{
|
|
int index = 1;
|
|
if (columns == null)
|
|
{
|
|
columns = new List<string>(index);
|
|
}
|
|
// Foglalkozas betöltése
|
|
// Foglalkozas mezői
|
|
if (((columnFilterMode == ColumnFilterMode.DEFAULT_ALLOWED) ^ (columns.Contains("FoglalkozasTipusa"))))
|
|
{
|
|
entity.m_FoglalkozasTipusa = DAUtil.ReadIntegerAttribute(reader, index++, -1);
|
|
}
|
|
if (((columnFilterMode == ColumnFilterMode.DEFAULT_ALLOWED) ^ (columns.Contains("Oraszam"))))
|
|
{
|
|
entity.m_Oraszam = DAUtil.ReadDoubleAttribute(reader, index++, 0);
|
|
}
|
|
if (((columnFilterMode == ColumnFilterMode.DEFAULT_ALLOWED) ^ (columns.Contains("Nev"))))
|
|
{
|
|
entity.m_Nev = DAUtil.ReadStringAttribute(reader, index++);
|
|
}
|
|
if (((columnFilterMode == ColumnFilterMode.DEFAULT_ALLOWED) ^ (columns.Contains("ErtekelesKell"))))
|
|
{
|
|
entity.m_ErtekelesKell = DAUtil.ReadBooleanAttribute(reader, index++);
|
|
}
|
|
if (((columnFilterMode == ColumnFilterMode.DEFAULT_ALLOWED) ^ (columns.Contains("MulasztasKell"))))
|
|
{
|
|
entity.m_MulasztasKell = DAUtil.ReadBooleanAttribute(reader, index++);
|
|
}
|
|
if (((columnFilterMode == ColumnFilterMode.DEFAULT_ALLOWED) ^ (columns.Contains("TanarFelveheti"))))
|
|
{
|
|
entity.m_TanarFelveheti = DAUtil.ReadBooleanAttribute(reader, index++);
|
|
}
|
|
if (((columnFilterMode == ColumnFilterMode.DEFAULT_ALLOWED) ^ (columns.Contains("Importalt"))))
|
|
{
|
|
entity.m_Importalt = DAUtil.ReadBooleanAttribute(reader, index++, false);
|
|
}
|
|
if (((columnFilterMode == ColumnFilterMode.DEFAULT_ALLOWED) ^ (columns.Contains("IsOsszevontOra"))))
|
|
{
|
|
entity.m_IsOsszevontOra = DAUtil.ReadBooleanAttribute(reader, index++, false);
|
|
}
|
|
if (((columnFilterMode == ColumnFilterMode.DEFAULT_ALLOWED) ^ (columns.Contains("IsNemzetisegi"))))
|
|
{
|
|
entity.m_IsNemzetisegi = DAUtil.ReadBooleanAttribute(reader, index++, false);
|
|
}
|
|
if (((columnFilterMode == ColumnFilterMode.DEFAULT_ALLOWED) ^ (columns.Contains("TuloraSzam"))))
|
|
{
|
|
entity.m_TuloraSzam = DAUtil.ReadDoubleAttribute(reader, index++, 0);
|
|
}
|
|
if (((columnFilterMode == ColumnFilterMode.DEFAULT_ALLOWED) ^ (columns.Contains("MegbizasiOraszam"))))
|
|
{
|
|
entity.m_MegbizasiOraszam = DAUtil.ReadDoubleAttribute(reader, index++, 0);
|
|
}
|
|
// Foglalkozas kapcsoló mezői
|
|
DAUtil.ReadIDAttribute(reader, index++, ref entity.m_TantargyId, -1);
|
|
DAUtil.ReadIDAttribute(reader, index++, ref entity.m_OsztalyCsoportId, -1);
|
|
DAUtil.ReadIDAttribute(reader, index++, ref entity.m_TanarId, 0);
|
|
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(Foglalkozas entity, SDA.DataProvider.SDACommand command)
|
|
{
|
|
DAUtil.BindParameter(command, "pFOGLALKOZASTIPUSA", SDA.DataProvider.SDADBType.Int /* DictionaryItem */, 15, entity.m_FoglalkozasTipusa, false);
|
|
|
|
DAUtil.BindParameter(command, "pORASZAM", SDA.DataProvider.SDADBType.Double, 10, entity.m_Oraszam, false);
|
|
|
|
DAUtil.BindParameter(command, "pNEV", SDA.DataProvider.SDADBType.String, 771, entity.m_Nev, entity.m_Nev == null);
|
|
|
|
DAUtil.BindParameter(command, "pERTEKELESKELL", SDA.DataProvider.SDADBType.Boolean /* Boolean */, 1, entity.m_ErtekelesKell, entity.m_ErtekelesKell == null);
|
|
|
|
DAUtil.BindParameter(command, "pMULASZTASKELL", SDA.DataProvider.SDADBType.Boolean /* Boolean */, 1, entity.m_MulasztasKell, entity.m_MulasztasKell == null);
|
|
|
|
DAUtil.BindParameter(command, "pTANARFELVEHETI", SDA.DataProvider.SDADBType.Boolean /* Boolean */, 1, entity.m_TanarFelveheti, entity.m_TanarFelveheti == null);
|
|
|
|
DAUtil.BindParameter(command, "pIMPORTALT", SDA.DataProvider.SDADBType.Boolean /* Boolean */, 1, entity.m_Importalt, false);
|
|
|
|
DAUtil.BindParameter(command, "pISOSSZEVONTORA", SDA.DataProvider.SDADBType.Boolean /* Boolean */, 1, entity.m_IsOsszevontOra, false);
|
|
|
|
DAUtil.BindParameter(command, "pISNEMZETISEGI", SDA.DataProvider.SDADBType.Boolean /* Boolean */, 1, entity.m_IsNemzetisegi, false);
|
|
|
|
DAUtil.BindParameter(command, "pTULORASZAM", SDA.DataProvider.SDADBType.Double, 10, entity.m_TuloraSzam, false);
|
|
|
|
DAUtil.BindParameter(command, "pMEGBIZASIORASZAM", SDA.DataProvider.SDADBType.Double, 10, entity.m_MegbizasiOraszam, false);
|
|
}
|
|
|
|
public override void DynamicBindAttributes(Foglalkozas entity, SDA.DataProvider.SDACommand command)
|
|
{
|
|
System.Text.StringBuilder sb = new System.Text.StringBuilder();
|
|
if (entity.HasChanged("FoglalkozasTipusa"))
|
|
{
|
|
sb.Append("C_FOGLALKOZASTIPUSA = :pFOGLALKOZASTIPUSA,");
|
|
|
|
DAUtil.BindParameter(command, "pFOGLALKOZASTIPUSA", SDA.DataProvider.SDADBType.Int /* DictionaryItem */, 15, entity.m_FoglalkozasTipusa, false);
|
|
|
|
}
|
|
if (entity.HasChanged("Oraszam"))
|
|
{
|
|
sb.Append("C_ORASZAM = :pORASZAM,");
|
|
|
|
DAUtil.BindParameter(command, "pORASZAM", SDA.DataProvider.SDADBType.Double, 10, entity.m_Oraszam, false);
|
|
|
|
}
|
|
if (entity.HasChanged("Nev"))
|
|
{
|
|
sb.Append("C_NEV = :pNEV,");
|
|
|
|
DAUtil.BindParameter(command, "pNEV", SDA.DataProvider.SDADBType.String, 771, entity.m_Nev, entity.m_Nev == null);
|
|
|
|
}
|
|
if (entity.HasChanged("ErtekelesKell"))
|
|
{
|
|
sb.Append("C_ERTEKELESKELL = :pERTEKELESKELL,");
|
|
|
|
DAUtil.BindParameter(command, "pERTEKELESKELL", SDA.DataProvider.SDADBType.Boolean /* Boolean */, 1, entity.m_ErtekelesKell, entity.m_ErtekelesKell == null);
|
|
|
|
}
|
|
if (entity.HasChanged("MulasztasKell"))
|
|
{
|
|
sb.Append("C_MULASZTASKELL = :pMULASZTASKELL,");
|
|
|
|
DAUtil.BindParameter(command, "pMULASZTASKELL", SDA.DataProvider.SDADBType.Boolean /* Boolean */, 1, entity.m_MulasztasKell, entity.m_MulasztasKell == null);
|
|
|
|
}
|
|
if (entity.HasChanged("TanarFelveheti"))
|
|
{
|
|
sb.Append("C_TANARFELVEHETI = :pTANARFELVEHETI,");
|
|
|
|
DAUtil.BindParameter(command, "pTANARFELVEHETI", SDA.DataProvider.SDADBType.Boolean /* Boolean */, 1, entity.m_TanarFelveheti, entity.m_TanarFelveheti == null);
|
|
|
|
}
|
|
if (entity.HasChanged("Importalt"))
|
|
{
|
|
sb.Append("C_IMPORTALT = :pIMPORTALT,");
|
|
|
|
DAUtil.BindParameter(command, "pIMPORTALT", SDA.DataProvider.SDADBType.Boolean /* Boolean */, 1, entity.m_Importalt, false);
|
|
|
|
}
|
|
if (entity.HasChanged("IsOsszevontOra"))
|
|
{
|
|
sb.Append("C_ISOSSZEVONTORA = :pISOSSZEVONTORA,");
|
|
|
|
DAUtil.BindParameter(command, "pISOSSZEVONTORA", SDA.DataProvider.SDADBType.Boolean /* Boolean */, 1, entity.m_IsOsszevontOra, false);
|
|
|
|
}
|
|
if (entity.HasChanged("IsNemzetisegi"))
|
|
{
|
|
sb.Append("C_ISNEMZETISEGI = :pISNEMZETISEGI,");
|
|
|
|
DAUtil.BindParameter(command, "pISNEMZETISEGI", SDA.DataProvider.SDADBType.Boolean /* Boolean */, 1, entity.m_IsNemzetisegi, false);
|
|
|
|
}
|
|
if (entity.HasChanged("TuloraSzam"))
|
|
{
|
|
sb.Append("C_TULORASZAM = :pTULORASZAM,");
|
|
|
|
DAUtil.BindParameter(command, "pTULORASZAM", SDA.DataProvider.SDADBType.Double, 10, entity.m_TuloraSzam, false);
|
|
|
|
}
|
|
if (entity.HasChanged("MegbizasiOraszam"))
|
|
{
|
|
sb.Append("C_MEGBIZASIORASZAM = :pMEGBIZASIORASZAM,");
|
|
|
|
DAUtil.BindParameter(command, "pMEGBIZASIORASZAM", SDA.DataProvider.SDADBType.Double, 10, entity.m_MegbizasiOraszam, false);
|
|
|
|
}
|
|
command.CommandText = command.CommandText.Replace("{COLUMNS}", sb.ToString());
|
|
}
|
|
|
|
public override void BindAssociations(Foglalkozas entity, SDA.DataProvider.SDACommand command)
|
|
{
|
|
DAUtil.BindIdParameter(command, "pTANTARGYID", entity.InternalTantargyId);
|
|
DAUtil.BindIdParameter(command, "pOSZTALYCSOPORTID", entity.InternalOsztalyCsoportId);
|
|
DAUtil.BindIdParameter(command, "pTANARID", entity.InternalTanarId);
|
|
DAUtil.BindIdParameter(command, "pINTEZMENYID", entity.InternalIntezmenyId);
|
|
DAUtil.BindIdParameter(command, "pTANEVID", entity.InternalTanevId);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
|
|
internal class FoglalkozasDA : EntityDataAccessor<Foglalkozas>
|
|
{
|
|
private static FoglalkozasDBHelper m_dbhelper = new FoglalkozasDBHelper();
|
|
|
|
protected override IEntityDBHelper<Foglalkozas> dbhelper
|
|
{
|
|
get { return m_dbhelper; }
|
|
}
|
|
|
|
#region Load
|
|
|
|
public override bool LoadEntity(Foglalkozas entity, int entityId)
|
|
{
|
|
return LoadById(entity, entityId);
|
|
}
|
|
|
|
public override bool FilteredLoadEntity(Foglalkozas entity, int entityId, ColumnFilterMode columnFilterMode, IEnumerable<string> columns)
|
|
{
|
|
return LoadById(entity, entityId, columnFilterMode, columns);
|
|
}
|
|
|
|
public bool LoadById(Foglalkozas entity, int entityId)
|
|
{
|
|
using (SDA.DataProvider.SDACommand command = dbhelper.CreateEmptyQueryCommand())
|
|
{
|
|
command.CommandText += " and (T_FOGLALKOZAS_OSSZES.ID = :pID) ";
|
|
command.Parameters.Add("pID", SDA.DataProvider.SDADBType.Int).Value = entityId;
|
|
return dbhelper.LoadSingleEntity(entity, command);
|
|
}
|
|
}
|
|
|
|
public bool LoadById(Foglalkozas entity, int entityId, ColumnFilterMode columnFilterMode, IEnumerable<string> columns)
|
|
{
|
|
using (SDA.DataProvider.SDACommand command = dbhelper.CreateDynamicQueryCommand(columnFilterMode, columns))
|
|
{
|
|
command.CommandText += " and (T_FOGLALKOZAS_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<Foglalkozas> 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<Foglalkozas> 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_FOGLALKOZAS_OSSZES (
|
|
C_FOGLALKOZASTIPUSA,
|
|
C_ORASZAM,
|
|
C_NEV,
|
|
C_ERTEKELESKELL,
|
|
C_MULASZTASKELL,
|
|
C_TANARFELVEHETI,
|
|
C_IMPORTALT,
|
|
C_ISOSSZEVONTORA,
|
|
C_ISNEMZETISEGI,
|
|
C_TULORASZAM,
|
|
C_MEGBIZASIORASZAM,
|
|
C_TANTARGYID,
|
|
C_OSZTALYCSOPORTID,
|
|
C_TANARID,
|
|
C_INTEZMENYID,
|
|
C_TANEVID,
|
|
TOROLT,
|
|
SERIAL,
|
|
CREATED,
|
|
CREATOR)
|
|
values (
|
|
:pFOGLALKOZASTIPUSA,
|
|
:pORASZAM,
|
|
:pNEV,
|
|
:pERTEKELESKELL,
|
|
:pMULASZTASKELL,
|
|
:pTANARFELVEHETI,
|
|
:pIMPORTALT,
|
|
:pISOSSZEVONTORA,
|
|
:pISNEMZETISEGI,
|
|
:pTULORASZAM,
|
|
:pMEGBIZASIORASZAM,
|
|
:pTANTARGYID,
|
|
:pOSZTALYCSOPORTID,
|
|
:pTANARID,
|
|
:pINTEZMENYID,
|
|
:pTANEVID,
|
|
:pTOROLT,
|
|
:pSERIAL,
|
|
:pCREATED,
|
|
:pCREATOR);
|
|
|
|
SELECT SCOPE_IDENTITY() as ID;
|
|
|
|
";
|
|
|
|
public override void InsertEntity(Foglalkozas 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_FOGLALKOZAS_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(Foglalkozas 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_FOGLALKOZAS_OSSZES WHERE (ID = :pID) ";
|
|
private const string m_LogikaiDeleteCommandText = @"
|
|
UPDATE T_FOGLALKOZAS_OSSZES
|
|
SET TOROLT = 'T' ,
|
|
SERIAL = SERIAL + 1,
|
|
LASTCHANGED = :pLASTCHANGED,
|
|
MODIFIER = :pMODIFIER
|
|
WHERE (ID = :pID) ";
|
|
|
|
public override void DeleteEntity(Foglalkozas 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("Foglalkozas", entity.ID);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region UpdateAssociations
|
|
|
|
private const string m_UpdateAssociationCommandText = @"
|
|
update T_FOGLALKOZAS_OSSZES
|
|
set
|
|
C_TANTARGYID = :pTANTARGYID,
|
|
C_OSZTALYCSOPORTID = :pOSZTALYCSOPORTID,
|
|
C_TANARID = :pTANARID,
|
|
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(Foglalkozas 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
|
|
|
|
// kapcsolómező a másik táblában van, és nem önmagára mutat
|
|
private const string m_LoadByOrarendiOraIdFilter = @" and (exists (select 1 from T_ORARENDIORA_OSSZES where C_FOGLALKOZASID = T_FOGLALKOZAS_OSSZES.ID and T_ORARENDIORA_OSSZES.ID = :pID)) ";
|
|
|
|
public bool LoadByOrarendiOraId(int id, Foglalkozas entity)
|
|
{
|
|
return dbhelper.LoadByPartnerId(entity, m_LoadByOrarendiOraIdFilter, id);
|
|
}
|
|
|
|
// kapcsolómező a másik táblában van, és nem önmagára mutat
|
|
private const string m_LoadByTanitasiOraIdFilter = @" and (exists (select 1 from T_TANITASIORA_OSSZES where C_FOGLALKOZASID = T_FOGLALKOZAS_OSSZES.ID and T_TANITASIORA_OSSZES.ID = :pID)) ";
|
|
|
|
public bool LoadByTanitasiOraId(int id, Foglalkozas entity)
|
|
{
|
|
return dbhelper.LoadByPartnerId(entity, m_LoadByTanitasiOraIdFilter, id);
|
|
}
|
|
|
|
// kapcsolómező a másik táblában van, és nem önmagára mutat
|
|
private const string m_LoadByFoglalkozasAmiTanuloIdFilter = @" and (exists (select 1 from T_FOGLALKOZASAMITANULO_OSSZES where C_FOGLALKOZASID = T_FOGLALKOZAS_OSSZES.ID and T_FOGLALKOZASAMITANULO_OSSZES.ID = :pID)) ";
|
|
|
|
public bool LoadByFoglalkozasAmiTanuloId(int id, Foglalkozas entity)
|
|
{
|
|
return dbhelper.LoadByPartnerId(entity, m_LoadByFoglalkozasAmiTanuloIdFilter, id);
|
|
}
|
|
|
|
|
|
#endregion
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Az osztály elvégzi az UML modell 'Tantargy -> Foglalkozas (Foglalkozasok)'
|
|
/// asszociációjának teljes kezelését.
|
|
/// </summary>
|
|
internal class Tantargy_Foglalkozasok_DA : EntityCollectionDA<Tantargy, Foglalkozas>
|
|
{
|
|
internal protected Tantargy_Foglalkozasok_DA(Tantargy owner)
|
|
: base(owner)
|
|
{
|
|
}
|
|
|
|
// Nincs kapcsolótábla
|
|
private const string m_Filter = @" and (T_FOGLALKOZAS_OSSZES.C_TANTARGYID = :pID) ";
|
|
|
|
public override void LoadCollection(IAssociatedEntityCollection<Foglalkozas> collection)
|
|
{
|
|
new FoglalkozasDBHelper().LoadByPartnerId(collection, m_Filter, Owner.ID);
|
|
}
|
|
|
|
private static SDA.DataProvider.SDACommand CreateInsertFoglalkozasokCommand()
|
|
{
|
|
SDA.DataProvider.SDACommand result = new SDA.DataProvider.SDACommand();
|
|
// nincs kapcsolótábla...
|
|
result.CommandText = @"update T_FOGLALKOZAS_OSSZES set C_TANTARGYID = :pTANTARGYID where (ID = :pFOGLALKOZASOKID)";
|
|
result.Parameters.Add("pTANTARGYID", SDA.DataProvider.SDADBType.Int);
|
|
result.Parameters.Add("pFOGLALKOZASOKID", SDA.DataProvider.SDADBType.Int);
|
|
return result;
|
|
}
|
|
|
|
private void DoAdd(Tantargy owner, Foglalkozas partner)
|
|
{
|
|
using (SDA.DataProvider.SDACommand command = CreateInsertFoglalkozasokCommand())
|
|
{
|
|
command.Connection = UserContext.Instance.SDAConnection;
|
|
command.Transaction = UserContext.Instance.SDATransaction;
|
|
command.Parameters["pTANTARGYID"].Value = owner.ID;
|
|
command.Parameters["pFOGLALKOZASOKID"].Value = partner.ID;
|
|
command.ExecuteNonQuery();
|
|
}
|
|
}
|
|
|
|
public override void AddItem(Foglalkozas entity)
|
|
{
|
|
var assochandler = AssociationHandlerManager.Create<Foglalkozas, Tantargy>("Foglalkozasok_Tantargy");
|
|
assochandler.BeforeInsert(entity, this.Owner);
|
|
this.DoAdd(this.Owner, entity);
|
|
assochandler.AfterInsert(entity, this.Owner);
|
|
}
|
|
|
|
private static SDA.DataProvider.SDACommand CreateDeleteFoglalkozasokCommand()
|
|
{
|
|
SDA.DataProvider.SDACommand result = new SDA.DataProvider.SDACommand();
|
|
// nincs kapcsolótábla...
|
|
result.CommandText = @"update T_FOGLALKOZAS_OSSZES set C_TANTARGYID = null where (C_TANTARGYID = :pTANTARGYID and ID = :pFOGLALKOZASOKID)";
|
|
result.Parameters.Add("pTANTARGYID", SDA.DataProvider.SDADBType.Int);
|
|
result.Parameters.Add("pFOGLALKOZASOKID", SDA.DataProvider.SDADBType.Int);
|
|
return result;
|
|
}
|
|
|
|
private void DoRemove(Tantargy owner, Foglalkozas partner)
|
|
{
|
|
using (SDA.DataProvider.SDACommand command = CreateDeleteFoglalkozasokCommand())
|
|
{
|
|
command.Connection = UserContext.Instance.SDAConnection;
|
|
command.Transaction = UserContext.Instance.SDATransaction;
|
|
command.Parameters["pTANTARGYID"].Value = owner.ID;
|
|
command.Parameters["pFOGLALKOZASOKID"].Value = partner.ID;
|
|
command.ExecuteNonQuery();
|
|
}
|
|
}
|
|
|
|
public override void DeleteItem(Foglalkozas entity)
|
|
{
|
|
var assochandler = AssociationHandlerManager.Create<Foglalkozas, Tantargy>("Foglalkozasok_Tantargy");
|
|
assochandler.BeforeDelete(entity, this.Owner);
|
|
this.DoRemove(this.Owner, entity);
|
|
assochandler.AfterDelete(entity, this.Owner);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Az osztály elvégzi az UML modell 'OsztalyCsoport -> Foglalkozas (Foglalkozasok)'
|
|
/// asszociációjának teljes kezelését.
|
|
/// </summary>
|
|
internal class OsztalyCsoport_Foglalkozasok_DA : EntityCollectionDA<OsztalyCsoport, Foglalkozas>
|
|
{
|
|
internal protected OsztalyCsoport_Foglalkozasok_DA(OsztalyCsoport owner)
|
|
: base(owner)
|
|
{
|
|
}
|
|
|
|
// Nincs kapcsolótábla
|
|
private const string m_Filter = @" and (T_FOGLALKOZAS_OSSZES.C_OSZTALYCSOPORTID = :pID) ";
|
|
|
|
public override void LoadCollection(IAssociatedEntityCollection<Foglalkozas> collection)
|
|
{
|
|
new FoglalkozasDBHelper().LoadByPartnerId(collection, m_Filter, Owner.ID);
|
|
}
|
|
|
|
private static SDA.DataProvider.SDACommand CreateInsertFoglalkozasokCommand()
|
|
{
|
|
SDA.DataProvider.SDACommand result = new SDA.DataProvider.SDACommand();
|
|
// nincs kapcsolótábla...
|
|
result.CommandText = @"update T_FOGLALKOZAS_OSSZES set C_OSZTALYCSOPORTID = :pOSZTALYCSOPORTID where (ID = :pFOGLALKOZASOKID)";
|
|
result.Parameters.Add("pOSZTALYCSOPORTID", SDA.DataProvider.SDADBType.Int);
|
|
result.Parameters.Add("pFOGLALKOZASOKID", SDA.DataProvider.SDADBType.Int);
|
|
return result;
|
|
}
|
|
|
|
private void DoAdd(OsztalyCsoport owner, Foglalkozas partner)
|
|
{
|
|
using (SDA.DataProvider.SDACommand command = CreateInsertFoglalkozasokCommand())
|
|
{
|
|
command.Connection = UserContext.Instance.SDAConnection;
|
|
command.Transaction = UserContext.Instance.SDATransaction;
|
|
command.Parameters["pOSZTALYCSOPORTID"].Value = owner.ID;
|
|
command.Parameters["pFOGLALKOZASOKID"].Value = partner.ID;
|
|
command.ExecuteNonQuery();
|
|
}
|
|
}
|
|
|
|
public override void AddItem(Foglalkozas entity)
|
|
{
|
|
var assochandler = AssociationHandlerManager.Create<Foglalkozas, OsztalyCsoport>("Foglalkozasok_OsztalyCsoport");
|
|
assochandler.BeforeInsert(entity, this.Owner);
|
|
this.DoAdd(this.Owner, entity);
|
|
assochandler.AfterInsert(entity, this.Owner);
|
|
}
|
|
|
|
private static SDA.DataProvider.SDACommand CreateDeleteFoglalkozasokCommand()
|
|
{
|
|
SDA.DataProvider.SDACommand result = new SDA.DataProvider.SDACommand();
|
|
// nincs kapcsolótábla...
|
|
result.CommandText = @"update T_FOGLALKOZAS_OSSZES set C_OSZTALYCSOPORTID = null where (C_OSZTALYCSOPORTID = :pOSZTALYCSOPORTID and ID = :pFOGLALKOZASOKID)";
|
|
result.Parameters.Add("pOSZTALYCSOPORTID", SDA.DataProvider.SDADBType.Int);
|
|
result.Parameters.Add("pFOGLALKOZASOKID", SDA.DataProvider.SDADBType.Int);
|
|
return result;
|
|
}
|
|
|
|
private void DoRemove(OsztalyCsoport owner, Foglalkozas partner)
|
|
{
|
|
using (SDA.DataProvider.SDACommand command = CreateDeleteFoglalkozasokCommand())
|
|
{
|
|
command.Connection = UserContext.Instance.SDAConnection;
|
|
command.Transaction = UserContext.Instance.SDATransaction;
|
|
command.Parameters["pOSZTALYCSOPORTID"].Value = owner.ID;
|
|
command.Parameters["pFOGLALKOZASOKID"].Value = partner.ID;
|
|
command.ExecuteNonQuery();
|
|
}
|
|
}
|
|
|
|
public override void DeleteItem(Foglalkozas entity)
|
|
{
|
|
var assochandler = AssociationHandlerManager.Create<Foglalkozas, OsztalyCsoport>("Foglalkozasok_OsztalyCsoport");
|
|
assochandler.BeforeDelete(entity, this.Owner);
|
|
this.DoRemove(this.Owner, entity);
|
|
assochandler.AfterDelete(entity, this.Owner);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Az osztály elvégzi az UML modell 'Alkalmazott -> Foglalkozas (Foglalkozas)'
|
|
/// asszociációjának teljes kezelését.
|
|
/// </summary>
|
|
internal class Alkalmazott_Foglalkozas_DA : EntityCollectionDA<Alkalmazott, Foglalkozas>
|
|
{
|
|
internal protected Alkalmazott_Foglalkozas_DA(Alkalmazott owner)
|
|
: base(owner)
|
|
{
|
|
}
|
|
|
|
// Nincs kapcsolótábla
|
|
private const string m_Filter = @" and (T_FOGLALKOZAS_OSSZES.C_TANARID = :pID) ";
|
|
|
|
public override void LoadCollection(IAssociatedEntityCollection<Foglalkozas> collection)
|
|
{
|
|
new FoglalkozasDBHelper().LoadByPartnerId(collection, m_Filter, Owner.ID);
|
|
}
|
|
|
|
private static SDA.DataProvider.SDACommand CreateInsertFoglalkozasCommand()
|
|
{
|
|
SDA.DataProvider.SDACommand result = new SDA.DataProvider.SDACommand();
|
|
// nincs kapcsolótábla...
|
|
result.CommandText = @"update T_FOGLALKOZAS_OSSZES set C_TANARID = :pTANARID where (ID = :pFOGLALKOZASID)";
|
|
result.Parameters.Add("pTANARID", SDA.DataProvider.SDADBType.Int);
|
|
result.Parameters.Add("pFOGLALKOZASID", SDA.DataProvider.SDADBType.Int);
|
|
return result;
|
|
}
|
|
|
|
private void DoAdd(Alkalmazott owner, Foglalkozas partner)
|
|
{
|
|
using (SDA.DataProvider.SDACommand command = CreateInsertFoglalkozasCommand())
|
|
{
|
|
command.Connection = UserContext.Instance.SDAConnection;
|
|
command.Transaction = UserContext.Instance.SDATransaction;
|
|
command.Parameters["pTANARID"].Value = owner.ID;
|
|
command.Parameters["pFOGLALKOZASID"].Value = partner.ID;
|
|
command.ExecuteNonQuery();
|
|
}
|
|
}
|
|
|
|
public override void AddItem(Foglalkozas entity)
|
|
{
|
|
var assochandler = AssociationHandlerManager.Create<Foglalkozas, Alkalmazott>("Foglalkozas_Tanar");
|
|
assochandler.BeforeInsert(entity, this.Owner);
|
|
entity.ModifyTanar(this.Owner);
|
|
if (entity.State == EntityState.Modified)
|
|
{
|
|
entity.UpdateAssociations(true);
|
|
}
|
|
else
|
|
{
|
|
entity.Insert(true);
|
|
}
|
|
assochandler.AfterInsert(entity, this.Owner);
|
|
}
|
|
|
|
private static SDA.DataProvider.SDACommand CreateDeleteFoglalkozasCommand()
|
|
{
|
|
SDA.DataProvider.SDACommand result = new SDA.DataProvider.SDACommand();
|
|
// nincs kapcsolótábla...
|
|
result.CommandText = @"update T_FOGLALKOZAS_OSSZES set C_TANARID = null where (C_TANARID = :pTANARID and ID = :pFOGLALKOZASID)";
|
|
result.Parameters.Add("pTANARID", SDA.DataProvider.SDADBType.Int);
|
|
result.Parameters.Add("pFOGLALKOZASID", SDA.DataProvider.SDADBType.Int);
|
|
return result;
|
|
}
|
|
|
|
private void DoRemove(Alkalmazott owner, Foglalkozas partner)
|
|
{
|
|
using (SDA.DataProvider.SDACommand command = CreateDeleteFoglalkozasCommand())
|
|
{
|
|
command.Connection = UserContext.Instance.SDAConnection;
|
|
command.Transaction = UserContext.Instance.SDATransaction;
|
|
command.Parameters["pTANARID"].Value = owner.ID;
|
|
command.Parameters["pFOGLALKOZASID"].Value = partner.ID;
|
|
command.ExecuteNonQuery();
|
|
}
|
|
}
|
|
|
|
public override void DeleteItem(Foglalkozas entity)
|
|
{
|
|
var assochandler = AssociationHandlerManager.Create<Foglalkozas, Alkalmazott>("Foglalkozas_Tanar");
|
|
assochandler.BeforeDelete(entity, this.Owner);
|
|
entity.Delete(true);
|
|
assochandler.AfterDelete(entity, this.Owner);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Az osztály elvégzi az UML modell 'Intezmeny -> Foglalkozas (Foglalkozas)'
|
|
/// asszociációjának teljes kezelését.
|
|
/// </summary>
|
|
internal class Intezmeny_Foglalkozas_DA : EntityCollectionDA<Intezmeny, Foglalkozas>
|
|
{
|
|
internal protected Intezmeny_Foglalkozas_DA(Intezmeny owner)
|
|
: base(owner)
|
|
{
|
|
}
|
|
|
|
// Nincs kapcsolótábla
|
|
private const string m_Filter = @" and (T_FOGLALKOZAS_OSSZES.C_INTEZMENYID = :pID) ";
|
|
|
|
public override void LoadCollection(IAssociatedEntityCollection<Foglalkozas> collection)
|
|
{
|
|
new FoglalkozasDBHelper().LoadByPartnerId(collection, m_Filter, Owner.ID);
|
|
}
|
|
|
|
private static SDA.DataProvider.SDACommand CreateInsertFoglalkozasCommand()
|
|
{
|
|
SDA.DataProvider.SDACommand result = new SDA.DataProvider.SDACommand();
|
|
// nincs kapcsolótábla...
|
|
result.CommandText = @"update T_FOGLALKOZAS_OSSZES set C_INTEZMENYID = :pINTEZMENYID where (ID = :pFOGLALKOZASID)";
|
|
result.Parameters.Add("pINTEZMENYID", SDA.DataProvider.SDADBType.Int);
|
|
result.Parameters.Add("pFOGLALKOZASID", SDA.DataProvider.SDADBType.Int);
|
|
return result;
|
|
}
|
|
|
|
private void DoAdd(Intezmeny owner, Foglalkozas partner)
|
|
{
|
|
using (SDA.DataProvider.SDACommand command = CreateInsertFoglalkozasCommand())
|
|
{
|
|
command.Connection = UserContext.Instance.SDAConnection;
|
|
command.Transaction = UserContext.Instance.SDATransaction;
|
|
command.Parameters["pINTEZMENYID"].Value = owner.ID;
|
|
command.Parameters["pFOGLALKOZASID"].Value = partner.ID;
|
|
command.ExecuteNonQuery();
|
|
}
|
|
}
|
|
|
|
public override void AddItem(Foglalkozas entity)
|
|
{
|
|
var assochandler = AssociationHandlerManager.Create<Foglalkozas, Intezmeny>("Foglalkozas_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 CreateDeleteFoglalkozasCommand()
|
|
{
|
|
SDA.DataProvider.SDACommand result = new SDA.DataProvider.SDACommand();
|
|
// nincs kapcsolótábla...
|
|
result.CommandText = @"update T_FOGLALKOZAS_OSSZES set C_INTEZMENYID = null where (C_INTEZMENYID = :pINTEZMENYID and ID = :pFOGLALKOZASID)";
|
|
result.Parameters.Add("pINTEZMENYID", SDA.DataProvider.SDADBType.Int);
|
|
result.Parameters.Add("pFOGLALKOZASID", SDA.DataProvider.SDADBType.Int);
|
|
return result;
|
|
}
|
|
|
|
private void DoRemove(Intezmeny owner, Foglalkozas partner)
|
|
{
|
|
using (SDA.DataProvider.SDACommand command = CreateDeleteFoglalkozasCommand())
|
|
{
|
|
command.Connection = UserContext.Instance.SDAConnection;
|
|
command.Transaction = UserContext.Instance.SDATransaction;
|
|
command.Parameters["pINTEZMENYID"].Value = owner.ID;
|
|
command.Parameters["pFOGLALKOZASID"].Value = partner.ID;
|
|
command.ExecuteNonQuery();
|
|
}
|
|
}
|
|
|
|
public override void DeleteItem(Foglalkozas entity)
|
|
{
|
|
var assochandler = AssociationHandlerManager.Create<Foglalkozas, Intezmeny>("Foglalkozas_Intezmeny");
|
|
assochandler.BeforeDelete(entity, this.Owner);
|
|
entity.Delete(true);
|
|
assochandler.AfterDelete(entity, this.Owner);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Az osztály elvégzi az UML modell 'Tanev -> Foglalkozas (Foglalkozas)'
|
|
/// asszociációjának teljes kezelését.
|
|
/// </summary>
|
|
internal class Tanev_Foglalkozas_DA : EntityCollectionDA<Tanev, Foglalkozas>
|
|
{
|
|
internal protected Tanev_Foglalkozas_DA(Tanev owner)
|
|
: base(owner)
|
|
{
|
|
}
|
|
|
|
// Nincs kapcsolótábla
|
|
private const string m_Filter = @" and (T_FOGLALKOZAS_OSSZES.C_TANEVID = :pID) ";
|
|
|
|
public override void LoadCollection(IAssociatedEntityCollection<Foglalkozas> collection)
|
|
{
|
|
new FoglalkozasDBHelper().LoadByPartnerId(collection, m_Filter, Owner.ID);
|
|
}
|
|
|
|
private static SDA.DataProvider.SDACommand CreateInsertFoglalkozasCommand()
|
|
{
|
|
SDA.DataProvider.SDACommand result = new SDA.DataProvider.SDACommand();
|
|
// nincs kapcsolótábla...
|
|
result.CommandText = @"update T_FOGLALKOZAS_OSSZES set C_TANEVID = :pTANEVID where (ID = :pFOGLALKOZASID)";
|
|
result.Parameters.Add("pTANEVID", SDA.DataProvider.SDADBType.Int);
|
|
result.Parameters.Add("pFOGLALKOZASID", SDA.DataProvider.SDADBType.Int);
|
|
return result;
|
|
}
|
|
|
|
private void DoAdd(Tanev owner, Foglalkozas partner)
|
|
{
|
|
using (SDA.DataProvider.SDACommand command = CreateInsertFoglalkozasCommand())
|
|
{
|
|
command.Connection = UserContext.Instance.SDAConnection;
|
|
command.Transaction = UserContext.Instance.SDATransaction;
|
|
command.Parameters["pTANEVID"].Value = owner.ID;
|
|
command.Parameters["pFOGLALKOZASID"].Value = partner.ID;
|
|
command.ExecuteNonQuery();
|
|
}
|
|
}
|
|
|
|
public override void AddItem(Foglalkozas entity)
|
|
{
|
|
var assochandler = AssociationHandlerManager.Create<Foglalkozas, Tanev>("Foglalkozas_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 CreateDeleteFoglalkozasCommand()
|
|
{
|
|
SDA.DataProvider.SDACommand result = new SDA.DataProvider.SDACommand();
|
|
// nincs kapcsolótábla...
|
|
result.CommandText = @"update T_FOGLALKOZAS_OSSZES set C_TANEVID = null where (C_TANEVID = :pTANEVID and ID = :pFOGLALKOZASID)";
|
|
result.Parameters.Add("pTANEVID", SDA.DataProvider.SDADBType.Int);
|
|
result.Parameters.Add("pFOGLALKOZASID", SDA.DataProvider.SDADBType.Int);
|
|
return result;
|
|
}
|
|
|
|
private void DoRemove(Tanev owner, Foglalkozas partner)
|
|
{
|
|
using (SDA.DataProvider.SDACommand command = CreateDeleteFoglalkozasCommand())
|
|
{
|
|
command.Connection = UserContext.Instance.SDAConnection;
|
|
command.Transaction = UserContext.Instance.SDATransaction;
|
|
command.Parameters["pTANEVID"].Value = owner.ID;
|
|
command.Parameters["pFOGLALKOZASID"].Value = partner.ID;
|
|
command.ExecuteNonQuery();
|
|
}
|
|
}
|
|
|
|
public override void DeleteItem(Foglalkozas entity)
|
|
{
|
|
var assochandler = AssociationHandlerManager.Create<Foglalkozas, Tanev>("Foglalkozas_Tanev");
|
|
assochandler.BeforeDelete(entity, this.Owner);
|
|
entity.Delete(true);
|
|
assochandler.AfterDelete(entity, this.Owner);
|
|
}
|
|
}
|
|
|
|
}
|
|
|