73 lines
2.2 KiB
C#
73 lines
2.2 KiB
C#
using System.Data;
|
|
using Kreta.DataAccess.Interfaces;
|
|
using Kreta.DataAccessManual.Interfaces;
|
|
using Kreta.DataAccessManual.Util;
|
|
using Kreta.Framework;
|
|
using SDA.DataProvider;
|
|
using SDA.Kreta.Entities;
|
|
|
|
namespace Kreta.DataAccessManual
|
|
{
|
|
public class TbJogviszonyDal : DataAccessBase, ITbJogviszonyDal
|
|
{
|
|
public TbJogviszonyDal(DalHandler handler) : base(handler)
|
|
{
|
|
}
|
|
|
|
public ITbJogviszony Get(int? id = null)
|
|
{
|
|
var entity = TbJogviszony.GiveAnInstance();
|
|
if (id.HasValue)
|
|
{
|
|
entity.LoadByID(id.Value);
|
|
}
|
|
return entity;
|
|
}
|
|
|
|
public int Insert(ITbJogviszony dto, int? kovTanevId)
|
|
{
|
|
var entity = dto as TbJogviszony;
|
|
entity.Insert(true);
|
|
DalHelper.Commit();
|
|
|
|
if (kovTanevId.HasValue)
|
|
{
|
|
FollowUpTbJogviszony(entity.IntezmenyId, entity.TanevId, kovTanevId.Value, entity.ID);
|
|
}
|
|
|
|
return entity.ID;
|
|
}
|
|
|
|
public void Update(ITbJogviszony dto, int? kovTanevId)
|
|
{
|
|
var entity = dto as TbJogviszony;
|
|
entity.Update();
|
|
DalHelper.Commit();
|
|
|
|
if (kovTanevId.HasValue)
|
|
{
|
|
FollowUpTbJogviszony(entity.IntezmenyId, entity.TanevId, kovTanevId.Value, entity.ID);
|
|
}
|
|
}
|
|
|
|
public void FollowUpTbJogviszony(int intezmenyId, int aktTanevId, int kovTanevId, int felhasznaloId)
|
|
{
|
|
using (var command = new SDACommand())
|
|
{
|
|
command.Connection = UserContext.Instance.SDAConnection;
|
|
command.Transaction = UserContext.Instance.SDATransaction;
|
|
|
|
command.CommandType = CommandType.StoredProcedure;
|
|
command.CommandText = "uspFollowUpTBJogviszony";
|
|
|
|
command.Parameters.Add("IntezmenyId", intezmenyId);
|
|
command.Parameters.Add("AktTanevId", aktTanevId);
|
|
command.Parameters.Add("KovetkezoTanevId", kovTanevId);
|
|
command.Parameters.Add("FelhasznaloId", felhasznaloId);
|
|
|
|
command.ExecuteNonQuery();
|
|
}
|
|
DalHelper.Commit();
|
|
}
|
|
}
|
|
}
|