86 lines
2.8 KiB
C#
86 lines
2.8 KiB
C#
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using Kreta.DataAccess.Interfaces;
|
|
using Kreta.DataAccessManual.Interfaces;
|
|
using Kreta.DataAccessManual.Util;
|
|
using Kreta.Framework.Util;
|
|
using SDA.Kreta.Entities;
|
|
|
|
namespace Kreta.DataAccessManual
|
|
{
|
|
internal class SzirStatFileDAL : DataAccessBase, ISzirStatFileDAL
|
|
{
|
|
public SzirStatFileDAL(DalHandler handler) : base(handler) { }
|
|
public SzirStatFileDAL(DalHandler handler, GridParameters parameters) : base(handler, parameters) { }
|
|
|
|
public ISzirStatFile Get()
|
|
{
|
|
return SzirStatFile.GiveAnInstance();
|
|
}
|
|
|
|
public ISzirStatFile Get(int id)
|
|
{
|
|
var entity = SzirStatFile.GiveAnInstance();
|
|
entity.LoadByID(id);
|
|
return entity;
|
|
}
|
|
|
|
public List<int> GetSzirStatFileIdByTipusIdAndFeladatellatasiHelyId(int intezmenyId, int tanevId, int szirStatTipusId, int kirSzirFeladatellatasiHelyId)
|
|
{
|
|
List<int> result = new List<int>();
|
|
var commandParameterList = new List<CommandParameter>
|
|
{
|
|
new CommandParameter(nameof(intezmenyId), intezmenyId),
|
|
new CommandParameter(nameof(tanevId), tanevId),
|
|
new CommandParameter(nameof(szirStatTipusId), szirStatTipusId),
|
|
};
|
|
|
|
if (kirSzirFeladatellatasiHelyId > 0)
|
|
{
|
|
commandParameterList.Add(new CommandParameter(nameof(kirSzirFeladatellatasiHelyId), kirSzirFeladatellatasiHelyId));
|
|
}
|
|
string commandText = $@"
|
|
SELECT
|
|
ID
|
|
FROM
|
|
T_SZIRSTATFILE_OSSZES
|
|
WHERE
|
|
TOROLT = 'F'
|
|
AND C_SZIRSTATTIPUSID = @{nameof(szirStatTipusId)}" +
|
|
(kirSzirFeladatellatasiHelyId > 0 ? $@" AND C_KIRSZIRFELADATELLATASIHELYID = @{nameof(kirSzirFeladatellatasiHelyId)}" : "") + $@"
|
|
AND C_INTEZMENYID = @{nameof(intezmenyId)}
|
|
AND C_TANEVID = @{nameof(tanevId)}
|
|
ORDER BY LASTCHANGED DESC";
|
|
|
|
DataSet dataSet = GetData(commandText, commandParameterList);
|
|
if (dataSet != null && dataSet.Tables.Count > 0)
|
|
{
|
|
result = dataSet.Tables[0].AsEnumerable().Select(r => r.Field<int>("ID")).ToList();
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
public int Insert(ISzirStatFile dto)
|
|
{
|
|
var entity = dto as SzirStatFile;
|
|
|
|
entity.Insert();
|
|
dto.ID = entity.ID;
|
|
DalHelper.Commit();
|
|
|
|
return dto.ID;
|
|
}
|
|
|
|
public void Delete(int id, int userId)
|
|
{
|
|
var entity = Get(id) as SzirStatFile;
|
|
|
|
entity.Torolt = true;
|
|
|
|
entity.FullUpdate();
|
|
DalHelper.Commit();
|
|
}
|
|
}
|
|
}
|