QuickReport imprimir um valor dependedo de uma condição
Tenho um aplicativo de banco de dados feito em delphi, gostaria de saber, como um valor que está em qrlabel(quickReport) mudar dependendo do que esteja inserido em um determinado campo de uma tabela?
Ex. se campo1 = semestral, qrlabel1 = 30,00
se campo1 = anual, qrlabel1 = 50,00
se campo1 = outros, qrlabel1 = 60,00
Grato, Adriano
Ex. se campo1 = semestral, qrlabel1 = 30,00
se campo1 = anual, qrlabel1 = 50,00
se campo1 = outros, qrlabel1 = 60,00
Grato, Adriano
Xadriano
Curtidas 0
Respostas
Zottis
24/07/2004
Você pode usar o evento onpreview ou ao chamar o form.
Ex:
procedure TFrmBaixas.BitBtn1Click(Sender: TObject);
const
Periodo = ´De ´´¬s´´ Até ´´¬s´´´;
begin
//ImprimirCtasvencidas é o form a ser impresso.
Application.CreateForm(TImprimirCtasvencidas,ImprimirCtasvencidas);
if RadioGroup1.ItemIndex = 0 then
begin
ImprimirCtasvencidas.QRlabel3.caption:=´Todos(Pagas e Abertas)´;
end;
if RadioGroup1.ItemIndex = 1 then
begin
ImprimirCtasvencidas.QRlabel3.caption:=´Liquidadas´;
end;
if RadioGroup1.ItemIndex = 2 then
begin
ImprimirCtasvencidas.QRlabel3.caption:=´Não Pagas´;
end;
ImprimirCtasvencidas.Periodolabel.caption :=
Format(Periodo, [DateToStr(Data1.date), DateToStr(Data2.date)]);
ImprimirCtasvencidas.Preview;
ImprimirCtasvencidas.free;
end;
espero que te ajude.
Ex:
procedure TFrmBaixas.BitBtn1Click(Sender: TObject);
const
Periodo = ´De ´´¬s´´ Até ´´¬s´´´;
begin
//ImprimirCtasvencidas é o form a ser impresso.
Application.CreateForm(TImprimirCtasvencidas,ImprimirCtasvencidas);
if RadioGroup1.ItemIndex = 0 then
begin
ImprimirCtasvencidas.QRlabel3.caption:=´Todos(Pagas e Abertas)´;
end;
if RadioGroup1.ItemIndex = 1 then
begin
ImprimirCtasvencidas.QRlabel3.caption:=´Liquidadas´;
end;
if RadioGroup1.ItemIndex = 2 then
begin
ImprimirCtasvencidas.QRlabel3.caption:=´Não Pagas´;
end;
ImprimirCtasvencidas.Periodolabel.caption :=
Format(Periodo, [DateToStr(Data1.date), DateToStr(Data2.date)]);
ImprimirCtasvencidas.Preview;
ImprimirCtasvencidas.free;
end;
espero que te ajude.
GOSTEI 0
Xadriano
24/07/2004
o que estou querendo é seguinte:
Se o aluno for do curso anual valor do qrlabel = 30,00
Se o aluno for do curso semestral valor do qrlabel = 50,00
se for de outro curso qr label = 60,00
Ficarei muito grato se puderes me ajudar,
Adriano
Se o aluno for do curso anual valor do qrlabel = 30,00
Se o aluno for do curso semestral valor do qrlabel = 50,00
se for de outro curso qr label = 60,00
Ficarei muito grato se puderes me ajudar,
Adriano
GOSTEI 0
Zottis
24/07/2004
a sintese é essa que te passei
é só passar a condição e jogar no QRlabel.
if Se o alunoCurso.value = ´anual´ then
begin
FormImpressao.QRlabel3.caption:=´R$30,00´;
end else
if Se o alunoCurso.value = ´semestral´ then
begin
FormImpressao.QRlabel3.caption:=´R$50,00´;
end else
if Se o alunoCurso.value = ´Outro´ then
begin
FormImpressao.QRlabel3.caption:=´R$60,00´;
end;
é só passar a condição e jogar no QRlabel.
if Se o alunoCurso.value = ´anual´ then
begin
FormImpressao.QRlabel3.caption:=´R$30,00´;
end else
if Se o alunoCurso.value = ´semestral´ then
begin
FormImpressao.QRlabel3.caption:=´R$50,00´;
end else
if Se o alunoCurso.value = ´Outro´ then
begin
FormImpressao.QRlabel3.caption:=´R$60,00´;
end;
GOSTEI 0
Xadriano
24/07/2004
zottis
eu fiz desta maneira no evento onpreview:
procedure TFrmPrint.QuickRep1Preview(Sender: TObject);
begin
if Datamodule2.ADOQueryGeralCURSO.Value = ´Anual´ then
begin
Qrlabel137.Caption:=´R$ 30,00´;
End else
if Datamodule2.ADOQueryGeralCURSO.Value = ´Semestral´ then
begin
qrlabel137.Caption:=´R$ 50,00´;
End Else
if Datamodule2.ADOQueryGeralCURSO.Value = ´E.J.A´ then
Begin
qrlabel137.Caption:=´R$ 50,00´
So que compila mas não abre, onde estou errando?
eu fiz desta maneira no evento onpreview:
procedure TFrmPrint.QuickRep1Preview(Sender: TObject);
begin
if Datamodule2.ADOQueryGeralCURSO.Value = ´Anual´ then
begin
Qrlabel137.Caption:=´R$ 30,00´;
End else
if Datamodule2.ADOQueryGeralCURSO.Value = ´Semestral´ then
begin
qrlabel137.Caption:=´R$ 50,00´;
End Else
if Datamodule2.ADOQueryGeralCURSO.Value = ´E.J.A´ then
Begin
qrlabel137.Caption:=´R$ 50,00´
So que compila mas não abre, onde estou errando?
GOSTEI 0
Ariovaldo
24/07/2004
Olha essa situação eu controlo com campo calculado, com certeza este relatório é resultado de uma query, pois bem nesta query no fields editor vc coloca um campo calculado por Ex. Calc_ValorMensal e no evento calcFields da query vc coloca o bloco de comando
if Datamodule2.ADOQueryGeralCURSO.Value = ´Anual´ then
begin
Qrlabel137.Caption:=´R$ 30,00´;
End else
||
Espero ter ajudado
if Datamodule2.ADOQueryGeralCURSO.Value = ´Anual´ then
begin
Qrlabel137.Caption:=´R$ 30,00´;
End else
||
Espero ter ajudado
GOSTEI 0
Zottis
24/07/2004
se você não quer usar as condições na chamada do formulário, tente usar isso:
procedure TImprime.QuickRepBeforePrint(
Sender: TCustomQuickRep; var PrintReport: Boolean);
begin
Sender.AllDataSets.Add(Datamodule2.ADOQueryGeral);
end;
mas tente usar a 1ª opcão que te passei, para mim funciona redondinho.
ou tente no evento startpage.
procedure TQuickReport1.QuickRepStartPage(Sender: TCustomQuickRep);
begin
if Datamodule2.ADOQueryGeralCURSO.Value = ´Anual´ then
begin
Qrlabel137.Caption:=´R$ 30,00´;
End else
if Datamodule2.ADOQueryGeralCURSO.Value = ´Semestral´ then
begin
qrlabel137.Caption:=´R$ 50,00´;
End Else
if Datamodule2.ADOQueryGeralCURSO.Value = ´E.J.A´ then
Begin
qrlabel137.Caption:=´R$ 50,00´
end;
procedure TImprime.QuickRepBeforePrint(
Sender: TCustomQuickRep; var PrintReport: Boolean);
begin
Sender.AllDataSets.Add(Datamodule2.ADOQueryGeral);
end;
mas tente usar a 1ª opcão que te passei, para mim funciona redondinho.
ou tente no evento startpage.
procedure TQuickReport1.QuickRepStartPage(Sender: TCustomQuickRep);
begin
if Datamodule2.ADOQueryGeralCURSO.Value = ´Anual´ then
begin
Qrlabel137.Caption:=´R$ 30,00´;
End else
if Datamodule2.ADOQueryGeralCURSO.Value = ´Semestral´ then
begin
qrlabel137.Caption:=´R$ 50,00´;
End Else
if Datamodule2.ADOQueryGeralCURSO.Value = ´E.J.A´ then
Begin
qrlabel137.Caption:=´R$ 50,00´
end;
GOSTEI 0
Xadriano
24/07/2004
Valeu zottis, eu usei a rotina do onstartpage deu certinho, fico te devendo essa :lol:
Adriano
Adriano
GOSTEI 0
Zottis
24/07/2004
se precisar...
www.zottis.com.br estou começando e em breve será outro site mais incrementado para a programação delphi.
zottis@zottis.com.br
suporte@zottis.com.br
www.zottis.com.br estou começando e em breve será outro site mais incrementado para a programação delphi.
zottis@zottis.com.br
suporte@zottis.com.br
GOSTEI 0