Esempio n. 1
0
        public static void SampleData()
        {
            try
            {
                Staff teacher = new Staff("Neil Urqhart", "C59 Merchiston", "*****@*****.**", 9253, "Software Engineering", "Lecturer");
                StaffList.Add(teacher);

                Module subject = new Module("Software Dev 2", "SET08108", teacher);
                ModuleList.Add(subject);

                teacher = new Staff("Ben Kenwright", "C48 Merchiston", "*****@*****.**", 9876, "Digital Media", "Lecturer");
                StaffList.Add(teacher);

                subject = new Module("Computer Graphics", "IMD09132", teacher);
                ModuleList.Add(subject);

                teacher = new Staff("Brian Davidson", "C56 Merchiston", "*****@*****.**", 9267, "Computing", "Lecturer");
                StaffList.Add(teacher);

                subject = new Module("Database Systems", "INF08104", teacher);
                ModuleList.Add(subject);

                teacher = new Staff("Andrew Cumming", "C39 Merchiston", "*****@*****.**", 9112, "Software Engineering", "Senior Lecturer");
                StaffList.Add(teacher);

                subject = new Module("Web Technologies", "SET08101", teacher);
                ModuleList.Add(subject);

                teacher = new Staff("Sally Smith", "C66 Merchiston", "*****@*****.**", 9005, "Computing", "Senior Lecturer");
                StaffList.Add(teacher);

                subject = new Module("Mobile Apps", "SET08114", teacher);
                ModuleList.Add(subject);

                Student pupil = new Student("Bill Grimes", "22 Houslane", "*****@*****.**", 1020);
                StudentList.Add(pupil);

                pupil = new Student("Sophie Jackson", "6/6 Longstreet", "*****@*****.**", 1453);
                StudentList.Add(pupil);

                pupil = new Student("Jim Watt", "37 Dell AV", "*****@*****.**", 4532);
                StudentList.Add(pupil);

                pupil = new Student("Helen Doul", "6 Mainstreet", "*****@*****.**", 4562);
                StudentList.Add(pupil);

                pupil = new Student("Jannet Mole", "15 Crossdale", "*****@*****.**", 8763);
                StudentList.Add(pupil);
            }
            catch (ArgumentNullException)
            {

            }
            catch (ArgumentOutOfRangeException)
            {

            }
         

        }
        //ok button handler
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            string newStaffName, newStaffAddress, newStaffEmail, newStaffDepartment, newStaffRole;
            int newStaffPayroll;

            if ((validName == false) || (validAddress == false) || (validEmail == false) || (ValidPayroll == false) || (validDeptartment == false))
            {
                invForm = invName + invAddress + invEmail + invPay + invDept;
                MessageBox.Show("invalid form\n" + invForm);
            }
            else
            {
                newStaffName = txtName.Text;
                newStaffAddress = txtAddress.Text;
                newStaffEmail = txtEmail.Text;
                newStaffPayroll = Convert.ToInt32(txtPayroll.Text);
                newStaffDepartment = txtDepart.Text;
                newStaffRole = ((ComboBoxItem)cbRole.SelectedItem).Content.ToString();

                Staff newStaff = new Staff(newStaffName, newStaffAddress, newStaffEmail,
                                        newStaffPayroll, newStaffDepartment, newStaffRole);
                University.StaffList.Add(newStaff);
                this.Close();
            }
        }
Esempio n. 3
0
 //constructor
 public Module(string n, string c, Staff s)
 {
     if (string.IsNullOrWhiteSpace(n))
     {
         throw new ArgumentNullException("name", NameBlankMessage);
     }
     else if (string.IsNullOrWhiteSpace(c))
     {
         throw new ArgumentNullException("moduleCode", ModuleCodeBlankMessage);
     }
     else if (Module.usedModuleCodes.Contains(c))
     {
         throw new ArgumentOutOfRangeException("moduleCode", ModuleCodeIsNotUniqueMessage);
     }
     else if (Staff.UsedPayrollNumbers.Contains(s.PayrollNumber) != true)
     {
         throw new ArgumentOutOfRangeException("moduleLeader", ModuleLeaderDoesNotExistMessage);
     }
     else
     {
         name = n;
         moduleCode = c;
         moduleLeader = s;
         usedModuleCodes.Add(c);
     }
 }
Esempio n. 4
0
 //methods
 public void UpdateLeader(Staff s)
 {
     if (Staff.UsedPayrollNumbers.Contains(s.PayrollNumber) != true)
     {
         throw new ArgumentOutOfRangeException("moduleLeader", ModuleLeaderDoesNotExistMessage);
     }
     else
     {
         moduleLeader = s;
     }
 }
Esempio n. 5
0
 public void ValidModuleCreation()
 {
     //arrange
     Staff staff = new Staff("Joe Blogs", "22 Houselane", "*****@*****.**", 9001, "Software Engineering", "Lecturer");
     string name = "Software Dev 2";
     string code = "SET001";
     Staff leader = staff;
     int expectedNoOfModCodes = 1;
     //act
     Module testModule = new Module(name, code, leader);
     //asert
     int actualNoOFModCodes = Module.UsedModuleCodes.Count;
     Assert.AreEqual(expectedNoOfModCodes, actualNoOFModCodes, 0, "number of module codes does not match");
 }
Esempio n. 6
0
 public void ModuleCreationNonUniqueModCode_ShouldThrowOutOfRange()
 {
     Staff staff = new Staff("Joe Blogs", "22 Houselane", "*****@*****.**", 9005, "Software Engineering", "Lecturer");
     //arrange
     string name = "Web Tech";
     string code = "SET001";
     Staff leader = staff;
     try
     {
         //act
         Module testMod = new Module(name, code, leader);
     }
     catch (ArgumentOutOfRangeException e)
     {
         //assert
         StringAssert.Contains(e.Message, Module.ModuleCodeIsNotUniqueMessage);
         return;
     }
     Assert.Fail("no exception thrown");
 }
Esempio n. 7
0
 public void ModuleCreationBlankName_ShouldThrowNull()
 {
     Staff staff = new Staff("Joe Blogs", "22 Houselane", "*****@*****.**", 9003, "Software Engineering", "Lecturer");
     //arrange
     string name = "";
     string code = "SET002";
     Staff leader = staff;
     try
     {
         //act
         Module testMod = new Module(name, code, leader);
     }
     catch(ArgumentNullException e)
     {
         //assert
         StringAssert.Contains(e.Message, Module.NameBlankMessage);
         return;
     }
     Assert.Fail("no exception thrown");
 }