Beispiel #1
0
        /// <summary>
        /// Funcion que accede a la tabla autores y localiza el valor máximo de ID para utilizarlo como contador de IDs en los constructores
        /// de autor
        /// </summary>
        /// <returns>Entero que cuyo valor es el último ID de autores</returns>
        public static int IDactual()
        {
            int             ID      = 0;
            MySqlCommand    comando = new MySqlCommand("SELECT MAX(autores.ID) FROM autores;");
            MySqlDataReader reader  = BBDD.ExecuteQuery(comando);

            if (reader.HasRows && reader.Read())
            {
                ID = reader.GetInt32(0);
            }
            reader.Close();
            return(ID);
        }
Beispiel #2
0
        public static AutorExterno BuscarAutorExternoPorID(int id)
        {
            AutorExterno autor   = null;
            MySqlCommand comando = new MySqlCommand("SELECT autores.ID,autores.nombre,autores.apellido FROM autores WHERE autores.deUniversidad=0 && autores.ID=@ID;");

            comando.Parameters.AddWithValue("@ID", id);
            MySqlDataReader reader = BBDD.ExecuteQuery(comando);

            if (reader.HasRows && reader.Read())
            {
                autor    = new AutorExterno(reader.GetString(1), reader.GetString(2));
                autor.ID = reader.GetInt32(0);
            }
            reader.Close();
            return(autor);
        }
        public static AutorUniversidad BuscarAutorUniversidadPorID(int id)
        {
            AutorUniversidad autor   = null;
            MySqlCommand     comando = new MySqlCommand("SELECT autores.ID,autores.nombre,autores.apellido,autoresuniversidad.DNI,autoresuniversidad.edad,autoresuniversidad.departamento" +
                                                        " FROM autores INNER JOIN autoresuniversidad ON autores.ID=autoresuniversidad.id_autor WHERE autores.ID=@ID;");

            comando.Parameters.AddWithValue("@ID", id);
            MySqlDataReader reader = BBDD.ExecuteQuery(comando);

            if (reader.HasRows && reader.Read())
            {
                autor    = new AutorUniversidad(reader.GetString(1), reader.GetString(2), reader.GetString(3), reader.GetInt32(4), reader.GetString(5));
                autor.ID = reader.GetInt32(0);
            }
            reader.Close();
            return(autor);
        }
Beispiel #4
0
        //En esta clase creamos los métodos de acceso a datos para tratar el tipo de dato "conferencia", desarrollamos un métrodo
        //MostrarTodo para que importe los datos de las conferencias, uno para actualizarlas, uno para insetar nuevos registros
        // uno para borrar registros y uno para actualizar la relación autor-articulo de conferencia
        public static ICollection <Conferencia> MostrarTodo()
        {
            ICollection <Conferencia> Lista = new List <Conferencia>();
            MySqlCommand    comando         = new MySqlCommand("SELECT produccioncientifica.ID, produccioncientifica.titulo,produccioncientifica.año,articulocientifico.numPaginas, articulocientifico.numCitas,articulocientifico.DOI,articulocientifico.nombreConferencia,articulocientifico.lugar, articulocientifico.categoría FROM produccioncientifica INNER JOIN articulocientifico ON produccioncientifica.ID=articulocientifico.id_produccion AND produccioncientifica.tipo='conferencia';");
            MySqlDataReader reader          = BBDD.ExecuteQuery(comando);

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    Conferencia conferencia = new Conferencia(reader.GetString(1), reader.GetInt32(2), reader.GetInt32(3), reader.GetInt32(4), reader.GetString(5), reader.GetString(6), reader.GetString(7), reader.GetString(8));
                    conferencia.ID = reader.GetInt32(0);
                    Lista.Add(conferencia);
                }
            }
            reader.Close();
            return(Lista);
        }
Beispiel #5
0
        public static ICollection <AutorExterno> MostrarExternosInternos()
        {
            ICollection <AutorExterno> Lista = new List <AutorExterno>();
            MySqlCommand    comando          = new MySqlCommand("SELECT autores.ID,autores.nombre,autores.apellido FROM autores;");
            MySqlDataReader reader           = BBDD.ExecuteQuery(comando);

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    AutorExterno autor = new AutorExterno(reader.GetString(1), reader.GetString(2));
                    autor.ID = reader.GetInt32(0);
                    Lista.Add(autor);
                }
            }
            reader.Close();
            return(Lista);
        }
Beispiel #6
0
        public static ICollection <Patente> MostrarTodo()
        {
            ICollection <Patente> Lista   = new List <Patente>();
            MySqlCommand          comando = new MySqlCommand("SELECT produccioncientifica.ID, produccioncientifica.titulo,produccioncientifica.año, patentes.cuantia, patentes.fechaVencimiento FROM produccioncientifica INNER JOIN patentes ON produccioncientifica.ID=patentes.id_produccion;");
            MySqlDataReader       reader  = BBDD.ExecuteQuery(comando);

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    Patente patente = new Patente(reader.GetString(1), reader.GetInt32(2), reader.GetDateTime(4).Date, reader.GetDouble(3));
                    patente.ID = reader.GetInt32(0);
                    Lista.Add(patente);
                }
            }
            reader.Close();
            return(Lista);
        }
        public static ICollection <AutorUniversidad> MostrarTodo()
        {
            ICollection <AutorUniversidad> ListaAutoresUniversidad = new List <AutorUniversidad>();
            MySqlCommand comando = new MySqlCommand("SELECT autores.ID,autores.nombre,autores.apellido,autoresuniversidad.DNI,autoresuniversidad.edad,autoresuniversidad.departamento" +
                                                    " FROM autores INNER JOIN autoresuniversidad ON autores.ID=autoresuniversidad.id_autor;");
            MySqlDataReader reader = BBDD.ExecuteQuery(comando);

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    AutorUniversidad autor = new AutorUniversidad(reader.GetString(1), reader.GetString(2), reader.GetString(3), reader.GetInt32(4), reader.GetString(5));
                    autor.ID = reader.GetInt32(0);
                    ListaAutoresUniversidad.Add(autor);
                }
            }
            reader.Close();
            return(ListaAutoresUniversidad);
        }
Beispiel #8
0
        public static ICollection <int> MostrarAutoresPublicacion(int id)
        {
            ICollection <int> Lista   = new List <int>();
            MySqlCommand      comando = new MySqlCommand("SELECT publica.id_autor FROM publica WHERE publica.id_produccion=@id;");

            comando.Parameters.AddWithValue("@id", id);
            MySqlDataReader reader = BBDD.ExecuteQuery(comando);

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    int ID = reader.GetInt32(0);
                    Lista.Add(ID);
                }
            }
            reader.Close();
            return(Lista);
        }
Beispiel #9
0
        public static ICollection <AutorExterno> BuscarAutorExternoPorNombre(string nombre)
        {
            ICollection <AutorExterno> ListaAutoresExternos = new List <AutorExterno>();
            MySqlCommand comando = new MySqlCommand("SELECT autores.ID,autores.nombre,autores.apellido FROM autores WHERE autores.deUniversidad=0 && autores.nombre=@nombre;");

            comando.Parameters.AddWithValue("@nombre", nombre);
            MySqlDataReader reader = BBDD.ExecuteQuery(comando);

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    AutorExterno autor = new AutorExterno(reader.GetString(1), reader.GetString(2));
                    autor.ID = reader.GetInt32(0);
                    ListaAutoresExternos.Add(autor);
                }
            }
            reader.Close();
            return(ListaAutoresExternos);
        }
        public static ICollection <ProduccionCientifica> BuscarProduccionPorAutor(string nombre)
        {
            ICollection <ProduccionCientifica> ListaProducciones = new List <ProduccionCientifica>();
            MySqlCommand comando = new MySqlCommand("SELECT produccioncientifica.ID, produccioncientifica.titulo, produccioncientifica.año, produccioncientifica.tipo FROM produccioncientifica INNER JOIN publica ON produccioncientifica.ID= publica.id_produccion INNER JOIN autores ON publica.id_autor= autores.ID WHERE autores.nombre=@nombre;");

            comando.Parameters.AddWithValue("@nombre", nombre);
            MySqlDataReader reader = BBDD.ExecuteQuery(comando);

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    ProduccionCientifica produccion = new ProduccionCientifica(reader.GetString(1), reader.GetInt32(2));
                    produccion.ID   = reader.GetInt32(0);
                    produccion.Tipo = reader.GetString(3);
                    ListaProducciones.Add(produccion);
                }
            }
            reader.Close();
            return(ListaProducciones);
        }