View Issue Details

IDProjectCategoryView StatusLast Update
0001335JEDI VCL00 JVCL Componentspublic2004-03-09 02:47
ReporterxerkanAssigned Toogiesen 
PrioritynormalSeverityfeatureReproducibilityN/A
Status closedResolutionfixed 
Product Version 
Target VersionFixed in Version 
Summary0001335: date null in TjvDBDatePickerEdit
DescriptionIf the date in a TjbDBDatePickerEdit has resigned selecting it and giving to him to suppress, it remains his maskedit " / / " and does not allow to advance, it might be possible that if it has resigned when it tries to pass to the following field it leaves the date as null
Additional InformationSi la fecha en un TjbDBDatePickerEdit se ha borrado seleccionandola y dandole a suprimir, se queda su maskedit " / / " y no deja avanzar, podria ser posible que si se ha borrado cuando se intente pasar al siguiente campo deje la fecha como nula
TagsNo tags attached.

Activities

user72

2004-02-17 05:33

  ~0002959

What would you suggest as an alternative?

xerkan

2004-02-17 09:13

reporter   ~0002963

Last edited: 2004-02-17 09:19

I have done a test and more or less this is what he wanted (the test has one date format of dd/MM/yyyy)

I change in the source jvDatePickerEdit

function TJvCustomDatePickerEdit.AttemptTextToDate(const AText: string;
  var ADate: TDateTime; const AForce: Boolean; const ARaise: Boolean): Boolean;
var
  lFormatBup: string;
  lDate: TDateTime;
  lDummy: Integer;
begin
  Result := Validate(AText, lDummy);
  {only attempt to convert, if at least the Mask is matched
     - otherwise we'd be swamped by exceptions during input}
  if Result or AForce then
  begin
     lDate := ADate;
     lFormatBup := ShortDateFormat;
     try
        ShortDateFormat := Self.DateFormat;
        try
          if Trim(AText)='/ /' then
             ADate:=0
          else
             ADate := StrToDate(AText);
          Result := True;
        except
          Result := False;
          if (ARaise) then
             raise
          else
             ADate := lDate;
        end;
     finally
        ShortDateFormat := lFormatBup;
     end;
  end;
end;

the important thing is the line that it puts:

if Trim(AText)='/ /' then
 ADate:=0
else
 ADate := StrToDate(AText);

pd: in the quotation marks of the if between the bars there two spaces

editada el: 02-17-04 09:19

user72

2004-02-17 09:57

  ~0002965

Shouldn't that be:

if AnsiSameText(AText, EditMask) then
...

otherwise the code will fail if the mask ever changes...

user72

2004-02-17 12:22

  ~0002969

I've committed a version with your suggested changes but with the "if AnsiSameText(AText, EditMask) then" test instead. If that isn't what you're looking for, let me know ASAP since the JVCL3 beta will be released soon.

ogiesen

2004-02-18 01:40

developer   ~0002970

Peter, your fix is utterly broken. By renaming the local vars, you redeclared the ADate identifier which is already the name of a parameter to the function. I know my "l"-prefix for local vars is non-standard but isn't there a guideline that says "A"-prefixes should only be used for arguments?

I have to admit though that I haven't fully grasped the nature of the reported problem itself yet. I have severe problems understanding Xerkan's English and I don't speak Spanish/Portuguese either. Could maybe someone paraphrase?

I'm looking into this right now and will post a complete fix ASAP.

xerkan

2004-02-18 01:51

reporter   ~0002971

my English is very bad, and I have to translate some things with a translator :(

what I want is that when one erases a date selecting it and he giving to suppress, when it goes out it gives an error of conversion, which I would like is that it was putting itself on 0 (as when you pulsate alt+del)

ogiesen

2004-02-18 03:18

developer   ~0002972

OK, I think I got it now. I performed some tests and it seems this simple fix would only apply to controls where AllowNoDate = True and I do think that it makes sense there. For AllowNoDate = False however the fix makes things worse as you suddenly get three error messages instead of one: "[ControlName] must have a date!", then "Invalid input value. Use escape key to abandon changes." and once more "[ControlName] must have a date!".

I don't really think it makes sense to set AllowNoDate = False and nevertheless let the user leave the control empty, so I will check in a fix that will enable the new behaviour only when AllowNoDate = True. OK?

I have also made a change to support all date formats. Checking against EditMask makes no sense as EditMask is something like "!00/00/9900;1;_" which is unlikely ever to appear as text. Instead I store the text of the control right after applying the EditMask to an empty text in a variable and use that compare to. I'd like to declare this variable protected as it might be of potential use to descendants but this would violate the current code freeze if I understood correctly. Peter?

ogiesen

2004-02-18 04:45

developer   ~0002973

OK, I have now checked in the complete fix (even though Olivier beat me to committing the compile fix ;) ). I left the empty mask check declared private for now to comply with the code freeze in any case. I have to go on with other things now so I couldn't wait... feel free to redeclare the IsEmptyMaskText function as protected if you think it's safe (I do).

Issue History

Date Modified Username Field Change
2004-02-16 23:48 xerkan New Issue
2004-02-17 05:33 user72 Note Added: 0002959
2004-02-17 05:33 user72 Status new => assigned
2004-02-17 05:33 user72 Assigned To => user72
2004-02-17 05:33 user72 Status assigned => feedback
2004-02-17 09:13 xerkan Note Added: 0002963
2004-02-17 09:19 xerkan Note Edited: 0002963
2004-02-17 09:57 user72 Note Added: 0002965
2004-02-17 12:22 user72 Note Added: 0002969
2004-02-18 01:40 ogiesen Note Added: 0002970
2004-02-18 01:40 ogiesen Status feedback => assigned
2004-02-18 01:40 ogiesen Assigned To user72 => ogiesen
2004-02-18 01:51 xerkan Note Added: 0002971
2004-02-18 03:18 ogiesen Note Added: 0002972
2004-02-18 03:24 ogiesen Status assigned => feedback
2004-02-18 03:24 ogiesen ETA none => < 1 day
2004-02-18 03:24 ogiesen Summary date null in TjbDBDatePickerEdit => date null in TjvDBDatePickerEdit
2004-02-18 04:45 ogiesen Note Added: 0002973
2004-02-18 04:45 ogiesen Status feedback => resolved
2004-02-18 04:45 ogiesen Resolution open => fixed
2004-03-09 02:47 user72 Status resolved => closed