private void Button_Click(object sender, RoutedEventArgs e) { if (StackAdd.Children.OfType <TextBox>().Any(x => x.Text == "")) { MessageBox.Show("Заполните все поля"); return; } try { Stadium.Photo = BArray; Connection.NewInstance().StadiumT.Add(Stadium); Connection.NewInstance().SaveChanges(); } catch { MessageBox.Show("12"); } finally { DataContext = null; Stadium = new StadiumT(); PhotoImage.Source = null; BArray = null; StackAdd.Children.OfType <TextBox>().ToList().ForEach(x => x.Text = ""); DataContext = this; } }
private void Button_Click(object sender, RoutedEventArgs e) { try { Stadium = DeleteComboBox.SelectedItem as StadiumT; Connection.NewInstance().StadiumT.Remove(Stadium); Connection.NewInstance().SaveChanges(); } catch { MessageBox.Show("Выберите стадион для удаления и проверьте что на нем не играют команды"); } finally { Stadiums = Connection.NewInstance().StadiumT.ToList(); DeleteComboBox.SelectedIndex = -1; DeleteComboBox.ItemsSource = Stadiums; } }
public CreateStadium() { InitializeComponent(); Stadium = new StadiumT(); DataContext = this; }
private void StadiumComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { Stadium = StadiumComboBox?.SelectedItem as StadiumT; }