Re: tricky TimeSpan editing



Ok, I finally got it working and it does seem to work much smoother.
here is the final code:

private bool CheckOverlap(DateTime ts, DateTime te) {
bool hasChanged = false;
DataSet ds = this.GetTimeEntryByDay(DayID);

int i;
for(i=0;i<ds.Tables["TimeEntry"].Rows.Count;i++) {
DataRow dr = ds.Tables["TimeEntry"].Rows[i];
if ((int)dr["TimeEntryID"] == TimeEntryID) {
// TimeEnd has been changed, Change the TimeStart of the next row,
if it exists
if ((DateTime)dr["TimeEnd"] != te && i !=
ds.Tables["TimeEntry"].Rows.Count - 1) {
DataRow nextDR = ds.Tables["TimeEntry"].Rows[i+1];
nextDR["TimeStart"] = te;

// Save the next TimeEntry back to the database
hasChanged = true;
this.UpdateTimeEntry((int)nextDR["TimeEntryID"],
(int)nextDR["DayID"], (DateTime)nextDR["TimeStart"],
(DateTime)nextDR["TimeEnd"], (int)nextDR["EntryTypeID"]);
}
// TimeStart has been changed, Change the previous items TimeEnd,
if it exists
if ((DateTime)dr["TimeStart"] != ts && i != 0) {
DataRow prevDR = ds.Tables["TimeEntry"].Rows[i-1];
prevDR["TimeEnd"] = ts;

// Save the prev TimeEntry back to the database
hasChanged = true;
this.UpdateTimeEntry((int)prevDR["TimeEntryID"],
(int)prevDR["DayID"], (DateTime)prevDR["TimeStart"],
(DateTime)prevDR["TimeEnd"], (int)prevDR["EntryTypeID"]);
}
}
}
return hasChanged;
}

If hasChanged is true, then I loop through each timeEntry and reset the
TimeStart's that you mentioned in Rule #2

thanks for your help!

.



Relevant Pages

  • Re: uk.radio.amateur net nite.
    ... smoother and quieter flight. ... and didnt crack at corners:-| ... Prev by Date: ...
    (uk.radio.amateur)
  • Re: Little bit of help?
    ... have worked (touch wood) as the whole process went smoother than it was ... If you're going to do something stupid, at least do it with style! ... Prev by Date: ...
    (uk.religion.pagan)
  • Re: Most Boring Flame War...Ever!
    ... /me waves to Xena & hopes the move is going smoother than glass. ... Cat ... Prev by Date: ...
    (alt.support.stop-smoking)
  • Re: 00 Sienna Misfiring
    ... smoother than before. ... Check engine light is now blinking. ... Prev by Date: ...
    (alt.autos.toyota)
  • Re: Best freestyle crank lenth(vote for the best size)
    ... Everything just feels so much smoother and faster, ... sevenasterisks - Mediocre Unicyclist ... sevenasterisks's Profile: http://www.unicyclist.com/profile/8632 ... Prev by Date: ...
    (rec.sport.unicycling)

Loading