Escrever o valor de campo num application.messagebox
Olá amigos, eu tenho uma tabela de clientes e fiz isso para que quando o programa abra avise se têm alguem de aniversario.
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;
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
Curtidas 0
Melhor post
Marcio.theis
04/11/2005
Outra forma que vc pode fazer é a seguinte:
Acredito que esta funcionando, pois não testei....
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....
GOSTEI 1
Mais Respostas
Adriano Santos
04/11/2005
Jogue isso no seu MessageBox.
dmdados.qryclienterel.FieldByName(´NOME_CAMPO´).AsString
dmdados.qryclienterel.FieldByName(´NOME_CAMPO´).AsString
GOSTEI 1
Adriano Santos
04/11/2005
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);
GOSTEI 0
Marcio.theis
04/11/2005
Acho que vc se anganou, pois antes é validado e não estiver vazia começa passando o texto ´aux:=´O(s) seguinte(s) cliente(s) estão de aniversário hoje:´;´ e depois dentro do while coloca os clientes todos em uma única mensagem, da forma que vc colocou ira fazer com que quando a tabela esteja vazia seja atribuido o valor ´aux:=´O(s) seguinte(s) cliente(s) estão de aniversário hoje:´;´ a variável.
GOSTEI 0
Jorgerock
04/11/2005
Obrigado pela ajuda pessoal, vou testar tudo e se ocorrer algum erro eu posto ai, mas acredito que esta tudo certo!
Valeu , e muito obrigado pela atenção e compartilhamento de conhecimento!
Um forte abraço a todos!
Valeu , e muito obrigado pela atenção e compartilhamento de conhecimento!
Um forte abraço a todos!
GOSTEI 0
Martins
04/11/2005
[quote:091c306e65=´/]/]@t´]Acho que vc se anganou, pois antes é validado e não estiver vazia começa passando o texto ´aux:=´O(s) seguinte(s) cliente(s) estão de aniversário hoje:´;´ e depois dentro do while coloca os clientes todos em uma única mensagem, da forma que vc colocou ira fazer com que quando a tabela esteja vazia seja atribuido o valor ´aux:=´O(s) seguinte(s) cliente(s) estão de aniversário hoje:´;´ a variável.[/quote:091c306e65]Concordo com colega.
Entendi assim, talvez eu tenha feito confusão, estou meio lento hj, precisando de manutenção, hehehe.
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.
GOSTEI 0
Adriano Santos
04/11/2005
Tb tô lento, tô com uma gripe danada...acho que preciso desconectar um pouco...:D
GOSTEI 0
Jorgerock
04/11/2005
Obrigado pessoal! Funcionou perfeito!
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!
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!
GOSTEI 0