870 lines
36 KiB
C#
870 lines
36 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using Kreta.Core.Logic;
|
|
using Kreta.DataAccess.Interfaces;
|
|
using Kreta.DataAccessManual.Interfaces;
|
|
using Kreta.DataAccessManual.Util;
|
|
using Kreta.Enums;
|
|
using Kreta.Framework;
|
|
using Kreta.Framework.Util;
|
|
using Kreta.Resources;
|
|
using SDA.DataProvider;
|
|
using SDA.Kreta.Entities;
|
|
|
|
namespace Kreta.DataAccessManual
|
|
{
|
|
internal class TantargyDAL : DataAccessBase, ITantargyDal
|
|
{
|
|
public TantargyDAL(DalHandler dalHandler) : base(dalHandler)
|
|
{
|
|
}
|
|
|
|
public TantargyDAL(DalHandler dalHandler, GridParameters parameters) : base(dalHandler, parameters)
|
|
{
|
|
}
|
|
|
|
public ITantargyNyelv GetTantargyNyelv()
|
|
{
|
|
return TantargyNyelv.GiveAnInstance();
|
|
}
|
|
|
|
public ITantargy GetTantargy()
|
|
{
|
|
return Tantargy.GiveAnInstance();
|
|
}
|
|
|
|
public ITantargy GetTantargy(int id)
|
|
{
|
|
var entity = Tantargy.GiveAnInstance();
|
|
entity.LoadByID(id);
|
|
|
|
return entity;
|
|
}
|
|
|
|
public DataSet GetTantargyDataSet(int tanevId, int? tanarId, bool filterNincsBeloleOra = false)
|
|
{
|
|
var commandText = @"SELECT DISTINCT
|
|
tantargy.ID,
|
|
tantargy.C_GYAKORLATI GyakorlatiTargy,
|
|
tantargy.C_NEV TantargyNev,
|
|
tantargy.C_ROVIDNEV TantargyRovidNev,
|
|
tantargy.C_TARGYKATEGORIA TargyKategoria,
|
|
tantargy.C_FOTARGYID FoTargyID,
|
|
fotargy.C_NEV FoTargyNev,
|
|
tantargy.C_FOTARGYE isFoTargy,
|
|
tantargy.C_SZERVEZETID SzervezetId
|
|
FROM T_TANTARGY_OSSZES tantargy
|
|
LEFT JOIN T_TANTARGY_OSSZES fotargy ON fotargy.ID = tantargy.C_FOTARGYID"
|
|
+ (tanarId.HasValue ? @" INNER JOIN T_FOGLALKOZAS_OSSZES ON tantargy.ID = T_FOGLALKOZAS_OSSZES.C_TANTARGYID" : " ")
|
|
+ " WHERE tantargy.TOROLT='F' " +
|
|
"AND tantargy.C_TANEVID = :pTanevID "
|
|
+ (tanarId.HasValue ? @" AND T_FOGLALKOZAS_OSSZES.C_TANARID = :pTanarID AND T_FOGLALKOZAS_OSSZES.TOROLT= 'F'" : " ")
|
|
+ (filterNincsBeloleOra ? @" AND tantargy.C_ISNINCSBELOLEORA = 'F'" : string.Empty);
|
|
|
|
//1-es a tanórán kívüli foglalkozás, default data-ból jön, nem lehet törölni, módosítani
|
|
|
|
var param = new List<CommandParameter>();
|
|
param.Add(new CommandParameter("pTanevID", tanevId));
|
|
if (tanarId.HasValue)
|
|
{
|
|
param.Add(new CommandParameter("pTanarID", tanarId.Value));
|
|
}
|
|
|
|
DataSet ds = this.GetData(commandText, param, dictionaryItemColumns: "TargyKategoria");
|
|
|
|
return ds;
|
|
}
|
|
|
|
public DataSet GetTantargyakKiveveAltargyak(int? userId)
|
|
{
|
|
using (SDACommand command = new SDACommand())
|
|
{
|
|
command.Connection = UserContext.Instance.SDAConnection;
|
|
command.Transaction = UserContext.Instance.SDATransaction;
|
|
command.CommandType = CommandType.StoredProcedure;
|
|
|
|
command.CommandText = "sp_GetFelhasznaloErintettTargyai";
|
|
command.Parameters.Add("felhasznaloId", userId);
|
|
|
|
var dts = new DataSet();
|
|
using (var adapter = new SDADataAdapter())
|
|
{
|
|
adapter.SelectCommand = command;
|
|
adapter.Fill(dts);
|
|
}
|
|
|
|
return dts;
|
|
}
|
|
}
|
|
|
|
public DataSet GetTantargyakNincsBeloleOra(int tanevId)
|
|
{
|
|
var paramlist = new List<CommandParameter>();
|
|
paramlist.Add(new CommandParameter("pTanevID", tanevId));
|
|
var CommandText = @"
|
|
SELECT C_NEV AS TantargyNev
|
|
FROM T_TANTARGY_OSSZES
|
|
WHERE C_ISNINCSBELOLEORA = 'T'
|
|
AND TOROLT = 'F'
|
|
AND C_TANEVID = :pTanevID
|
|
";
|
|
|
|
DataSet ds = GetData(CommandText, paramlist);
|
|
|
|
return ds;
|
|
}
|
|
|
|
public DataSet GetFotargyak(int? kiveve = null)
|
|
{
|
|
var commandText = new StringBuilder(@"select
|
|
ID Id,
|
|
C_NEV Nev
|
|
from T_TANTARGY_OSSZES
|
|
where
|
|
C_FOTARGYE = 'T' and
|
|
TOROLT = 'F'");
|
|
var parameters = new List<CommandParameter>();
|
|
|
|
if (kiveve.HasValue)
|
|
{
|
|
commandText.Append(@"
|
|
AND T_TANTARGY.ID <> :pID");
|
|
parameters.Add(new CommandParameter("pID", kiveve));
|
|
}
|
|
|
|
DataSet ds = this.GetData(commandText.ToString(), parameters);
|
|
|
|
return ds;
|
|
}
|
|
|
|
public DataSet GetFotargyakByTanev(int tanevId)
|
|
{
|
|
var commandText = new StringBuilder(@"
|
|
select
|
|
t.ID Id,
|
|
t.C_NEV Nev
|
|
from T_TANTARGY_OSSZES t
|
|
where
|
|
t.C_FOTARGYE = 'T' and t.TOROLT = 'F'");
|
|
|
|
var parameters = new List<CommandParameter>();
|
|
commandText.Append(@" AND t.C_TANEVID = :pTanevId");
|
|
parameters.Add(new CommandParameter("pTanevId", tanevId));
|
|
|
|
DataSet ds = this.GetData(commandText.ToString(), parameters);
|
|
return ds;
|
|
}
|
|
|
|
public bool IsGyakorlatiTantargy(int tantargyId)
|
|
{
|
|
using (SDACommand command = new SDACommand())
|
|
{
|
|
command.Connection = UserContext.Instance.SDAConnection;
|
|
command.Transaction = UserContext.Instance.SDATransaction;
|
|
command.CommandText = "select 1 from T_TANTARGY where C_GYAKORLATI = 'T' and ID = :pTantargyId";
|
|
command.Parameters.Add("pTantargyId", tantargyId);
|
|
|
|
var result = command.ExecuteScalar();
|
|
if (result != null)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public DataSet GetTanarTantargyaiByTanevCsoportositva(int tanevId, string egyebGroup, bool filterNincsBeloleOra = false)
|
|
{
|
|
var paramlist = new List<CommandParameter>();
|
|
paramlist.Add(new CommandParameter("pTanevID", tanevId));
|
|
paramlist.Add(new CommandParameter("pEgyeb", egyebGroup));
|
|
var CommandText = @"
|
|
SELECT
|
|
T_TANTARGY_OSSZES.ID ID,
|
|
T_TANTARGY_OSSZES.C_NEV TantargyNev,
|
|
:pEgyeb GroupName
|
|
FROM T_TANTARGY_OSSZES
|
|
WHERE T_TANTARGY_OSSZES.TOROLT='F'
|
|
AND T_TANTARGY_OSSZES.C_TANEVID = :pTanevID"
|
|
+ (filterNincsBeloleOra ? " AND C_ISNINCSBELOLEORA = 'F'" : string.Empty) + @"
|
|
ORDER BY GroupName, TantargyNev
|
|
";
|
|
|
|
DataSet ds = GetData(CommandText, paramlist);
|
|
|
|
return ds;
|
|
}
|
|
|
|
public bool TantargyKategoriaHasznalatbanVan(int targyKatId)
|
|
{
|
|
using (SDACommand command = new SDACommand())
|
|
{
|
|
command.Connection = UserContext.Instance.SDAConnection;
|
|
command.Transaction = UserContext.Instance.SDATransaction;
|
|
command.Parameters.Add("pTargyKatID", targyKatId);
|
|
command.CommandText = @"select count(1)
|
|
from T_TANTARGY
|
|
where TOROLT = 'F' and
|
|
C_TARGYKATEGORIA = :pTargyKatID";
|
|
|
|
int cnt = Convert.ToInt32(command.ExecuteScalar());
|
|
|
|
return cnt != 0;
|
|
}
|
|
}
|
|
|
|
public DataSet GetExportTantargyakMindenAdataExcelExport(int tanevId,
|
|
string tantargyNev,
|
|
int? tantargyKategoriaId,
|
|
int? eslTargykategoriaTipusId,
|
|
int? isErtekelesKorlatozva,
|
|
int? isFotargy,
|
|
int? fotargyId,
|
|
int? isGyakorlati,
|
|
string rovidNev,
|
|
string bizonyitvanyNev,
|
|
int? isAltantargykentBizonyitvanyban,
|
|
int? isNincsBeloleOra,
|
|
int? isOsztalyNaplobanNemJelenikMeg,
|
|
int? isOsztalyokOrarendjebenMegjelenik,
|
|
int? isTanulmanyiAtlagbaSzamit,
|
|
int? isAmiTargy,
|
|
int? isKollegiumTargy,
|
|
int? isEgymiTargy,
|
|
int? isFelnottoktatasTargy,
|
|
int? isMszgTargy,
|
|
string angolNev,
|
|
string nemetNev,
|
|
string horvatNev,
|
|
string romanNev,
|
|
string szerbNev,
|
|
bool? nincsTantargykategoria)
|
|
{
|
|
List<CommandParameter> paramsList = new List<CommandParameter>();
|
|
paramsList.Add(new CommandParameter("pTanevId", tanevId));
|
|
|
|
var command = new StringBuilder($@"
|
|
SELECT DISTINCT
|
|
tantargy.C_SORSZAM as '{TantargyResource.Sorszam}'
|
|
,tantargy.C_NEV as '{TantargyResource.TantargyNev}'
|
|
,tanev.C_NEV as '{TantargyResource.Tanev}'
|
|
, IIF(tantargy.C_TARGYKATEGORIA IS NULL, '-', kategoria.C_NAME) as '{TantargyResource.TantargyKategoria}'
|
|
, IIF(tantargy.C_ESLTANTARGYKATEGORIAID IS NULL, '-', eslKategoria.C_NAME) as '{TantargyResource.ESLTantargyKategoria}'
|
|
, IIF(tantargy.C_ROVIDNEV IS NULL, '-', tantargy.C_ROVIDNEV) as '{TantargyResource.TantargyRovidnev}'
|
|
, IIF(tantargy.C_NEVNYOMTATVANYBAN IS NULL, tantargy.C_ROVIDNEV, tantargy.C_NEVNYOMTATVANYBAN) as '{TantargyResource.BizonyitvanybanMegjelenoNev}'
|
|
, IIF(tantargy.C_FOTARGYE = 'T', 'Igen', 'Nem') as '{TantargyResource.Fotantargy}'
|
|
, IIF(tt.C_NEV IS NULL, '-', tt.C_NEV) as '{TantargyResource.KapcsolodoFotantargyNeve}'
|
|
, IIF(tantargy.C_ALTANTARGYKENTNYOMTATVANYBAN = 'T', 'Igen', 'Nem') as '{TantargyResource.AltantargykentBizonyitvanyban}'
|
|
, IIF(tantargy.C_GYAKORLATI = 'T', 'Igen', 'Nem') as '{TantargyResource.GyakorlatiTargy}'
|
|
, IIF(tantargy.C_GYAKORLATIGENYESSEG IS NULL, '-', tantargy.C_GYAKORLATIGENYESSEG) as '{TantargyResource.Gyakorlatigenyesseg}'
|
|
,tantargy.C_MEGJEGYZES as '{CommonResource.Megjegyzes}'
|
|
, IIF(tantargy.C_ISAMITARGY = 'T', 'Igen', 'Nem') as '{TantargyResource.AmiTargy}'
|
|
, IIF(tantargy.C_ISMSZGTARGY = 'T', 'Igen', 'Nem') as '{TantargyResource.MSZGtantargy}'
|
|
, IIF(tantargy.C_ISKOLLEGIUMTARGY = 'T', 'Igen', 'Nem') as '{TantargyResource.KollegiumTargy}'
|
|
, IIF(tantargy.C_ISEGYMITARGY = 'T', 'Igen', 'Nem') as '{TantargyResource.EgymiTargy}'
|
|
, IIF(tantargy.C_ISFELNOTTOKTATASTARGY = 'T', 'Igen', 'Nem') as '{TantargyResource.FelnottoktatasTargy}'
|
|
, IIF(tantargy.C_ISTANULMANYIATLAGBANEMSZAMIT = 'T', 'Igen', 'Nem') as '{TantargyResource.TantagyAtlagbaSzamitasa}'
|
|
, IIF(tantargy.C_ISNINCSBELOLEORA = 'T', 'Igen', 'Nem') as '{TantargyResource.NincsBeloleOra}'
|
|
, IIF(tantargy.C_ISOSZTALYZATTALERTEKELHETO = 'F' OR
|
|
tantargy.C_ISSZAZALEKOSANERTEKELHETO = 'F' OR
|
|
tantargy.C_ISSZOVEGESENERTEKELHETO = 'F', 'Igen', 'Nem') as '{TantargyResource.ErtekelesKorlatozas}'
|
|
, IIF(tantargy.C_ISOSZTALYZATTALERTEKELHETO = 'T', 'Igen', 'Nem') as '{TantargyResource.OsztalyzattalErtekelheto}'
|
|
, IIF(tantargy.C_ISSZOVEGESENERTEKELHETO = 'T', 'Igen', 'Nem') as '{TantargyResource.SzovegesenErtekelheto}'
|
|
, IIF(tantargy.C_ISSZAZALEKOSANERTEKELHETO = 'T', 'Igen', 'Nem') as '{TantargyResource.SzazalekosanErtekelheto}'
|
|
, IIF(tantargy.C_ISOSZTALYNAPLOBANEMLATSZIK = 'T', 'Igen', 'Nem') as '{TantargyResource.OsztalynaplobanNemJelenikMeg}'
|
|
,CASE WHEN tantargy.C_FOTARGYID IS NULL THEN ISNULL(kategoria.C_ORDER, 10000) ELSE ISNULL(fotargyKategoria.C_ORDER, 10000) END AS KategoriaOrder
|
|
,COALESCE(tt.C_NEVNYOMTATVANYBAN, tt.C_NEV, tantargy.C_NEV) AS NevOrder
|
|
FROM T_TANTARGY_OSSZES tantargy
|
|
INNER JOIN T_DICTIONARYITEMBASE_OSSZES kategoria ON kategoria.ID = tantargy.C_TARGYKATEGORIA AND tantargy.C_TANEVID = kategoria.C_TANEVID
|
|
JOIN T_TANEV_OSSZES tanev on tanev.ID = tantargy.C_TANEVID and tanev.TOROLT = 'F'
|
|
LEFT JOIN T_TANTARGY_OSSZES tt on tt.ID = tantargy.C_FOTARGYID and tt.TOROLT = 'F'
|
|
LEFT JOIN T_TANTARGYNYELV tny ON tantargy.ID = tny.C_TANTARGYID AND tny.C_TANEVID = :pTanevId
|
|
LEFT JOIN T_DICTIONARYITEMBASE_OSSZES fotargyKategoria ON fotargyKategoria.ID = tt.C_TARGYKATEGORIA AND fotargyKategoria.TOROLT = 'F' AND fotargyKategoria.C_TANEVID = tt.C_TANEVID
|
|
LEFT JOIN T_DICTIONARYITEMBASE_OSSZES eslKategoria ON eslKategoria.ID = tantargy.C_ESLTANTARGYKATEGORIAID AND eslKategoria.TOROLT = 'F' AND eslKategoria.C_TANEVID = tantargy.C_TANEVID
|
|
WHERE
|
|
tantargy.TOROLT = 'F' AND tantargy.C_TANEVID = :pTanevId
|
|
");
|
|
|
|
if (!string.IsNullOrWhiteSpace(tantargyNev))
|
|
{
|
|
command.Append($" and lower(tantargy.C_NEV) like '%' + @{nameof(tantargyNev)} + '%'");
|
|
paramsList.Add(new CommandParameter(nameof(tantargyNev), tantargyNev.ToLowerInvariant()));
|
|
}
|
|
|
|
if (nincsTantargykategoria.HasValue && nincsTantargykategoria.Value)
|
|
{
|
|
command.Append(@" and tantargy.C_TARGYKATEGORIA = :pKatID");
|
|
paramsList.Add(new CommandParameter("pKatID", TargyKategoriaTipusEnum.na));
|
|
}
|
|
else if (tantargyKategoriaId.HasValue)
|
|
{
|
|
command.Append(@" and tantargy.C_TARGYKATEGORIA = :pKatID");
|
|
paramsList.Add(new CommandParameter("pKatID", tantargyKategoriaId));
|
|
}
|
|
|
|
if (eslTargykategoriaTipusId.HasValue)
|
|
{
|
|
command.Append(@" and tantargy.C_ESLTANTARGYKATEGORIAID = :pEslTargykategoriaTipusId");
|
|
paramsList.Add(new CommandParameter("pEslTargykategoriaTipusId", eslTargykategoriaTipusId));
|
|
}
|
|
|
|
if (isFotargy.HasValue)
|
|
{
|
|
if (isFotargy.Value == 1)
|
|
{
|
|
command.Append(@" and tantargy.C_FOTARGYE = 'T'");
|
|
}
|
|
if (isFotargy.Value == 0)
|
|
{
|
|
command.Append(@" and tantargy.C_FOTARGYE = 'F'");
|
|
}
|
|
}
|
|
|
|
if (isErtekelesKorlatozva.HasValue)
|
|
{
|
|
if (isErtekelesKorlatozva.Value == 1)
|
|
{
|
|
command.Append(@" and (tantargy.C_ISOSZTALYZATTALERTEKELHETO = 'F' OR
|
|
tantargy.C_ISSZAZALEKOSANERTEKELHETO = 'F' OR
|
|
tantargy.C_ISSZOVEGESENERTEKELHETO = 'F')");
|
|
}
|
|
if (isErtekelesKorlatozva.Value == 0)
|
|
{
|
|
command.Append(@" and tantargy.C_ISOSZTALYZATTALERTEKELHETO = 'T' and
|
|
tantargy.C_ISSZAZALEKOSANERTEKELHETO = 'T' and
|
|
tantargy.C_ISSZOVEGESENERTEKELHETO = 'T'");
|
|
}
|
|
}
|
|
|
|
if (fotargyId.HasValue)
|
|
{
|
|
command.Append(@" and tt.ID = :pFotargyID");
|
|
paramsList.Add(new CommandParameter("pFotargyID", fotargyId));
|
|
}
|
|
|
|
if (isGyakorlati.HasValue)
|
|
{
|
|
if (isGyakorlati.Value == 1)
|
|
{
|
|
command.Append(@" and tantargy.C_GYAKORLATI = 'T'");
|
|
}
|
|
if (isGyakorlati.Value == 0)
|
|
{
|
|
command.Append(@" and tantargy.C_GYAKORLATI = 'F'");
|
|
}
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(rovidNev))
|
|
{
|
|
command.Append($" and lower(tantargy.C_ROVIDNEV) like '%' + @{nameof(rovidNev)} + '%'");
|
|
paramsList.Add(new CommandParameter(nameof(rovidNev), rovidNev.ToLowerInvariant()));
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(bizonyitvanyNev))
|
|
{
|
|
command.Append($" and lower(tantargy.C_NEVNYOMTATVANYBAN) like '%' + @{nameof(bizonyitvanyNev)} + '%'");
|
|
paramsList.Add(new CommandParameter(nameof(bizonyitvanyNev), bizonyitvanyNev.ToLowerInvariant()));
|
|
}
|
|
|
|
if (isAltantargykentBizonyitvanyban.HasValue)
|
|
{
|
|
if (isAltantargykentBizonyitvanyban.Value == 1)
|
|
{
|
|
command.Append(@" and tantargy.C_ALTANTARGYKENTNYOMTATVANYBAN = 'T'");
|
|
}
|
|
if (isAltantargykentBizonyitvanyban.Value == 0)
|
|
{
|
|
command.Append(@" and tantargy.C_ALTANTARGYKENTNYOMTATVANYBAN = 'F'");
|
|
}
|
|
}
|
|
|
|
if (isNincsBeloleOra.HasValue)
|
|
{
|
|
if (isNincsBeloleOra.Value == 1)
|
|
{
|
|
command.Append(@" and tantargy.C_ISNINCSBELOLEORA = 'T'");
|
|
}
|
|
if (isNincsBeloleOra.Value == 0)
|
|
{
|
|
command.Append(@" and tantargy.C_ISNINCSBELOLEORA = 'F'");
|
|
}
|
|
}
|
|
|
|
if (isOsztalyNaplobanNemJelenikMeg.HasValue)
|
|
{
|
|
if (isOsztalyNaplobanNemJelenikMeg.Value == 1)
|
|
{
|
|
command.Append(@" and tantargy.C_ISOSZTALYNAPLOBANEMLATSZIK = 'T'");
|
|
}
|
|
if (isOsztalyNaplobanNemJelenikMeg.Value == 0)
|
|
{
|
|
command.Append(@" and tantargy.C_ISOSZTALYNAPLOBANEMLATSZIK = 'F'");
|
|
}
|
|
}
|
|
|
|
if (isOsztalyokOrarendjebenMegjelenik.HasValue)
|
|
{
|
|
if (isOsztalyokOrarendjebenMegjelenik.Value == 1)
|
|
{
|
|
command.Append(@" and tantargy.C_ISOSZTALYORARENDBENEMLATSZIK = 'F'");
|
|
}
|
|
if (isOsztalyokOrarendjebenMegjelenik.Value == 0)
|
|
{
|
|
command.Append(@" and tantargy.C_ISOSZTALYORARENDBENEMLATSZIK = 'T'");
|
|
}
|
|
}
|
|
|
|
if (isTanulmanyiAtlagbaSzamit.HasValue)
|
|
{
|
|
if (isTanulmanyiAtlagbaSzamit.Value == 1)
|
|
{
|
|
command.Append(@" and tantargy.C_ISTANULMANYIATLAGBANEMSZAMIT = 'F'");
|
|
}
|
|
if (isTanulmanyiAtlagbaSzamit.Value == 0)
|
|
{
|
|
command.Append(@" and tantargy.C_ISTANULMANYIATLAGBANEMSZAMIT = 'T'");
|
|
}
|
|
}
|
|
|
|
if (isAmiTargy.HasValue)
|
|
{
|
|
if (isAmiTargy.Value == 1)
|
|
{
|
|
command.Append(@" and tantargy.C_ISAMITARGY = 'T'");
|
|
}
|
|
if (isAmiTargy.Value == 0)
|
|
{
|
|
command.Append(@" and tantargy.C_ISAMITARGY = 'F'");
|
|
}
|
|
}
|
|
|
|
if (isKollegiumTargy.HasValue)
|
|
{
|
|
if (isKollegiumTargy.Value == 1)
|
|
{
|
|
command.Append(@" and tantargy.C_ISKOLLEGIUMTARGY = 'T'");
|
|
}
|
|
if (isKollegiumTargy.Value == 0)
|
|
{
|
|
command.Append(@" and tantargy.C_ISKOLLEGIUMTARGY = 'F'");
|
|
}
|
|
}
|
|
|
|
if (isEgymiTargy.HasValue)
|
|
{
|
|
if (isEgymiTargy.Value == 1)
|
|
{
|
|
command.Append(@" and tantargy.C_ISEGYMITARGY = 'T'");
|
|
}
|
|
if (isEgymiTargy.Value == 0)
|
|
{
|
|
command.Append(@" and tantargy.C_ISEGYMITARGY = 'F'");
|
|
}
|
|
}
|
|
|
|
if (isFelnottoktatasTargy.HasValue)
|
|
{
|
|
if (isFelnottoktatasTargy.Value == 1)
|
|
{
|
|
command.Append(@" and tantargy.C_ISFELNOTTOKTATASTARGY = 'T'");
|
|
}
|
|
if (isFelnottoktatasTargy.Value == 0)
|
|
{
|
|
command.Append(@" and tantargy.C_ISFELNOTTOKTATASTARGY = 'F'");
|
|
}
|
|
}
|
|
|
|
if (isMszgTargy.HasValue)
|
|
{
|
|
if (isMszgTargy.Value == 1)
|
|
{
|
|
command.Append(@" and tantargy.C_ISMSZGTARGY = 'T'");
|
|
}
|
|
if (isMszgTargy.Value == 0)
|
|
{
|
|
command.Append(@" and tantargy.C_ISMSZGTARGY = 'F'");
|
|
}
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(angolNev))
|
|
{
|
|
command.Append($" and lower(tantargy.C_ANGOLNEV) like '%' + @{nameof(angolNev)} + '%'");
|
|
paramsList.Add(new CommandParameter(nameof(angolNev), angolNev.ToLowerInvariant()));
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(nemetNev))
|
|
{
|
|
command.Append($" and lower(tantargy.C_NEMETNEV) like '%' + @{nameof(nemetNev)} + '%'");
|
|
paramsList.Add(new CommandParameter(nameof(nemetNev), nemetNev.ToLowerInvariant()));
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(horvatNev) || !string.IsNullOrWhiteSpace(romanNev) || !string.IsNullOrWhiteSpace(szerbNev))
|
|
{
|
|
var nyelvFilters = new List<string>();
|
|
if (!string.IsNullOrWhiteSpace(horvatNev))
|
|
{
|
|
nyelvFilters.Add($" (tny.C_NYELVID = 500 AND lower(tny.C_NEV) like '%' + @{nameof(horvatNev)} + '%')");
|
|
paramsList.Add(new CommandParameter(nameof(horvatNev), horvatNev.ToLowerInvariant()));
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(romanNev))
|
|
{
|
|
nyelvFilters.Add($" (tny.C_NYELVID = 523 AND lower(tny.C_NEV) like '%' + @{nameof(romanNev)} + '%')");
|
|
paramsList.Add(new CommandParameter(nameof(romanNev), romanNev.ToLowerInvariant()));
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(szerbNev))
|
|
{
|
|
nyelvFilters.Add($" (tny.C_NYELVID = 536 AND lower(tny.C_NEV) like '%' + @{nameof(szerbNev)} + '%')");
|
|
paramsList.Add(new CommandParameter(nameof(szerbNev), szerbNev.ToLowerInvariant()));
|
|
}
|
|
|
|
command.Append($" AND ({string.Join(" OR", nyelvFilters)})");
|
|
}
|
|
|
|
command.Append(@"
|
|
ORDER BY
|
|
tantargy.C_SORSZAM
|
|
,CASE WHEN tantargy.C_FOTARGYID IS NULL THEN ISNULL(kategoria.C_ORDER, 10000) ELSE ISNULL(fotargyKategoria.C_ORDER, 10000) END
|
|
,COALESCE(tt.C_NEVNYOMTATVANYBAN, tt.C_NEV, tantargy.C_NEV)");
|
|
|
|
return GetData(command.ToString(), paramsList);
|
|
}
|
|
|
|
public void Insert(ITantargy tantargy)
|
|
{
|
|
var entity = tantargy as Tantargy;
|
|
entity.Importalt = false;
|
|
entity.Insert();
|
|
FollowUp(entity);
|
|
DalHelper.Commit();
|
|
}
|
|
|
|
public void FullUpdate(ITantargy tantargy)
|
|
{
|
|
var entity = tantargy as Tantargy;
|
|
entity.Importalt = false;
|
|
entity.FullUpdate();
|
|
FollowUp(entity);
|
|
DalHelper.Commit();
|
|
}
|
|
|
|
public void Delete(ITantargy tantargy, int intezmenyId, int tanevId, bool updateTanoraEvesSorszam = true)
|
|
{
|
|
var entity = tantargy as Tantargy;
|
|
|
|
entity.Importalt = false;
|
|
entity.Tanmenet.RemoveAll();
|
|
entity.TantargyNyelv.DeleteAll();
|
|
entity.DKT_Feladat.DeleteAll();
|
|
|
|
var oraSorszamozasHalmazDAL = DalHelper.OraSorszamozasHalmaz();
|
|
foreach (var osszerendeles in entity.OraSorszamozasHalmazOsszerendeles)
|
|
{
|
|
oraSorszamozasHalmazDAL.DeleteOsszerendeles(osszerendeles.ID, intezmenyId, tanevId, updateTanoraEvesSorszam: false);
|
|
}
|
|
|
|
entity.Delete();
|
|
|
|
if (updateTanoraEvesSorszam)
|
|
{
|
|
DalHelper.TanitasiOra().UpdateTanitasiOraEvesSorszamTeljesTanev(intezmenyId, tanevId);
|
|
}
|
|
|
|
DalHelper.Commit();
|
|
}
|
|
|
|
public void FollowUpTantargy(int intezmenyId, int aktTanevId, int kovetkezoTanevId, int tantargyId = 0)
|
|
{
|
|
using (SDACommand command = new SDACommand())
|
|
{
|
|
command.Connection = UserContext.Instance.SDAConnection;
|
|
command.Transaction = UserContext.Instance.SDATransaction;
|
|
command.CommandText = "uspFollowUpTantargy";
|
|
command.Parameters.Add("intezmenyId", intezmenyId);
|
|
command.Parameters.Add("aktTanevId", aktTanevId);
|
|
command.Parameters.Add("kovetkezoTanevId", kovetkezoTanevId);
|
|
command.Parameters.Add("tantargyId", tantargyId);
|
|
command.CommandType = CommandType.StoredProcedure;
|
|
command.ExecuteNonQuery();
|
|
DalHelper.Commit();
|
|
}
|
|
}
|
|
|
|
public void FollowUpTantargyNyelv(int intezmenyId, int aktTanevId, int kovetkezoTanevId, int tantargyNyelvId)
|
|
{
|
|
using (SDACommand command = new SDACommand())
|
|
{
|
|
command.Connection = UserContext.Instance.SDAConnection;
|
|
command.Transaction = UserContext.Instance.SDATransaction;
|
|
command.CommandText = "uspFollowUpTantargyNyelv";
|
|
command.Parameters.Add("intezmenyId", intezmenyId);
|
|
command.Parameters.Add("aktTanevId", aktTanevId);
|
|
command.Parameters.Add("kovetkezoTanevId", kovetkezoTanevId);
|
|
command.Parameters.Add("tantargyNyelvId", tantargyNyelvId);
|
|
command.CommandType = CommandType.StoredProcedure;
|
|
command.ExecuteNonQuery();
|
|
DalHelper.Commit();
|
|
}
|
|
}
|
|
|
|
public bool HasTantargyFotargyAltargy(int intezmenyId, int tanevId, int fotargyAltargyId)
|
|
{
|
|
using (var sdaCommand = new SDACommand())
|
|
{
|
|
sdaCommand.Connection = UserContext.Instance.SDAConnection;
|
|
sdaCommand.Transaction = UserContext.Instance.SDATransaction;
|
|
sdaCommand.CommandType = CommandType.StoredProcedure;
|
|
|
|
sdaCommand.CommandText = "sp_HasTantargyFotargyAltargy";
|
|
|
|
sdaCommand.Parameters.Add("pIntezmenyId", intezmenyId);
|
|
sdaCommand.Parameters.Add("pTanevId", tanevId);
|
|
sdaCommand.Parameters.Add("pFotargyAltargyId", fotargyAltargyId);
|
|
|
|
bool result = Convert.ToBoolean(sdaCommand.ExecuteScalar());
|
|
return result;
|
|
}
|
|
}
|
|
|
|
public DataSet GetFotargyhozTartozoAltargyak(List<int> tantargyIdList)
|
|
{
|
|
using (var command = new SDACommand())
|
|
{
|
|
command.Connection = UserContext.Instance.SDAConnection;
|
|
command.Transaction = UserContext.Instance.SDATransaction;
|
|
command.CommandType = CommandType.StoredProcedure;
|
|
|
|
command.CommandText = "sp_GetFotargyakhozTartozoAltargyak";
|
|
|
|
command.Parameters.Add("pFotargyIdList", string.Join(",", tantargyIdList.ToArray()));
|
|
|
|
var dts = new DataSet();
|
|
using (var adapter = new SDADataAdapter())
|
|
{
|
|
adapter.SelectCommand = command;
|
|
adapter.Fill(dts);
|
|
}
|
|
return dts;
|
|
}
|
|
}
|
|
|
|
public DataSet GetTantargyDataSet(int tanevId, bool isRendezoOszlopokKell = false)
|
|
{
|
|
using (var command = new SDACommand())
|
|
{
|
|
command.Connection = UserContext.Instance.SDAConnection;
|
|
command.Transaction = UserContext.Instance.SDATransaction;
|
|
command.CommandType = CommandType.StoredProcedure;
|
|
command.CommandText = "uspGetTantargyData";
|
|
|
|
command.Parameters.Add("pTanevId", tanevId);
|
|
command.Parameters.Add("pIsRendezoOszlopokKell", isRendezoOszlopokKell);
|
|
|
|
var ds = new DataSet();
|
|
using (var adapter = new SDADataAdapter())
|
|
{
|
|
adapter.SelectCommand = command;
|
|
adapter.Fill(ds);
|
|
}
|
|
SetDNAME(ds.Tables[0], "TargykategoriaTipusId");
|
|
return ds;
|
|
}
|
|
}
|
|
|
|
public DataSet GetTantargyAMISablonhoz(int tanevId, int amiTantargySablonId)
|
|
{
|
|
var commandParameterList = new List<CommandParameter>
|
|
{
|
|
new CommandParameter("pTanevId", tanevId),
|
|
new CommandParameter("pAmiTantargySablonId", amiTantargySablonId)
|
|
};
|
|
|
|
string commandText = @"
|
|
SELECT
|
|
ISNULL(tantargy1.ID, tantargy2.ID) AS TantargyId
|
|
,amiTantargy.ID AS AMITantargyId
|
|
,amiTantargy.C_NEV AS TantargyNev
|
|
FROM T_AMITANTARGYSABLON amiTantargy
|
|
LEFT JOIN T_TANTARGY_OSSZES tantargy1 ON amiTantargy.ID = tantargy1.C_AMITANTARGYSABLONID
|
|
AND tantargy1.TOROLT = 'F'
|
|
AND tantargy1.C_TANEVID = :pTanevId
|
|
LEFT JOIN T_TANTARGY_OSSZES tantargy2 ON UPPER(amiTantargy.C_NEV) = UPPER(tantargy2.C_NEV)
|
|
AND tantargy2.TOROLT = 'F'
|
|
AND tantargy2.C_TANEVID = :pTanevId
|
|
WHERE amiTantargy.TOROLT = 'F'
|
|
AND amiTantargy.ID = :pAmiTantargySablonId
|
|
";
|
|
|
|
return GetData(commandText, commandParameterList);
|
|
}
|
|
|
|
public DataSet GetTantargyakSablonokkal(int tanevId)
|
|
{
|
|
var commandParameterList = new List<CommandParameter>
|
|
{
|
|
new CommandParameter("pTanevId", tanevId),
|
|
};
|
|
|
|
string commandText = @"
|
|
SELECT
|
|
ROW_NUMBER() OVER (ORDER BY tantargy.[Text]) AS ID
|
|
,tantargy.[Text]
|
|
,tantargy.TantargyId
|
|
,tantargy.SemaId
|
|
FROM (
|
|
SELECT
|
|
t.C_NEV AS [Text]
|
|
,t.ID AS TantargyId
|
|
,ISNULL(t.C_AMITANTARGYSABLONID, amiTantargy.ID) AS SemaId
|
|
FROM T_TANTARGY_OSSZES t
|
|
LEFT JOIN T_AMITANTARGYSABLON amiTantargy ON UPPER(amiTantargy.C_NEV) = UPPER(t.C_NEV)
|
|
AND amiTantargy.TOROLT = 'F'
|
|
WHERE t.TOROLT = 'F'
|
|
AND t.C_TANEVID = @pTanevId
|
|
|
|
UNION
|
|
|
|
SELECT
|
|
amiTantargy.C_NEV AS [Text]
|
|
,ISNULL(tantargy1.ID, tantargy2.ID) AS TantargyId
|
|
,amiTantargy.ID AS SemaId
|
|
FROM T_AMITANTARGYSABLON amiTantargy
|
|
LEFT JOIN T_TANTARGY_OSSZES tantargy1 ON amiTantargy.ID = tantargy1.C_AMITANTARGYSABLONID
|
|
AND tantargy1.TOROLT = 'F'
|
|
AND tantargy1.C_TANEVID = @pTanevId
|
|
LEFT JOIN T_TANTARGY_OSSZES tantargy2 ON UPPER(amiTantargy.C_NEV) = UPPER(tantargy2.C_NEV)
|
|
AND tantargy2.TOROLT = 'F'
|
|
AND tantargy2.C_TANEVID = @pTanevId
|
|
WHERE amiTantargy.TOROLT = 'F'
|
|
) tantargy
|
|
";
|
|
|
|
return GetData(commandText, commandParameterList);
|
|
}
|
|
|
|
public DataSet GetTantargyakEgyesErtekelessel(int tanevId, int intezmenyId, List<int> tantargyIdList)
|
|
{
|
|
var commandParameterList = new List<CommandParameter>
|
|
{
|
|
new CommandParameter("pTanevId", tanevId),
|
|
new CommandParameter("pIntezmenyId", intezmenyId),
|
|
new CommandParameter("pElegtelenOsztalyzat", (int)OsztalyzatTipusEnum.elegtelen_1_),
|
|
};
|
|
|
|
string commandText = $@"
|
|
SELECT DISTINCT
|
|
C_NEV
|
|
FROM T_TANULOERTEKELES_OSSZES
|
|
INNER JOIN T_TANTARGY_OSSZES ON T_TANTARGY_OSSZES.ID = T_TANULOERTEKELES_OSSZES.C_TANTARGYID
|
|
WHERE C_ERTEKELESOSZTALYZATID = @pElegtelenOsztalyzat
|
|
AND T_TANULOERTEKELES_OSSZES.C_TANEVID = @pTanevId
|
|
AND T_TANULOERTEKELES_OSSZES.C_INTEZMENYID = @pIntezmenyId
|
|
AND T_TANULOERTEKELES_OSSZES.TOROLT = 'F'
|
|
AND T_TANULOERTEKELES_OSSZES.C_TANTARGYID IN({ SqlLogic.ParseListToParameter(tantargyIdList)})";
|
|
|
|
return GetData(commandText, commandParameterList);
|
|
}
|
|
|
|
public void InsertNyelv(ITantargyNyelv tantargyNyelv)
|
|
{
|
|
var entity = tantargyNyelv as TantargyNyelv;
|
|
entity.Insert();
|
|
FollowUp(entity);
|
|
DalHelper.Commit();
|
|
}
|
|
|
|
public void FullUpdateNyelv(ITantargyNyelv tantargyNyelv)
|
|
{
|
|
var entity = tantargyNyelv as TantargyNyelv;
|
|
entity.FullUpdate();
|
|
FollowUp(entity);
|
|
DalHelper.Commit();
|
|
}
|
|
|
|
public (bool isOsztalyzattalErtekelheto, bool isSzovegesenErtekelheto, bool isSzazalekosanErtekelheto) GetErtekelesKorlatozasok(int tantargyId)
|
|
{
|
|
var paramList = new List<CommandParameter>
|
|
{
|
|
new CommandParameter("pTantargyId", tantargyId)
|
|
};
|
|
|
|
var command = @"
|
|
SELECT
|
|
ISNULL(MIN(tantargy.C_ISOSZTALYZATTALERTEKELHETO),'F') AS IsOsztalyzattalErtekelheto
|
|
,ISNULL(MIN(tantargy.C_ISSZOVEGESENERTEKELHETO),'F') AS IsSzovegesenErtekelheto
|
|
,ISNULL(MIN(tantargy.C_ISSZAZALEKOSANERTEKELHETO),'F') AS IsSzazalekosanErtekelheto
|
|
FROM T_TANTARGY_OSSZES tantargy
|
|
WHERE tantargy.TOROLT = 'F'
|
|
AND tantargy.ID = :pTantargyId
|
|
";
|
|
|
|
var ds = GetData(command, paramList);
|
|
|
|
var isOsztalyzattalErtekelheto = Convert.ToBoolean(ds.Tables[0].Rows[0]["IsOsztalyzattalErtekelheto"].ToString() == "T");
|
|
var isSzovegesenErtekelheto = Convert.ToBoolean(ds.Tables[0].Rows[0]["IsSzovegesenErtekelheto"].ToString() == "T");
|
|
var isSzazalekosanErtekelheto = Convert.ToBoolean(ds.Tables[0].Rows[0]["IsSzazalekosanErtekelheto"].ToString() == "T");
|
|
|
|
return (isOsztalyzattalErtekelheto, isSzovegesenErtekelheto, isSzazalekosanErtekelheto);
|
|
}
|
|
|
|
public DataSet GetTanuloAktualisanTanultTantargyai(int tanuloId, string magatartas, string szorgalom, List<int> tantargyIds = null, int? oktatasiNevelesiFeladatId = null)
|
|
{
|
|
using (var command = new SDACommand())
|
|
{
|
|
command.Connection = UserContext.Instance.SDAConnection;
|
|
command.Transaction = UserContext.Instance.SDATransaction;
|
|
command.CommandType = CommandType.StoredProcedure;
|
|
command.CommandText = "uspGetTanuloAktualisanTanultTantargyai";
|
|
|
|
command.Parameters.Add("tanuloId", tanuloId);
|
|
command.Parameters.Add("magatartas", magatartas);
|
|
command.Parameters.Add("szorgalom", szorgalom);
|
|
command.Parameters.Add("oktatasiNevelesiFeladatId", oktatasiNevelesiFeladatId);
|
|
|
|
if (tantargyIds != null)
|
|
{
|
|
command.Parameters.Add("tantargyIds", string.Join(",", tantargyIds.Select(x => x.ToString())));
|
|
}
|
|
|
|
else
|
|
{
|
|
command.Parameters.Add("tantargyIds", DBNull.Value);
|
|
}
|
|
|
|
var ds = new DataSet();
|
|
using (var adapter = new SDADataAdapter())
|
|
{
|
|
adapter.SelectCommand = command;
|
|
adapter.Fill(ds);
|
|
}
|
|
return ds;
|
|
}
|
|
}
|
|
|
|
public int? GetDualisKepzesTantargyId(int intezmenyId, int tanevId)
|
|
{
|
|
using (var command = new SDACommand())
|
|
{
|
|
command.Connection = UserContext.Instance.SDAConnection;
|
|
command.Transaction = UserContext.Instance.SDATransaction;
|
|
command.CommandText = $"SELECT TOP 1 ID FROM T_TANTARGY_OSSZES WHERE C_TANEVID = :pTanevId AND C_INTEZMENYID = :pIntezmenyId AND C_NEV = '{TantargyResource.DualisKepzes}' AND TOROLT = 'F'";
|
|
|
|
command.Parameters.Add("pIntezmenyId", intezmenyId);
|
|
command.Parameters.Add("pTanevId", tanevId);
|
|
|
|
var result = command.ExecuteScalar();
|
|
|
|
if (result != DBNull.Value && result != null)
|
|
{
|
|
return Convert.ToInt32(result);
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
}
|