Пример #1
0
        private void btnBuscar_Click(object sender, EventArgs e)
        {
            dtgLibros.Refresh();

            int    id          = -1;
            string titulo      = "";
            int    anno        = -1;
            int    idAutor     = -1;
            int    idEditorial = -1;

            if (chkTitulo.Checked)
            {
                if (txtTiluto.Text.Trim().Equals(""))
                {
                    MessageBox.Show("Ingrese el Titulo del Libro", "Escuela Platanares", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                titulo = txtTiluto.Text.Trim();
            }

            if (chkAnno.Checked)
            {
                if (mskAnno.Text.Equals(""))
                {
                    MessageBox.Show("Ingrese el Año del Libro", "Escuela Platanares", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
                anno = Convert.ToInt32(mskAnno.Text.Trim());
            }



            if (chkEditorial.Checked)
            {
                if (cmbEditorial.SelectedItem == null)
                {
                    MessageBox.Show("Seleccione la Editorial del Libro", "Escuela Platanares", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
                idEditorial = ((Editorial)cmbEditorial.SelectedItem).Id;
            }

            if (chkAutor.Checked)
            {
                if (cmbAutor.SelectedItem == null)
                {
                    MessageBox.Show("Seleccione el Autor del Libro", "Escuela Platanares", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                idAutor = ((Autor)cmbAutor.SelectedItem).Id;
            }

            dtgLibros.DataSource = Logica.SeleccionarTodosFiltro(id, titulo, idAutor, idEditorial, anno);
        }