Example #1
0
 private void btnEliminar_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Desea eliminar el registro seleccionado?", "Pregunta", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         CLS.Libros oLibro = new CLS.Libros();
         oLibro.IDLibro = dtgRegistros.CurrentRow.Cells["IDLibro"].Value.ToString();
         if (oLibro.Eliminar())
         {
             MessageBox.Show("Eliminado");
             CargarDatos();
         }
         else
         {
             MessageBox.Show("Falló la eliminación");
         }
     }
 }
Example #2
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            CLS.Libros oLibro = new CLS.Libros();
            oLibro.IDLibro           = txtIDLibro.Text;
            oLibro.Titulo            = txtTitulo.Text;
            oLibro.IDAutor           = cmbAutores.SelectedValue.ToString();
            oLibro.IDEditorial       = cmbEditoriales.SelectedValue.ToString();
            oLibro.IDCategoria       = cmbCategorias.SelectedValue.ToString();
            oLibro.Edicion           = txtEdicion.Text;
            oLibro.Paginas           = txtPaginas.Text;
            oLibro.Contenidos        = txtContenidos.Text;
            oLibro.Fecha_Lanzamiento = dtFecha.Text;
            oLibro.Portada           = pbxPortada.Image;

            if (txtIDLibro.TextLength > 0)
            {
                if (oLibro.Actualzar())
                {
                    MessageBox.Show("Actualizado");
                    Close();
                }
                else
                {
                    MessageBox.Show("Falló la Actualizacion");
                }
            }
            else
            {
                if (oLibro.Insertar())
                {
                    MessageBox.Show("Insertado");
                    Close();
                }
                else
                {
                    MessageBox.Show("Falló la Insercion");
                }
            }
        }