Ejemplo n.º 1
0
        // load file
        public Student(string fromFile) : base(fromFile)
        {
            char[] delimiters = { '|', ',' };

            string[] tokens = fromFile.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);

            // call constructor to set contact information of faculty staff
            studentCont = new ContactStudent(tokens[3], tokens[4]);

            graduationYear = tokens[5];

            // read course list until end
            int len = tokens.Length;

            for (int i = 6; i < len; i++)
            {
                course.Add(tokens[i]);
            }
        }
Ejemplo n.º 2
0
        private List <string> course = new List <string>();         // list of courses are taking

        // constructor

        public Student(string firstName,
                       string lastName,
                       string department,
                       ContactStudent studentCont,
                       string graduationYear,
                       List <string> course) : base(firstName, lastName, department)
        {
            if (!validateGraduationYear(graduationYear))
            {
                throw new ArgumentException("bad graduation year");
            }

            if (!validateCourses(course))
            {
                throw new ArgumentException("bad course name");
            }

            this.studentCont    = studentCont;
            this.graduationYear = graduationYear;
            this.course         = course;
        }
Ejemplo n.º 3
0
        // Function - Edit student contact information
        private void EditStudentPerson(int index, int mode)
        {
            // create a dialog and configure for edit or only display

            AddEditStudentDialog adsd = new AddEditStudentDialog();

            switch (mode)
            {
            case 0:         // 0 - show mode
            case 2:         // 2 - edit mode

                Student s = (Student)personList[index];

                // assign values in personList to public properties in AddEditFacultyDialog
                adsd.StudentEditMode     = mode;
                adsd.StudentFirstName    = s.FirstName;
                adsd.StudentLastName     = s.LastName;
                adsd.StudentAcademicDept = s.Department;
                adsd.StudentEmail        = s.StudentCont.Email;
                adsd.StudentMail         = s.StudentCont.SnailMail;
                adsd.StudentGradYear     = s.GraduationYear;
                // change s.course list to adsd.course string
                adsd.StudentCourses = stdCourseListToString(s.Course);

                break;

            case 1:         // 1 - add mode
                adsd.StudentEditMode = mode;
                break;
            }


            // show the dialog and wait for a ok

            DialogResult result = adsd.ShowDialog();

            // if answer was ok update the contact information with the new values and update display

            // update student contact information



            if (result == DialogResult.OK)
            {
                ContactStudent studentInfo;
                try
                {
                    studentInfo = new ContactStudent(adsd.StudentEmail, adsd.StudentMail);
                }
                catch (Exception excp)
                {
                    MessageBox.Show($"email address error. {excp.Message}");
                    return;
                }

                Person p = new Student(adsd.StudentFirstName,
                                       adsd.StudentLastName,
                                       adsd.StudentAcademicDept,
                                       studentInfo,
                                       adsd.StudentGradYear,
                                       // change adsd.StudentCourses string to p.Course list
                                       stdCourseStringToList(adsd.StudentCourses)
                                       );

                // set mode to public property
                p.Type = "Student";

                switch (mode)
                {
                case 0:     // show mode
                    break;

                case 2:     // edit mode

                    // update new values for dispaly and list

                    personList[index] = p;
                    personListListBox.Items[index] = p.ToFormattedString();
                    EditCount++;                        // EditCount add 1 after sucessful edit
                    break;

                case 1:     //add mode

                    // add to list
                    personList.Add(p);

                    // add to list box for display
                    personListListBox.Items.Add(p.ToFormattedString());
                    EditCount++;                        // EditCount add 1 after sucessful add
                    break;

                default:
                    break;
                }
            }
            else if (result == DialogResult.Cancel)
            {
                return;
            }
            else
            {
                MessageBox.Show("AddEditFacultyDialog not return OK ....debug");
                return;
            }
        }