public void AddProforma(Proforma proforma)
        {
            var newProforma = new Proforma();

            newProforma.ClienteId = proforma.ClienteId;

            // newVenta.Cliente = venta.Cliente;
            newProforma.Fecha = proforma.Fecha;
            newProforma.total = proforma.total;

            //newVenta.TipoDocumento = venta.TipoDocumento;

            foreach (var item in proforma.detalleproforma)
            {
                var detalle = new DetalleProforma();
                detalle.Cantidad   = item.Cantidad;
                detalle.ProductoId = item.ProductoId;

                detalle.Precio = item.Precio;
                //TIPO DOC

                newProforma.detalleproforma.Add(detalle);
            }


            _context.Proformas.Add(newProforma);
            _context.SaveChanges();
        }
        protected void lvProformas_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            if (e.CommandName == "agregar")
            {
                var productoId = Convert.ToInt32(e.CommandArgument.ToString());

                var producto = ProductoService.GetProductoById(productoId);

                var proforma = Cache.Get("proforma") as Proforma;

                var existe = proforma.detalleproforma.SingleOrDefault(d => d.ProductoId.Equals(productoId));

                if (existe == null)
                {
                    var detalleproforma = new DetalleProforma()
                    {
                        ProductoId = productoId,
                        producto   = producto,
                        Cantidad   = 1,
                        ProformaId = proforma.Id,
                        Precio     = producto.PrecioUnitarioDeVenta
                    };

                    proforma.detalleproforma.Add(detalleproforma);
                }
                else
                {
                    existe.Cantidad += 1;
                }

                BindProforma(proforma);
                Cache.Insert("proforma", proforma);
            }
        }