/// <summary>
        /// This method add a new refresh in database if something fall, return 0
        /// </summary>
        /// <param name="r"></param>
        /// <returns> 0 if refresh is not added succesfully or return 1 if refresh is added succesfully</returns>
        public async Task <int> agregarBebida(Refresco r)
        {
            int agregado = 0;

            try
            {
                limpiarListas();
                listaParam.Add("name");
                listaParam.Add("price");
                listaParam.Add("image");

                listaValues.Add(r.getNombre());
                listaValues.Add(r.getPrecio().ToString());
                listaValues.Add(r.getImagen());


                String json = await hreq.sendRequestPOST("/ServicioMyPizza/servicios/WSProducto/addbebida", listaParam, listaValues);

                agregado = JsonConvert.DeserializeObject <int>(json);
            }
            catch (System.Net.WebException swe)
            {
                agregado = 0;
            }
            return(agregado);
        }
        //remove the node selected
        private async void bQuitar_Click(object sender, EventArgs e)
        {
            try
            {
                String nodeSeleccionado = treeViewPedido.SelectedNode.Text; //producto seleccionado

                Pizza p = await cp.buscarPizzaPorNombre(nodeSeleccionado);

                Refresco r = await cp.buscarRefrescoPorNombre(nodeSeleccionado);

                if (p != null)
                {
                    double num = cPed.restarTotal(p.getPrecio());
                    treeViewPedido.SelectedNode.Remove();
                    actualizarTxtTotal(num);
                }
                else if (r != null)
                {
                    double num = cPed.restarTotal(r.getPrecio());
                    treeViewPedido.SelectedNode.Remove();
                    actualizarTxtTotal(num);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("No hay ningun item seleccionado", "Error");
            }
        }
        private async void pressedBebida(object sender, EventArgs e)
        {
            PictureBox pb = (PictureBox)sender;

            Refresco r = await cp.buscarRefrescoPorNombre(pb.Name);

            addBebida(r);
        }
Example #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            var pizza = new Pizza();

            MessageBox.Show("Pedido guardado");

            var Refresco = new Refresco();

            pizza.Refresco = Refresco;
        }
        /// <summary>
        /// This method add a drink in the listview pedido
        /// </summary>
        /// <param name="bebida">drink</param>
        public void addBebida(Refresco bebida)
        {
            ImageList imagelist2 = new ImageList();

            imagelist2.Images.Add(Image.FromFile("..\\..\\Resources\\can.png"));

            treeViewPedido.Nodes.Add(bebida.getNombre());

            double num = cPed.sumarTotal(bebida.getPrecio());

            actualizarTxtTotal(num);

            treeViewPedido.ImageList = imagelist2;
        }
Example #6
0
        /// <summary>
        /// This method save the select item from listview and put the name, image and price in the form.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void listViewBebidas_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listViewBebidas.SelectedItems.Count > 0)
            {
                ListViewItem listItem     = listViewBebidas.SelectedItems[0];
                String       nombreBebida = listItem.Text;
                txtBebida.Text = nombreBebida;


                Refresco r = await cp.buscarRefrescoPorNombre(nombreBebida);

                txtPrecio.Text = r.getPrecio().ToString();

                String pathImage = r.getImagen();
                pictureBox1.ImageLocation = "http://provenapps.cat/~dam1804/Images/bebidas/" + pathImage;
            }
        }
Example #7
0
        //Metodo guardar bebida
        private async Task <int> guardarBebida(String nombreBebida, String precio, String imagen)
        {
            int answ = 0;

            MessageBox.Show(nombreBebida + precio + imagen);

            if (nombreBebida != "" && precio != "")
            {
                Refresco r = new Refresco(nombreBebida, Double.Parse(precio), imagen);
                answ = await cp.agregarBebida(r);
            }
            else
            {
                Alert("Porfavor rellene los campos", "Campos vacios");
            }

            return(answ);
        }
        /// <summary>
        /// this method assigns the received parameter to a list and sends it by post, and that information
        /// is collected in a string, that string is serialized to a refresh, if the refresh has not been found, it
        /// returns null, if it does not return the refresh
        /// </summary>
        /// <param name="nombreRefresco"></param>
        /// <returns></returns>
        public async Task <Refresco> buscarRefrescoPorNombre(String nombreRefresco)
        {
            Refresco r = null;

            try
            {
                limpiarListas();
                listaParam.Add("name");
                listaValues.Add(nombreRefresco);

                String json = await hreq.sendRequestPOST("/ServicioMyPizza/servicios/WSProducto/buscarbebida", listaParam, listaValues);

                r = JsonConvert.DeserializeObject <Refresco>(json);
            }
            catch (System.Net.WebException swe)
            {
                r = null;
            }
            return(r);
        }
 public void eliminarBebida(Refresco r)
 {
 }
 public void modificarBebida(Refresco r)
 {
 }
Example #11
0
        private void cmdSeleccionar_Click(object sender, EventArgs e)
        {
            Refresco refresco = (Refresco)this.cboEstrategias.SelectedItem;

            dispensador.CambiarEstrategia(refresco);
        }