コード例 #1
0
        public void EnterNewPaper()
        {
            //Getting user information from text boxes
            string name             = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(txtBNameOfPaper.Text);
            string paperCode        = txtBPaperCode.Text;
            string paperCoordinator = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(txtBPaperCoordinator.Text);

            newItemForComboBox.Add(name);
            //creating a new file of papers when new paper is added.
            if (!HomePageForm.dictionaryWithPaperInfo.ContainsKey(name))
            {
                HomePageForm.dictionaryWithPaperInfo.Add(name, new Paper(name, paperCode, paperCoordinator, new List <string>()));
            }
            else
            {
                MessageBox.Show("A paper already exists with that paper name", "Paper already exists",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            StreamWriter fileText = new StreamWriter(File.Create("Courses.txt"));

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

            hpForm.Show();
            Hide();
        }
コード例 #2
0
        private void HomeToolStripMenuItemClick(object sender, EventArgs e)
        {
            HomePageForm hpForm = new HomePageForm();

            hpForm.Show();
            Hide();
        }
コード例 #3
0
        private void EnterNewStudent()
        {
            //Getting user information from text boxes
            string studentID = txtBID.Text;
            string DOB       = txtBDOB.Text;

            //Checking all text boxes for user validation
            if (CheckFullName())
            {
                return;
            }
            if (CheckDOB(DOB))
            {
                return;
            }
            if (CheckStudentID(studentID))
            {
                return;
            }
            if (CheckAddress())
            {
                return;
            }
            //Converting full name so that each word in string starts with a capital, for comparison later
            //only loading variables once error checks have been done to ensure correct information before procceding
            string fullName = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(txtBFirstName.Text + " " + txtBLastName.Text);
            string address  = txtBStreetNo.Text + " " + txtBStreetName.Text + ", " + txtBSuburb.Text + ", " + txtBCity.Text;

            //saving students to file everytime a new student is added.
            if (!HomePageForm.dictionaryWithStudentInfo.ContainsKey(studentID))
            {
                //New student will be added only if the student ID does not already exist.
                HomePageForm.dictionaryWithStudentInfo.Add(studentID, new Student(fullName, address, DOB, studentID, new List <string>()));
            }
            StreamWriter fileText = new StreamWriter(File.Create("Students.txt"));

            foreach (KeyValuePair <string, Student> item in HomePageForm.dictionaryWithStudentInfo)
            {
                //loop to write the dictionary to a new file.
                CreateNewStudentsFile(item.Value, fileText);
            }
            fileText.Close();
            //Returns to homepage after adding a new student.
            HomePageForm hpForm = new HomePageForm();

            hpForm.Show();
            Hide();
        }
コード例 #4
0
        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();
        }