private void editButton_Click(object sender, RoutedEventArgs e)
        {
            if (resTypesGrid.SelectedItems.Count > 0)
            {
                var resType = resTypesGrid.SelectedItems[0] as ResourceTypes;

                if (resType == null)
                {
                    return;
                }

                var dialog = new ResourceTypeEditWindow(resType);

                if (dialog.ShowDialog() == true)
                {
                    try
                    {
                        db.ResourceTypes_Update(resType.ResourceTypeId, resType.Name);

                        resTypesGrid.ItemsSource = null;
                        resTypesGrid.ItemsSource = db.ResourceTypes.ToList();
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Проверьте введённые значения");
                    }
                }
            }
        }
        private void addButton_Click(object sender, RoutedEventArgs e)
        {
            var resType = new ResourceTypes();
            var dialog  = new ResourceTypeEditWindow(resType);

            if (dialog.ShowDialog() == true)
            {
                try
                {
                    db.ResourceTypes_Create(resType.Name);

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