Example #1
0
        private void editButton_Click(object sender, RoutedEventArgs e)
        {
            if (resourcesGrid.SelectedItems.Count > 0)
            {
                var resource = resourcesGrid.SelectedItems[0] as Resources;

                if (resource == null)
                {
                    return;
                }

                var dialog = new ResourceEditWindow(resource, ResourceNames, false);

                if (dialog.ShowDialog() == true)
                {
                    try
                    {
                        db.Resources_Update(resource.ResourceNameId, resource.Name, resource.Price);

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

            if (dialog.ShowDialog() == true)
            {
                try
                {
                    db.Resources_Create(resource.ResourceNameId, resource.Name, resource.Price);

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