コード例 #1
0
        private void btnAddStudent_Click(object sender, RoutedEventArgs e)
        {
            StudentEntryForm frm = new StudentEntryForm();

            frm.ShowDialog();
            if (frm.AddSuccessful)
            {
                // added student
                Student lastStudentAdded = DataStore.Students.Values.Last();
                int     newID            = DataStore.Students.Count();
                lastStudentAdded.InClass = true;
                lastStudentAdded.ID      = newID;
                // rebuild student grid to make sure it now contains the new student.
                MakeStudentGrid(lastStudentAdded, chkShowFullNames.IsChecked);
                UpdateStudentGridStyle(lastStudentAdded); // updates styles for new student.
            }
        }
コード例 #2
0
        private void BtnEdit_Click(object sender, RoutedEventArgs e)
        {
            Button btn = (Button)sender;

            string[] idParts    = btn.Name.Split("_");
            int      studentID  = int.Parse(idParts[1]);
            Student  studToEdit = DataStore.Students.Values
                                  .FirstOrDefault(s => s.ID == studentID);

            if (studToEdit != null)
            {
                StudentEntryForm frm = new StudentEntryForm(studToEdit);
                frm.ShowDialog();
                if (frm.AddSuccessful)
                {
                    // Student email changed
                }
                FillWrapPanel(chkShowFullNames.IsChecked);
            }
            else
            {
                ShowPopUp("Could not find the student to edit.");
            }
        }