Added: TJDBLabeledFloatEdit and TJDBLabeledCurrencyEdit null value support

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2847 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
jujibo
2013-11-23 12:47:14 +00:00
parent db4eec3283
commit 60a5a4279b
2 changed files with 20 additions and 4 deletions

View File

@@ -35,6 +35,7 @@ type
fFormat: string;
FDataLink: TFieldDataLink;
fDecimales: integer;
fNull: boolean;
procedure DataChange(Sender: TObject);
function getDecimals: integer;
@@ -81,6 +82,7 @@ type
property DataSource: TDataSource read GetDataSource write SetDataSource;
property Decimals: integer read getDecimals write setDecimals;
property ReadOnly: boolean read GetReadOnly write SetReadOnly default False;
property AllowNull: boolean read fNull write fNull default False;
property Action;
property Align;
@@ -175,6 +177,9 @@ var
begin
if FDataLink.Field <> nil then
begin
if fNull and (Length(Caption) = 0) then
FDataLink.Field.Value := Null
else
if IsValidCurrency(Text) then
begin
theValue := StrToCurr(Text);
@@ -242,6 +247,9 @@ procedure TJDBLabeledCurrencyEdit.formatInput;
begin
if FDataLink.Field <> nil then
//FDataLink.Field.DisplayText -> formatted (tdbgridcolumns/persistent field DisplayFormat
if FDataLink.Field.IsNull then
Caption := ''
else
if fFormat <> '' then
Caption := FormatFloat(fFormat, FDataLink.Field.AsCurrency)
else

View File

@@ -36,6 +36,7 @@ type
fEFormat: string;
FDataLink: TFieldDataLink;
fDecimales: integer;
fNull: boolean;
procedure DataChange(Sender: TObject);
function getDecimals: integer;
@@ -83,6 +84,7 @@ type
property DataSource: TDataSource read GetDataSource write SetDataSource;
property Decimals: integer read getDecimals write setDecimals;
property ReadOnly: boolean read GetReadOnly write SetReadOnly default False;
property AllowNull: boolean read fNull write fNull default False;
property Action;
property Align;
@@ -179,6 +181,9 @@ var
begin
if FDataLink.Field <> nil then
begin
if fNull and (Length(Caption) = 0) then
FDataLink.Field.Value := Null
else
if IsValidFloat(Text) then
begin
theValue := StrToFloat(Text);
@@ -252,6 +257,9 @@ procedure TJDBLabeledFloatEdit.formatInput;
begin
if FDataLink.Field <> nil then
//FDataLink.Field.DisplayText -> formatted (tdbgridcolumns/persistent field DisplayFormat
if FDataLink.Field.IsNull then
Caption := ''
else
if fFormat <> '' then
Caption := FormatFloat(fFormat, FDataLink.Field.AsFloat)
else