kreta/Kreta.DataAccessManual/FelmentesDal.cs
2024-03-13 00:33:46 +01:00

86 lines
4.2 KiB
C#

using System.Data;
using Kreta.Core;
using Kreta.DataAccessManual.Interfaces;
using Kreta.DataAccessManual.ParameterClasses;
using Kreta.DataAccessManual.Util;
using Kreta.Framework;
using Kreta.Framework.Util;
using SDA.DataProvider;
namespace Kreta.DataAccessManual
{
internal class FelmentesDal : DataAccessBase, IFelmentesDal
{
public FelmentesDal(DalHandler handler, GridParameters gridParameters) : base(handler, gridParameters)
{ }
public FelmentesDal(DalHandler handler) : base(handler)
{ }
public DataSet GetFelmentesGrid(FelmentesSearchPco pco, int intezmenyId, 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 = "uspGetFelmentesAdatok";
command.Parameters.Add("pIntezmenyId", SDADBType.Int).Value = intezmenyId;
command.Parameters.Add("pTanevId", SDADBType.Int).Value = tanevId;
if (pco.ID.IsEntityId()) { command.Parameters.Add("pFelmentesId", SDADBType.Int).Value = pco.ID; }
if (!string.IsNullOrWhiteSpace(pco.TanuloNeve)) { command.Parameters.Add("pTanuloNeve", SDADBType.String).Value = pco.TanuloNeve; }
if (pco.TanuloOsztalyId.IsEntityId()) { command.Parameters.Add("pOsztalyId", SDADBType.Int).Value = pco.TanuloOsztalyId; }
if (pco.TantargyId.IsEntityId()) { command.Parameters.Add("pTantargyId", SDADBType.Int).Value = pco.TantargyId; }
if (pco.KezdeteDateFrom.HasValue) { command.Parameters.Add("pFelmentesKezdeteTol", SDADBType.DateTime).Value = pco.KezdeteDateFrom.Value; }
if (pco.KezdeteDateTo.HasValue) { command.Parameters.Add("pFelmentesKezdeteIg", SDADBType.DateTime).Value = pco.KezdeteDateTo.Value; }
if (pco.VegeDateFrom.HasValue) { command.Parameters.Add("pFelmentesVegeTol", SDADBType.DateTime).Value = pco.VegeDateFrom.Value; }
if (pco.VegeDateTo.HasValue) { command.Parameters.Add("pFelmentesVegeIg", SDADBType.DateTime).Value = pco.VegeDateTo.Value; }
if (pco.IsTanoraLatogatasaAloli.HasValue) { command.Parameters.Add("pIsTanoraLatogatasaAloliFelmentes", pco.IsTanoraLatogatasaAloli.ToBool()); }
if (pco.IsErtekelesAloli.HasValue) { command.Parameters.Add("pIsErtekelesAloliFelmentes", pco.IsErtekelesAloli.ToBool()); }
if (pco.IsSzovegesenErtekelheto.HasValue) { command.Parameters.Add("pIsSzovegesenErtekelheto", pco.IsSzovegesenErtekelheto.ToBool()); }
if (!string.IsNullOrWhiteSpace(pco.FelmentesOka)) { command.Parameters.Add("pFelmentesOka", SDADBType.String).Value = pco.FelmentesOka; }
if (pco.RogzitesDateFrom.HasValue) { command.Parameters.Add("pRogzitesDatumaTol", SDADBType.DateTime).Value = pco.RogzitesDateFrom.Value; }
if (pco.RogzitesDateTo.HasValue) { command.Parameters.Add("pRogzitesDatumaIg", SDADBType.DateTime).Value = pco.RogzitesDateTo.Value; }
if (!string.IsNullOrWhiteSpace(pco.RogzitoNeve)) { command.Parameters.Add("pFelmentesRogzitoje", SDADBType.String).Value = pco.RogzitoNeve; }
if (pco.ModositasDateFrom.HasValue) { command.Parameters.Add("pUtolsoModositasTol", SDADBType.DateTime).Value = pco.ModositasDateFrom.Value; }
if (pco.ModositasDateTo.HasValue) { command.Parameters.Add("pUtolsoModositasIg", SDADBType.DateTime).Value = pco.ModositasDateTo.Value; }
if (!string.IsNullOrWhiteSpace(pco.ModositoNeve)) { command.Parameters.Add("pUtolsoModosito", SDADBType.String).Value = pco.ModositoNeve; }
if (pco.Torolt.HasValue) { command.Parameters.Add("pIsFelmentesTorolt", pco.Torolt.ToBool()); }
using (var adapter = new SDADataAdapter())
{
adapter.SelectCommand = command;
adapter.Fill(ds);
}
}
DataTable dt = SortingAndPaging(ds.Tables[0], GridParameters);
return dt.AsDataSet();
}
}
}