Пример #1
0
        private void editButton_Click(object sender, RoutedEventArgs e)
        {
            if (resourcesGrid.SelectedItems.Count > 0)
            {
                var resName = resourcesGrid.SelectedItems[0] as ResourceNames;

                if (resName == null)
                {
                    return;
                }

                var dialog = new ResourceNameEditWindow(resName, ResourceTypes, false);

                if (dialog.ShowDialog() == true)
                {
                    try
                    {
                        db.ResourceNames_Update(resName.ResourceNameId, resName.Name);

                        resourcesGrid.ItemsSource = null;
                        resourcesGrid.ItemsSource = db.ResourceNames.ToList();
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Проверьте введённые значения");
                    }
                }
            }
        }
Пример #2
0
        private void addButton_Click(object sender, RoutedEventArgs e)
        {
            var resName = new ResourceNames();
            var dialog  = new ResourceNameEditWindow(resName, ResourceTypes, true);

            if (dialog.ShowDialog() == true)
            {
                try
                {
                    db.ResourceNames_Create(resName.Name, resName.ResourceTypeId);

                    resourcesGrid.ItemsSource = null;
                    resourcesGrid.ItemsSource = db.ResourceNames.ToList();
                }
                catch (Exception)
                {
                    MessageBox.Show("Проверьте введённые значения");
                }
            }
        }