Пример #1
0
        private void buttonGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                TipoCombustible   tipoC  = (TipoCombustible)comboBoxTipoComb.SelectedItem;
                TanqueCombustible tanque = (TanqueCombustible)comboBoxTanque.SelectedItem;

                if ((textBoxCantidad.Text.Trim().Length > 0) && (tipoC != null) && (tanque != null))
                {
                    int cantidad = Convert.ToInt32(textBoxCantidad.Text.Trim());

                    if (tareaSeleccionada == null)
                    {
                        fachada.crearTareaReposicionCombustible((TanqueCombustible)comboBoxTanque.SelectedItem, cantidad);
                        MessageBox.Show("La tarea ha sido creada");
                    }

                    listBoxListaTareas.Items.Clear();
                    foreach (TareaReposicionCombustible t in fachada.getListaTareasReposicionCombustible())
                    {
                        listBoxListaTareas.Items.Add(t);
                    }
                    listBoxListaTareas.Show();
                    borrarDatos();
                }
                else
                {
                    MessageBox.Show("Faltan datos.", "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);
            }
        }