Esempio n. 1
0
 void ObjectsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     if (e.Action == NotifyCollectionChangedAction.Remove)
     {
         try
         {
             foreach (object item in e.OldItems)
             {
                 VariableHydroPlantViewModel UIObject = item as VariableHydroPlantViewModel;
                 VariableHydroPlantsDataAccess.DeleteObject(UIObject.GetDataObject());
             }
         }
         catch (Exception ex)
         {
             log.Error(ex.StackTrace);
         }
     }
 }
Esempio n. 2
0
        void ObjectsItemEndEdit(IEditableObject sender)
        {
            VariableHydroPlantViewModel UIObject = sender as VariableHydroPlantViewModel;

            try
            {
                if (UIObject.Name != null && UIObject.Reservoir != null)
                {
                    int id = VariableHydroPlantsDataAccess.UpdateObject(UIObject.GetDataObject());
                    if (id != -1)
                    {
                        UIObject.Id = id;
                    }
                }
            }
            catch
            {
                UIObjects.Remove(UIObject);
                MessageBox.Show(MessageUtil.FormatMessage("ERROR.DuplicatedVariableHydroPlant", UIObject.Name, UIObject.Reservoir, UIObject.Segment, UIObject.Case),
                                "DHOG", MessageBoxButton.OK, MessageBoxImage.Exclamation);
            }
        }