Exemplo n.º 1
0
        private void edit_Button_Click(object sender, EventArgs e)
        {
            TeamEditor editor = new TeamEditor();

            editor.name_textBox.Text  = team.Name;
            editor.couch_TextBox.Text = team.Couch;
            DialogResult result = editor.ShowDialog(this);

            if (result == DialogResult.Cancel)
            {
                return;
            }

            team.Name  = editor.name_textBox.Text;
            team.Couch = editor.couch_TextBox.Text;

            context.SaveChanges();
            teams_DataGridView.Refresh();
        }
Exemplo n.º 2
0
        private void add_Button_Click(object sender, EventArgs e)
        {
            TeamEditor   editor = new TeamEditor();
            DialogResult result = editor.ShowDialog(this);

            if (result == DialogResult.Cancel)
            {
                return;
            }

            context.Teams.Add
            (
                new Team
            {
                Name  = editor.name_textBox.Text,
                Couch = editor.couch_TextBox.Text == string.Empty ? null : editor.couch_TextBox.Text
            }
            );

            context.SaveChanges();
            teams_DataGridView.Refresh();
        }