private void btnBuscar_Click(object sender, EventArgs e)
        {
            int id = -1;

            try
            {
                id = Int32.Parse(txtIdentificadorB.Text);
            }
            catch
            {
                MessageBox.Show("Ingrese un identificador valido");
                return;
            }

            Producto buscada = Bebida.buscarBebida(id);

            if (buscada == null)
            {
                MessageBox.Show("No existe la bebida buscada");
                return;
            }
            bebida                = Bebida.buscarBebida(id);
            busqueda              = true;
            txtNombreB.Text       = bebida.getNombre();
            txtPrecioB.Text       = Convert.ToString(bebida.getPrecio());
            txtPresentacionB.Text = bebida.getPresentacion();
            txtCantidadB.Text     = Convert.ToString(bebida.getCantidad());
        }
示例#2
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            int id = -1;

            try
            {
                id = Int32.Parse(txtIdentificador.Text);
            }
            catch
            {
                MessageBox.Show("Ingrese un identificador valido");
                return;
            }

            Producto buscada = Bebida.buscarBebida(id);

            if (buscada == null)
            {
                MessageBox.Show("No existe la bebida buscada");
                return;
            }
            txtNombre.Text       = buscada.getNombre();
            txtPrecio.Text       = Convert.ToString(buscada.getPrecio());
            txtPresentacion.Text = buscada.getPresentacion();
            txtCantidad.Text     = Convert.ToString(buscada.getCantidad());

            MessageBoxButtons botones = MessageBoxButtons.YesNo;
            DialogResult      dr      = MessageBox.Show("Desea Eliminar a: " + buscada.getNombre() + "?", "Eliminar", botones);

            if (dr == DialogResult.Yes)
            {
                try
                {
                    Bebida.eliminarBebida(id);
                    MessageBox.Show(buscada.getNombre() + ", Ha sido Eliminado!");
                    this.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            this.Close();
        }
        private void btnModificar_Click(object sender, EventArgs e)
        {
            if (busqueda == true)
            {
                int id = Int32.Parse(txtIdentificadorB.Text);

                bebida = Bebida.buscarBebida(id);


                if (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 modificar la bebida");
                    return;
                }

                try
                {
                    bebida.setNombre(txtNombre.Text);
                    bebida.setPrecio(Double.Parse(txtPrecio.Text));
                    bebida.setPresentacion(txtPresentacion.Text);
                    bebida.setCantidad(Convert.ToInt32(txtCantidad.Text));
                    MessageBox.Show("El producto ha sido modificado correctamente");
                    this.Close();
                }
                catch
                {
                    MessageBox.Show("Alguno de los campos ingresados no es valido. \n" +
                                    "Posibles errores en la digitacion de:  \n" +
                                    "Identificador, Precio, Cantidad");
                }
            }
            else
            {
                MessageBox.Show("Es necesario realizar primeramente una busqueda de la bebida a modificar");
            }
        }
示例#4
0
        private void btnAceptar_Click(object sender, EventArgs e)
        {
            int id       = 0;
            int cantidad = 0;

            try
            {
                id       = Int32.Parse(txtIdentificador.Text);
                cantidad = Int32.Parse(txtCantidad.Text);
            }
            catch
            {
                MessageBox.Show("Ingrese un valor valido");
            }

            String idUsuario = txtIdentificacionUsuario.Text;

            if (idUsuario.Length == 0)
            {
                MessageBox.Show("Ingrese un valor valido para la identificacion del usuario");
                return;
            }

            Cliente user = Usuario.buscarUsuario(idUsuario);

            if (user == null)
            {
                MessageBoxButtons botonesConf = MessageBoxButtons.YesNo;
                DialogResult      dR          = MessageBox.Show("El usuario con la identificacion: " + idUsuario + " No existe, ¿Desea crearlo?", "Crear Usuario", botonesConf);

                if (dR == DialogResult.Yes)
                {
                    GUIAgregar agregar = new GUIAgregar();
                    agregar.Show();
                }
                return;
            }

            Producto buscada = Bebida.buscarBebida(id);

            if (buscada == null)
            {
                MessageBoxButtons botonesBeb = MessageBoxButtons.YesNo;
                DialogResult      dbeb       = MessageBox.Show("La bebida buscada con el id: " + id + " No existe, ¿Desea crearla?", "Crear Bebida", botonesBeb);

                if (dbeb == DialogResult.Yes)
                {
                    GUIAgregarBebida agregar = new GUIAgregarBebida();
                    agregar.Show();
                }

                return;
            }

            Bebida.setNumBebidas(cantidad);

            MessageBoxButtons botones = MessageBoxButtons.YesNo;
            DialogResult      dr      = MessageBox.Show("El total a pagar es : " + Bebida.totalAPagar(id) + "$. Desea adquirir los productos?", "Pagar", botones);

            if (dr == DialogResult.Yes)
            {
                try
                {
                    Bebida.pedirBebida(id);
                    MessageBox.Show("Los productos fueron adquiridos correctamente por el cliente " + user.getNombre() + "!");
                    this.Close();
                }

                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }