Fórum FormatFloat #280698
09/05/2005
0
procedure TFRel.qrpPesquisaBeforePrint(Sender: TCustomQuickRep;
var PrintReport: Boolean);
var
total : double;
begin
qrlTitulo.Caption := ´Pesquisa Organizacional - ´ + FPesquisaOrg.cbFabrica.Text ;
qrl1.Caption := FPesquisaOrg.Frame11.Lb1.Caption;
qrl2.Caption := FPesquisaOrg.Frame11.lb2.Caption;
work.SQL.Text := ´Select count(*) as Contador ´ +
´ from ´ +
´´C:\PesquisaOrg\dbPesquisaOrg.DB´´ +
´ where Q1 = ´ + QuotedStr(´M´) + ´and´ +
´ Fabrica = ´ + QuotedStr(FImpFab.cbFabrica.Text) ;
work.Open;
WORK1.SQL.Text := ´Select Total ´ +
´ from ´ +
´´C:\PesquisaOrg\dbPesquisaOrgTotal.DB´´ +
´ where Fabrica = ´ + QuotedStr(FImpFab.cbFabrica.Text) ;
WORK1.Open;
showmessage(work1.fieldByNAME(´total´).AsString);
total := work.fieldByName(´Contador´).AsInteger / WORK1.fieldByName(´Total´).AsInteger * 100;
showmessage(formatFloat(´#.´, total));
qrl1Masculino.Caption := ´Masculino: ´ + FormatFloat(´.´, total);
Daia
Curtir tópico
+ 0Posts
09/05/2005
Rjun
Gostei + 0
09/05/2005
Daia
Gostei + 0
09/05/2005
Rjun
Gostei + 0
09/05/2005
Daia
Gostei + 0
09/05/2005
Rjun
[b]3 / 2 * 100 = 150[b] Se você quer calcular a porcentagem, então algo esta errado com sua tabela. Veja que o numero do contador teria que ser menor ou igual ao total.
Gostei + 0
09/05/2005
Daia
Gostei + 0
09/05/2005
Rjun
Você tem uma tabela que guarda somente o total de perguntas respondidas ? Não é necessário ter campos que guardam totalizações ja que elas podem ser obtidas através de um SQL.
Gostei + 0
09/05/2005
Daia
´Select count(*) as Total ´ +
´ from ´ +
´´C:\PesquisaOrg\dbPesquisaOrg.DB´´ +
´ where Q1 = ´ + QuotedStr(´M´) + ´or´ +
´ Q1 = ´ + QuotedStr(´F´) + ´or´ +
´ Q1 = ´ + QuotedStr(´ ´) + ´or´ +
´ Fabrica = ´ + QuotedStr(FImpFab.cbFabrica.Text) ;
Gostei + 0
09/05/2005
Rjun
Gostei + 0
09/05/2005
Daia
Por exemplo agora fiz por Filial1, não está dando certo, pois o resultado ficou:
M: 10¬ e Nulo: 10¬, mas na verdade tenho gravado apenas 1 pessoa do sexo M e uma que está em branco, ele deveria fazer M: 50¬ e Nulo: 50¬??
Gostei + 0
09/05/2005
Rjun
Gostei + 0
09/05/2005
Daia
procedure TFRel.qrpPesquisaBeforePrint(Sender: TCustomQuickRep;
var PrintReport: Boolean);
var
total : double;
begin
total:=0;
qrlTitulo.Caption := ´Pesquisa Organizacional - ´ + FImpFab.cbFabrica.Text ;
qrl1.Caption := FPesquisaOrg.Frame11.Lb1.Caption;
qrl2.Caption := FPesquisaOrg.Frame11.lb2.Caption;
//se masculino
work.SQL.Text := ´Select count(*) as Contador ´ +
´ from ´ +
´´C:\PesquisaOrg\dbPesquisaOrg.DB´´ +
´ where Q1 = ´ + QuotedStr(´M´) + ´and´ +
´ Fabrica = ´ + QuotedStr(FImpFab.cbFabrica.Text) ;
work.Open;
WORK1.SQL.Text := ´Select count(*) as Total ´ +
´ from ´ +
´´C:\PesquisaOrg\dbPesquisaOrg.DB´´ +
´ where Fabrica = ´ + QuotedStr(FImpFab.cbFabrica.Text) + ´and´ +
´ Q1 = ´ + QuotedStr(´M´) + ´or´ +
´ Q1 = ´ + QuotedStr(´F´) + ´or´ +
´ Q1 = ´ + QuotedStr(´´);
WORK1.Open;
total := work.fieldByName(´Contador´).AsInteger / WORK1.fieldByName(´Total´).AsInteger * 100;
qrl1Masculino.Caption := ´Masculino: ´ + FormatFloat(´#.´, total) + ´ ¬´;
//se feminino
work.SQL.Text := ´Select count(*) as Contador ´ +
´ from ´ +
´´C:\PesquisaOrg\dbPesquisaOrg.DB´´ +
´ where Q1 = ´ + QuotedStr(´F´) + ´and´ +
´ Fabrica = ´ + QuotedStr(FImpFab.cbFabrica.Text) ;
work.Open;
WORK1.SQL.Text := ´Select count(*) as Total ´ +
´ from ´ +
´´C:\PesquisaOrg\dbPesquisaOrg.DB´´ +
´ where Fabrica = ´ + QuotedStr(FImpFab.cbFabrica.Text) + ´and´ +
´ Q1 = ´ + QuotedStr(´M´) + ´or´ +
´ Q1 = ´ + QuotedStr(´F´) + ´or´ +
´ Q1 = ´ + QuotedStr(´´);
WORK1.Open;
total := work.fieldByName(´Contador´).AsInteger / WORK1.fieldByName(´Total´).AsInteger * 100;
qrl1Feminino.Caption := ´Feminino: ´ + FormatFloat(´#.´, total) + ´ ¬´;
//se nulo
work.SQL.Text := ´Select count(*) as Contador ´ +
´ from ´ +
´´C:\PesquisaOrg\dbPesquisaOrg.DB´´ +
´ where Q1 = ´ + QuotedStr(´´) + ´and´ +
´ Fabrica = ´ + QuotedStr(FImpFab.cbFabrica.Text) ;
work.Open;
WORK1.SQL.Text := ´Select count(*) as Total ´ +
´ from ´ +
´´C:\PesquisaOrg\dbPesquisaOrg.DB´´ +
´ where Fabrica = ´ + QuotedStr(FImpFab.cbFabrica.Text) + ´and´ +
´ Q1 = ´ + QuotedStr(´M´) + ´or´ +
´ Q1 = ´ + QuotedStr(´F´) + ´or´ +
´ Q1 = ´ + QuotedStr(´´);
WORK1.Open;
total := work.fieldByName(´Contador´).AsInteger / WORK1.fieldByName(´Total´).AsInteger * 100;
qrl1Nulo.Caption := ´Nulo: ´ + FormatFloat(´#.´, total) + ´ ¬´;
Gostei + 0
09/05/2005
Rjun
procedure TFRel.qrpPesquisaBeforePrint(Sender: TCustomQuickRep; var PrintReport: Boolean);
var
total : double;
begin
total:=0;
qrlTitulo.Caption := ´Pesquisa Organizacional - ´ + FImpFab.cbFabrica.Text ;
qrl1.Caption := FPesquisaOrg.Frame11.Lb1.Caption;
qrl2.Caption := FPesquisaOrg.Frame11.lb2.Caption;
//se masculino
work.SQL.Text := ´Select count(*) as Contador from "C:\PesquisaOrg\dbPesquisaOrg.DB" where Q1 = ´´M´´ and Fabrica = :Fab´;
work.ParamByName(´Fab´).Value := FImpFab.cbFabrica.Text;
work.Open;
work1.SQL.Text := ´Select count(*) as Total from "C:\PesquisaOrg\dbPesquisaOrg.DB" where Fabrica = :Fab´;
work1.ParamByName(´Fab´).Value := FImpFab.cbFabrica.Text;
work1.Open;
total := work.fieldByName(´Contador´).AsInteger / work1.fieldByName(´Total´).AsInteger * 100;
qrl1Masculino.Caption := ´Masculino: ´ + FormatFloat(´#.´, total) + ´ ¬´;
{Coloque aqui o restante do código}
end;
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)