Example #1
0
 public void Room_Remove()
 {
     Room r = new Room("Network Lab", "Y106", Color.Blue, 20);
     DataCollection.Instance.Add(r);
     Assert.IsTrue(DataCollection.Instance.Rooms.Contains(r), "Rooms does not contain Room");
     DataCollection.Instance.Remove(r);
     Assert.IsFalse(DataCollection.Instance.Rooms.Contains(r), "Rooms still contains Room");
 }
Example #2
0
 public void Room_Constructor()
 {
     Room r = new Room("Network Lab", "Y106", Color.Blue, 20);
     Assert.AreEqual("Network Lab", r.Name);
     Assert.AreEqual("Y106", r.Label);
     Assert.AreEqual<Color>(Color.Blue, r.Colour);
     Assert.AreEqual<int>(20, r.Capacity);
 }
Example #3
0
 public void Room_GetterAndSetter()
 {
     Room r = new Room("", "", Color.Empty, 0);
     r.Name = "Y106";
     r.Label = "106";
     r.Colour = Color.Crimson;
     r.Capacity = 69;
     Assert.AreEqual("Y106", r.Name);
     Assert.AreEqual("106", r.Label);
     Assert.AreEqual<Color>(Color.Crimson, r.Colour);
     Assert.AreEqual<int>(69, r.Capacity);
 }
Example #4
0
        public void Room_Add()
        {
            Room r1 = new Room("Room1", "L1", Color.Blue, 20);
            Room r2 = new Room("Room2", "L2", Color.Blue, 19);
            Room r3 = new Room("Room3", "L3", Color.Blue, 17);

            DataCollection.Instance.Add(r1);
            DataCollection.Instance.Add(r2);
            DataCollection.Instance.Add(r3);

            DataCollection.Instance.Add(r1);
            Assert.AreEqual<Room>(r1, DataCollection.Instance.Rooms[0], "Room1 not found at 0");

            DataCollection.Instance.Add(r2);
            Assert.AreEqual<Room>(r2, DataCollection.Instance.Rooms[1], "Room2 not found at 1");

            DataCollection.Instance.Insert(r3, 1);
            Assert.AreEqual<Room>(r3, DataCollection.Instance.Rooms[1], "Room3 not found at 1");
            Assert.AreEqual<Room>(r2, DataCollection.Instance.Rooms[2], "Room2 not found at 2");
        }
Example #5
0
        public void LoadRooms()
        {
            m_reader = new XmlTextReader(m_fileName);
            XmlDocument xml = new XmlDocument();
            xml.Load(m_reader);
            XmlNodeList nodes = xml.GetElementsByTagName("Rooms");
            if ((nodes.Item(0).Attributes["Count"].Value.Equals("0")))
                return;

            foreach (XmlNode node in nodes.Item(0).ChildNodes)
            {
                String name = null;
                String label = null;
                int capacity = 0;
                Boolean lecturerPC = false;
                Boolean smartboard = false;
                Boolean tv = false;
                Boolean projector = false;
                Boolean networkLab = false;
                Color color = Color.Empty;

                foreach (XmlNode data in node.ChildNodes)
                {
                    try
                    {
                        if (data.Name.Equals(m_roomCols[0]))
                        {
                            name = data.InnerText;
                        }
                        else if (data.Name.Equals(m_roomCols[1]))
                        {
                            label = data.InnerText;
                        }
                        else if (data.Name.Equals(m_roomCols[2]))
                        {
                            capacity = int.Parse(data.InnerText);
                        }
                        else if (data.Name.Equals(m_roomCols[3]))
                        {
                            lecturerPC = Boolean.Parse(data.InnerText);
                        }
                        else if (data.Name.Equals(m_roomCols[4]))
                        {
                            smartboard = Boolean.Parse(data.InnerText);
                        }
                        else if (data.Name.Equals(m_roomCols[5]))
                        {
                            tv = Boolean.Parse(data.InnerText);
                        }
                        else if (data.Name.Equals(m_roomCols[6]))
                        {
                            projector = Boolean.Parse(data.InnerText);
                        }
                        else if (data.Name.Equals(m_roomCols[7]))
                        {
                            networkLab = Boolean.Parse(data.InnerText);
                        }
                        else if (data.Name.Equals(m_roomCols[8]))
                        {
                            color = Color.FromArgb(int.Parse(data.InnerText));
                        }

                        if (name != null && label != null && capacity != 0 && color != Color.Empty)
                        {
                            Room room = new Room(name, label, color, capacity);
                            room.SetEquipment(0, lecturerPC);
                            room.SetEquipment(1, smartboard);
                            room.SetEquipment(2, tv);
                            room.SetEquipment(3, projector);
                            room.SetEquipment(4, networkLab);
                            DataCollection.Instance.Add(room);
                        }
                    }
                    catch
                    {
                        return;
                    }
                }
            }
        }
Example #6
0
        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();
            }
        }
Example #7
0
 /// <summary>
 /// Add Room
 /// </summary>
 /// <param name="room">Room instance to add into list</param>
 public void Add(Room room)
 {
     Rooms.Add(room);
 }
Example #8
0
 public void Remove(Room room)
 {
     if (Rooms.Contains(room))
         Rooms.Remove(room);
 }
Example #9
0
 public void Insert(Room room, int index)
 {
     Rooms.Insert(index, room);
 }