Exemplo n.º 1
0
        private void addToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            dataGridView1.Visible = true;
            Form_AddGroup addGroup = new Form_AddGroup();

            if (addGroup.ShowDialog() == DialogResult.OK)
            {
                Group group = new Group()
                {
                    Title = addGroup.textBox1.Text,
                };
                repositoryGroup.Add(group);
                dataGridView1.DataSource = repositoryGroup.GetAll().Select(x => new { Id = x.Id, Tille = x.Title }).ToList();
            }
        }
Exemplo n.º 2
0
        private void updateToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            dataGridView1.Visible = true;
            Form_AddGroup addGroup = new Form_AddGroup();
            int           id       = Int32.Parse(dataGridView1.SelectedRows[0].Cells[0].Value.ToString());
            var           group    = repositoryGroup.FindById(id);

            addGroup.textBox1.Text = group.Title;
            if (addGroup.ShowDialog() == DialogResult.OK)
            {
                group.Title = addGroup.textBox1.Text;
                repositoryGroup.Update(group);
            }
            dataGridView1.DataSource = repositoryGroup.GetAll().Select(x => new { Id = x.Id, Tille = x.Title }).ToList();
        }