예제 #1
0
        protected void btnFinalizarVenta_Click(object sender, EventArgs e)
        {
            var muebleVenta = MuebleController.searchMuebleByMultipleId(idList);
            var i           = 0;

            foreach (var item in muebleVenta)
            {
                item.cantidad_stock = item.cantidad_stock - (Convert.ToInt32(((TextBox)(gvMuebles.Rows[i].FindControl("txtCantidad"))).Text));
                MuebleController.updateMueble(item);
                i++;
            }
            Session["idList"] = null;
            Response.Redirect("venta.aspx");
        }
예제 #2
0
        protected void txtCantidad_TextChanged(object sender, EventArgs e)
        {
            var total       = 0;
            var i           = 0;
            var muebleVenta = MuebleController.searchMuebleByMultipleId(idList);

            foreach (var item in muebleVenta)
            {
                total = total + (Convert.ToInt32(item.precio) * Convert.ToInt32(((TextBox)(gvMuebles.Rows[i].FindControl("txtCantidad"))).Text));
                Session["totalVenta"] = total;
                i++;
            }
            lblTotal.InnerText = "$ " + Session["totalVenta"].ToString();
        }
예제 #3
0
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            var idMuebleToSell = txtSearch.Text;

            if (!idMuebleToSell.All(char.IsDigit))
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Codigo invalido');", true);
                return;
            }
            var mueble = MuebleController.searchMuebleById(Convert.ToInt32(idMuebleToSell));

            if (mueble == null)
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Producto inexistente');", true);
                return;
            }
            if (mueble.cantidad_stock == 0)
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Producto no disponible en stock');", true);
                return;
            }
            idList.Add(Convert.ToInt32(idMuebleToSell));
            Session["idList"] = idList;
            List <string> cantidades = new List <string>();

            foreach (GridViewRow item in gvMuebles.Rows)
            {
                cantidades.Add(((TextBox)item.FindControl("txtCantidad")).Text);
            }
            var muebleVenta = MuebleController.searchMuebleByMultipleId(idList);

            gvMuebles.DataSource = muebleVenta;
            gvMuebles.DataBind();
            var total = 0;
            var i     = 0;

            foreach (var item in muebleVenta)
            {
                if (cantidades.Count() > i)
                {
                    ((TextBox)(gvMuebles.Rows[i].FindControl("txtCantidad"))).Text = cantidades[i];
                }
                total = total + (Convert.ToInt32(item.precio) * Convert.ToInt32(((TextBox)(gvMuebles.Rows[i].FindControl("txtCantidad"))).Text));
                Session["totalVenta"] = total;
                i++;
            }

            lblTotal.InnerText = "$ " + Session["totalVenta"].ToString();
        }