示例#1
0
 /// <summary>
 /// Открыть окно с деталями о команде
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OpenTeamDetails()
 {
     if (teamsDataGrid.SelectedItems.Count > 0)
     {
         for (int i = 0; i < teamsDataGrid.SelectedItems.Count; i++)
         {
             if (teamsDataGrid.SelectedItems[i] is Team team)
             {
                 TeamDataForm teamDataForm = new TeamDataForm(team.Id, team.LongName);
                 teamDataForm.Show();
             }
         }
     }
 }
        /// <summary>
        /// Сохраняет новую команду, открывает окно с деталями этой команды, закрывает форму
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CreateNewTeamButton_Click(object sender, RoutedEventArgs e)
        {
            db = new AppDbContext();
            db.Teams.Load();

            Team newTeam = new Team
            {
                Name         = nameTextBox.Text,
                Abbreviation = abbreviationTextBox.Text
            };

            db.Teams.Local.Add(newTeam);

            db.SaveChanges();

            TeamDataForm teamDataForm = new TeamDataForm(newTeam.Id, newTeam.LongName);

            teamDataForm.Show();

            db.Dispose();

            Close();
        }