Пример #1
0
        public NonConventionalPlantsDataGrid(EntitiesCollections entitiesCollections) : base(entitiesCollections)
        {
            InitializeComponent();

            NonConventionalPlantsCollectionViewModel items = ItemsSource as NonConventionalPlantsCollectionViewModel;

            if (items.Count == 1)
            {
                NonConventionalPlantViewModel item = items[0] as NonConventionalPlantViewModel;
                if (item.Name == null)
                {
                    CurrentColumn         = NameColumn;
                    NameColumn.IsReadOnly = false;
                    CaseColumn.IsReadOnly = false;
                }
            }
        }
Пример #2
0
 void ObjectsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     if (e.Action == NotifyCollectionChangedAction.Remove)
     {
         try
         {
             foreach (object item in e.OldItems)
             {
                 NonConventionalPlantViewModel UIObject = item as NonConventionalPlantViewModel;
                 NonConventionalPlantsDataAccess.DeleteObject(UIObject.GetDataObject());
             }
         }
         catch (Exception ex)
         {
             log.Error(ex.StackTrace);
         }
     }
 }
Пример #3
0
        void ObjectsItemEndEdit(IEditableObject sender)
        {
            NonConventionalPlantViewModel UIObject = sender as NonConventionalPlantViewModel;

            try
            {
                if (UIObject.Name != null)
                {
                    int id = NonConventionalPlantsDataAccess.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)
                });
            }
        }