Exemple #1
0
 /// <summary>
 /// Handles a change to a TimeUnit record in the data model.
 /// </summary>
 /// <param name="sender">The object that originated the event.</param>
 /// <param name="e">The event arguments.</param>
 void OnTimeUnitRowDeleted(Object sender, DataModel.TimeUnitRowChangeEventArgs e)
 {
     // This will delete the item from the list when it is deleted from the data model.
     if (e.Action == DataRowAction.Delete)
     {
         Int32 index = this.BinarySearch(timeUnitItem => timeUnitItem.TimeUnitCode, e.Row.TimeUnitCode);
         if (index >= 0)
         {
             this.RemoveAt(index);
         }
     }
 }
Exemple #2
0
 /// <summary>
 /// Handles a change to a TimeUnit record in the data model.
 /// </summary>
 /// <param name="sender">The object that originated the event.</param>
 /// <param name="e">The event arguments.</param>
 void OnTimeUnitRowChanged(Object sender, DataModel.TimeUnitRowChangeEventArgs e)
 {
     // We're only interested in additions and changes in this handler.
     if (e.Action == DataRowAction.Add || e.Action == DataRowAction.Change)
     {
         // If the item doesn't exist, it is added.  If it exists, it's updated.
         Int32 index = this.BinarySearch(timeUnitItem => timeUnitItem.TimeUnitCode, e.Row.TimeUnitCode);
         if (index < 0)
         {
             this.Insert(~index, new TimeUnitItem(e.Row));
         }
         else
         {
             this[index].Copy(e.Row);
         }
     }
 }