Beispiel #1
0
 private void btnConfirmar_Click(object sender, EventArgs e)
 {
     if (txtIdentificador.Text.Length == 0 || txtNombre.Text.Length == 0 || txtPrecio.Text.Length == 0 || txtPresentacion.Text.Length == 0 || txtCantidad.Text.Length == 0)
     {
         MessageBox.Show("Hay espacios vacios, No se ha podido agregar la bebida");
         return;
     }
     try
     {
         int      id           = Int32.Parse(txtIdentificador.Text);
         String   nombre       = txtNombre.Text;
         double   precio       = Double.Parse(txtPrecio.Text);
         String   presentacion = txtPresentacion.Text;
         int      cantidad     = Int32.Parse(txtCantidad.Text);
         Producto producto     = new Producto(id, nombre, precio, presentacion, cantidad);
         try
         {
             Bebida.agregarBebida(producto);
             MessageBox.Show(producto.getNombre() + ", Ha sido registrado con exito");
             this.Close();
         }catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
     catch
     {
         MessageBox.Show("Alguno de los campos ingresados no es valido. \n" +
                         "Posibles errores en la digitacion de:  \n" +
                         "Identificador, Precio, Cantidad");
     }
 }