Aggregates e Displayformat - Solução

24/03/2006

0

Tive muitos problemas com aggregates e formatação de saída

Uma solução para a formatação de campos aggregados no clientdataset....existe um bug q mesmo q vc coloque qquer mascara, currency=true, o campo nao formata nem a bala, entao o bug está na unit db.pas

segue rotina e solucao do problema

procedure TAggregateField.GetText(var Text: string; DisplayText: Boolean);
var
  Format: TFloatFormat;
  FmtStr: string;
  Digits: Integer;
  V: Variant;
begin
  Text := ´´;
  V := Dataset.GetAggregateValue(Self);
  if VarIsNull(V) then
    Exit;
//antes era assim*******************************************
  if FResultType in [ftFloat, ftCurrency] then antes da mudanca a funcao nao testava se existia em Fresulttype o tipo ftFMTBcd portanto //saia la no final do if sem qquer mascara, coloquei o tipo ftFMTBcd e funcionou corretamente
//*****************************************************
  if FResultType in [ftFloat, ftCurrency, ftFMTBcd] then
  begin
    if DisplayText then
      FmtStr := FDisplayFormat;
    if FmtStr = ´´ then
    begin
      if FCurrency then
      begin
        if DisplayText then Format := ffCurrency else Format := ffFixed;
        Digits := CurrencyDecimals;
      end
      else begin
        Format := ffGeneral;
        Digits := 0;
      end;
      Text := FloatToStrF(V, Format, FPrecision, Digits);
    end else
      Text := FormatFloat(FmtStr, V);
  end else if FResultType in [ftDate, ftTime, ftDatetime] then
  begin
    if DisplayText and (FDisplayFormat <> ´´) then
      FmtStr := FDisplayFormat
    else
      case DataType of
        ftDate: FmtStr := ShortDateFormat;
        ftTime: FmtStr := LongTimeFormat;
      end;
    DateTimeToString(Text, FmtStr, V);
  end else
    Text := VarToStr(V);
end;



é isso


Ederson Selvati


Eselvati

Eselvati

Responder

Posts

24/03/2006

Sremulador

qual a versão do Delphi ?


Responder

24/03/2006

Eselvati

Delphi 7.0 e 7.1 e acredito que em versões posteriores tb, nao testei no D6.





Ederson


Responder

Assista grátis a nossa aula inaugural

Assitir aula

Saiba por que programar é uma questão de
sobrevivência e como aprender sem riscos

Assistir agora

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar