コード例 #1
0
ファイル: LecturerTest.cs プロジェクト: GeoffNukem/CWA-TMS
 public void Lecturer_Remove()
 {
     Lecturer l = new Lecturer("Joe Bloggs", 14, "JB", Color.Blue);
     DataCollection.Instance.Add(l);
     Assert.IsTrue(DataCollection.Instance.Lecturers.Contains(l), "Lecturers does not contain Lecturer");
     DataCollection.Instance.Remove(l);
     Assert.IsFalse(DataCollection.Instance.Lecturers.Contains(l), "Lecturers still contains Lecturer");
 }
コード例 #2
0
ファイル: LecturerTest.cs プロジェクト: GeoffNukem/CWA-TMS
 public void Lecturer_GetterAndSetter()
 {
     Lecturer l = new Lecturer("", 0, "", Color.Empty);
     l.Name = "Mr. T";
     l.Label = "T";
     l.HoursPerWeek = 6;
     l.Colour = Color.AliceBlue;
     Assert.AreEqual("Mr. T", l.Name, "Failed @ Name");
     Assert.AreEqual("T", l.Label, "Failed @ Label");
     Assert.AreEqual<int>(6, l.HoursPerWeek, "Failed @ HoursPerWeek");
     Assert.AreEqual<Color>(Color.AliceBlue, l.Colour, "Failed @ Colour");
 }
コード例 #3
0
ファイル: LecturerTest.cs プロジェクト: GeoffNukem/CWA-TMS
 public void Lecturer_Constructor()
 {
     Lecturer l = new Lecturer("Joe Bloggs", 14, "JB", Color.Blue);
     Assert.AreEqual("Joe Bloggs", l.Name, "Failed @ Name");
     Assert.AreEqual("JB", l.Label, "Failed @ Label");
     Assert.AreEqual<int>(14, l.HoursPerWeek, "Failed @ HoursPerWeek");
     Assert.AreEqual<Color>(Color.Blue, l.Colour, "Failed @ Colour");
     l.Name = "Mr. T";
     l.Label = "T";
     l.HoursPerWeek = 6;
     l.Colour = Color.AliceBlue;
     Assert.AreEqual("Mr. T", l.Name, "Failed @ Name");
     Assert.AreEqual("T", l.Label, "Failed @ Label");
     Assert.AreEqual<int>(6, l.HoursPerWeek, "Failed @ HoursPerWeek");
     Assert.AreEqual<Color>(Color.AliceBlue, l.Colour, "Failed @ Colour");
 }
コード例 #4
0
ファイル: LecturerTest.cs プロジェクト: GeoffNukem/CWA-TMS
        public void Lecturer_Add()
        {
            //  Create test instances
            Lecturer l = new Lecturer("Joe Bloggs", 14, "JB", Color.Blue);
            Lecturer l2 = new Lecturer("John Smith", 32, "JS1", Color.Blue);
            Lecturer l3 = new Lecturer("Fred Flintstone", 50, "FF", Color.Blue);

            //  Add an instance to the list and check if the instance is in the first index (0)
            DataCollection.Instance.Add(l);
            Assert.AreEqual<Lecturer>(l, DataCollection.Instance.Lecturers[0], "Lecturer1 not found at 0");

            //  Add another instance and check if this instance is in the second index (1)
            DataCollection.Instance.Add(l2);
            Assert.AreEqual<Lecturer>(l2, DataCollection.Instance.Lecturers[1], "Lecturer2 not found at 1");

            //  Insert an instance into the second index (1) and check if the instance is at that index and the instance
            //    before has moved to the next index (2)
            DataCollection.Instance.Insert(l3, 1);
            Assert.AreEqual<Lecturer>(l3, DataCollection.Instance.Lecturers[1], "Lecturer3 not found at 1");
            Assert.AreEqual<Lecturer>(l2, DataCollection.Instance.Lecturers[2], "Lecturer2 not found at 2");
        }
コード例 #5
0
ファイル: FormData.cs プロジェクト: GeoffNukem/CWA-TMS
        private void dataLecTable_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            DataGridView dgv = (DataGridView)sender;

            //  Input for row will
            if (validate(dgv, e))
            {
                switch (tabControl1.SelectedIndex)
                {
                    case 0:	//	Lecturer DGV
                        dgv = dataLecTable;
                        if (dgv.Rows[e.RowIndex].Cells[0].Value != null &&
                            dgv.Rows[e.RowIndex].Cells[1].Value != null &&
                            dgv.Rows[e.RowIndex].Cells[2].Value != null &&
                            dgv.Rows[e.RowIndex].Cells[3].Value != null)
                        {
                            string name = dgv.Rows[e.RowIndex].Cells[0].Value.ToString();
                            string label = dgv.Rows[e.RowIndex].Cells[1].Value.ToString();
                            int hours;
                            if (!int.TryParse(dgv.Rows[e.RowIndex].Cells[2].Value.ToString(), out hours)) //converts int to bool, if invalid then return false
                            {
                                return;
                            }
                            Color colour = dgv.Rows[e.RowIndex].Cells[3].Style.BackColor;
                            Lecturer lect = new Lecturer(name, hours, label, colour);
                            if (!loading)
                            {
                                try
                                {
                                    DataCollection.Instance.Lecturers[e.RowIndex] = lect;
                                }
                                catch
                                {

                                    DataCollection.Instance.Insert(lect, e.RowIndex);
                                }

                            }
                        }
                        break;

                    case 1:	//	Module DGV
                        dgv = dataSubTable;
                        if (dgv.Rows[e.RowIndex].Cells[0].Value != null &&
                            dgv.Rows[e.RowIndex].Cells[1].Value != null &&
                            dgv.Rows[e.RowIndex].Cells[2].Value != null &&
                            dgv.Rows[e.RowIndex].Cells[3].Value != null)
                        {
                            String subject = dgv.Rows[e.RowIndex].Cells[0].Value.ToString();
                            String label = dgv.Rows[e.RowIndex].Cells[1].Value.ToString();
                            String courseLevel = dgv.Rows[e.RowIndex].Cells[2].Value.ToString();
                            Color colour = dgv.Rows[e.RowIndex].Cells[3].Style.BackColor;
                            Module mod = new Module(subject, label, courseLevel, colour);
                            if (!loading)
                            {
                                try
                                {
                                    DataCollection.Instance.Modules[e.RowIndex] = mod;
                                }
                                catch
                                {

                                    DataCollection.Instance.Insert(mod, e.RowIndex);
                                }

                            }
                        }
                        break;

                    case 2:	//	Room DGV
                        dgv = dataRoomTable;
                        if (dgv.Rows[e.RowIndex].Cells[0].Value != null &&
                           dgv.Rows[e.RowIndex].Cells[1].Value != null &&
                           dgv.Rows[e.RowIndex].Cells[2].Value != null &&
                           dgv.Rows[e.RowIndex].Cells[8].Value != null)
                        {
                            String name = dgv.Rows[e.RowIndex].Cells[0].Value.ToString();
                            String label = dgv.Rows[e.RowIndex].Cells[1].Value.ToString();
                            String sCap = dgv.Rows[e.RowIndex].Cells[2].Value.ToString();
                            Color colour = dgv.Rows[e.RowIndex].Cells[8].Style.BackColor;
                            int capacity;
                            try
                            {
                                capacity = int.Parse(sCap);
                            }
                            catch
                            {
                                return;
                            }
                            Room room = new Room(name, label, colour, capacity);
                            room.SetEquipment(0, dgv.Rows[e.RowIndex].Cells[3].Value != null ? true : false);
                            room.SetEquipment(1, dgv.Rows[e.RowIndex].Cells[4].Value != null ? true : false);
                            room.SetEquipment(2, dgv.Rows[e.RowIndex].Cells[5].Value != null ? true : false);
                            room.SetEquipment(3, dgv.Rows[e.RowIndex].Cells[6].Value != null ? true : false);
                            room.SetEquipment(4, dgv.Rows[e.RowIndex].Cells[7].Value != null ? true : false);
                            if (!loading)
                            {
                                try
                                {
                                    DataCollection.Instance.Rooms[e.RowIndex] = room;
                                }
                                catch
                                {

                                    DataCollection.Instance.Insert(room, e.RowIndex);
                                }

                            }
                        }
                        break;

                    case 3:	//	Group DGV
                        dgv = dataClassTable;
                        if (dgv.Rows[e.RowIndex].Cells[0].Value != null &&
                          dgv.Rows[e.RowIndex].Cells[1].Value != null &&
                          dgv.Rows[e.RowIndex].Cells[2].Value != null &&
                          dgv.Rows[e.RowIndex].Cells[3].Value != null)
                        {
                            string group = dgv.Rows[e.RowIndex].Cells[0].Value.ToString();
                            string label = dgv.Rows[e.RowIndex].Cells[1].Value.ToString();
                            string sStudents = dgv.Rows[e.RowIndex].Cells[2].Value.ToString();
                            Color colour = dgv.Rows[e.RowIndex].Cells[3].Style.BackColor;
                            int numStudents;
                            try
                            {
                                numStudents = int.Parse(sStudents);
                            }
                            catch
                            {
                                return;
                            }
                            Group grp = new Group(group, label, colour, numStudents);
                            if (!loading)
                            {
                                try
                                {
                                    DataCollection.Instance.Groups[e.RowIndex] = grp;
                                }
                                catch
                                {

                                    DataCollection.Instance.Insert(grp, e.RowIndex);
                                }

                            }
                        }
                        break;
                    default:
                        break;
                }
                FormMain main = (FormMain)(this.MdiParent);
                main.populateTab();
                main.populateViewMenu();
            }
        }
コード例 #6
0
ファイル: DataCollection.cs プロジェクト: GeoffNukem/CWA-TMS
 /// <summary>
 /// Add Lecturer
 /// </summary>
 /// <param name="lecturer">Lecturer instance to add into list</param>
 public void Add(Lecturer lecturer)
 {
     Lecturers.Add(lecturer);
 }
コード例 #7
0
ファイル: DataCollection.cs プロジェクト: GeoffNukem/CWA-TMS
 public void Remove(Lecturer lecturer)
 {
     if (Lecturers.Contains(lecturer))
         Lecturers.Remove(lecturer);
 }
コード例 #8
0
ファイル: DataCollection.cs プロジェクト: GeoffNukem/CWA-TMS
 /// <summary>
 /// Insert Lecturer into the list at a specific Index
 /// </summary>
 /// <param name="lecturer"></param>
 /// <param name="index"></param>
 public void Insert(Lecturer lecturer, int index)
 {
     Lecturers.Insert(index, lecturer);
 }