Wil Cantrell
|
|
Group: Forum Members
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
|
|
|
Trent Taylor
|
|
Group: StrataFrame Developers
Posts: 6.6K,
Visits: 6.9K
|
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: - 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.
- 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.
|
|
|
Trent Taylor
|
|
Group: StrataFrame Developers
Posts: 6.6K,
Visits: 6.9K
|
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.
|
|
|
Wil Cantrell
|
|
Group: Forum Members
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
|
|
|
Wil Cantrell
|
|
Group: Forum Members
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
|
|
|
Trent Taylor
|
|
Group: StrataFrame Developers
Posts: 6.6K,
Visits: 6.9K
|
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.
|
|
|
Trent Taylor
|
|
Group: StrataFrame Developers
Posts: 6.6K,
Visits: 6.9K
|
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.
|
|
|
Wil Cantrell
|
|
Group: Forum Members
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
|
|
|
Trent Taylor
|
|
Group: StrataFrame Developers
Posts: 6.6K,
Visits: 6.9K
|
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
|
|
|