Exemplo n.º 1
0
        // Construct the database and update it
        public courseDatabase(ref userDatabase userDB)
        {
            this.crsLst = new List <course>();
            string line;

            System.IO.StreamReader input = new System.IO.StreamReader(@"..\..\courseDB.in");
            while ((line = input.ReadLine()) != null)
            {
                string        code            = line.Substring(0, 10).Trim();
                string        title           = line.Substring(11, 15).Trim();
                string        instructor      = line.Substring(27, 10).Trim().ToLower();
                string        credit          = line.Substring(38, 4).Trim();
                int           seats           = Convert.ToInt32(line.Substring(43, 3).Trim());
                int           num_time_blocks = int.Parse(line.Substring(47, 1).Trim());
                int           index           = 49;
                List <string> BlockLst        = new List <string>();
                for (int i = 0; i < num_time_blocks; i++)
                {
                    string time_block = line.Substring(index, 5);
                    BlockLst.Add(time_block);
                    index += 6;
                }
                course crs = new course(code, title, instructor, credit, seats, num_time_blocks, BlockLst);
                crsLst.Add(crs);
                faculty courseFac = userDB.getFaculty(instructor.Trim());
                courseFac.nextSemesterCourses.Add(crs);
            }
            input.Close();
        }
Exemplo n.º 2
0
        public facMainpage(string username, userDatabase usrDB, courseDatabase crsDB)
        {
            InitializeComponent();
            this.usrDB = usrDB;
            this.crsDB = crsDB;
            fac        = usrDB.getFaculty(username);

            // Change texts
            welcome.Text += fac.fname + " " + fac.lname;

            // Create all the tables
            createCrsLst();
            createFacSch();
            createAdviseeLst();

            // Auto complete
            foreach (course crs in crsDB.getCourseList())
            {
                crsIDBox.AutoCompleteCustomSource.Add(crs.crsID);
            }

            // Clear selection of tables
            facSch.ClearSelection();
            adviseeLst.ClearSelection();
        }
Exemplo n.º 3
0
        // Change the database
        public void removeCrs(string crsID, string filepath, ref userDatabase usrDB)
        {
            // Remove the course from the offering
            course removedCrs = getCourse(crsID);

            crsLst.Remove(removedCrs);

            // Remove the course from students' schedule
            List <student> enrolledStdLst = removedCrs.getStudents();

            foreach (student std in enrolledStdLst)
            {
                std.dropCrsFromNext(removedCrs);
            }

            // Remove the course from faculties' schedule
            faculty fac = usrDB.getFaculty(removedCrs.instructor);

            fac.removeCrsFromNext(removedCrs);

            ////Updates the coursedb.in file to remove the removed course from it
            //string[] courseLines = File.ReadAllLines(filepath);
            //string[] newCourseLinesArr;
            //List<string> newCourseLines = new List<string>();
            //foreach (string courseString in courseLines)
            //{
            //    string courseID = courseString.Substring(0, 10).Trim();
            //    //string courseID = courseString.Substring(4, 10);
            //    if (courseID == removedCrs.crsID.Trim())
            //        continue;   // Skip the iteration if the course is being deleted
            //    else
            //        newCourseLines.Add(courseString);

            //    newCourseLinesArr = newCourseLines.ToArray();
            //    File.WriteAllLines(filepath, newCourseLinesArr);
            //}
        }