public static Entidades.DetalleProducto datoAEntidad(Detalle_producto detalle)
 {
     Entidades.DetalleProducto retorno = new Entidades.DetalleProducto();
     retorno.Cantidad = (int)detalle.cantidad;
     retorno.Cod_producto =(int) detalle.pro_codigo;
     retorno.Num_factura =(int) detalle.cantidad;
     retorno.Subtotal = (double)detalle.subtotal;
     retorno.Descripcion = detalle.descripcion;
     return retorno;
 }
        public void agregarProducto(Entidades.Producto p, int cantidad)
        {
            Entidades.DetalleProducto d = new Entidades.DetalleProducto();
            d.Cod_producto = p.Codigo;
            d.Num_factura = Convert.ToInt32(txtNfactura.Text);
            d.Cantidad = cantidad;
            d.Descripcion = p.Tipo + " " + p.Modelo;
            d.Subtotal = d.Cantidad * p.Costo;

            p.Cantidad = p.Cantidad - d.Cantidad;

            listadetalles.Add(d);
            lista_productos.Add(p);

            actualizarFactura();
        }