private void добавитьToolStripMenuItem_Click(object sender, EventArgs e) { AddForm form = new AddForm(); form.Owner = this; form.ShowDialog(); var u = form.User; gridPeople.DataSource = people.ToTable(); gridAwards.DataSource = awards.ToTable(); gridPeople.Refresh(); gridAwards.Refresh(); gridPeople_CellClick(new object(), new DataGridViewCellEventArgs(0, gridPeople.CurrentRow.Index)); }
private void editToolStripMenuItem_Click(object sender, EventArgs e) { if (tcFullInfo.SelectedIndex == 0) { int ID = int.Parse(gridPeople[0, gridPeople.SelectedCells[0].RowIndex].Value.ToString()); Person person = people.GetPerson(ID); AddForm form = new AddForm(person, awards.Awards); form.ShowDialog(); if (form.DeleteState) { people.DeletePerson(form.User); } else { people.ReplaceData(form.User); } } else if (tcFullInfo.SelectedIndex == 1) { int ID = int.Parse(gridAwards[0, gridAwards.SelectedCells[0].RowIndex].Value.ToString()); Award award = awards.GetAward(ID); AddForm form = new AddForm(award); form.ShowDialog(); if (form.DeleteState) { foreach (Person i in people.People) { i.GetAwards().RemoveAll(item => item.ID == award.ID); } awards.DeleteAward(form.Award); } else { awards.ReplaceData(form.Award); } } UpdateData(); }
private void AddToolStripMenuItem_Click(object sender, EventArgs e) { if (tcFullInfo.SelectedIndex == 0) { AddForm form = new AddForm(true, awards.Awards); form.ShowDialog(); if (form.User != null) { people.AddPerson(form.User); } } else if (tcFullInfo.SelectedIndex == 1) { AddForm form = new AddForm(false, awards.Awards); form.ShowDialog(); if (form.Award != null) { awards.AddAward(form.Award); } } UpdateData(); }