示例#1
0
        private void Modify_btn_Click(object sender, RoutedEventArgs e)
        {
            MotoGPTeam modified = (MotoGPTeam)Teams_dgw.SelectedItem;

            //if nothing selected, do not respond
            if (modified == null)
            {
                return;
            }

            AddOrModify addOrModify = new AddOrModify(modified, true);

            addOrModify.ShowDialog();

            //Clicked OK (validated)
            if (addOrModify.DialogResult.HasValue && addOrModify.DialogResult.Value)
            {
                //Upserting value
                using (MotoGPContext db = new MotoGPContext())
                {
                    db.Teams.AddOrUpdate(modified);
                    db.SaveChanges();
                    teams = db.Teams.ToList();
                    Teams_dgw.ItemsSource = teams;
                }
            }
        }
示例#2
0
        private void Add_btn_Click(object sender, RoutedEventArgs e)
        {
            MotoGPTeam modified = new MotoGPTeam();

            AddOrModify addOrModify = new AddOrModify(modified, false);

            addOrModify.ShowDialog();

            //Clicked OK (validated)
            if (addOrModify.DialogResult.HasValue && addOrModify.DialogResult.Value)
            {
                //Upserting value
                using (MotoGPContext db = new MotoGPContext())
                {
                    db.Teams.AddOrUpdate(modified);
                    db.SaveChanges();
                    teams = db.Teams.ToList();
                    Teams_dgw.ItemsSource = teams;
                }
            }
        }