From a7d87c1cfa1ad697f2e9efad2830d343cca67ae2 Mon Sep 17 00:00:00 2001 From: jujibo Date: Thu, 15 Mar 2012 10:36:27 +0000 Subject: [PATCH] Extra checks for db null dates git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2341 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/jujiboutils/src/jdbgridutils.pas | 30 ++++++++++++++++----- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/components/jujiboutils/src/jdbgridutils.pas b/components/jujiboutils/src/jdbgridutils.pas index bdb420bd0..2250b7f4f 100644 --- a/components/jujiboutils/src/jdbgridutils.pas +++ b/components/jujiboutils/src/jdbgridutils.pas @@ -320,7 +320,10 @@ begin else begin ShowMessage(Format(SInvalidDateTime, [CellEditor.Caption])); - CellEditor.Text := FormatDateTime(DisplayFormat, Field.AsDateTime); + if Field.IsNull then + CellEditor.Text:= '' + else + CellEditor.Text := FormatDateTime(DisplayFormat, Field.AsDateTime); end; end; @@ -363,7 +366,10 @@ begin (not IsValidDateTimeString(NormalizeDateTime(CellEditor.Caption, theValue))) then begin ShowMessage(Format(SInvalidDateTime, [CellEditor.Caption])); - CellEditor.Text := FormatDateTime(DisplayFormat, theValue); + if Field.IsNull then + CellEditor.Text:= '' + else + CellEditor.Text := FormatDateTime(DisplayFormat, theValue); CellEditor.SelectAll; Key := VK_UNKNOWN; end @@ -499,7 +505,10 @@ begin else begin ShowMessage(Format(SInvalidTime, [CellEditor.Caption])); - CellEditor.Text := FormatDateTime(DisplayFormat, Field.AsDateTime); + if Field.IsNull then + CellEditor.Text:= '' + else + CellEditor.Text := FormatDateTime(DisplayFormat, Field.AsDateTime); end; end; end; @@ -540,7 +549,10 @@ begin (not IsValidTimeString(NormalizeTime(CellEditor.Caption, theValue))) then begin ShowMessage(Format(SInvalidTime, [CellEditor.Caption])); - CellEditor.Text := FormatDateTime(DisplayFormat, theValue); + if Field.IsNull then + CellEditor.Text:= '' + else + CellEditor.Text := FormatDateTime(DisplayFormat, theValue); CellEditor.SelectAll; Key := VK_UNKNOWN; end @@ -676,7 +688,10 @@ begin else begin ShowMessage(Format(SInvalidDate, [CellEditor.Caption])); - CellEditor.Text := FormatDateTime(DisplayFormat, Field.AsDateTime); + if Field.IsNull then + CellEditor.Text:= '' + else + CellEditor.Text := FormatDateTime(DisplayFormat, Field.AsDateTime); end; end; end; @@ -718,7 +733,10 @@ begin (not IsValidDateString(NormalizeDate(CellEditor.Caption, theValue))) then begin ShowMessage(Format(SInvalidDate, [CellEditor.Caption])); - CellEditor.Text := FormatDateTime(DisplayFormat, theValue); + if Field.IsNull then + CellEditor.Text:= '' + else + CellEditor.Text := FormatDateTime(DisplayFormat, theValue); CellEditor.SelectAll; Key := VK_UNKNOWN; end