void TankListCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { //throw new NotImplementedException(); if (e.Action == NotifyCollectionChangedAction.Remove) { try { foreach (object item in e.OldItems) { TankUIObject iTabObject = item as TankUIObject; // use the data access layer to delete the wrapped data object dataAccessLayer.DeleteTank(iTabObject.GetDataObject()); } } catch (Exception ex) { if (TankListPersistenceError != null) { TankListPersistenceError(this, ex); } App.Log.LogException(ex); } } else if (e.Action == NotifyCollectionChangedAction.Add) { try { foreach (object item in e.NewItems) { TankUIObject iTabObject = item as TankUIObject; iTabObject.StationId = currentStationId; } } catch (Exception ex) { if (TankListPersistenceError != null) { TankListPersistenceError(this, ex); } App.Log.LogException(ex); } } }
void TankListItemEndEdit(System.ComponentModel.IEditableObject sender) { //throw new NotImplementedException(); TankUIObject iTabObject = sender as TankUIObject; try { //if (iTabObject.TankId == 0) //{ // iTabObject.TankId = currTankId; //} // use the data access layer to update the wrapped data object dataAccessLayer.UpdateTank(iTabObject.GetDataObject()); iTabObject.NotifyIdChange(); } catch (Exception ex) { if (TankListPersistenceError != null) { TankListPersistenceError(this, ex); } App.Log.LogException(ex); App.Log.LogInfoMessage(ex.Message); } }