Exemplo n.º 1
0
    private void cargarRInventario()
    {
        if ((Request.QueryString["Invet"] != null) && (Request.QueryString["Prod"] != null))
        {
            int     _ivent = int.Parse(Request.QueryString["Invet"].ToString());
            int     _prod  = int.Parse(Request.QueryString["Prod"].ToString());
            DataSet _cat   = _consulta.Com21_consulta_inventario_productos_id(_ivent, _prod);
            if (_cat.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow r in _cat.Tables[0].Rows)
                {
                    lblcantidadini.Text  = r["Cantidad"].ToString();
                    lblprecionini.Text   = r["Precio"].ToString().Replace(".", ",");
                    lbltitulo.Text       = r["Titulo"].ToString();
                    lblmarca.Text        = r["Marca"].ToString();
                    lblpreciocompra.Text = r["PrecioCompra"].ToString().Replace(".", ",");
                    lblsubcategoria.Text = r["SubCategoria"].ToString();
                    lblCategoria.Text    = r["Categoria"].ToString();
                    imgRuta.ImageUrl     = r["Ruta"].ToString();
                }
            }
            if (_cat.Tables[1].Rows.Count > 0)
            {
                pInvetS.Visible = true;
                pInvetN.Visible = false;
                decimal _totalC = 0;
                decimal _totalV = 0;
                foreach (DataRow r in _cat.Tables[1].Rows)
                {
                    if (r["IdentificadorCV"].ToString() == "Compra")
                    {
                        _totalC = _totalC + decimal.Parse(r["Subtotal"].ToString());
                    }
                    if (r["IdentificadorCV"].ToString() == "Venta")
                    {
                        _totalV = _totalV + decimal.Parse(r["Subtotal"].ToString());
                    }
                }
                lbltotalC.Text  = "$" + Convert.ToString(_totalC);
                lbltotalV.Text  = "$" + Convert.ToString(_totalV);
                lbltotalCV.Text = "$" + Convert.ToString(_totalC - _totalV);

                GvRProductos.DataSource = _cat.Tables[1];
                GvRProductos.DataBind();
            }
            else
            {
                pInvetS.Visible = false;
                pInvetN.Visible = true;
            }
        }
    }