Example #1
0
        //este boton se encarga de refrescar el panel con el filtro correspondiente
        //no comento el codigo interior porque es el mismo pero con los vehiculos filtrados
        protected void btnBuscar_Click(object sender, EventArgs e)
        {
            Panel1.Controls.Clear();

            ArrayList vehiculos = new ArrayList(ws.WSBuscarVehiculos(tbModelo.Text, tbcombustible.Text, Convert.ToDouble(tbPrecio.Text)));

            //inicializamos los componentes
            List <Button> buttons = new List <Button>();
            List <Label>  labels  = new List <Label>();
            List <Image>  images  = new List <Image>();

            for (int i = 0; i < vehiculos.Count; i++)
            {
                WSServicios.vehiculo ve = (WSServicios.vehiculo)vehiculos[i];

                //boton de seleccionar coche
                Button newButton = new Button();
                newButton.Text   = "Alquilar";
                newButton.Click += delegate { Response.Redirect("alquilerCoche.aspx?idu=" + Request.QueryString["idu"] + "&idc=" + ve.GSIdVehiculo.ToString()); };
                buttons.Add(newButton);

                //label
                Label  lblCaracteristicas = new Label();
                string disponible;
                if (ve.GSDisponible == true)
                {
                    disponible = "SI";
                }
                else
                {
                    disponible = "NO";
                }

                lblCaracteristicas.Text = "</br>------------------------------------------" +
                                          "</br>Disponible: " + disponible +
                                          "</br>Modelo: " + ve.GSNombre +
                                          "</br>Año: " + ve.GSAno +
                                          "</br>Color: " + ve.GSColor +
                                          "</br>Puertas: " + ve.GSPuertas +
                                          "</br>Combustible: " + ve.GSCombustible +
                                          "</br></br>Valoracion: " + ve.GSValoracion + "/5" +
                                          "</br>Precio: " + ve.GSPrecio + " €" +
                                          "</br></br>Prestaciones:</br>" + ve.GSPrestaciones +
                                          "</br></br>";;
                labels.Add(lblCaracteristicas);

                //imagen
                Image ImgCoche = new Image();
                ImgCoche.Width    = 70;
                ImgCoche.Height   = 70;
                ImgCoche.ImageUrl = "coche.jpg";
                images.Add(ImgCoche);
            }

            for (int j = 0; j < vehiculos.Count; j++)
            {
                Panel1.Controls.Add(labels[j]);
                Panel1.Controls.Add(images[j]);
                Panel1.Controls.Add(buttons[j]);
            }
        }