From d9914d4650b485eee139cfe7e5e3096ff368bf3d Mon Sep 17 00:00:00 2001 From: jujibo Date: Sun, 9 May 2021 08:22:00 +0000 Subject: [PATCH] Fix fmtBCD data type git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8009 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/jujiboutils/src/jdbgridutils.pas | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/components/jujiboutils/src/jdbgridutils.pas b/components/jujiboutils/src/jdbgridutils.pas index 2c90c88fb..981806b63 100644 --- a/components/jujiboutils/src/jdbgridutils.pas +++ b/components/jujiboutils/src/jdbgridutils.pas @@ -199,7 +199,7 @@ type implementation uses - Math, dateutils; + Math, FMTBcd, dateutils; { TJDbGridStringCtrl } @@ -1015,7 +1015,11 @@ begin Field.DataSet.Edit; if decimals > 0 then theValue := ScaleTo(theValue, fDecimals); - Field.Value := theValue; + if Field.FieldDef.DataType = ftFMTBcd then + Field.AsBCD := StrToBCD(FormatFloat('0.' + + StringOfChar('0', Decimals), theValue)) + else + Field.Value := theValue; Field.DataSet.EnableControls; updated := True; end; @@ -1083,7 +1087,10 @@ begin Field.DataSet.Edit; if decimals > 0 then theValue := ScaleTo(theValue, fDecimals); - Field.Value := theValue; + if Field.FieldDef.DataType = ftFMTBcd then + Field.AsBCD := StrToBCD(FormatFloat('0.' + StringOfChar('0', Decimals), theValue)) + else + Field.Value := theValue; CellEditor.Text := Field.AsString; updated := True; end;