Escrever o valor de campo num application.messagebox
04/11/2005
0
A duvida é a seguinte, aqui eu coloquei num edit o nome do cliente, e copio ele para o showmessage, gostaria de não ter que fazer isso, apenas copiar o valor do campo da query para o application.messagebox.
É possivel fazer isso?
Se alguem tiver uma dica, eu agradeço!
Muito obrigado pela atenção!
Abaixo segue oque eu faço!
dmdados.qryclienterel.SQL.Clear;
dmdados.qryclienterel.SQL.Add(´select * from CLIENTE´);
dmdados.qryclienterel.SQL.Add(´where EXTRACT( DAY from DATANASCIMENTO ) = :dia´);
dmdados.qryclienterel.SQL.Add(´and EXTRACT( MONTH from DATANASCIMENTO ) = :mes´);
dmdados.qryclienterel.SQL.Add(´order by NOMECLIENTE´);
dmdados.qryclienterel.ParamByName(´dia´).AsInteger:= DayOf(date);
dmdados.qryclienterel.ParamByName(´mes´).AsInteger:= MonthOf(date);
dmdados.qryclienterel.Prepared:= True;
dmdados.qryclienterel.Open;
While not dmdados.qryclienterel.Eof do
begin
begin
showmessage(´O cliente ´ + dbedit1.text +´ está de aniversário hoje´);
MessageBeep(0);
end;
dmdados.qryclienterel.Next;
end;
Jorgerock
Post mais votado
04/11/2005
var aux: string; begin aux:=´´; dmdados.qryclienterel.SQL.Clear; dmdados.qryclienterel.SQL.Add(´select * from CLIENTE´); dmdados.qryclienterel.SQL.Add(´where EXTRACT( DAY from DATANASCIMENTO ) = :dia´); dmdados.qryclienterel.SQL.Add(´and EXTRACT( MONTH from DATANASCIMENTO ) = :mes´); dmdados.qryclienterel.SQL.Add(´order by NOMECLIENTE´); dmdados.qryclienterel.ParamByName(´dia´).AsInteger:= DayOf(date); dmdados.qryclienterel.ParamByName(´mes´).AsInteger:= MonthOf(date); dmdados.qryclienterel.Prepared:= True; dmdados.qryclienterel.Open; if not dmdados.qryclienterel.IsEmpty then begin aux:=´O(s) seguinte(s) cliente(s) estão de aniversário hoje:´; while not dmdados.qryclienterel.Eof do begin aux:=aux + #13 + dmdados.qryclienterel.FieldByName(´NOME_CAMPO´).AsString; dmdados.qryclienterel.Next; end; end; if aux <> ´´ then Application.MessageBox(PChar(aux),´Aniversariante(s)´,MB_OK or MB_APPLMODAL or MB_ICONINFORMATION);
Acredito que esta funcionando, pois não testei....
Marcio.theis
Mais Posts
04/11/2005
Adriano Santos
dmdados.qryclienterel.FieldByName(´NOME_CAMPO´).AsString
04/11/2005
Adriano Santos
if not dmdados.qryclienterel.IsEmpty then begin aux:=´O(s) seguinte(s) cliente(s) estão de aniversário hoje:´; while not dmdados.qryclienterel.Eof do begin aux:=aux + #13 + dmdados.qryclienterel.FieldByName(´NOME_CAMPO´).AsString; dmdados.qryclienterel.Next; end; end; if aux <> ´´ then Application.MessageBox(PChar(aux),´Aniversariante(s)´,MB_OK or MB_APPLMODAL or MB_ICONINFORMATION);
Só que tem erro. Do jeito que está se a tabela não estiver vazia ele vai atribuir o texto ´O(s) seguinte(s) cliente(s) estão de aniversário hoje:´; + o texto que é montado dentro do while.
Vamos melhorar:
if not dmdados.qryclienterel.IsEmpty then begin while not dmdados.qryclienterel.Eof do begin aux:=aux + 13 + dmdados.qryclienterel.FieldByName(´NOME_CAMPO´).AsString; dmdados.qryclienterel.Next; end; end else aux:=´O(s) seguinte(s) cliente(s) estão de aniversário hoje:´; Application.MessageBox(PChar(aux),´Aniversariante(s)´,MB_OK or MB_APPLMODAL or MB_ICONINFORMATION);
04/11/2005
Marcio.theis
04/11/2005
Jorgerock
Valeu , e muito obrigado pela atenção e compartilhamento de conhecimento!
Um forte abraço a todos!
04/11/2005
Martins
if not dmdados.qryclienterel.IsEmpty then //Se não estiver vazia begin aux:=´O(s) seguinte(s) cliente(s) estão de aniversário hoje:´; while not dmdados.qryclienterel.Eof do //Enquanto não chegar ao fim begin aux:=aux + #13 + dmdados.qryclienterel.FieldByName (´NOME_CAMPO´).AsString; //Aux vai acumulando os nomes dos clientes. dmdados.qryclienterel.Next; end; end; if aux <> ´´ then //Se aux não estiver vazio Application.MessageBox(PChar(aux),´Aniversariante(s)´,MB_OK or MB_APPLMODAL or MB_ICONINFORMATION);
Entendi assim, talvez eu tenha feito confusão, estou meio lento hj, precisando de manutenção, hehehe.
04/11/2005
Adriano Santos
04/11/2005
Jorgerock
Como eu sei pouco, fiz algo meio que remendado antes, mas agora ficou legal.
Mas agora tá tudo redondinho!
Precisando de alguma coisa, se eu puder ajudar podem contar comigo!
Um forte abraço a todos!
Clique aqui para fazer login e interagir na Comunidade :)