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