761 lines
32 KiB
C#
761 lines
32 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Text;
|
|
using Kreta.Core;
|
|
using Kreta.DataAccess.Interfaces;
|
|
using Kreta.DataAccessManual.Interfaces;
|
|
using Kreta.DataAccessManual.Util;
|
|
using Kreta.Enums;
|
|
using Kreta.Enums.ManualEnums;
|
|
using Kreta.Framework;
|
|
using Kreta.Framework.Util;
|
|
using SDA.DataProvider;
|
|
using SDA.Kreta.Entities;
|
|
|
|
namespace Kreta.DataAccessManual
|
|
{
|
|
internal class FoglalkozasDal : DataAccessBase, IFoglalkozasDal
|
|
{
|
|
public FoglalkozasDal(DalHandler handler)
|
|
: base(handler)
|
|
{
|
|
}
|
|
|
|
public FoglalkozasDal(DalHandler handler, GridParameters parameters)
|
|
: base(handler, parameters)
|
|
{
|
|
}
|
|
|
|
public DataSet GetTanarFoglalkozasTipusok(int tanarId, int tanevId)
|
|
{
|
|
var parameters = new List<CommandParameter>();
|
|
parameters.Add(new CommandParameter("pTanarID", tanarId));
|
|
parameters.Add(new CommandParameter("pTanevID", tanevId));
|
|
var command = @"SELECT C_FOGLALKOZASTIPUSA Tipus
|
|
FROM T_FOGLALKOZAS_OSSZES foglalkozas
|
|
WHERE
|
|
foglalkozas.TOROLT = 'F' AND
|
|
foglalkozas.C_TANARID = :pTanarID AND
|
|
foglalkozas.C_TANEVID = :pTanevID
|
|
GROUP BY C_FOGLALKOZASTIPUSA";
|
|
|
|
return GetData(command, parameters, "Tipus");
|
|
}
|
|
|
|
/// <summary>
|
|
/// Vissza adja a tanár által tartott foglalkozásokat.
|
|
/// </summary>
|
|
/// <param name="tanarId"> Tanar azonosítü</param>
|
|
/// <param name="typeId">Az adott foglakozás tipusa ha nincs kitölte értéke -1 és mindent visszaad</param>
|
|
/// <returns></returns>
|
|
public DataSet GetTanarFoglalkozasok(int tanarId, int tanevId, string typeId = "")
|
|
{
|
|
var ds = new DataSet();
|
|
using (var command = new SDACommand())
|
|
{
|
|
command.Connection = UserContext.Instance.SDAConnection;
|
|
command.Transaction = UserContext.Instance.SDATransaction;
|
|
command.CommandType = CommandType.StoredProcedure;
|
|
command.CommandText = "uspGetTanarFoglalkozasai";
|
|
command.Parameters.Add("pTanarId", SDADBType.Int).Value = tanarId;
|
|
command.Parameters.Add("pTanevId", SDADBType.Int).Value = tanevId;
|
|
if (!string.IsNullOrWhiteSpace(typeId))
|
|
{
|
|
command.Parameters.Add("pFoglalkozasTipusId", SDADBType.Int).Value = typeId;
|
|
|
|
}
|
|
using (var adapter = new SDADataAdapter())
|
|
{
|
|
adapter.SelectCommand = command;
|
|
adapter.Fill(ds);
|
|
}
|
|
return ds;
|
|
}
|
|
}
|
|
|
|
public DataSet GetTanarNemTanitottFoglalkozasok(int tanarId, int tanevId)
|
|
{
|
|
var ds = new DataSet();
|
|
using (var command = new SDACommand())
|
|
{
|
|
command.Connection = UserContext.Instance.SDAConnection;
|
|
command.Transaction = UserContext.Instance.SDATransaction;
|
|
command.CommandType = CommandType.StoredProcedure;
|
|
command.CommandText = "uspGetTanarNemTanitottOsztalyaiByFoglalkozas";
|
|
command.Parameters.Add("pTanarId", SDADBType.Int).Value = tanarId;
|
|
command.Parameters.Add("pTanevId", SDADBType.Int).Value = tanevId;
|
|
using (var adapter = new SDADataAdapter())
|
|
{
|
|
adapter.SelectCommand = command;
|
|
adapter.Fill(ds);
|
|
}
|
|
return ds;
|
|
}
|
|
}
|
|
|
|
public DataSet GetFoglalkozasNev(int tanarId, int tantargyId, int osztalycsoportId, OktNevelesiKategoriaEnum? kategoria)
|
|
{
|
|
var parameters = new List<CommandParameter>();
|
|
parameters.Add(new CommandParameter("pTanarID", tanarId));
|
|
parameters.Add(new CommandParameter("pTantargyID", tantargyId));
|
|
parameters.Add(new CommandParameter("pOsztalycsoportID", osztalycsoportId));
|
|
|
|
if (kategoria.HasValue)
|
|
{
|
|
parameters.Add(new CommandParameter(nameof(kategoria), (int)kategoria));
|
|
}
|
|
else
|
|
{
|
|
parameters.Add(new CommandParameter(nameof(kategoria), DBNull.Value));
|
|
}
|
|
|
|
var command = $@"SELECT
|
|
F.ID,
|
|
OCS.C_NEV + ' - ' + T.C_NEV Nev,
|
|
F.C_TANTARGYID,
|
|
F.C_OSZTALYCSOPORTID
|
|
FROM T_FOGLALKOZAS F
|
|
INNER JOIN T_TANTARGY T on T.ID = F.C_TANTARGYID AND T.TOROLT = 'F'
|
|
INNER JOIN T_OSZTALYCSOPORT OCS on OCS.ID = F.C_OSZTALYCSOPORTID AND OCS.TOROLT = 'F'
|
|
AND (OCS.C_FELADATKATEGORIAID = @{nameof(kategoria)} OR @{nameof(kategoria)} IS NULL)
|
|
where F.TOROLT = 'F'
|
|
AND F.C_TANARID = :pTanarID
|
|
AND F.C_TANTARGYID = :pTantargyID
|
|
AND F.C_OSZTALYCSOPORTID = :pOsztalycsoportID";
|
|
|
|
return GetData(command, parameters);
|
|
}
|
|
|
|
public DataSet GetOsszesFoglalkozas(int tanevId, int? oktNevelesiKategoriaId = (int)OktNevelesiKategoriaEnum.NevelesOktatas)
|
|
{
|
|
var parameters = new List<CommandParameter>();
|
|
parameters.Add(new CommandParameter("pTanevID", tanevId));
|
|
|
|
if (oktNevelesiKategoriaId.HasValue)
|
|
{
|
|
parameters.Add(new CommandParameter("OktNevKatTipus", oktNevelesiKategoriaId));
|
|
}
|
|
else
|
|
{
|
|
parameters.Add(new CommandParameter("OktNevKatTipus", DBNull.Value));
|
|
}
|
|
var command = $@"SELECT DISTINCT
|
|
foglalkozas.ID,
|
|
osztalycsoport.ID OCSID,
|
|
(osztalycsoport.C_NEV + ' - ' + tantargy.C_NEV) NEV
|
|
FROM T_FOGLALKOZAS_OSSZES foglalkozas
|
|
INNER JOIN T_OSZTALYCSOPORT_OSSZES osztalycsoport
|
|
ON foglalkozas.C_OSZTALYCSOPORTID = osztalycsoport.ID
|
|
AND (osztalycsoport.C_FELADATKATEGORIAID = @OktNevKatTipus OR @OktNevKatTipus IS NULL )
|
|
INNER JOIN T_TANTARGY_OSSZES tantargy
|
|
ON tantargy.ID = foglalkozas.C_TANTARGYID
|
|
WHERE
|
|
foglalkozas.TOROLT = 'F'
|
|
AND foglalkozas.C_TANEVID = :pTanevID
|
|
AND tantargy.TOROLT = 'F'
|
|
AND osztalycsoport.TOROLT = 'F'
|
|
";
|
|
|
|
return GetData(command, parameters);
|
|
}
|
|
|
|
public DataSet GetOsztalyCsoportFoglalkozasai(int osztalyCsoportId, int tanevId, OktNevelesiKategoriaEnum? kategoria)
|
|
{
|
|
var parameters = new List<CommandParameter>();
|
|
parameters.Add(new CommandParameter("pOsztalyCsoportID", osztalyCsoportId));
|
|
parameters.Add(new CommandParameter("pTanevID", tanevId));
|
|
|
|
if (kategoria.HasValue && ((int)kategoria).IsEntityId())
|
|
{
|
|
parameters.Add(new CommandParameter(nameof(kategoria), (int)kategoria));
|
|
}
|
|
else
|
|
{
|
|
parameters.Add(new CommandParameter(nameof(kategoria), DBNull.Value));
|
|
}
|
|
|
|
string commandText = $@"
|
|
SELECT DISTINCT
|
|
foglalkozas.ID as ID,
|
|
foglalkozas.C_ORASZAM as Oraszam,
|
|
foglalkozas.C_FOGLALKOZASTIPUSA as Tipus,
|
|
STUFF(
|
|
(SELECT ',' + C_NYOMTATASINEV
|
|
FROM T_FELHASZNALO_OSSZES
|
|
inner join T_FOGLALKOZAS_OSSZES on T_FELHASZNALO_OSSZES.ID = T_FOGLALKOZAS_OSSZES.C_TANARID
|
|
where T_FOGLALKOZAS_OSSZES.ID = foglalkozas.ID
|
|
FOR XML PATH (''))
|
|
, 1, 1, '') Tanar,
|
|
T_TANTARGY_OSSZES.C_NEV as Tantargy
|
|
from T_FOGLALKOZAS_OSSZES foglalkozas
|
|
inner join T_FELHASZNALO_OSSZES on T_FELHASZNALO_OSSZES.ID = foglalkozas.C_TANARID AND T_FELHASZNALO_OSSZES.TOROLT='F'
|
|
inner join T_TANTARGY_OSSZES on T_TANTARGY_OSSZES.ID = foglalkozas.C_TANTARGYID AND T_TANTARGY_OSSZES.TOROLT='F'
|
|
inner join T_OSZTALYCSOPORT_OSSZES ocs on ocs.ID = foglalkozas.C_OSZTALYCSOPORTID AND ocs.TOROLT='F'
|
|
AND (ocs.C_FELADATKATEGORIAID = @{nameof(kategoria)} OR @{nameof(kategoria)} IS NULL)
|
|
WHERE
|
|
ocs.ID = :pOsztalyCsoportID
|
|
AND foglalkozas.TOROLT='F'";
|
|
|
|
DataSet ds = GetData(commandText, parameters, dictionaryItemColumns: "Tipus");
|
|
var tfDal = new TantargyFelosztasDAL(null);
|
|
|
|
tfDal.GetOraszamSUM(ds, commandText.ToString(), parameters);
|
|
return ds;
|
|
}
|
|
|
|
public DataSet GetTanuloFoglalkozasai(int tanuloId, int osztalyId, int tanevId, bool egyeni, IEnumerable<int> amiEgyeniCsoportok, OktNevelesiKategoriaEnum? kategoria, DateTime tanevElsoNapja)
|
|
{
|
|
var parameters = new List<CommandParameter>
|
|
{
|
|
new CommandParameter("pTanuloId", tanuloId),
|
|
new CommandParameter("pTanevID", tanevId),
|
|
new CommandParameter("pOsztalyId", osztalyId)
|
|
};
|
|
|
|
if (kategoria.HasValue)
|
|
{
|
|
parameters.Add(new CommandParameter(nameof(kategoria), (int)kategoria));
|
|
}
|
|
else
|
|
{
|
|
parameters.Add(new CommandParameter(nameof(kategoria), DBNull.Value));
|
|
}
|
|
|
|
string tanevBelepesDatumClause;
|
|
if (DateTime.Now < tanevElsoNapja)
|
|
{
|
|
tanevBelepesDatumClause = $"C_BELEPESDATUM = @{nameof(tanevElsoNapja)}";
|
|
parameters.Add(new CommandParameter(nameof(tanevElsoNapja), tanevElsoNapja));
|
|
}
|
|
else
|
|
{
|
|
tanevBelepesDatumClause = "C_BELEPESDATUM <= GETDATE()";
|
|
}
|
|
|
|
string commandText = $@"
|
|
SELECT DISTINCT
|
|
f.ID
|
|
,t.ID AS {(egyeni ? "Egyeni" : "")}TantargyID
|
|
,u.ID AS {(egyeni ? "Egyeni" : "")}TanarID
|
|
,f.C_ORASZAM AS {(egyeni ? "Egyeni" : "")}Oraszam
|
|
,f.C_ISOSSZEVONTORA AS {(egyeni ? "Egyeni" : "")}OsszevontOra
|
|
,ocs.ID AS {(egyeni ? "Egyeni" : "")}OsztalyId
|
|
,fat.ID AS {(egyeni ? "Egyeni" : "")}AmiFoglalkozasID
|
|
,fat.C_AMIFOTARGYID AS {(egyeni ? "Egyeni" : "")}AmiFotargy
|
|
,fat.C_AMITAGOZATID AS {(egyeni ? "Egyeni" : "")}AmiTagozat
|
|
,fat.C_AMITANTARGYKOTELEZOSEGID AS {(egyeni ? "Egyeni" : "")}AmiTantargyKotelezoseg
|
|
,fat.C_EVFOLYAMTIPUSID AS {(egyeni ? "Egyeni" : "")}EvfolyamTipus
|
|
,@pTanuloId AS TanuloId
|
|
,t.C_AMITANTARGYSABLONID AS {(egyeni ? "Egyeni" : "")}AmiTantargyID
|
|
,ocs.C_NEV AS Osztaly
|
|
,t.C_NEV AS Tantargy
|
|
,u.Nev AS Tanar
|
|
,f.C_FOGLALKOZASTIPUSA AS {(egyeni ? "Egyeni" : "")}FoglalkozasTipusa
|
|
,f.C_ISNEMZETISEGI AS {(egyeni ? "Egyeni" : "")}NemzetisegiOra
|
|
,f.C_TULORASZAM AS {(egyeni ? "Egyeni" : "")}TuloraSzam
|
|
,f.C_MEGBIZASIORASZAM AS {(egyeni ? "Egyeni" : "")}MegbizasiOraszam
|
|
FROM (
|
|
SELECT
|
|
C_OSZTALYCSOPORTID
|
|
FROM T_TANULOCSOPORT_OSSZES
|
|
WHERE TOROLT = 'F'
|
|
AND {tanevBelepesDatumClause}
|
|
AND (C_KILEPESDATUM IS NULL OR C_KILEPESDATUM > GETDATE())
|
|
AND C_TANULOID = @pTanuloId
|
|
AND C_TANEVID = @pTanevID
|
|
) tcs
|
|
INNER JOIN (
|
|
SELECT
|
|
fo.ID
|
|
,fo.C_TANTARGYID
|
|
,fo.C_OSZTALYCSOPORTID
|
|
,fo.C_TANARID
|
|
,fo.C_ORASZAM
|
|
,fo.C_ISOSSZEVONTORA
|
|
,fo.C_FOGLALKOZASTIPUSA
|
|
,fo.C_ISNEMZETISEGI
|
|
,fo.C_TULORASZAM
|
|
,fo.C_MEGBIZASIORASZAM
|
|
FROM T_FOGLALKOZAS_OSSZES fo
|
|
WHERE TOROLT = 'F'
|
|
AND C_TANEVID = @pTanevID
|
|
) f ON f.C_OSZTALYCSOPORTID = tcs.C_OSZTALYCSOPORTID
|
|
INNER JOIN (
|
|
SELECT
|
|
ID
|
|
,IIF(C_NEVSORREND = 'T', C_UTONEV + ' ' + C_VEZETEKNEV, IIF(C_ELOTAG IS NULL, '', C_ELOTAG + ' ') + C_VEZETEKNEV + ' ' + C_UTONEV) AS Nev
|
|
FROM T_FELHASZNALO_OSSZES
|
|
WHERE TOROLT = 'F'
|
|
AND C_TANEVID = @pTanevID
|
|
) u ON f.C_TANARID = u.ID
|
|
INNER JOIN (
|
|
SELECT
|
|
tantargy.ID
|
|
,ISNULL(tantargy.C_AMITANTARGYSABLONID, amiTantargy.ID) AS C_AMITANTARGYSABLONID
|
|
,tantargy.C_NEV
|
|
FROM T_TANTARGY_OSSZES tantargy
|
|
LEFT JOIN T_AMITANTARGYSABLON amiTantargy ON UPPER(amiTantargy.C_NEV) = UPPER(tantargy.C_NEV)
|
|
AND amiTantargy.TOROLT = 'F'
|
|
WHERE tantargy.TOROLT = 'F'
|
|
AND tantargy.C_TANEVID = @pTanevID
|
|
) t ON f.C_TANTARGYID = t.ID
|
|
INNER JOIN (
|
|
SELECT
|
|
ID
|
|
,C_NEV
|
|
FROM T_OSZTALYCSOPORT_OSSZES
|
|
WHERE TOROLT = 'F'
|
|
AND C_TANEVID = @pTanevID
|
|
AND (C_FELADATKATEGORIAID = @{nameof(kategoria)} OR @{nameof(kategoria)} IS NULL)
|
|
) ocs ON ocs.ID = f.C_OSZTALYCSOPORTID
|
|
LEFT JOIN (
|
|
SELECT
|
|
ID
|
|
,C_AMIFOTARGYID
|
|
,C_AMITAGOZATID
|
|
,C_AMITANTARGYKOTELEZOSEGID
|
|
,C_EVFOLYAMTIPUSID
|
|
,C_FOGLALKOZASID
|
|
FROM T_FOGLALKOZASAMITANULO_OSSZES
|
|
WHERE TOROLT = 'F'
|
|
AND C_TANEVID = @pTanevID
|
|
AND C_TANULOID = @pTanuloId
|
|
) fat ON fat.C_FOGLALKOZASID = f.ID
|
|
LEFT JOIN (
|
|
SELECT
|
|
ID
|
|
,C_TIPUSA
|
|
,C_OSZTALYBONTASID
|
|
FROM T_CSOPORT_OSSZES
|
|
WHERE TOROLT = 'F'
|
|
AND C_ALTANEVID = @pTanevID
|
|
) cs ON f.C_OSZTALYCSOPORTID = cs.ID
|
|
WHERE " + (egyeni ? @" cs.C_TIPUSA IN (" + string.Join(",", amiEgyeniCsoportok) + @")
|
|
AND cs.C_OSZTALYBONTASID = @pOsztalyId"
|
|
: @" (cs.C_TIPUSA NOT IN (" + string.Join(",", amiEgyeniCsoportok) + @")
|
|
OR cs.C_TIPUSA IS NULL)
|
|
AND (tcs.C_OSZTALYCSOPORTID = @pOsztalyId
|
|
OR cs.C_OSZTALYBONTASID = @pOsztalyId
|
|
OR (cs.C_OSZTALYBONTASID IS NULL AND cs.ID IS NOT NULL))");
|
|
|
|
var dictionaryItemColumns = egyeni ? "EgyeniAmiFotargy,EgyeniAmiTagozat,EgyeniAmiTantargyKotelezoseg,EgyeniEvfolyamTipus" : "AmiFotargy,AmiTagozat,AmiTantargyKotelezoseg,EvfolyamTipus";
|
|
var booleanColumns = egyeni ? "EgyeniOsszevontOra,EgyeniNemzetisegiOra" : "OsszevontOra,NemzetisegiOra";
|
|
|
|
DataSet ds = GetData(commandText, parameters, dictionaryItemColumns, booleanColumns);
|
|
return ds;
|
|
}
|
|
|
|
public DataSet GetFoglalkozasok(int? tanarId, int tanevId)
|
|
{
|
|
var parameters = new List<CommandParameter>();
|
|
parameters.Add(new CommandParameter("pTanevID", tanevId));
|
|
|
|
if (tanarId.HasValue)
|
|
{
|
|
parameters.Add(new CommandParameter("pTanarID", tanarId));
|
|
}
|
|
|
|
string command = @"
|
|
SELECT
|
|
foglalkozas.ID ID,
|
|
foglalkozas.C_NEV FoglalkozasNev,
|
|
foglalkozas.C_FOGLALKOZASTIPUSA FoglalkozasTipusa,
|
|
osztalycsoport.ID OsztalyCsoportID,
|
|
osztalycsoport.C_NEV OsztalyCsoportNev,"
|
|
+ (tanarId.HasValue ? @"
|
|
tanar.ID TanarID,
|
|
tanar.C_NYOMTATASINEV TanarNev,"
|
|
: "'' TanarID, '' TanarNev,")
|
|
+ @"
|
|
tantargy.ID TantargyID,
|
|
tantargy.C_NEV TantargyNev
|
|
FROM
|
|
T_FOGLALKOZAS_OSSZES foglalkozas
|
|
LEFT JOIN T_OSZTALYCSOPORT_OSSZES osztalycsoport ON osztalycsoport.ID = foglalkozas.C_OSZTALYCSOPORTID
|
|
LEFT JOIN T_TANTARGY_OSSZES tantargy ON tantargy.ID = foglalkozas.C_TANTARGYID"
|
|
+ (tanarId.HasValue ? @"
|
|
LEFT JOIN T_FELHASZNALO_OSSZES tanar ON tanar.ID = foglalkozas.C_TANARID"
|
|
: "")
|
|
+ @"
|
|
WHERE
|
|
foglalkozas.TOROLT = 'F' AND
|
|
foglalkozas.C_TANEVID = :pTanevID"
|
|
+ (tanarId.HasValue ? @"
|
|
AND foglalkozas.C_TANARID = :pTanarID"
|
|
: "")
|
|
;
|
|
|
|
return GetData(command, parameters, dictionaryItemColumns: "FoglalkozasTipusa");
|
|
}
|
|
|
|
public DataSet GetTantargyfelosztasDataSet(int intezmenyId, int tanevId, int? alkalmazottId = null, int? osztalyCsoportId = null, int? oktNevelesiKategoriaId = null, bool isOsztalybontasokkal = false, bool isKapcsolodoCsoportokkal = false, bool isFromSzervezet = false, int? szervezetId = null)
|
|
{
|
|
using (var command = new SDACommand())
|
|
{
|
|
command.Connection = UserContext.Instance.SDAConnection;
|
|
command.Transaction = UserContext.Instance.SDATransaction;
|
|
command.CommandType = CommandType.StoredProcedure;
|
|
command.CommandText = "uspGetTantargyfelosztasData";
|
|
|
|
command.Parameters.Add("pTanevId", SDADBType.Int).Value = tanevId;
|
|
command.Parameters.Add("pIsOsztalybontasokkal", isOsztalybontasokkal);
|
|
command.Parameters.Add("pIsKapcsolodoCsoportokkal", isKapcsolodoCsoportokkal);
|
|
command.Parameters.Add("pIntezmenyId", SDADBType.Int).Value = intezmenyId;
|
|
command.Parameters.Add("pIsFromSzervezet", isFromSzervezet);
|
|
command.Parameters.Add("pSzervezetId", SDADBType.Int).Value = szervezetId.IsEntityId() ? szervezetId : (object)DBNull.Value;
|
|
command.Parameters.Add("pSzervezetekHalmaza", SDADBType.Int).Value = (int)SzervezetAdatokHalmazaEnum.SzervezetEsAlSzervezetek;
|
|
|
|
if (alkalmazottId.IsEntityId())
|
|
{
|
|
command.Parameters.Add("pAlkalmazottId", SDADBType.Int).Value = alkalmazottId.Value;
|
|
}
|
|
if (osztalyCsoportId.IsEntityId())
|
|
{
|
|
command.Parameters.Add("pOsztalyCsoportId", SDADBType.Int).Value = osztalyCsoportId.Value;
|
|
}
|
|
if (oktNevelesiKategoriaId.IsEntityId())
|
|
{
|
|
command.Parameters.Add("pOktNevelesiKategoriaId", SDADBType.Int).Value = oktNevelesiKategoriaId.Value;
|
|
}
|
|
|
|
var ds = new DataSet();
|
|
|
|
using (var adapter = new SDADataAdapter())
|
|
{
|
|
adapter.SelectCommand = command;
|
|
adapter.Fill(ds);
|
|
}
|
|
SetDNAME(ds.Tables[0], "TipusId");
|
|
|
|
return ds;
|
|
}
|
|
}
|
|
|
|
public DataSet GetTanoranKivuliFoglalkozasok(int? tanarId, int tanevId)
|
|
{
|
|
var parameters = new List<CommandParameter>();
|
|
parameters.Add(new CommandParameter("pTanevID", tanevId));
|
|
parameters.Add(new CommandParameter("OktNevKatTipus", (int)OktNevelesiKategoriaEnum.NevelesOktatas));
|
|
if (tanarId.HasValue)
|
|
{
|
|
parameters.Add(new CommandParameter("pTanarID", tanarId));
|
|
}
|
|
|
|
/*1339 a Tanóra, 1368 a Tanóra (osztálybontásos), ezért ezeket kiszűrjük...*/
|
|
string command = @"
|
|
SELECT
|
|
foglalkozas.ID ID,
|
|
foglalkozas.C_NEV FoglalkozasNev,
|
|
foglalkozas.C_FOGLALKOZASTIPUSA FoglalkozasTipusa,
|
|
osztalycsoport.ID OsztalyCsoportID,
|
|
osztalycsoport.C_NEV OsztalyCsoportNev,"
|
|
+ (tanarId.HasValue ? @"
|
|
tanar.ID TanarID,
|
|
tanar.C_NYOMTATASINEV TanarNev,"
|
|
: "'' TanarID, '' TanarNev,")
|
|
+ @"
|
|
tantargy.ID TantargyID,
|
|
tantargy.C_NEV TantargyNev
|
|
FROM
|
|
T_FOGLALKOZAS_OSSZES foglalkozas
|
|
LEFT JOIN T_OSZTALYCSOPORT_OSSZES osztalycsoport ON osztalycsoport.ID = foglalkozas.C_OSZTALYCSOPORTID
|
|
AND osztalycsoport.C_FELADATKATEGORIAID = @OktNevKatTipus
|
|
LEFT JOIN T_TANTARGY_OSSZES tantargy ON tantargy.ID = foglalkozas.C_TANTARGYID"
|
|
+ (tanarId.HasValue ? @"
|
|
LEFT JOIN T_FELHASZNALO_OSSZES tanar ON tanar.ID = foglalkozas.C_TANARID"
|
|
: "")
|
|
+ @"
|
|
WHERE
|
|
foglalkozas.TOROLT = 'F' AND
|
|
foglalkozas.C_TANEVID = :pTanevID AND
|
|
foglalkozas.C_FOGLALKOZASTIPUSA NOT IN (1339, 1368)"
|
|
+ (tanarId.HasValue ? @"
|
|
AND foglalkozas.C_TANARID = :pTanarID"
|
|
: "")
|
|
;
|
|
|
|
return GetData(command, parameters, dictionaryItemColumns: "FoglalkozasTipusa");
|
|
}
|
|
|
|
public DataSet GetTanarokTanoranKivuliFoglalkozashoz(int tanoranKivuliFoglalkozasId, int tanevId)
|
|
{
|
|
var parameters = new List<CommandParameter>();
|
|
parameters.Add(new CommandParameter("pTanevID", tanevId));
|
|
parameters.Add(new CommandParameter("pTanoranKivuliFoglalkozasID", tanoranKivuliFoglalkozasId));
|
|
|
|
string command = @"
|
|
SELECT
|
|
foglalkozas.C_TANARID ID,
|
|
tanar.C_NYOMTATASINEV TanarNev
|
|
FROM
|
|
T_FOGLALKOZAS_OSSZES foglalkozas
|
|
LEFT JOIN T_FELHASZNALO_OSSZES tanar ON tanar.ID = foglalkozas.C_TANARID
|
|
WHERE
|
|
foglalkozas.ID = :pTanoranKivuliFoglalkozasID AND
|
|
tanar.C_TANEVID = :pTanevID
|
|
";
|
|
|
|
return GetData(command, parameters);
|
|
}
|
|
|
|
public DataTable GetFoglalkozasokMegtartandoOraSzama()
|
|
{
|
|
var ds = new DataSet();
|
|
|
|
using (var command = new SDACommand())
|
|
{
|
|
command.Connection = UserContext.Instance.SDAConnection;
|
|
command.Transaction = UserContext.Instance.SDATransaction;
|
|
command.CommandType = CommandType.StoredProcedure;
|
|
command.CommandText = "sp_GetFoglalkozasokMegtartandoOraSzama";
|
|
using (var adapter = new SDADataAdapter())
|
|
{
|
|
adapter.SelectCommand = command;
|
|
adapter.Fill(ds);
|
|
}
|
|
|
|
return ds.Tables[0];
|
|
}
|
|
}
|
|
|
|
public int? GetFoglalkozasTipusByOsztalyCsoportTipus(int osztalyCsoportTipus, bool? isBontott)
|
|
{
|
|
using (var command = new SDACommand())
|
|
{
|
|
command.Connection = UserContext.Instance.SDAConnection;
|
|
command.Transaction = UserContext.Instance.SDATransaction;
|
|
command.Parameters.Add("pOsztalyCsoportTipus", osztalyCsoportTipus);
|
|
|
|
var isCsoportTipusBontottStr = new StringBuilder(string.Empty);
|
|
if (isBontott.HasValue)
|
|
{
|
|
isCsoportTipusBontottStr.Append(isBontott.Value ? " AND (C_CSOPORTBONTOTT = 'T' " : " AND (C_CSOPORTBONTOTT = 'F' ");
|
|
isCsoportTipusBontottStr.Append(" OR C_CSOPORTBONTOTT IS NULL) ");
|
|
// Előfordulhat, hogy csoportbontott, de a Task mellékletében az összerendelési táblázat nem kötötte ki, hogy bontott vagy sem --> NULL a C_CSOPORTBONTOTT mező...
|
|
}
|
|
else
|
|
{
|
|
isCsoportTipusBontottStr.Append(" AND C_CSOPORTBONTOTT IS NULL ");
|
|
}
|
|
|
|
var sb = new StringBuilder(@"
|
|
SELECT
|
|
C_FOGLALKOZASTIPUSID FoglalkozasTipus
|
|
FROM
|
|
T_CSOPORTTIPUS_FOGLALKOZASTIPU
|
|
WHERE
|
|
C_CSOPORTTIPUSID = :pOsztalyCsoportTipus ");
|
|
sb.Append(isCsoportTipusBontottStr);
|
|
|
|
command.CommandText = sb.ToString();
|
|
|
|
var result = command.ExecuteScalar();
|
|
|
|
int? ret = null;
|
|
if (result != null && result != DBNull.Value)
|
|
{
|
|
ret = Convert.ToInt32(result);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
public DataSet GetFelhasznaloFoglalkozasokErtekelesekhez(int tanevId, int tanarId)
|
|
{
|
|
using (var command = new SDACommand())
|
|
{
|
|
command.Connection = UserContext.Instance.SDAConnection;
|
|
command.Transaction = UserContext.Instance.SDATransaction;
|
|
command.CommandType = CommandType.StoredProcedure;
|
|
|
|
command.CommandText = "sp_GetFelhasznaloFoglalkozasokErtekelesekhez";
|
|
command.Parameters.Add("pTanevId", tanevId);
|
|
command.Parameters.Add("pTanarId", tanarId);
|
|
|
|
var ds = new DataSet();
|
|
using (var adapter = new SDADataAdapter())
|
|
{
|
|
adapter.SelectCommand = command;
|
|
adapter.Fill(ds);
|
|
}
|
|
|
|
return ds;
|
|
}
|
|
}
|
|
|
|
public DataSet GetErtekelesFotargyiFoglalkozasData(int tanevId, int tanarId)
|
|
{
|
|
using (var command = new SDACommand())
|
|
{
|
|
command.Connection = UserContext.Instance.SDAConnection;
|
|
command.Transaction = UserContext.Instance.SDATransaction;
|
|
command.CommandType = CommandType.StoredProcedure;
|
|
|
|
command.CommandText = "sp_GetErtekelesFotargyiFoglalkozasData";
|
|
command.Parameters.Add("pTanevId", tanevId);
|
|
command.Parameters.Add("pTanarId", tanarId);
|
|
|
|
var ds = new DataSet();
|
|
using (var adapter = new SDADataAdapter())
|
|
{
|
|
adapter.SelectCommand = command;
|
|
adapter.Fill(ds);
|
|
}
|
|
|
|
return ds;
|
|
}
|
|
}
|
|
|
|
public IFoglalkozas Get()
|
|
{
|
|
return Foglalkozas.GiveAnInstance();
|
|
}
|
|
|
|
public IFoglalkozas Get(int id)
|
|
{
|
|
var entity = Foglalkozas.GiveAnInstance();
|
|
entity.LoadByID(id);
|
|
return entity;
|
|
}
|
|
|
|
public void FullUpdate(IFoglalkozas dto)
|
|
{
|
|
var entity = dto as Foglalkozas;
|
|
entity.Importalt = false;
|
|
entity.FullUpdate();
|
|
|
|
DalHelper.Commit();
|
|
}
|
|
|
|
public void Update(IFoglalkozas dto)
|
|
{
|
|
var entity = dto as Foglalkozas;
|
|
entity.Importalt = false;
|
|
entity.Update();
|
|
|
|
DalHelper.Commit();
|
|
}
|
|
|
|
public void Insert(IFoglalkozas dto)
|
|
{
|
|
var entity = dto as Foglalkozas;
|
|
entity.Importalt = false;
|
|
entity.Insert();
|
|
|
|
dto.ID = entity.ID;
|
|
DalHelper.Commit();
|
|
}
|
|
|
|
public void Delete(int id)
|
|
{
|
|
var entity = Foglalkozas.GiveAnInstance();
|
|
entity.LoadByID(id);
|
|
entity.FoglalkozasAmiTanulo.DeleteAll();
|
|
entity.OrarendiOra.RemoveAll();
|
|
entity.TanitasiOra.RemoveAll();
|
|
entity.Importalt = false;
|
|
entity.Delete();
|
|
|
|
DalHelper.Commit();
|
|
}
|
|
|
|
public DataSet GetSablonok(int tanevId, int osztalyId)
|
|
{
|
|
var commandParameterList = new List<CommandParameter>
|
|
{
|
|
new CommandParameter("pTanevId", tanevId),
|
|
new CommandParameter("pOsztalyId", osztalyId)
|
|
};
|
|
|
|
string commandText = @"
|
|
SELECT
|
|
sablon.ID
|
|
,sablon.Evfolyam + N'. évfolyam ' + sablon.Tantargy + N' (' + sablon.Tagozat + N')' AS SablonNev
|
|
,sablon.Evfolyam
|
|
,sablon.Tantargy
|
|
,sablon.Tagozat
|
|
FROM (
|
|
SELECT DISTINCT
|
|
ttfSablon.ID
|
|
,evfolyamTipus.C_NAME AS Evfolyam
|
|
,tantargySablon.C_NEV AS Tantargy
|
|
,tagozatTipus.C_NAME AS Tagozat
|
|
FROM T_AMITTFSABLON ttfSablon
|
|
INNER JOIN T_DICTIONARYITEMBASE_OSSZES evfolyamTipus ON evfolyamTipus.ID = ttfSablon.C_EVFOLYAMTIPUSID
|
|
AND evfolyamTipus.TOROLT = 'F'
|
|
AND evfolyamTipus.C_TANEVID = :pTanevId
|
|
INNER JOIN T_DICTIONARYITEMBASE_OSSZES tagozatTipus ON tagozatTipus.ID = ttfSablon.C_AMITAGOZATID
|
|
AND tagozatTipus.TOROLT = 'F'
|
|
AND tagozatTipus.C_TANEVID = :pTanevId
|
|
INNER JOIN T_AMIFOTARGY_AMIALTARGY foaltargy ON foaltargy.C_AMIFOTARGYID = ttfSablon.ID
|
|
INNER JOIN T_AMITANTARGYSABLON tantargySablon ON tantargySablon.ID = ttfSablon.C_AMITANTARGYSABLONID
|
|
AND tantargySablon.TOROLT = 'F'
|
|
INNER JOIN T_FELADATELLATASIHELY_OSSZES feladathely ON feladathely.C_OKTATASINEVELESIFELADATTIPUS = ttfSablon.C_OKTATASINEVELESIFELADATID
|
|
AND feladathely.TOROLT = 'F'
|
|
AND feladathely.C_TANEVID = evfolyamtipus.C_TANEVID
|
|
INNER JOIN T_OSZTALYCSOPORT_OSSZES ocs ON ocs.C_FELADATELLATASIHELYID = feladathely.ID
|
|
AND ocs.TOROLT = 'F'
|
|
AND ocs.C_TANEVID = evfolyamtipus.C_TANEVID
|
|
AND ocs.ID = :pOsztalyId
|
|
WHERE ttfSablon.TOROLT = 'F'
|
|
) sablon
|
|
";
|
|
|
|
return GetData(commandText, commandParameterList);
|
|
}
|
|
|
|
public DataSet GetSablon(int sablonId)
|
|
{
|
|
var commandParameterList = new List<CommandParameter>
|
|
{
|
|
new CommandParameter("pSablonId", sablonId)
|
|
};
|
|
|
|
string commandText = @"
|
|
SELECT
|
|
ttfSablon.ID
|
|
,CAST((ttfSablon.C_IDOTARTAM / 60.0) AS numeric (10, 2)) AS Oraszam
|
|
,ttfSablon.C_AMIFOTARGYID AS AmiFotargy
|
|
,ttfSablon.C_AMITAGOZATID AS AmiTagozat
|
|
,ttfSablon.C_AMITANTARGYKOTELEZOSEGID AS AmiTantargyKotelezoseg
|
|
,ttfSablon.C_EVFOLYAMTIPUSID AS EvfolyamTipus
|
|
,ttfSablon.C_ISCSOPORTOS AS IsCsoportos
|
|
,tantargySablon.ID AS AmiTantargySablonId
|
|
FROM T_AMITTFSABLON ttfSablon
|
|
INNER JOIN T_AMITANTARGYSABLON tantargySablon ON ttfSablon.C_AMITANTARGYSABLONID = tantargySablon.ID
|
|
AND tantargySablon.TOROLT = 'F'
|
|
WHERE ttfSablon.TOROLT = 'F'
|
|
AND (ttfSablon.ID = :pSablonId OR ttfSablon.ID IN (SELECT C_AMIALTARGYID FROM T_AMIFOTARGY_AMIALTARGY WHERE C_AMIFOTARGYID = :pSablonId))
|
|
";
|
|
|
|
return GetData(commandText, commandParameterList, booleanColumns: "IsCsoportos");
|
|
}
|
|
|
|
public DataSet GetFoglalkozasOsszOraszamok(int tanevId, bool isFromSzervezet = false)
|
|
{
|
|
var commandParameterList = new List<CommandParameter>
|
|
{
|
|
new CommandParameter("pTanevId", tanevId),
|
|
new CommandParameter("pFoglalkozasTipusId", (int)FoglalkozasTipusEnum.dualis_foglalkozas)
|
|
};
|
|
|
|
var commandText = $@"
|
|
SELECT
|
|
SUM(CASE WHEN f.C_ISOSSZEVONTORA = 'F' THEN f.C_ORASZAM ELSE 0 END) AS Oraszam
|
|
,SUM(CASE WHEN f.C_ISOSSZEVONTORA = 'T' THEN f.C_ORASZAM ELSE 0 END) AS TtfKorrekcioOraszam
|
|
FROM T_FOGLALKOZAS_OSSZES f
|
|
WHERE
|
|
f.C_TANEVID = :pTanevId
|
|
AND f.TOROLT = 'F'";
|
|
|
|
if (isFromSzervezet)
|
|
{
|
|
commandText += " AND f.C_FOGLALKOZASTIPUSA = :pFoglalkozasTipusId";
|
|
}
|
|
|
|
return GetData(commandText, commandParameterList);
|
|
}
|
|
}
|
|
}
|