/*================================================================================ * GET CONDUCTORES *================================================================================*/ public static List <Conductor> GetConductores() { // Creamos la lista y el comando que extrae los gráficos. List <Conductor> lista = new List <Conductor>(); using (OleDbConnection conexion = new OleDbConnection(App.Global.CadenaConexion)) { //string comandoSQL = "SELECT * FROM Conductores ORDER BY Id"; string comandoSQL = "GetConductores"; OleDbCommand Comando = new OleDbCommand(comandoSQL, conexion); Comando.CommandType = System.Data.CommandType.StoredProcedure; //TODO: Eliminar tras probar. OleDbDataReader lector = null; try { conexion.Open(); lector = Comando.ExecuteReader(); while (lector.Read()) { Conductor conductor = new Conductor(lector); conductor.ListaRegulaciones = new NotifyCollection <RegulacionConductor>(BdRegulacionConductor.GetRegulaciones(conductor.Id)); lista.Add(conductor); conductor.Nuevo = false; conductor.Modificado = false; } } catch (Exception ex) { Utils.VerError("BdConductores.GetConductores", ex); } finally { lector.Close(); } } return(lista); }
/*================================================================================ * GET CONDUCTOR *================================================================================*/ public static Conductor GetConductor(int idconductor) { Conductor conductor = null; using (OleDbConnection conexion = new OleDbConnection(App.Global.CadenaConexion)) { // Creamos el comando que extrae el conductor //string comandoSQL = "SELECT * FROM Conductores WHERE Id = ?"; string comandoSQL = "GetConductor"; OleDbCommand Comando = new OleDbCommand(comandoSQL, conexion); Comando.CommandType = System.Data.CommandType.StoredProcedure; Comando.Parameters.AddWithValue("@Id", idconductor); OleDbDataReader lector = null; try { conexion.Open(); lector = Comando.ExecuteReader(); if (lector.Read()) { conductor = new Conductor(lector); conductor.ListaRegulaciones = new NotifyCollection <RegulacionConductor>(BdRegulacionConductor.GetRegulaciones(conductor.Id)); } } catch (Exception ex) { Utils.VerError("BdConductores.GetConductor", ex); } finally { lector.Close(); } } return(conductor); }