void ObjectsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if (e.Action == NotifyCollectionChangedAction.Remove) { try { foreach (object item in e.OldItems) { NonConventionalPlantBlockViewModel UIObject = item as NonConventionalPlantBlockViewModel; NonConventionalPlantBlocksDataAccess.DeleteObject(UIObject.GetDataObject()); } } catch (Exception ex) { log.Error(ex.StackTrace); } } }
public NonConventionalPlantBlocksDataGrid(EntitiesCollections entitiesCollections) : base(entitiesCollections) { InitializeComponent(); NonConventionalPlantBlocksCollectionViewModel items = ItemsSource as NonConventionalPlantBlocksCollectionViewModel; if (items.Count == 1) { NonConventionalPlantBlockViewModel item = items[0] as NonConventionalPlantBlockViewModel; if (item.Name == null) { CurrentColumn = NameColumn; NameColumn.IsReadOnly = false; BlockColumn.IsReadOnly = false; ReductionFactor.IsReadOnly = false; Case.IsReadOnly = false; Id.IsReadOnly = false; } } }
void ObjectsItemEndEdit(IEditableObject sender) { NonConventionalPlantBlockViewModel UIObject = sender as NonConventionalPlantBlockViewModel; try { if (UIObject.Name != null) { int id = NonConventionalPlantBlocksDataAccess.UpdateObject(UIObject.GetDataObject()); if (id != -1) { UIObject.Id = id; } } } catch (Exception e) { UIObjects.Remove(UIObject); RadWindow.Alert(new DialogParameters { Content = MessageUtil.FormatMessage("ERROR.DuplicatedEntryNameBlock", UIObject.Name, UIObject.Block) }); } }