Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Impresión
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

 
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 14-09-2011
Avatar de microbiano
microbiano microbiano is offline
Miembro
 
Registrado: sep 2008
Ubicación: Mexico D.F
Posts: 349
Poder: 17
microbiano Va por buen camino
ayuda con impresion de 3 consultas en un solo Reporte.

bueno resulta que tengo AdoQuery's de la sigueinte manera.

1.- el primera me regresa el resultado de una busqueda y esta enlazado a un Dbgrid. con sl siguiente codigo
Código Delphi [-]
procedure TForm_requerimiento.btnBtn_seleccionarClick(Sender: TObject);
var wlic,wgpo,wgen,wesp:string;
begin
  wlic:=Trim(Self.cbb_tipo.Text);
  wgpo:=Trim(Self.txtgpo.Text);
  wgen:=Trim(Self.txtgen.Text);
  wesp:=Trim(self.txtesp.Text);
  if wlic<>'' then
    begin
     with Self.Qry_resumen do
      begin
        sql.Clear;
        SQL.Add('select LICITACION,ZONA,GPO,GEN,ESP,DIF,[VAR],DESCRIPCION,PMR AS "PMR/MEDIANA",MAXIMO,IMPORTE_MAX from requerimiento');
        SQL.Add('where licitacion=:Plic');
        Parameters.ParamByName('Plic').Value:=wlic;
        if wgpo<>'' then
          begin
            SQL.Add('and gpo=:Pgpo');
            Parameters.ParamByName('Pgpo').Value:=wgpo;
          end;
          if wgen<>'' then
          begin
            SQL.Add('and gen=:Pgen');
            Parameters.ParamByName('Pgen').Value:=wgen;
          end;
          if wesp<>'' then
          begin
            SQL.Add('and esp=:Pesp');
            Parameters.ParamByName('Pesp').Value:=wesp;
          end;
         SQL.Add('order by 1,3,4,5,6,2');
         open;
         if Qry_resumen.Recordset.RecordCount<=0 then
            begin
             Application.MessageBox('El registro que Intenta buscar no existe'+Chr(13)+'Verifique los datos Proporcionardos',PChar(Application.Title), MB_OK + MB_ICONERROR);
             Qry_resumen.SQL.Clear;
             Qry_detalle.SQL.Clear;
             Exit;
            end
         else
          begin
            Self.grid_db.Columns[0].Width:=130;
            Self.grid_db.Columns[1].Width:=40;
            Self.grid_db.Columns[2].Width:=30;
            Self.grid_db.Columns[3].Width:=30;
            Self.grid_db.Columns[4].Width:=30;
            Self.grid_db.Columns[5].Width:=30;
            Self.grid_db.Columns[6].Width:=30;
            Self.grid_db.Columns[7].Width:=180;
            (FieldByName('PMR/MEDIANA') AS TFloatField).DisplayFormat:= ',0.00';
            Self.grid_db.Columns[8].Width:=90;
            (FieldByName('maximo') As TNumericField).DisplayFormat:=',0.##';
            Self.grid_db.Columns[9].Width:=80;
            (FieldByName('importe_max') AS TFloatField).DisplayFormat:= ',0.00';
            Self.grid_db.Columns[10].Width:=100;
          end;
      end;
    end;
      //valido clave
      if wlic='' then
        begin
          With Qry_resumen do
           begin
             Close;
              sql.Clear;
              if (wgpo<>'') and (wgen<>'') and (wesp<>'') then
                begin
                  SQL.Add('select LICITACION,ZONA,GPO,GEN,ESP,DIF,[VAR],DESCRIPCION,PMR AS "PMR/MEDIANA",MAXIMO,IMPORTE_MAX from requerimiento');
                  SQL.Add('where gpo=:Pgpo and gen=:Pgen and esp=:Pesp');
                  Parameters.ParamByName('Pgpo').Value:=wgpo;
                  Parameters.ParamByName('Pgen').Value:=wgen;
                  Parameters.ParamByName('Pesp').Value:=wesp;
                  SQL.Add('order by 1,3,4,5,6,2');
                  try
                    open;
                    if Qry_resumen.Recordset.RecordCount<=0 then
                      begin
                        Application.MessageBox('El registro que Intenta buscar no existe'+Chr(13)+'Verifique los datos Proporcionardos',PChar(Application.Title), MB_OK + MB_ICONERROR);
                        Qry_resumen.SQL.Clear;
                        Qry_detalle.SQL.Clear;
                        Exit;
                      end
                    else
                      begin
                        Self.grid_db.Columns[0].Width:=130;
                        Self.grid_db.Columns[1].Width:=40;
                        Self.grid_db.Columns[2].Width:=30;
                        Self.grid_db.Columns[3].Width:=30;
                        Self.grid_db.Columns[4].Width:=30;
                        Self.grid_db.Columns[5].Width:=30;
                        Self.grid_db.Columns[6].Width:=30;
                        Self.grid_db.Columns[7].Width:=180;
                        (FieldByName('PMR/MEDIANA') AS TFloatField).DisplayFormat:= ',0.00';
                        Self.grid_db.Columns[8].Width:=90;
                        (FieldByName('maximo') As TNumericField).DisplayFormat:=',0.##';
                        Self.grid_db.Columns[9].Width:=80;
                        (FieldByName('importe_max') AS TFloatField).DisplayFormat:= ',0.00';
                        Self.grid_db.Columns[10].Width:=100;
                      end;
                  except
                    on E:EOleException do
                      begin
                        MessageDlg(Format('Error: %s    Codigo: %d', [E.Message, E.ErrorCode]), mtError, [mbOK], 0);
                      end;
                  end;
                end
               else
                begin
                 Application.MessageBox('Proporcione:'+Chr(13)+'<>'+chr(13)+'<>'+chr(13)+'<>'+chr(13)+  'para poder realizar la busqueda',PChar(Application.Title), MB_OK + MB_ICONERROR);
                 Qry_resumen.SQL.Clear;
                 Qry_detalle.SQL.Clear;
                 Exit;
                end;

           end;
        end;
end;

y en su propiedad: AfterScroll pasa parametros al segundo adqoquery, esto con la finalidad de que cada que cambie de registro se ejecute una segunda consulta con los parametros que se obtienen del primer adoQuery este es el codigo
Código Delphi [-]
procedure TForm_requerimiento.Qry_resumenAfterScroll(DataSet: TDataSet);
var wlicitacion,wzona,wgpo,wgen,wesp,wdif,wvar:string;
begin
wlicitacion:=Qry_resumen.Fields[0].AsString;
wzona:=Qry_resumen.Fields[1].AsString;
wgpo:=Qry_resumen.Fields[2].AsString;
wgen:=Qry_resumen.Fields[3].AsString;
wesp:=Qry_resumen.Fields[4].AsString;
wdif:=Qry_resumen.Fields[5].AsString;
wvar:=Qry_resumen.Fields[6].AsString;
if (wlicitacion='') or (wgpo='') or (wgen='') or (wesp='') or (wdif='') or (wvar='') then
  begin

  end
else
  begin
    limpia_campos;
     with Qry_detalle do
      begin
       sql.Clear;
       sql.Add('SELECT LICITANTE,RFC, MARCA, ORIGEN, FABRICANTE, PMR as "PMR/MEDIANA", PRE_OFER, DESCUENTO, PRECIO_NETO, ASIG_FINAL, CANT_MAX_ASIG, IMPORTE FROM E_DETALLE');
       SQL.Add('where licitacion=:Plicitacion and zona=:Pzona and gpo=:Pgpo and gen=:Pgen and esp=:Pesp and dif=:Pdif and var=:Pvar');
       Parameters.ParamByName('Plicitacion').Value:=wlicitacion;
       Parameters.ParamByName('Pzona').Value:=wzona;
       Parameters.ParamByName('Pgpo').Value:=wgpo;
       Parameters.ParamByName('Pgen').Value:=wgen;
       Parameters.ParamByName('Pesp').Value:=wesp;
       Parameters.ParamByName('Pdif').Value:=wdif;
       Parameters.ParamByName('Pvar').Value:=wvar;
       try
         Open;
         if Qry_detalle.Recordset.RecordCount<=0 then
          begin
            btn_siguiente.Visible:=False;
            btn_anterior.Visible:=False;
          end
         else
          begin
            if  Qry_detalle.Recordset.RecordCount>1 then
              begin
               btn_siguiente.Visible:=True;
               btn_anterior.Visible:=True;
               Self.txtregistros.Value:=Qry_detalle.RecordCount;
               //intento poner los datos en los campos de
                Self.txtproveedor.Text:=(FieldByName('LICITANTE').AsString);
                self.txtrfc.Text:=(Fieldbyname('rfc').AsString);
                Self.txtmarca.Text:=(fieldByname('marca').AsString);
                self.txtorigen.Text:=(FieldByname('origen').AsString);
                self.txtfabricante.Text:=(fieldByname('fabricante').AsString);
                Self.txtpmr.Value:=(FieldByname('PMR/MEDIANA').AsFloat);
                self.txtofertado.Value:=(FieldByname('pre_ofer').AsFloat);
                self.txtdesc.Value:=(FieldByname('descuento').AsFloat);
                self.txtneto.Value:=(FieldByname('precio_neto').AsFloat);
                self.txtasignacion.Value:=(FieldByname('cant_max_asig').AsInteger);
                Self.txtimporte.Value:=(fieldByname('importe').AsFloat);
                Self.txtporc_asign.Value:=(FieldByname('asig_final').AsFloat);
              end
            else
              begin
                btn_siguiente.Visible:=False;
                btn_anterior.Visible:=False;
                Self.txtregistros.Value:=Qry_detalle.RecordCount;
                //intento poner los datos en los campos de
                Self.txtproveedor.Text:=(FieldByName('LICITANTE').AsString);
                self.txtrfc.Text:=(Fieldbyname('rfc').AsString);
                Self.txtmarca.Text:=(fieldByname('marca').AsString);
                self.txtorigen.Text:=(FieldByname('origen').AsString);
                self.txtfabricante.Text:=(fieldByname('fabricante').AsString);
                Self.txtpmr.Value:=(FieldByname('PMR/MEDIANA').AsFloat);
                self.txtofertado.Value:=(FieldByname('pre_ofer').AsFloat);
                self.txtdesc.Value:=(FieldByname('descuento').AsFloat);
                self.txtneto.Value:=(FieldByname('precio_neto').AsFloat);
                self.txtasignacion.Value:=(FieldByname('cant_max_asig').AsInteger);
                Self.txtimporte.Value:=(fieldByname('importe').AsFloat);
                Self.txtporc_asign.Value:=(FieldByname('asig_final').AsFloat);
                  {Self.grid_1.Columns[0].Width:=200;
                self.grid_1.Columns[1].Width:=90;
                (FieldByName('PMR/MEDIANA') AS TFloatField).DisplayFormat:= ',0.00';
                Self.grid_1.Columns[2].Width:=70;
                (FieldByName('PRE_OFER') AS TFloatField).DisplayFormat:= ',0.00';
                Self.grid_1.Columns[3].Width:=70;
                (FieldByName('DESCUENTO') AS TFloatField).DisplayFormat:= ',0.00';
                Self.grid_1.Columns[4].Width:=100;
                (FieldByName('PRECIO_NETO') AS TFloatField).DisplayFormat:= ',0.00';
                Self.grid_1.Columns[5].Width:=90;
                (FieldByName('CANT_MAX_ASIG') As TNumericField).DisplayFormat:=',0.##';
                Self.grid_1.Columns[6].Width:=110;
                (FieldByName('IMPORTE') AS TFloatField).DisplayFormat:= ',0.00';
                Self.grid_1.Columns[7].Width:=30;}
              end;
          end;
       except
        on e:Eoleexception do
          begin
            MessageDlg(Format('Error: %s    Codigo: %d', [E.Message, E.ErrorCode]), mtError, [mbOK], 0);
          end;
       end;
      end;
  end;

end;

2.- El segundo asu vez muestra registros en unos TEdits, pero este a su vez tambien ejecuta una consulta para obtener datos de otra tabla y mostrarlos en los Tedit.

este a su vez en la propiedad AfterScroll pasa parametros al stercer adqoquery, esto con la finalidad de que cada que cambie de registro se ejecute una segunda consulta con los parametros que se obtienen del primer adoQuery
Código Delphi [-]
procedure TForm_requerimiento.Qry_detalleAfterScroll(DataSet: TDataSet);
var wlic,wgpo,wgen,wesp,wdif,wvar,wrfc_proveedor,wclave:string;
    wmaximo:Integer;
begin
wlic:=Qry_resumen.Fields[0].AsString;
wgpo:=Qry_resumen.Fields[2].AsString;
wgen:=Qry_resumen.Fields[3].AsString;
wesp:=Qry_resumen.Fields[4].AsString;
wdif:=Qry_resumen.Fields[5].AsString;
wvar:=Qry_resumen.Fields[6].AsString;
wrfc_proveedor:=Qry_detalle.Fields[1].AsString;
wmaximo:=Qry_detalle.Fields[10].AsInteger;

if (wlic='') or (wgpo='') or (wgen='') or (wesp='') or (wdif='') or (wvar='') then
  begin

  end
else
  begin
    limpia_campos;
    wclave:=wgpo+wgen+wesp+wdif+wvar;
    with Qry_contratos do
      begin
       SQL.Clear;
       sql.Add('select * from g_adq_mcontratos_lic');
       SQL.Add('where licitacion=licitacion and gpo+gen+esp+dif+var=:Pclave');
       sql.Add('and rfc_proveedor=:Prfc and cant_max=:Pcantidad');
       Parameters.ParamByName('Plicitacion').Value:=wlic;
       Parameters.ParamByName('Pclave').Value:=Wclave;
       Parameters.ParamByName('Prfc').Value:=wrfc_proveedor;
       Parameters.ParamByName('Pcantidad').Value:=wmaximo;
       try
        Open;
        if Qry_contratos.Recordset.RecordCount<=0 then
          begin
           limpia_campos;
          end
         else
          begin
            Self.txtcontrato.Text:=(FieldByname('no_contrato').AsString);
          end;
       except
         on e:EOleException do
          begin
           MessageDlg(Format('Error: %s    Codigo: %d', [E.Message, E.ErrorCode]), mtError, [mbOK], 0);
          end;  
       end;  
      end;  
  end;
end;

3.- El Tercer Adoquery recibe parametros de la segunda consulta (2do ado query)


pero no se como mostrar esos datos en el quick report alguna idea de como podria hacerlo?


ejemplo

datos a buscar: 060 0106 0109, resultados en el dbgrid

licitacion- gpo-gen-esp
00641321-017-10, 060-0106-0109
00641321-018-10, 060-0106-0109
00641321-019-10, 060-0106-0109
00641321-020-10, 060-0106-0109

bien la segunda consulta recibe como parametros los siguientes datos:

licitacion
gpo,gen,esp y ejecuta una segunda consulta y muestra los datos en unos tedit

la tercer aconsulta recibe datos de los tedit y ejecuta una consulta que complementa la informacion de todo lo anterior ahora bien el resultao que me gustaria seria el siguiente:

en el reporte de salida:

encabezado

060 0106 0109

detalle

00641321-017-10, campo del tedit del segudndo query, campo del tedi 3er query
00641321-018-10, campo del tedit del segudndo query,campo del tedi 3er query
00641321-019-10,campo del tedit del segudndo query,campo del tedi 3er query
00641321-020-10,campo del tedit del segudndo query,campo del tedi 3er query

de antemano muchas gracias
Responder Con Cita
 



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
ayuda con impresion en rbdetails, solo imprime el primer registro microbiano Impresión 7 09-09-2011 19:17:53
Ayuda con impresión de reporte matricial calogero Impresión 10 22-11-2009 20:38:51
Ayuda impresion de reporte con QReport4 para delphi7 jhoncacru Impresión 2 07-12-2006 03:04:17
Impresion de un Reporte (Ayuda) Inon Impresión 4 16-05-2005 21:39:34
Reporte con 2 Consultas minos Impresión 0 15-10-2004 22:09:22


La franja horaria es GMT +2. Ahora son las 22:44:05.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi