/// <summary>
        /// I should write a method which will save room name, then pick up these room name from roomList and make a selection if the room name is equal to another room name which is picked up from the TTTList, then update information for this room.
        ///
        /// </summary>
        /// <param name="newRoom"></param>
        ///

        public void collectTTTInfo(Room newRoom)
        {
            int TTTPosition = 0, roomListPosition = 0;

            //every time, the system will read "room.xml" which only includes a room name.

            SavingAndReading data = new SavingAndReading();

            data.ReadRoomFile("room.xml");

            foreach (Room e1 in SystemList.RoomsList)
            {
                //termTimetableList size is fixed, if doesnot initialize the TTTPosition,
                //then the TTTPosition will greater than the size of termTimetable
                TTTPosition = 0;
                foreach (WebpageTermTimetable e2 in SystemList.TermTimetableList)
                {
                    if (e1.RoomName == e2.RoomName)
                    {
                        SystemList.RoomsList[roomListPosition].TtDimensionArray[e2.Day][e2.StartHour - 9].HasSubject         = true;
                        SystemList.RoomsList[roomListPosition].TtDimensionArray[e2.Day][e2.StartHour - 9].TermTTListPosition = TTTPosition;
                    }
                    TTTPosition++;
                }
                roomListPosition++;
            }

            data.WriteRoomFile();
        }
        private void displayListView(int tabPage)
        {
            SavingAndReading data = new SavingAndReading();

            //data.ReadSystemList();
            //displayStudentListView();
            //displayLecturerListView();
            switch (tabPage)
            {
            case 0:
                data.ReadStudentFile();
                displayStudentListView();
                break;

            case 1:
                data.ReadLecturerFile();
                displayLecturerListView();
                break;

            case 2:
                data.ReadRoomFile(data.RoomFilename);
                displayRoomListView();
                break;
            }
        }
        private void lecturerListView_ItemActivate(object sender, EventArgs e)
        {
            SavingAndReading data = new SavingAndReading();

            data.ReadRoomFile(data.RoomFilename);
            data.ReadTermTimetableFile();
            data.ReadLecturerFile();


            removeControls();
            //collect the modules a lecuter is teaching
            var id = lecturerListView.SelectedItems[0].SubItems[0].Text;

            //List<Module> tempModuleList = new List<Module>();

            foreach (WebpageTermTimetable e1 in SystemList.TermTimetableList)
            {
                if (e1.LecturerID.ToString() == id)
                {
                    var moduleShortName = e1.ModuleShortName.Substring(3);
                    var roomName        = e1.RoomName;
                    var row             = e1.Day + 1;
                    var column          = e1.StartHour - 8;
                    var columnspan      = e1.EndHour - e1.StartHour;


                    Label newLabel = new Label();
                    newLabel.Dock      = DockStyle.Fill;
                    newLabel.Text      = roomName + "\n" + moduleShortName + "\n";
                    newLabel.TextAlign = ContentAlignment.MiddleCenter;
                    timetableLayoutPanel.Controls.Add(newLabel);
                    timetableLayoutPanel.SetCellPosition(newLabel, new TableLayoutPanelCellPosition(column, row));

                    if (columnspan > 1)
                    {
                        timetableLayoutPanel.SetColumnSpan(newLabel, columnspan);
                    }
                }
            }
        }
Exemple #4
0
        public void produceRoomTimetable()
        {
            int position = 0, hour = 1, count = 0;
            //string moduleFullName, moduleShortName, roomName, lecturerName = "", startPosition, endPosition;
            WebpageTermTimetable ttDetails = new WebpageTermTimetable();

            SavingAndReading data          = new SavingAndReading();
            //data.ReadSystemList();

            string docName = "TimetableTemplate.xlsx";
            //var workbook = new XLWorkbook(docName);
            //var ws = workbook.Worksheet(1);

            List <Room> tempRoomList = new List <Room>();

            data.ReadRoomFile("room.xml");
            tempRoomList = SystemList.RoomsList;
            data.ReadSystemList();



            //start to select each object from roomsList and print details
            foreach (Room e1 in SystemList.RoomsList)
            {
                var workbook = new XLWorkbook(docName);
                var ws       = workbook.Worksheet(1);
                //if (e1.RoomName == tempRoomList[count].RoomName)
                {
                    subHeader = e1.RoomName;

                    for (int i = 0; i < 5; i++)
                    {
                        for (int j = 0; j < 9; j++)
                        {
                            if (e1.TtDimensionArray[i][j].HasSubject == true)
                            {
                                position  = e1.TtDimensionArray[i][j].TermTTListPosition;
                                ttDetails = SystemList.TermTimetableList[position];

                                var moduleFullName  = ttDetails.ModuleFullName;
                                var moduleShortName = ttDetails.ModuleShortName;
                                var roomName        = ttDetails.RoomName;
                                var lecturerName    = findLecturerName(ttDetails.LecturerID);
                                hour = ttDetails.EndHour - ttDetails.StartHour;
                                //start inserting details for each timetable


                                //ProduceTT ptt = new ProduceTT();

                                //change the subHeader
                                insertTextToSubHeader(roomName, ws);

                                var startPosition = string.Format("{0}{1}", (char)(j + 66), (i + 4));
                                var endPosition   = string.Format("{0}{1}", (char)(j + 66 + hour - 1), (i + 4));
                                //if a module over one hour then merge the cells
                                if (hour > 1)
                                {
                                    mergeCells(startPosition, endPosition, ws);

                                    insertDetailsToCells(moduleFullName, moduleShortName, lecturerName, ws, startPosition, endPosition);
                                }
                                else
                                {
                                    insertDetailsToCells(moduleFullName, moduleShortName, lecturerName, ws, startPosition, endPosition);
                                }
                            }
                        }
                        createFolder();
                        string path = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Timetable System");

                        workbook.SaveAs(path + "\\Timetable\\" + e1.RoomName + ".xlsx");
                    }
                    colorSelectionList.Clear();
                    count++;
                }
            }
        }
        private void roomListView_ItemActivate(object sender, EventArgs e)
        {
            SavingAndReading data = new SavingAndReading();

            data.ReadRoomFile(data.RoomFilename);
            data.ReadTermTimetableFile();
            data.ReadLecturerFile();



            Room newRoom = new Room();

            newRoom.RoomName = roomListView.SelectedItems[0].SubItems[0].Text;
            //timetableLayoutPanel.Controls.Clear();
            removeControls();
            //drawingTimetable();
            foreach (Room e1 in SystemList.RoomsList)
            {
                if (e1.RoomName == newRoom.RoomName)
                {
                    for (int i = 0; i < 5; i++)
                    {
                        for (int j = 0; j < 9; j++)
                        {
                            if (e1.TtDimensionArray[i][j].HasSubject == true)
                            {
                                var position  = e1.TtDimensionArray[i][j].TermTTListPosition;
                                var ttDetails = SystemList.TermTimetableList[position];

                                var moduleFullName  = ttDetails.ModuleFullName;
                                var moduleShortName = ttDetails.ModuleShortName.Substring(3, ttDetails.ModuleShortName.Count() - 3);
                                var roomName        = ttDetails.RoomName;
                                var lecturerName    = findLecturerName(ttDetails.LecturerID);
                                var row             = ttDetails.Day + 1;
                                var column          = ttDetails.StartHour - 8;
                                var columnspan      = ttDetails.EndHour - ttDetails.StartHour;

                                Label newLabel = new Label();
                                newLabel.Dock      = DockStyle.Fill;
                                newLabel.Text      = newRoom.RoomName + "\n" + moduleShortName + "\n" + lecturerName;
                                newLabel.TextAlign = ContentAlignment.MiddleCenter;
                                timetableLayoutPanel.Controls.Add(newLabel);
                                timetableLayoutPanel.SetCellPosition(newLabel, new TableLayoutPanelCellPosition(column, row));

                                if (columnspan > 1)
                                {
                                    timetableLayoutPanel.SetColumnSpan(newLabel, columnspan);
                                }
                            }
                        }
                    }
                }
            }

            //Label newLabel = new Label();
            //newLabel.Dock = DockStyle.Fill;
            //newLabel.Text = newRoom.RoomName;
            //timetableLayoutPanel.Controls.Add(newLabel);
            //timetableLayoutPanel.SetCellPosition(newLabel, new TableLayoutPanelCellPosition(1, 1));
            //timetableLayoutPanel.SetColumnSpan(newLabel, 2);


            //timetableLayoutPanel.Controls.Add(new Label() {Text = "asdf", Dock = DockStyle.Fill  }, 1,1);
            //timetableLayoutPanel.GetCellPosition;
            //timetableLayoutPanel.GetCellPosition()
        }