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

147 lines
4.7 KiB
C#

using System.Data;
using Kreta.Core;
using Kreta.DataAccess.Interfaces;
using Kreta.DataAccessManual.Interfaces;
using Kreta.DataAccessManual.Util;
using Kreta.Framework;
using Kreta.Framework.Util;
using SDA.DataProvider;
using SDA.Kreta.Entities;
namespace Kreta.DataAccessManual
{
internal class EszkozigenylesDAL : DataAccessBase, IEszkozigenylesDal
{
public EszkozigenylesDAL(DalHandler handler, GridParameters parameters) : base(handler, parameters)
{
}
public EszkozigenylesDAL(DalHandler handler) : base(handler)
{
}
#region BaseCRUD
public IEszkozIgenyles Get()
{
return EszkozIgenyles.GiveAnInstance();
}
public IEszkozIgenyles Get(int id)
{
var entity = EszkozIgenyles.GiveAnInstance();
entity.LoadByID(id);
return entity;
}
public void Insert(IEszkozIgenyles dto)
{
var entity = dto as EszkozIgenyles;
entity.Insert();
dto.ID = entity.ID;
DalHelper.Commit();
}
public void Update(IEszkozIgenyles dto)
{
var entity = dto as EszkozIgenyles;
entity.Update();
DalHelper.Commit();
}
public void FullUpdate(IEszkozIgenyles entity)
{
((EszkozIgenyles)entity).FullUpdate();
DalHelper.Commit();
}
public void Delete(int id)
{
var oEszkoz = EszkozIgenyles.GiveAnInstance();
oEszkoz.LoadByID(id);
oEszkoz.Delete();
DalHelper.Commit();
}
public void Delete(IEszkozIgenyles dto)
{
var entity = dto as EszkozIgenyles;
entity.Delete();
DalHelper.Commit();
}
#endregion BaseCRUD
public DataSet GetGondviseloEszkozIgenylesAdat(int intezmenyId, int tanevId, int tanuloId)
{
using (var command = new SDACommand())
{
command.Connection = UserContext.Instance.SDAConnection;
command.Transaction = UserContext.Instance.SDATransaction;
command.CommandType = CommandType.StoredProcedure;
command.CommandText = "uspFeltarGondviseloEszkozIgenylesAdat";
command.Parameters.Add("pTanevId", tanevId);
command.Parameters.Add("pIntezmenyId", intezmenyId);
command.Parameters.Add("pTanuloId", tanuloId);
var dataSet = new DataSet();
using (var sdaDataAdapter = new SDADataAdapter())
{
sdaDataAdapter.SelectCommand = command;
sdaDataAdapter.Fill(dataSet);
}
return dataSet;
}
}
public bool IsAlkalmazottEszkozIgenyelheto(int intezmenyId, int tanevId, int alkalmazottId)
{
using (var command = new SDACommand())
{
command.Connection = UserContext.Instance.SDAConnection;
command.Transaction = UserContext.Instance.SDATransaction;
command.CommandType = CommandType.StoredProcedure;
command.CommandText = "uspFeltarAlkalmazottEszkozigenylesAdat";
command.Parameters.Add("pTanevId", tanevId);
command.Parameters.Add("pIntezmenyId", intezmenyId);
command.Parameters.Add("pAlkalmazottId", alkalmazottId);
var dataSet = new DataSet();
using (var sdaDataAdapter = new SDADataAdapter())
{
sdaDataAdapter.SelectCommand = command;
sdaDataAdapter.Fill(dataSet);
}
return !dataSet.Tables[0].Rows.Count.IsEntityId();
}
}
public DataSet IsEszkozKiosztva(int intezmenyId, int tanevId, int userId)
{
using (var command = new SDACommand())
{
command.Connection = UserContext.Instance.SDAConnection;
command.Transaction = UserContext.Instance.SDATransaction;
command.CommandType = CommandType.StoredProcedure;
command.CommandText = "uspEszkozigenylesEszkozKiosztvaAdat";
command.Parameters.Add("pTanevId", tanevId);
command.Parameters.Add("pIntezmenyId", intezmenyId);
command.Parameters.Add("pUserId", userId);
var dataSet = new DataSet();
using (var sdaDataAdapter = new SDADataAdapter())
{
sdaDataAdapter.SelectCommand = command;
sdaDataAdapter.Fill(dataSet);
}
return dataSet;
}
}
}
}