예제 #1
0
        /*
         * Autor: Johan Sebastian Piza Acosta
         * Evento que selecciona una talla del combobox
         */
        private void CbTallas_SelectedIndexChanged(object sender, EventArgs e)
        {
            int t = cbTallas.SelectedIndex;    // se guarda el combobox en una variable de tipo int

            if (t >= 1)
            {
                var talla = (Talla)cbTallas.SelectedItem;
                tallaCamiseta = tallasCamisetas
                                .Where(tc => tc.GeneroId == genero.Id && tc.TallaId == talla.Id)
                                .FirstOrDefault();

                if (tallaCamiseta != null)
                {
                    lblCantidad.Text = "Cantidad: " + tallaCamiseta.Cantidad;
                    var tallaGeneroDao = new TallaGeneroDao(db);
                    tallaGenero    = tallaGeneroDao.GetTallaGenero(talla, genero);
                    lblPrecio.Text = "Precio: " + tallaGenero.Precio;
                }
                else
                {
                    lblPrecio.Text   = "Precio: ";
                    lblCantidad.Text = "Cantidad: ";
                }
            }
        }
예제 #2
0
        public ActionResult Compras()
        {
            if (Session["factura"] == null)
            {
                Session["factura"] = new Factura {
                    DetallesFactura = new List <DetalleFactura>(),
                    Cliente         = (Cliente)Session["cliente"]
                };
            }
            var ligaIdStr   = Request.Form.Get("liga");
            var ligaId      = ligaIdStr == null ? null : new int?(Convert.ToInt32(ligaIdStr));
            var tallaIdStr  = Request.Form.Get("talla");
            var tallaId     = tallaIdStr == null ? null : new int?(Convert.ToInt32(tallaIdStr));
            var generoIdStr = Request.Form.Get("genero");
            var generoId    = generoIdStr == null ? null : new int?(Convert.ToInt32(generoIdStr));

            var ligaDao = new LigaDao(db);
            var ligas   = ligaDao.GetLigas();

            var tallaDao = new TallaDao(db);
            var tallas   = tallaDao.GetTallas();

            var generoDao = new GeneroDao(db);
            var generos   = generoDao.GetGeneros();

            var tallaGeneroDao   = new TallaGeneroDao(db);
            var tarjetasCamiseta = ligaId != null && tallaId != null && generoId != null?
                                   tallaGeneroDao.GetTarjetaCamiseta(ligaId.Value, tallaId.Value, generoId.Value)
                                       : new List <TarjetaCamiseta>();

            ViewBag.Ligas    = ligas;
            ViewBag.Tallas   = tallas;
            ViewBag.Generos  = generos;
            ViewBag.LigaId   = ligaId;
            ViewBag.TallaId  = tallaId;
            ViewBag.GeneroId = generoId;

            ViewBag.TarjetasCamiseta = tarjetasCamiseta;

            return(View());
        }