Exemplo n.º 1
0
        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();
            }
        }
Exemplo n.º 2
0
        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();
                }
            }
        }
Exemplo n.º 3
0
        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");
            }
        }
Exemplo n.º 4
0
 private void FrmStudents_Load(object sender, EventArgs e)
 {
     students = StudentDB.GetStudents();
     FillStudentListBox();
 }