private void btnInsertar_Click(object sender, EventArgs e) { if (this.editar == false) { try { if (ChequeoCamposCompletos()) { objCNProductos.InsertarProductos(txtNombre.Text, (this.cbSector.SelectedIndex + 1).ToString(), txtPrecio.Text, txtStock.Text); MessageBox.Show("Se insertó correctamente"); MostrarProductos(); LimpiarCampos(); } else { MessageBox.Show("Complete todos los campos", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); } } else { if (ChequeoCamposCompletos()) { try { objCNProductos.EditarProducto(txtNombre.Text, (this.cbSector.SelectedIndex + 1).ToString(), txtPrecio.Text, txtStock.Text, this.idProducto); MessageBox.Show("Se Edito correctamente"); MostrarProductos(); LimpiarCampos(); this.editar = false; } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); } } else { MessageBox.Show("Complete todos los campos", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }