private void btnRegistrar_Click(object sender, EventArgs e) { try { String descripcion = textDescripcion.Text.Trim(); if (descripcion.Length > 0) { if (tipoSeleccionado == null) { fachada.crearTipoCombustible(descripcion); MessageBox.Show("El tipo de combustible ha sido creado"); } else { fachada.editarTipoCombustible((TipoCombustible)listaTiposCombustible.SelectedItem, textDescripcion.Text); MessageBox.Show("Se ha editado el elemento seleccionado de forma correcta!"); } listaTiposCombustible.Items.Clear(); foreach (TipoCombustible t in fachada.getListaTiposCombustible()) { listaTiposCombustible.Items.Add(t); } listaTiposCombustible.Show(); } else { MessageBox.Show("Valores incorrectos.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (MiExcepcion es) { MessageBox.Show(es.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error en los datos", MessageBoxButtons.OK, MessageBoxIcon.Error); } tipoSeleccionado = null; listaTiposCombustible.SelectedItem = null; }