Re: tricky TimeSpan editing
- From: "DKode" <dkode8@xxxxxxxxx>
- Date: 22 Apr 2005 07:22:38 -0700
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!
.
- Follow-Ups:
- Re: tricky TimeSpan editing
- From: Bruce Wood
- Re: tricky TimeSpan editing
- References:
- tricky TimeSpan editing
- From: DKode
- Re: tricky TimeSpan editing
- From: Bruce Wood
- tricky TimeSpan editing
- Prev by Date: Re: Intellisense microsoft visual studio 2005 c#
- Next by Date: Re: add numbers in file
- Previous by thread: Re: tricky TimeSpan editing
- Next by thread: Re: tricky TimeSpan editing
- Index(es):
Relevant Pages
|
Loading