private void create_button_Click(object sender, EventArgs e) { Student newStudent = new Student(); CreateStudent studentModal = new CreateStudent(newStudent); studentModal.ShowDialog(); if (studentModal.ok) { StudentsList.Items.Add(studentModal.studentInfo); students.Add(studentModal.studentInfo); } else { MessageBox.Show("Зміни не збережено"); } }
private void edit_button_Click(object sender, EventArgs e) { int selectedIndex = StudentsList.SelectedIndex; if (selectedIndex < 0 || selectedIndex >= students.Count) { MessageBox.Show("Оберіть студента!"); return; } CreateStudent studentlModal = new CreateStudent(students[StudentsList.SelectedIndex]); studentlModal.ShowDialog(); if (studentlModal.ok) { StudentsList.Items[selectedIndex] = studentlModal.studentInfo; } else { MessageBox.Show("Зміни не збережено"); } }