Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (this.Session["username"] != null)
                {
                    N_Usuario      negU  = new N_Usuario();
                    N_Venta        negV  = new N_Venta();
                    N_DetalleVenta negDV = new N_DetalleVenta();

                    string codUsuario = negU.getIDporUsername(this.Session["username"].ToString());

                    DataTable tabla  = negV.getTablaVentasPorUsuario(codUsuario);
                    DataTable tabla2 = negDV.getTablaDetalleVentasPrecioTotalPorCodUsuario(codUsuario);
                    tabla.Columns.Add("PrecioTotal", typeof(string));
                    for (int i = 0; i < tabla.Rows.Count; i++)
                    {
                        decimal precio = Convert.ToDecimal(tabla2.Rows[i]["PrecioTotal"].ToString());

                        tabla.Rows[i]["PrecioTotal"] = precio.ToString("N2");
                    }
                    grdVentas.DataSource = tabla;
                    grdVentas.DataBind();
                }
            }
        }
Esempio n. 2
0
        protected void grdVentas_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            grdVentas.PageIndex = e.NewPageIndex;
            N_Usuario      negU  = new N_Usuario();
            N_Venta        negV  = new N_Venta();
            N_DetalleVenta negDV = new N_DetalleVenta();

            string codUsuario = negU.getIDporUsername(this.Session["username"].ToString());

            DataTable tabla  = negV.getTablaVentasPorUsuario(codUsuario);
            DataTable tabla2 = negDV.getTablaDetalleVentasPrecioTotalPorCodUsuario(codUsuario);

            tabla.Columns.Add("PrecioTotal", typeof(string));
            for (int i = 0; i < tabla.Rows.Count; i++)
            {
                decimal precio = Convert.ToDecimal(tabla2.Rows[i]["PrecioTotal"].ToString());

                tabla.Rows[i]["PrecioTotal"] = precio.ToString("N2");
            }
            grdVentas.DataSource = tabla;
            grdVentas.DataBind();
        }