Function

TfrmdlgProb.BadDates

Module

fProbEdt

Last Modified

7/15/2014 3:26:38 PM

Visibility

Public/Published

Owner

TfrmdlgProb

Declaration

function  BadDates:Boolean;

Calls Hierarchy


TfrmdlgProb.BadDates
 ├DateStringOK
 │ ├StripSpace
 │ └StrToFMDateTime
 ├Msg
 ├StrToFMDateTime
 └FMNow

Called-By Hierarchy


     TfrmdlgProb.BadDates
TfrmdlgProb.bbFileClick┘ 

Calls

Name Declaration Comments
DateStringOK Function DateStringOK(ds:string):string; -
FMNow function FMNow: TFMDateTime; -
Msg procedure Msg(msg: string); -
StrToFMDateTime function StrToFMDateTime(const AString: string): TFMDateTime; -

Called-By

Name Declaration Comments
TfrmdlgProb.bbFileClick procedure bbFileClick(Sender: TObject); -


Source

1035  function TfrmdlgProb.BadDates:Boolean;
1036  var
1037    ds:string;
1038    i:integer;
1039  
1040    procedure Msg(msg: string);
1041    begin
1042  // CQ #16123 - Modified error text to clarify proper date formats - JCS
1043      InfoBox('Dates must be in format m/d/yy, m/d/yyyy, m/d, m/yyyy, yyyy, T+d or T-d' +
1044        #13#10 + msg + ' is formatted improperly.' +
1045        #13#10 + '     Please check the other dates as well.',
1046        'Information', MB_OK or MB_ICONINFORMATION);
1047    end;
1048  begin
1049    result:=True;  {initialize for error condition}
1050    if edRecDate.text <>'' then
1051      begin
1052        ds:=DateStringOK(edRecDate.text);
1053        if ds = 'ERROR' then
1054          begin
1055            msg('Recorded');
1056            exit;
1057          end;
1058      end ;
1059    if edResDate.text <>'' then
1060      begin
1061        ds:=DateStringOK(edResDate.text);
1062        if ds = 'ERROR' then
1063          begin
1064            msg('Resolved');
1065            exit;
1066          end;
1067      end ;
1068    if edOnsetDate.text <>'' then
1069      begin
1070        ds:=DateStringOK(edOnsetDate.text);
1071        if ds = 'ERROR' then
1072          begin
1073            msg('Onset');
1074            exit;
1075          end;
1076        if StrToFMDateTime(edOnsetDate.Text) > FMNow then
1077          begin
1078            InfoBox('Onset dates in the future are not allowed.', 'Information', MB_OK or MB_ICONINFORMATION);
1079            Exit;
1080          end;
1081      end ;
1082    for i:=0 to pred(lstComments.Items.Count) do
1083      begin
1084        if Piece(lstComments.Items[i],u,2)<>'' then {may have blank lines at bottom}
1085          begin
1086            ds:=DateStringOK(Piece(lstComments.Items[i],u,1));
1087            if ds='ERROR' then
1088              begin
1089                msg('Comment #' + inttostr(i));
1090                exit;
1091              end;
1092          end;
1093      end;
1094    result:=False;  {made it through, so no bad dates}
1095  end;