Ejemplo n.º 1
0
        private void ExecuteAddStudent(object parameter)
        {
            var viewModel = UnityConfiguration.Resolve <AddStudentViewModel>();
            var dialog    = new AddStudentDialog(viewModel);

            dialog.ShowDialog();

            if (viewModel.ChangesSaved)
            {
                long    studentId = _uniqueIDGenerator.GetNextIdForUser();
                Student student   = new Student(studentId)
                {
                    FirstName      = viewModel.FirstName,
                    LastName       = viewModel.LastName,
                    ParentId       = viewModel.Parent?.Id,
                    Parent         = viewModel.Parent,
                    Login          = viewModel.Login,
                    Email          = viewModel.Email,
                    Password       = viewModel.Password,
                    HashedPassword = viewModel.HashedPassword
                };

                if (student.Parent != null)
                {
                    student.Parent.ChildId = student.Id;
                }

                Students.Add(student);
                OnPropertyChanged(nameof(Students));
            }
        }
        private void EditContactToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // make sure that someon is selected before displaying the information

            int    index = displayContactListbox.SelectedIndex;
            Person p;

            p = SelectContactFirst();

            if (p != null)
            {
                DialogResult result1 = MessageBox.Show($"Do you wish to edit " +
                                                       $"{p.FirstName} {p.LastName} contact information?", "Confirmation Message", MessageBoxButtons.YesNo);
                if (result1 == DialogResult.Yes)
                {
                    if (p is Faculty)
                    {
                        afd             = new AddStudentDialog();
                        afd.FacultyMode = true;
                        afd.EditMode    = true;
                        addFacultyDialog();

                        // if user confirm create a update the current contact information and student from the info from the dialog box
                        ContactInformation c = new ContactInformation();
                        c.EmailAddress   = afd.EmailAddress;
                        c.OfficeLocation = afd.SnailMailAddress;
                        Person p1 = new Faculty(afd.FirstName, afd.LastName, afd.AcademicDepartment, c);
                        PeopleInventory[index]             = p1;
                        displayContactListbox.Items[index] = p1.ToFormattedString();
                    }
                    else if (p is Student)
                    {
                        asd = new AddStudentDialog();
                        // ceate a new dialog for displaying and configure it
                        asd.EditMode    = true;
                        asd.StudentMode = true;
                        addStudentDialog();
                        // show the dialog and and wait for the Ok

                        // if user confirm create a update the current contact information and student from the info from the dialog box
                        ContactInformation c = new ContactInformation();
                        c.EmailAddress     = asd.EmailAddress;
                        c.SnailMailAddress = asd.SnailMailAddress;
                        Person p1 = new Student(asd.FirstName, asd.LastName, asd.AcademicDepartment, c, asd.GraduationYear, asd.CourseList);
                        PeopleInventory[index]             = p1;
                        displayContactListbox.Items[index] = p1.ToFormattedString();
                    }

                    haveFileBeenSaved = false;
                }
            }
        }
        public Person createFacultyContact()
        {
            afd             = new AddStudentDialog();
            afd.FacultyMode = true;

            DialogResult result = afd.ShowDialog();

            // issue a a confirmation dialog
            if (result != DialogResult.OK)
            {
                return(null);
            }
            //add the information enter into the dialog box into the display list
            // and the backing store list also people inventory list
            ContactInformation c = new ContactInformation();

            c.OfficeLocation = afd.SnailMailAddress; //(the snail email will be change to add a location in the add student dialog box by using code to change snail label to office build
            c.EmailAddress   = afd.EmailAddress;

            Person p = new Faculty(afd.FirstName, afd.LastName, afd.AcademicDepartment, c);

            return(p);
        }
        // method to enter and adding a student contact information
        public Person createStudentContact()
        {
            asd = new AddStudentDialog();

            DialogResult result = asd.ShowDialog();

            // issue a a confirmation dialog
            if (result != DialogResult.OK)
            {
                return(null);
            }

            //add the information enter into the dialog box into the display list
            // and the backing store list also people inventory list
            ContactInformation c = new ContactInformation();

            c.SnailMailAddress = asd.SnailMailAddress; // Used code on the add student dialog box to change the snail mail to office building text box
            c.EmailAddress     = asd.EmailAddress;

            Person p = new Student(asd.FirstName, asd.LastName, asd.AcademicDepartment, c, asd.GraduationYear, asd.CourseList);

            return(p);
        }