RobertoCarlos Melgar

RobertoCarlos Melgar

  • 1.6k
  • 159
  • 10.2k

Convert object type

Jul 18 2020 2:31 PM
Hello good afternoon to everyone. could you please help me with the following
I would like to bring to a datagridvew the corresponding sales between two date ranges
for this I have the following code
  1. namespace CapaLogica    
  2. {    
  3.     public class VentasEntreFechasDTO    
  4.     {    
  5.         public string NumeroVenta { getset; }    
  6.         public string Producto { getset; }    
  7.         public string Unidad { getset; }    
  8.         public decimal Precio { getset; }    
  9.         public int Cantidad { getset; }    
  10.         public decimal ValorFila { getset; }    
  11.     
  12.         //     
  13.         public static List<VentasEntreFechasDTO> Ventas(DateTime Inicio, DateTime Fin)    
  14.         {    
  15.     
  16.             using (GourmetEntities db = new GourmetEntities())    
  17.             {    
  18.                 var li = db.tblMaestroVentas.Include(x => x.tblDetalleVentas).Where(x => x.FechaVenta >= Inicio && x.FechaVenta <= Fin);    
  19.     
  20.                 return (List<VentasEntreFechasDTO>)li;    
  21.             }    
  22.         }    
  23.     
  24.     }    
  25. }  
this code apparently doesn't show me any error, but when I try to load it to a datagridview it shows me an error
  1. private void BtnBuscar_Click(object sender, EventArgs e)    
  2. {    
  3.     if(VerificarRangoFechas())    
  4.     {    
  5.         DataGridViewVentaEntreFechas.DataSource = VentasEntreFechasDTO.Ventas(DtpDesde.Value.Date, DtpHasta.Value.Date);    
  6.     }   
  7. }   
 
Please how can I solve this error since I need to visualize sales between date ranges
 
please help
Roberto Melgar

Answers (1)