示例#1
0
        private void BtnNewPaperClick(object sender, EventArgs e)
        {
            PaperForm pForm = new PaperForm();

            pForm.Show();
            Hide();
        }
        //The next 4 functions are for the menu. They are used to direct users to the correct page.
        private void SubmitANewPaperToolStripMenuItemClick(object sender, EventArgs e)
        {
            PaperForm pForm = new PaperForm();

            pForm.Show();
            Hide();
        }
        private void Enrolment()
        {
            if (CheckStudentExists())
            {
                return;
            }
            //checking that the student and paper both exist before continuing
            bool studentExists = false;

            studentExists = AddNewStudentToPaper(studentExists);
            if (!studentExists)
            {
                MessageBox.Show("Error: Student does not exist.");
            }
            studentExists = AddNewPaperToStudent(studentExists);
            if (!studentExists)
            {
                MessageBox.Show("Error: Paper does not exist.");
            }
            //updating file with new student list
            StreamWriter studentText = new StreamWriter(File.Create("Students.txt"));

            foreach (KeyValuePair <string, Student> item in HomePageForm.dictionaryWithStudentInfo)
            {
                //loop to write the dictionary to a new file.
                StudentForm.CreateNewStudentsFile(item.Value, studentText);
            }
            studentText.Close();
            //updating file with new papers list
            StreamWriter paperText = new StreamWriter(File.Create("Courses.txt"));

            foreach (KeyValuePair <string, Paper> item in HomePageForm.dictionaryWithPaperInfo)
            {
                //loop to write the dictionary to a new file.
                PaperForm.CreateNewPapersFile(item.Value, paperText);
            }
            paperText.Close();
            HomePageForm hpForm = new HomePageForm();

            hpForm.Show();
            Hide();
        }