SmartDate confusion

SmartDate confusion

Old forum URL: forums.lhotka.net/forums/t/6828.aspx


thaehn posted on Tuesday, April 21, 2009

I have two properties, StartedProperty and EndedProperty that are both dates.  They both have the same value {4/21/2009}.  When I check if StartedProperty is greater than EndedProperty it return true; when I check if StartedProperty is less than EndedProperty it returns false.  If I check if StartedProperty equals EndedProperty it return false.  It apprears that the value read from the database has a time portion (populated somewhere else), while the value supplied by the textbox (WPF Toolkit DatePicker) returns a string with just the date, which leaves the time at midnight.  Is there a way to tell SmartDate to only compare the date portion?  Here is the code:

if (target.ReadProperty(StartedProperty) > target.ReadProperty(EndedProperty))

{

      e.Description = "Start date can't be after end date";

      return false;

}

else

{

      return true;

}

Todd

rfcdejong replied on Tuesday, April 21, 2009

Didn't u place the code in your business object where u can access the smartdate propertyInfo? U shouldn't do the validation on the string properties.

thaehn replied on Tuesday, April 21, 2009

Sorry...this code is from the business rule.  the StartedProperty and EndedProperty are both SmartDate.

Todd

Copyright (c) Marimer LLC