private void EliminarAutor()
        {
            AutorExterno autor = BuscarSeleccionado();

            dataGridAutoresExt.Rows.Remove(dataGridAutoresExt.SelectedRows[0]);
            AutorExternoDAO.BorrarRegistro(autor);
            autoresExt.Remove(autor);
        }
        private void RellenarForm()
        {
            AutorExterno autor = new AutorExterno();

            autor             = BuscarSeleccionado();
            textNombre.Text   = autor.Nombre;
            textApellido.Text = autor.Apellido;
        }
Beispiel #3
0
        public static bool BorrarRegistro(AutorExterno autor)
        {
            MySqlCommand comando = new MySqlCommand("DELETE FROM autores WHERE autores.ID=@ID");

            comando.Parameters.AddWithValue("@ID", autor.ID);
            int filas = BBDD.ExecuteNonQuery(comando);

            return(filas >= 1);
        }
Beispiel #4
0
        public static bool ActualizarRegistro(AutorExterno autor)
        {
            MySqlCommand comando = new MySqlCommand("UPDATE autores SET nombre=@nombre, apellido=@apellido WHERE ID=@ID;");

            comando.Parameters.AddWithValue("@ID", autor.ID);
            comando.Parameters.AddWithValue("@nombre", autor.Nombre);
            comando.Parameters.AddWithValue("@apellido", autor.Apellido);
            int filas = BBDD.ExecuteNonQuery(comando);

            return(filas >= 1);
        }
Beispiel #5
0
        public static bool Insertar(AutorExterno autor)
        {
            MySqlCommand comando = new MySqlCommand("INSERT INTO gestorpublicaciones.autores VALUES (@ID, @nombre, @apellido, @deUniversidad);");

            comando.Parameters.AddWithValue("@ID", autor.ID);
            comando.Parameters.AddWithValue("@nombre", autor.Nombre);
            comando.Parameters.AddWithValue("@apellido", autor.Apellido);
            comando.Parameters.AddWithValue("@deUniversidad", autor.deUniversidad);
            int filas = BBDD.ExecuteNonQuery(comando);

            return(filas >= 1);
        }
Beispiel #6
0
        /// <summary>
        /// Metodo para encontrar por id un autor  dentro de una lista
        /// </summary>
        /// <returns>Devuelve un objeto de tipo AutorExterno</returns>
        public AutorExterno BuscarAutorSeleccionado()
        {
            int          id    = (int)dataGridAutores.SelectedRows[0].Cells[0].Value;
            AutorExterno Autor = null;

            foreach (AutorExterno a in ListaAutoresCompleta)
            {
                if (a.ID == id)
                {
                    Autor = a;
                    break;
                }
            }
            return(Autor);
        }
Beispiel #7
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);
        }
        private AutorExterno BuscarSeleccionado()
        {
            int          id    = (int)dataGridAutoresExt.SelectedRows[0].Cells[0].Value;
            AutorExterno autor = null;

            foreach (AutorExterno a in autoresExt)
            {
                if (a.ID == id)
                {
                    autor = a;
                    break;
                }
            }

            return(autor);
        }
        private void ModificarAutor()
        {
            AutorExterno autor = BuscarSeleccionado();

            autor          = BuscarSeleccionado();
            autor.Nombre   = textNombre.Text;
            autor.Apellido = textApellido.Text;
            int indice = autoresExt.IndexOf(autor);

            if (indice >= 0)
            {
                autoresExt[indice] = autor;
            }
            AutorExternoDAO.ActualizarRegistro(autor);
            MessageBox.Show("Registro modificado con éxito");
            RellenarDataGrid();
        }
Beispiel #10
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 #11
0
        /// <summary>
        /// Metodo que rellena el datagrid, vacía las listas de autores relacionados con la patente y la lista total de autores,
        /// activa los métodos de rellenado de los otros 2 datagrid al hacer click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dataGridPatente_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            modificado = true;
            ListaAutoresPublicacion.Clear();
            ListaIDAutoresPublicacion.Clear();
            RellenarForm();
            FilaSeleccionada = true;
            Patente patente = BuscarSeleccionado();

            PatenteSeleccionada       = BuscarSeleccionado();
            ListaIDAutoresPublicacion = PatenteDAO.MostrarAutoresPublicacion(patente.ID);
            foreach (int id in ListaIDAutoresPublicacion)
            {
                AutorExterno autor = AutorExternoDAO.BuscarAutorPorID(id);
                ListaAutoresPublicacion.Add(autor);
                //Console.WriteLine(autor.Nombre);
            }
            RellenarDataAutores(dataGridAutoresPublicacion, (List <AutorExterno>)ListaAutoresPublicacion);
        }
Beispiel #12
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);
        }
        private void InsertarAutor()
        {
            IDactualAutor = AutorExternoDAO.IDactual();
            AutorExterno autor = new AutorExterno();

            if (textNombre.Text.Trim() == "" || textApellido.Text.Trim() == "")
            {
                MessageBox.Show("Debe rellenar los campos primero");
            }

            else
            {
                autor.Nombre   = textNombre.Text;
                autor.Apellido = textApellido.Text;
                autoresExt.Add(autor);
                AutorExternoDAO.Insertar(autor);
                MessageBox.Show("Registro guardado con éxito");
                BorrarForm();
                RellenarDataGrid();
            }
        }
Beispiel #14
0
 private void dataGridAutores_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     AutorSeleccionado = BuscarAutorSeleccionado();
 }