StrataFrame Forum
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      



DateTime field not accepting timeExpand / Collapse
Author
Message
Posted 02/21/2008 9:17:52 AM


StrataFrame Beginner

StrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame Beginner

Group: StrataFrame Users
Last Login: 2 days ago @ 11:48:33 AM
Posts: 23, Visits: 129
We've created a scheduling application that stores a scheduled begin time and end time in the database. Both are System.DateTime values in .NET and datetime values in the database.

When updating the values, everything gets updated fine until I get to the begin time. If I set the value, the business object loses it's index and updates a different record with the correct date, but a midnight time.

For example, if StartTime is '2/25/2008 8:30 AM' and EndTime is '2/25/2008 2:00 PM' then after this:

if (CurrentScheduleDetailBO.NavigateToPrimaryKey(e.ScheduledEmployee.ScheduleDetailId, e.ScheduledEmployee.ScheduleId))

{
if (CurrentScheduledEmployeeBO.NavigateToPrimaryKey(e.ScheduledEmployee.EmployeeNumber, e.ScheduledEmployee.ScheduleId))
{

CurrentScheduleDetailBO.BeginMoment = startTime;
CurrentScheduleDetailBO.EndTime = endTime ;

// alternately, this does the same thing.
Runtime.
Static.CurrentScheduleDetailBO.CurrentRow["BeginMoment"] = startTime;
Runtime.
Static.CurrentScheduleDetailBO.CurrentRow["EndMoment"] = endTime ;

BeginMoment is '8/25/2008 12:00 AM' and the EndMoment is correct at '8/25/2008 2:00 PM'.

There are no triggers in the underlying datastore, nor are there any business rules that I can tell. EndMoment and every other datetime field I set is doing correctly. It's just the BeginMoment that is causing the problem.

____________________
Programmer/Analyst
Captain D's, LLC

Post #14482
Posted 02/21/2008 9:28:08 AM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Today @ 2:43:51 PM
Posts: 4,241, Visits: 4,285
We too have a scheduling application in our medical product as well as dates, and the one thing that I am VERY confident of is the fact that we do not change the time within the BO at any point.  There are only two places in the framework that we adjust the time portion of a DateTime:

  1. If binding to a DateTImePicker, there is a property called StripTimeFromValue, which by default is True.  So if you have this property set, it will set the time to midnight. 
  2. When searching within the BrowseDialog, we now have a Date tab that allows you to control the time of the browse DateTime control for a DateTime field.  You can leave the time alone, set the time to midnight, or the end of the day....but this is not way changes any underlying values...it is just for searching purposes

These are the ONLY two places in the framework that we adjust the time portion of a DateTime value.  So if I was to guess on this one, I would think that you are using an SF DateTimePicker control and have the StripTimeFromValue property set to True.

Post #14485
Posted 02/21/2008 9:31:10 AM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Today @ 2:43:51 PM
Posts: 4,241, Visits: 4,285
One other thought on this too...if there were something in the framework actually stripping the time past what I mentioned in my previous post, I KNOW for a fact that this would be coming up from everyplace....and this is the first time I have ever heard of this.
Post #14486
Posted 02/21/2008 9:36:48 AM


StrataFrame Beginner

StrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame Beginner

Group: StrataFrame Users
Last Login: 2 days ago @ 11:48:33 AM
Posts: 23, Visits: 129
The BO is not bound to any controls. The value is set in code, just as in the above snippet.

As soon as I set the BeginTime, it changes the time part to midnight and then the currentindex moves.

For example, this is actual code...nothing hidden lines or tricks between them:

Console.WriteLine(Runtime.Static.CurrentScheduleDetailBO.ScheduleDetailID.ToString());
Runtime.
Static.CurrentScheduleDetailBO.BeginMoment = scheduledEmployee.ClockTime.StartTime;
Runtime.
Static.CurrentScheduleDetailBO.EndMoment = scheduledEmployee.ClockTime.EndTime;
Console.WriteLine(Runtime.Static.CurrentScheduleDetailBO.ScheduleDetailID.ToString());

That ScheduleDetailID is different the second time it writes that value to the console, it is different.



____________________
Programmer/Analyst
Captain D's, LLC

Post #14487
Posted 02/21/2008 9:37:57 AM


StrataFrame Beginner

StrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame Beginner

Group: StrataFrame Users
Last Login: 2 days ago @ 11:48:33 AM
Posts: 23, Visits: 129
I've tried to step into, but those lines run in sequence. Is there a particular event I can subscribe to that would allow me to test those values?

Thanks

____________________
Programmer/Analyst
Captain D's, LLC

Post #14488
Posted 02/21/2008 9:44:48 AM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Today @ 2:43:51 PM
Posts: 4,241, Visits: 4,285
Set a break point in the Set of the property that represents the DateTime and step into it.  You should have the source code, so you can build the source in debug mode, and then you step into the Set you shold be able to see anything that SF is doing. 
Post #14489
Posted 02/21/2008 9:47:37 AM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Today @ 2:43:51 PM
Posts: 4,241, Visits: 4,285
Hey...do you have a sort or filter set on the BO?  I see that you are changing the CurrentRow property directly as well...since you mentioned that the CurrentIndex is moving, the only way it would move when you set a value is if you have a filter or sort set and this is part of the filter or sort, so the index is going to move in this case.  If you remove the sort or filter, then try it, I am sure that the index will not move.  The only other way the index would move is if you have a Changed or Changing event that is being handled and moving the row position.
Post #14490
Posted 02/21/2008 10:08:47 AM


StrataFrame Beginner

StrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame Beginner

Group: StrataFrame Users
Last Login: 2 days ago @ 11:48:33 AM
Posts: 23, Visits: 129
As far as I could see stepping into the code was the value being set in the BO (CurrentRow["BeginMoment"]=xxx).

But that you hit the nail on the head with the "Sort" clue. Yes, that BO's sort was set to BeginMoment...and fixing that is history. And it makes perfect sense now.

We were careful to reset filters after using them throughout the code, but didn't think about the sorts.

You've saved the day, Trent!

____________________
Programmer/Analyst
Captain D's, LLC

Post #14492
Posted 02/21/2008 10:46:56 AM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Today @ 2:43:51 PM
Posts: 4,241, Visits: 4,285
Glad to hear it...yeah, you are right about setting the CurrentRow directly, but I was referring more to if you were setting a property.  But yeah, once you set the CurrentRow that is about as far as you can go

But once I re-read your post and saw that your CurrentRowIndex was moving when you changed the value...the light came on  

Post #14495
« Prev Topic | Next Topic »