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

            try
            {
                if (UIObject.System != null && UIObject.Element != null && UIObject.Type != null && UIObject.ElementType != null)
                {
                    int id = HydroTopologyDataAccess.UpdateObject(UIObject.GetDataObject());
                    if (id != -1)
                    {
                        UIObject.Id = id;
                    }
                }
            }
            catch
            {
                UIObjects.Remove(UIObject);
                RadWindow.Alert(new DialogParameters
                {
                    Content = MessageUtil.FormatMessage("ERROR.DuplicatedEntryName", UIObject.System)
                });
            }
        }