示例#1
0
        private void btnRemoveManager_Click(object sender, RoutedEventArgs e)
        {
            if (lbxManagerDisplay.SelectedValue != null)
            {
                ManagerTBL selected = lbxManagerDisplay.SelectedValue as ManagerTBL;

                var removeManager = from manager in db.ManagerTBLs
                                    where manager.ManagerName == selected.ManagerName
                                    select manager;

                db.ManagerTBLs.RemoveRange(removeManager);
                db.SaveChanges();
            }

            else if (tbxTeamName.Text != null)
            {
                var removeTeam = from team in db.TeamTBLs
                                 where team.TeamName == tbxTeamName.Text
                                 select team;

                db.TeamTBLs.RemoveRange(removeTeam);
                db.SaveChanges();
            }

            else
            {
                MessageBox.Show("Please select a team from the league or input a team name into the 'Team Name:' box");
            }
        }
示例#2
0
        private void btnAddManager_Click(object sender, RoutedEventArgs e)
        {
            var query = (from t in db.ManagerTBLs
                         select t).First();

            ManagerTBL newManager = new ManagerTBL
            {
                ManagerName        = tbxMangerName.Text,
                ManagerNationality = tbxManagerNationality.Text,
                TeamName           = tbxManagerTeam.Text
            };

            db.ManagerTBLs.Add(newManager);
            db.SaveChanges();

            MessageBox.Show("Premiership News! New manager signs his contact with " + tbxMangerName.Text);
        }