Simplificar este código

Delphi

09/06/2005

Galera, como faço para simplificar este código, ele manda imprimir soh os que estao selecionados, ou seja, com o X

Abraço...

procedure TfrmLancamentoAvulso.SpeedButton14Click(Sender: TObject);
begin
qryOper.First;
qryImpressao.Close;
qryImpressao.Open;

if MessageBox(Handle, ´Imprimir Seleção?!´, ´AVISO!!!´,
MB_ICONWARNING or MB_YESNO or MB_DEFBUTTON2) = idYes then
Begin
while not qryOper.Eof do
Begin
if qryOperimpress.Value = ´X´ then
Begin
qryImpressao.Append;
qryImpressaoData.Value := qryOperData.Value;
qryImpressaoCdFunc.Value := qryOperCdFunc.Value;
qryImpressaoPortador.Value := qryOperPortador.Value;
qryImpressaoTexto.Value := qryOperTexto.Value;
qryImpressaoNmFunc.Value := qryOperNmFunc.Value;
qryImpressaoDescricao.Value := qryOperDescricao.Value;
qryImpressaoNrcontrLancDiv.Value := qryOperNrcontrLancDiv.Value;
qryImpressaoTipo.Value := qryOperTipo.Value;
end; //If
qryOper.Next;
end;
end
else
Begin
while not qryOper.Eof do
Begin
qryImpressao.Append;
qryImpressaoData.Value := qryOperData.Value;
qryImpressaoCdFunc.Value := qryOperCdFunc.Value;
qryImpressaoPortador.Value := qryOperPortador.Value;
qryImpressaoTexto.Value := qryOperTexto.Value;
qryImpressaoNmFunc.Value := qryOperNmFunc.Value;
qryImpressaoDescricao.Value := qryOperDescricao.Value;
qryImpressaoNrcontrLancDiv.Value := qryOperNrcontrLancDiv.Value;
qryImpressaoTipo.Value := qryOperTipo.Value;
qryOper.Next;
end;
end;
frmRelReqLancAvul := TfrmRelReqLancAvul.Create(Self);
frmRelReqLancAvul.qrpReqAvulsa.Preview;
end;


Tremonti

Tremonti

Curtidas 0

Respostas

Beppe

Beppe

09/06/2005

var
  Tudo: Boolean;
...
  Tudo := MessageBox(Handle, ´Imprimir Seleção?!´, ´AVISO!!!´,
    MB_ICONWARNING or MB_YESNO or MB_DEFBUTTON2) <> idYes;
  while not qryOper.Eof do
  Begin
    if Tudo or (ImqryOperimpress.Value = ´X´) then
    Begin
      qryImpressao.Append;
      qryImpressaoData.Value := qryOperData.Value;
      qryImpressaoCdFunc.Value := qryOperCdFunc.Value;
      qryImpressaoPortador.Value := qryOperPortador.Value;
      qryImpressaoTexto.Value := qryOperTexto.Value;
      qryImpressaoNmFunc.Value := qryOperNmFunc.Value;
      qryImpressaoDescricao.Value := qryOperDescricao.Value;
      qryImpressaoNrcontrLancDiv.Value := qryOperNrcontrLancDiv.Value;
      qryImpressaoTipo.Value := qryOperTipo.Value;
      qryOper.Next;
    end; //If
  end;


PS: Use as tags CODE para formatar seu código.


GOSTEI 0
POSTAR