Ver Mensaje Individual
  #2  
Antiguo 23-10-2016
wilcg wilcg is offline
Miembro
 
Registrado: abr 2014
Posts: 107
Reputación: 11
wilcg Va por buen camino
Prueba de esta manera,

Usa un Query para cada DBGrid.

// Filtrar todas la ventas que cumplen la condicion de busqueda
Código Delphi [-]
    with QueryVentas do
    begin
      Close;
      SQL.Clear;
      SQL.Add('SELECT * FROM ventas '+
         ' WHERE fecha_venta BETWEEN '+
         QuotedStr(FormatDateTime( 'yyyy/mm/dd',edtFInicio.Date ))+
         ' AND '+ QuotedStr(FormatDateTime( 'yyyy/mm/dd',edtFFin.Date ))+
         ' ORDER BY id_venta DESC ');
      Open;
      if RecNo < 1 then
        Close;
   end;

Ahora en el el evento OnDataChange del Datasouce vinculado a las ventas, este codigo.

// Filtrar detalles de acuerdo a la venta
Código Delphi [-]
  with QueryVentas do
  begin
    if (Active = True) AND (RecNo > 0) then
      jIdVenta := FieldByName('id_venta').Value;

   QueryDetalles.Close;
   QueryDetalles.SQL.Clear;
   QueryDetalles.SQL.Add('SELECT * FROM detalle_venta '+
     ' WHERE id_venta = :ID ');
   QueryDetalles.ParamByName('ID').Value := jIdVenta;
   QueryDetalles.Open;
   if QueryDetalles.RecNo < 1 then
     QueryDetalles.Close;
  end;

Esto hará que que conforme selecciones un registro de venta te mostrará los detalles en el DBGrid detalles de venta.
Espero que te sirva,

Última edición por wilcg fecha: 23-10-2016 a las 04:19:17.
Responder Con Cita