From 0f3f32ed94c63ddac9d445664ba469afe08e84e8 Mon Sep 17 00:00:00 2001 From: jujibo Date: Mon, 19 Sep 2011 11:59:02 +0000 Subject: [PATCH] Sanity checks git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1970 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../jujibo-utils/src/jdbcurrencyedit.pas | 44 ++++++++++++------- .../jujibo-utils/src/jdbdateedit.pas | 10 ++++- .../jujibo-utils/src/jdbintegeredit.pas | 15 +++++-- 3 files changed, 46 insertions(+), 23 deletions(-) diff --git a/components/jujiboutils/jujibo-utils/src/jdbcurrencyedit.pas b/components/jujiboutils/jujibo-utils/src/jdbcurrencyedit.pas index f9e6f0267..1c29fe69e 100644 --- a/components/jujiboutils/jujibo-utils/src/jdbcurrencyedit.pas +++ b/components/jujiboutils/jujibo-utils/src/jdbcurrencyedit.pas @@ -135,10 +135,15 @@ end; procedure TJDBCurrencyEdit.DataChange(Sender: TObject); begin - if not Focused then - formatInput + if FDataLink.Field <> nil then + begin + if not Focused then + formatInput + else + Caption := FDataLink.Field.AsString; + end else - Caption := FDataLink.Field.AsString; + Text := ''; end; function TJDBCurrencyEdit.getDecimals: integer; @@ -157,23 +162,28 @@ procedure TJDBCurrencyEdit.UpdateData(Sender: TObject); var theValue: currency; begin - if IsValidCurrency(Text) then + if FDataLink.Field <> nil then begin - theValue := StrToCurr(Text); - theValue := ScaleTo(theValue, fDecimales); - Text := CurrToStr(theValue); - FDataLink.Field.Text := Text; + if IsValidCurrency(Text) then + begin + theValue := StrToCurr(Text); + theValue := ScaleTo(theValue, fDecimales); + Text := CurrToStr(theValue); + FDataLink.Field.Text := Text; + end + else + begin + if FDataLink.Field <> nil then + begin + ShowMessage(Caption + ' no es un valor válido'); + Caption := FDataLink.Field.AsString; + SelectAll; + SetFocus; + end; + end; end else - begin - if FDataLink.Field <> nil then - begin - ShowMessage(Caption + ' no es un valor válido'); - Caption := FDataLink.Field.AsString; - SelectAll; - SetFocus; - end; - end; + Text := ''; end; procedure TJDBCurrencyEdit.FocusRequest(Sender: TObject); diff --git a/components/jujiboutils/jujibo-utils/src/jdbdateedit.pas b/components/jujiboutils/jujibo-utils/src/jdbdateedit.pas index f4709227b..21e8fc80c 100644 --- a/components/jujiboutils/jujibo-utils/src/jdbdateedit.pas +++ b/components/jujiboutils/jujibo-utils/src/jdbdateedit.pas @@ -130,10 +130,15 @@ end; procedure TJDBDateEdit.DataChange(Sender: TObject); begin + if FDataLink.Field <> nil then + begin if not Focused then formatInput else Caption := FDataLink.Field.AsString; + end + else + Text := ''; end; procedure TJDBDateEdit.UpdateData(Sender: TObject); @@ -157,8 +162,9 @@ begin SelectAll; SetFocus; end; - - end; + end + else + Text := ''; end; procedure TJDBDateEdit.FocusRequest(Sender: TObject); diff --git a/components/jujiboutils/jujibo-utils/src/jdbintegeredit.pas b/components/jujiboutils/jujibo-utils/src/jdbintegeredit.pas index db2dbbfe4..55b9d43d3 100644 --- a/components/jujiboutils/jujibo-utils/src/jdbintegeredit.pas +++ b/components/jujiboutils/jujibo-utils/src/jdbintegeredit.pas @@ -128,10 +128,15 @@ end; procedure TJDBIntegerEdit.DataChange(Sender: TObject); begin - if not Focused then - formatInput + if FDataLink.Field <> nil then + begin + if not Focused then + formatInput + else + Caption := FDataLink.Field.AsString; + end else - Caption := FDataLink.Field.AsString; + Text := ''; end; @@ -148,7 +153,9 @@ begin SelectAll; SetFocus; end; - end; + end + else + Text := ''; end; procedure TJDBIntegerEdit.FocusRequest(Sender: TObject);