Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

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

Coloboración Paypal con ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #6  
Antiguo 06-09-2012
cloayza cloayza is offline
Miembro
 
Registrado: may 2003
Ubicación: San Pedro de la Paz, Chile
Posts: 947
Poder: 25
cloayza Tiene un aura espectacularcloayza Tiene un aura espectacular
Otra alternativa
Código Delphi [-]
{
type
  TMiData=array of integer;

Función: GetValues(Senders:array of TObject; Var AValues:TMiData):Integer;
              Retorna la suma de los items del array AValues, si la suma es menor a cero, no hay selección
}

function TForm3.GetValues(Senders:array of TObject; Var AValues:TMiData):Integer;
var
   i:integer;
begin
     SetLength(AValues,High(Senders)+1);
     Result:=0;
     for i := Low(Senders) to High(Senders) do
     begin
          AValues[i]:=-1;
          if (TRadioGroup(Senders[i]).ItemIndex>-1)   then
             AValues[i]:=StrToInt(TRadioGroup(Senders[i]).Items[ TRadioGroup(Senders[i]).ItemIndex ]);
          Inc(Result,AValues[i]);
     end;
end;

procedure TForm3.BitBtn1Click(Sender: TObject);
var
  AValues:TMiData;
  i:Integer;
  Prefix:string;
begin
     {             AValues[0]   AValue[1]  }
     if GetValues([RadioGroup1, RadioGroup2],AValues)<0 then
     begin
          ShowMessage('Sin selección');
          Exit;
     end;

     With ADOQuery1 Do
     Begin
          Close;
          SQL.Clear;
          SQL.Add('SELECT * FROM A_CATALOGO WHERE ');

           Prefix:='';
           if AValues[0]>-1 then {Corresponde a RadioGroup1}
           begin
                Prefix:=' AND';
                SQL.Add(Format('(AÑO = %d)',[AValues[0]]));
           end;

           if AValues[1]>-1 then  {Corresponde a RadioGroup2}
           begin
               SQL.Add(Format('%s (MES = %d)',[Prefix, AValues[1]]));
               Prefix:=' AND';
           end;

          Open;
     End;
   
end;

Saludos cordiales
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 para Simplificar codigo escorpionrojo43 OOP 7 08-05-2010 17:55:48
Simplificar Seguridad En Random amonxanubis4 Varios 1 14-01-2010 11:46:59
Como simplificar y obtener el resultado en una fracción manuelalejandro Varios 3 10-12-2006 02:51:04
Radiogroup jmlifi OOP 2 12-01-2006 16:23:23


La franja horaria es GMT +2. Ahora son las 04:57:33.


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