using System.Data; using Kreta.Core; using Kreta.DataAccess.Interfaces; using Kreta.DataAccessManual.Interfaces; using Kreta.DataAccessManual.ParameterClasses; using Kreta.DataAccessManual.Util; using Kreta.Framework; using Kreta.Framework.Util; using SDA.DataProvider; using SDA.Kreta.Entities; namespace Kreta.DataAccessManual { internal class ErettsegiEredmenyDal : DataAccessBase, IErettsegiEredmenyDal { public ErettsegiEredmenyDal(DalHandler handler, GridParameters parameters) : base(handler, parameters) { } public ErettsegiEredmenyDal(DalHandler handler) : base(handler) { } public IErettsegiEredmeny Get() { return ErettsegiEredmeny.GiveAnInstance(); } public IErettsegiEredmeny Get(int id) { var entity = ErettsegiEredmeny.GiveAnInstance(); entity.LoadByID(id); return entity; } public void Insert(IErettsegiEredmeny dto) { var entity = dto as ErettsegiEredmeny; entity.Insert(); dto.ID = entity.ID; DalHelper.Commit(); } public void FullUpdate(IErettsegiEredmeny dto) { var entity = dto as ErettsegiEredmeny; entity.FullUpdate(); DalHelper.Commit(); } public void DeleteErettsegiEredmeny(int id) { var entity = ErettsegiEredmeny.GiveAnInstance(); entity.LoadByID(id); Delete(entity); } public void Delete(IErettsegiEredmeny dto) { var entity = dto as ErettsegiEredmeny; entity.Delete(); DalHelper.Commit(); } public DataSet GetErettsegiEredmenyekData(int osztalyId) { //List parameters = new List //{ // new CommandParameter("pOsztalyId", osztalyId, SDADBType.Int) //}; //var data = GetData(@"sp_GetErettsegiEredmenyekData", parameters, booleanColumns: "IsVegzos", commandType: CommandType.StoredProcedure); //return data; 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 = "uspGetErettsegiEredmenyekData"; command.Parameters.Add("pOsztalyId", SDADBType.Int).Value = osztalyId; using (var adapter = new SDADataAdapter()) { adapter.SelectCommand = command; adapter.Fill(ds); } } SetBoolFields(ds.Tables[0], "IsVegzos"); DataTable dt = SortingAndPaging(ds.Tables[0], GridParameters); return dt.AsDataSet(); } public DataSet GetErettsegiEredmenyekReszletekData(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 = "sp_GetErettsegiEredmenyekReszletekData"; command.Parameters.Add("pIntezmenyId", SDADBType.Int).Value = intezmenyId; command.Parameters.Add("pTanevId", SDADBType.Int).Value = tanevId; command.Parameters.Add("pTanuloId", SDADBType.Int).Value = tanuloId; var ds = new DataSet(); using (var adapter = new SDADataAdapter()) { adapter.SelectCommand = command; adapter.Fill(ds); } DataTable dt = SortingAndPaging(ds.Tables[0], GridParameters); return dt.AsDataSet(); } } public DataSet GetErettsegiTantargyakForComboBox(int intezmenyId, int tanevId) { using (var command = new SDACommand()) { command.Connection = UserContext.Instance.SDAConnection; command.Transaction = UserContext.Instance.SDATransaction; command.CommandType = CommandType.StoredProcedure; command.CommandText = "uspGetErettsegiTantargyakForComboBox"; command.Parameters.Add("pIntezmenyId", intezmenyId); command.Parameters.Add("pTanevId", tanevId); var dataSet = new DataSet(); using (var sdaDataAdapter = new SDADataAdapter()) { sdaDataAdapter.SelectCommand = command; sdaDataAdapter.Fill(dataSet); } return dataSet; } } public DataSet GetErettsegiTantargyakForValidate(int intezmenyId, int tanevId) { using (var command = new SDACommand()) { command.Connection = UserContext.Instance.SDAConnection; command.Transaction = UserContext.Instance.SDATransaction; command.CommandType = CommandType.StoredProcedure; command.CommandText = "uspGetErettsegiTantargyakForValidate"; command.Parameters.Add("pIntezmenyId", intezmenyId); command.Parameters.Add("pTanevId", tanevId); var dataSet = new DataSet(); using (var sdaDataAdapter = new SDADataAdapter()) { sdaDataAdapter.SelectCommand = command; sdaDataAdapter.Fill(dataSet); } return dataSet; } } public DataSet GetErettsegiSzintekForComboBox(int intezmenyId, int tanevId) { using (var command = new SDACommand()) { command.Connection = UserContext.Instance.SDAConnection; command.Transaction = UserContext.Instance.SDATransaction; command.CommandType = CommandType.StoredProcedure; command.CommandText = "uspGetErettsegiSzintekForComboBox"; command.Parameters.Add("pIntezmenyId", intezmenyId); command.Parameters.Add("pTanevId", tanevId); var dataSet = new DataSet(); using (var sdaDataAdapter = new SDADataAdapter()) { sdaDataAdapter.SelectCommand = command; sdaDataAdapter.Fill(dataSet); } return dataSet; } } public DataSet GetErettsegiTipusokForComboBox(int intezmenyId, int tanevId) { using (var command = new SDACommand()) { command.Connection = UserContext.Instance.SDAConnection; command.Transaction = UserContext.Instance.SDATransaction; command.CommandType = CommandType.StoredProcedure; command.CommandText = "uspGetErettsegiTipusokForComboBox"; command.Parameters.Add("pIntezmenyId", intezmenyId); command.Parameters.Add("pTanevId", tanevId); var dataSet = new DataSet(); using (var sdaDataAdapter = new SDADataAdapter()) { sdaDataAdapter.SelectCommand = command; sdaDataAdapter.Fill(dataSet); } return dataSet; } } public DataSet GetErettsegiMaxPontszamList(int intezmenyId, int tanevId) { using (var command = new SDACommand()) { command.Connection = UserContext.Instance.SDAConnection; command.Transaction = UserContext.Instance.SDATransaction; command.CommandType = CommandType.StoredProcedure; command.CommandText = "uspGetErettsegiMaxPontszamList"; command.Parameters.Add("pIntezmenyId", intezmenyId); command.Parameters.Add("pTanevId", tanevId); var dataSet = new DataSet(); using (var sdaDataAdapter = new SDADataAdapter()) { sdaDataAdapter.SelectCommand = command; sdaDataAdapter.Fill(dataSet); } return dataSet; } } public DataSet GetErettsegiEredmenyekData(int intezmenyId, int tanevId, ErettsegiEredmenyekKeresesPCO pco) { using (var command = new SDACommand()) { command.Connection = UserContext.Instance.SDAConnection; command.Transaction = UserContext.Instance.SDATransaction; command.CommandType = CommandType.StoredProcedure; command.CommandText = "uspGetErettsegiEredmenyekKeresesData"; command.Parameters.Add("pTanevId", SDADBType.Int).Value = tanevId; if (pco.Id.IsEntityId()) { command.Parameters.Add("pErettsegiEredmenyId", SDADBType.Int).Value = pco.Id.Value; } if (pco.Szazalek.HasValue) { command.Parameters.Add("pSzazalek", SDADBType.Int).Value = pco.Szazalek.Value; } if (pco.Erdemjegy.HasValue) { command.Parameters.Add("pErdemjegy", SDADBType.Int).Value = pco.Erdemjegy.Value; } if (pco.FeladatEllatasiHelyId.IsEntityId()) { command.Parameters.Add("pFeladatEllatasiHelyId", SDADBType.Int).Value = pco.FeladatEllatasiHelyId.Value; } if (pco.FeladatKategoriaId.IsEntityId()) { command.Parameters.Add("pFeladatKategoriaId", SDADBType.Int).Value = pco.FeladatKategoriaId.Value; } var ds = new DataSet(); using (var adapter = new SDADataAdapter()) { adapter.SelectCommand = command; adapter.Fill(ds); } SetDNAME(ds.Tables[0], "Szint,Tipus,Tantargy"); return ds; } } } }