Example #1
0
        private void buttonFiltrar_Click(object sender, EventArgs e)
        {
            try
            {
                if (radioIsbn.Checked == true)
                {
                    int          codigo = int.Parse(textBoxFiltro.Text);
                    List <Libro> aux    = admincopia.FiltroIsbn(codigo);
                    listBoxListado.DataSource = null;
                    listBoxListado.DataSource = aux;
                    listBoxListado.ClearSelected();
                    MessageBox.Show("Filtrado exitoso");
                }
                else
                {
                    if (radioButtonGenero.Checked == true)
                    {
                        string variable = textBoxFiltro.Text;
                        if (variable.Length == 0)
                        {
                            throw new BlancoException();
                        }
                        List <Libro> aux = admincopia.Filtrogenero(variable);
                        listBoxListado.DataSource = null;
                        listBoxListado.DataSource = aux;
                        listBoxListado.ClearSelected();
                        MessageBox.Show("Filtrado exitoso");
                    }
                    else
                    {
                        if (radioButtonEditorial.Checked == true)
                        {
                            string variable = textBoxFiltro.Text;
                            if (variable.Length == 0)
                            {
                                throw new BlancoException();
                            }
                            List <Libro> aux = admincopia.Filtroeditorial(variable);
                            listBoxListado.DataSource = null;
                            listBoxListado.DataSource = aux;
                            listBoxListado.ClearSelected();
                            MessageBox.Show("Filtrado exitoso");
                        }
                        else
                        {
                            if (radioButtonAutor.Checked == true)
                            {
                                string variable = textBoxFiltro.Text;
                                if (variable.Length == 0)
                                {
                                    throw new BlancoException();
                                }
                                List <Libro> aux = admincopia.Filtroautor(variable);
                                listBoxListado.DataSource = null;
                                listBoxListado.DataSource = aux;
                                listBoxListado.ClearSelected();
                                MessageBox.Show("Filtrado exitoso");
                            }
                            else
                            {
                                MessageBox.Show("No se encontro");
                                listBoxListado.DataSource = null;
                                listBoxListado.DataSource = libros;
                                listBoxListado.ClearSelected();
                            }
                        }
                    }
                }
            }

            catch (FormatException ex)
            {
                MessageBox.Show("Ingresó letras en lugar de número / o no ingresó nada");
            }
            catch (DniException ex)
            {
                MessageBox.Show(ex.Message);
            }
            catch (BlancoException ex)
            {
                MessageBox.Show(ex.Message);
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            //finally---> no me lo toma(revisar)
        }