Ejemplo n.º 1
0
        private void lbFacturas_SelectedIndexChanged(object sender, EventArgs e)
        {
            LogicaGo logica = new LogicaGo();

            lblFacturaId.Text = "Factura Numero: " + lbFacturas.SelectedValue.ToString();
            factura           = logica.obtenerFactura(lbFacturas.SelectedValue.ToString());
            if (factura != null)
            {
                lblComprador.Text = factura.Nombre;
                lblCelular.Text   = "Celular: " + factura.Celular;
                lblDireccion.Text = "Dirección: " + factura.Direccion;
                Decimal value;
                if (Decimal.TryParse(factura.ValorBruto.ToString(), out value))
                {
                    lblValorBruto.Text = "Valor Bruto: " + String.Format(System.Globalization.CultureInfo.CurrentCulture, "{0:C2}", value);
                }
                else
                {
                    lblValorBruto.Text = "Valor Bruto: $0";
                }
                if (Decimal.TryParse(factura.Iva.ToString(), out value))
                {
                    lblIVA.Text = "IVA: " + String.Format(System.Globalization.CultureInfo.CurrentCulture, "{0:C2}", value);
                }
                else
                {
                    lblIVA.Text = "IVA: $0";
                }
                if (Decimal.TryParse(factura.ValorTotal.ToString(), out value))
                {
                    lblTotal.Text = "Total: " + String.Format(System.Globalization.CultureInfo.CurrentCulture, "{0:C2}", value);
                }
                else
                {
                    lblTotal.Text = "Total: $0";
                }
                lblFecha.Text           = "Fecha: " + factura.Fecha;
                lblUsuario.Text         = "Usuario: " + factura.Usuario;
                datos                   = logica.obteverProductosVenta(lbFacturas.SelectedValue.ToString());
                dgvProductos.DataSource = datos;
                listaProductosVenta     = new List <ProductoVenta>();
                ProductoVenta pv;
                foreach (DataRow dt in datos.Rows)
                {
                    pv          = new ProductoVenta();
                    pv.Nombre   = dt["nombre"].ToString();
                    pv.Cantidad = Convert.ToDecimal(dt["cantidad"].ToString());
                    pv.Total    = Convert.ToDecimal(dt["valor_total"].ToString());
                    listaProductosVenta.Add(pv);
                }
                btnReimprimir.Enabled = true;
            }
        }