private void BtnAdd_Click(object sender, EventArgs e) { FrmAddStudents addForm = new FrmAddStudents(); Student s = addForm.GetNewStudent(); if (s != null) { students.Add(s); StudentDB.SaveStudents(students); FillStudentListBox(); } }
private void BtnDelete_Click(object sender, EventArgs e) { int x = lstStudents.SelectedIndex; if (x != -1) { Student student = students[x]; DialogResult result = MessageBox.Show("Are you sure you want to delete" + "\n" + student.StudentID + "\t" + student.StudentName, "Confirm Delete", MessageBoxButtons.OKCancel); if (result == DialogResult.OK) { students.Remove(student); StudentDB.SaveStudents(students); FillStudentListBox(); } } }
private void BtnUpdate_Click(object sender, EventArgs e) { int x = lstStudents.SelectedIndex; if (x != -1) { Student student = students[x]; FrmAddStudents updateForm = new FrmAddStudents(); student = updateForm.UpdateStudent(student); if (student != null) { students[x].MidtermGrade = student.MidtermGrade; students[x].FinalGrade = student.FinalGrade; StudentDB.SaveStudents(students); FillStudentListBox(); } } else { MessageBox.Show("Please select a student to update", "Error"); } }