Пример #1
0
 private void BtnUpdate_Click(object sender, EventArgs e)                          //event for updating a student's score
 {
     if (lstBoxStudents.SelectedIndex != -1)                                       //if the selected index of listbox is not -1
     {
         frmUpdateStudentScores updateStudentForm = new frmUpdateStudentScores();  //declare instance of frmUpdateStudentScores
         updateStudentForm.UpdateStudent = students[lstBoxStudents.SelectedIndex]; //upload stance of student from selected index
         updateStudentForm.Show();                                                 //show form
         this.Hide();                                                              //hide this form
         updateStudentForm.VisibleChanged += updateformVisibleChanged;             //change visibility status to new form
     }
 }
Пример #2
0
        private void updateformVisibleChanged(object sender, EventArgs e)              // event for when the form frmUpdateStudentScores closes
        {
            frmUpdateStudentScores updateStudentForm = (frmUpdateStudentScores)sender; //declare instance of that form

            if (!updateStudentForm.Visible)                                            //if form is not visible
            {
                if (updateStudentForm.DoUpdateStudent())                               //if action was updateStudent
                {
                    foreach (int i in updateStudentForm.StudentScores)                 //for every item in list StudentScores
                    {
                        students[lstBoxStudents.SelectedIndex].StudentScores.Add(i);   //add new scores
                    }
                    FillStudentListBox();                                              //call method to fill the list box
                }
                this.Show();                                                           //show this form
                updateStudentForm.Dispose();                                           //dispose of update student form
            }
        }