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

            try
            {
                if (UIObject.Name != null && UIObject.Reservoir != null)
                {
                    int id = PFEquationsDataAccess.UpdateObject(UIObject.GetDataObject());
                    if (id != -1)
                    {
                        UIObject.Id = id;
                    }
                }
            }
            catch (Exception e)
            {
                UIObjects.Remove(UIObject);
                log.Fatal(e.Message);
                MessageBox.Show(MessageUtil.FormatMessage("ERROR.DuplicatedPFEquation", UIObject.Name, UIObject.Reservoir, UIObject.Case),
                                "DHOG", MessageBoxButton.OK, MessageBoxImage.Exclamation);
            }
        }