From 5eff060af063921b5c2b3c3dd612e2d31821f66f Mon Sep 17 00:00:00 2001 From: michael Date: Sat, 4 Dec 2004 22:43:56 +0000 Subject: [PATCH] - implemented TBCDFields --- fcl/db/fields.inc | 114 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 91 insertions(+), 23 deletions(-) diff --git a/fcl/db/fields.inc b/fcl/db/fields.inc index 7ff7f3508e..9406c8d094 100644 --- a/fcl/db/fields.inc +++ b/fcl/db/fields.inc @@ -924,10 +924,20 @@ end; Function TLongintField.CheckRange(AValue : longint) : Boolean; begin - if FMaxValue=0 Then - Result:=(AValue<=FMaxRange) and (AValue>=FMinRange) + result := true; + if (FMaxValue=0) then + begin + if (AValue>FMaxRange) Then result := false; + end else - Result:=(AValue<=FMaxValue) and (AValue>=FMinValue); + if AValue>FMaxValue then result := false; + + if (FMinValue=0) then + begin + if (AValue 0 then result := precision + else result := 10; end; - procedure TBCDField.GetText(var TheText: string; ADisplayText: Boolean); +var c : system.currency; + begin - //!! To be implemented + If GetData(@C) then + begin + if ADisplayText then + begin + if Displayformat='' then + begin + if Fcurrency then TheText := FloatToStrF(C,ffcurrency,FPrecision,0) + else TheText := FloatToStrF(C,ffgeneral,FPrecision,0); + end + else + TheText := CurrToStr(C); // ToDo: Displayformat is ignored + end + else + begin + if (Displayformat='') and (Editformat='') then + begin + if Fcurrency then TheText := FloatToStrF(C,ffcurrency,FPrecision,0) + else TheText := FloatToStrF(C,ffFixed,FPrecision,0); + end + else + TheText := CurrToStr(C); // ToDo: Displayformat is ignored + end; + end + else + TheText:=''; end; +procedure TBCDField.SetAsCurrency(AValue: Currency); + +begin + If CheckRange(AValue) then + setdata(@AValue) + else + RangeError(AValue,FMinValue,FMaxvalue); +end; + +Function TBCDField.CheckRange(AValue : Currency) : Boolean; + +begin + If (FMinValue<>0) or (FmaxValue<>0) then + Result:=(AValue>=FMinValue) and (AVAlue<=FMaxValue) + else + Result:=True; +end; procedure TBCDField.SetAsFloat(AValue: Double); begin - //!! To be implemented + SetAsCurrency(AValue); end; procedure TBCDField.SetAsLongint(AValue: Longint); begin - //!! To be implemented + SetAsCurrency(AValue); end; procedure TBCDField.SetAsString(const AValue: string); begin - //!! To be implemented + SetAsCurrency(strtocurr(AValue)); end; - constructor TBCDField.Create(AOwner: TComponent); begin - DatabaseError('BCD fields not supported yet. Sorry !'); + Inherited Create(AOwner); + FMaxvalue := 0; + FMinvalue := 0; + SetDataType(ftBCD); + Size:=4; end; - { TBlobField } @@ -1865,7 +1930,10 @@ end; { $Log$ - Revision 1.16 2004-11-30 21:18:34 michael + Revision 1.17 2004-12-04 22:43:56 michael + - implemented TBCDFields + + Revision 1.16 2004/11/30 21:18:34 michael + Fix from Jesus Reyes to fix TfieldDefs.Assign Revision 1.15 2004/08/21 21:10:00 michael