コード例 #1
0
        public void removeStd(string username, ref courseDatabase crsDB)
        {
            student std = getStudent(username);

            // Increment the number of seats available for each course the student has registered for
            List <course> registeredCrsLst = std.registeredCrs;

            foreach (course registeredCrs in registeredCrsLst)
            {
                foreach (course crs in crsDB.getCourseList())
                {
                    if (registeredCrs.crsID == crs.crsID)
                    {
                        crs.disenrollUser(std);
                        break;
                    }
                }
            }

            // Remove the student from the advisees list of his advisor
            faculty advisor = getFaculty(std.advisor);

            advisor.removeAdvisee(username);

            // Remove the student from the database
            stdLst.Remove(std);
        }
コード例 #2
0
        public stdMainpage(string username, userDatabase usrDB, courseDatabase crsDB)
        {
            // Store attributes
            InitializeComponent();
            this.crsDB = crsDB;
            this.usrDB = usrDB;
            std        = usrDB.getStudent(username);

            // Change texts
            welcome.Text += std.fname + " " + std.lname;
            gpa.Text     += " " + std.GPA;
            credits.Text += " " + std.totalCredits;

            // Create all the tables
            createCrsLst();
            createGradeHist();
            createStdSch();

            // Clear selections on tables
            gradeHist.ClearSelection();
            stdSch.ClearSelection();

            // Auto completion source
            foreach (course crs in crsDB.getCourseList())
            {
                crsIDBox.AutoCompleteCustomSource.Add(crs.crsID);
            }
        }
コード例 #3
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();
        }
コード例 #4
0
        public void addPrevCourses(ref courseDatabase crsDB, string nextSemester)
        {
            string line;

            System.IO.StreamReader input = new System.IO.StreamReader(@"..\..\historyDB.in");
            while ((line = input.ReadLine()) != null)
            {
                string username     = line.Substring(0, 10).Trim().ToLower(); // Needed ToLower()
                string courseNumStr = line.Substring(11, 2).Trim();
                int    courseNum    = int.Parse(courseNumStr);
                int    loc          = 14;

                student std = stdLst.Find(s => s.username.Trim() == username);

                for (int i = 0; i < courseNum; i++)
                {
                    string crsID = line.Substring(loc, 10).Trim();
                    loc += 11;
                    string semester = line.Substring(loc, 3).Trim();
                    loc += 4;
                    string creditStr = line.Substring(loc, 4).Trim();
                    float  credit    = float.Parse(creditStr);
                    loc += 4;
                    string grade;
                    if ((line.Length - loc) >= 3)
                    {
                        grade = line.Substring(loc, 3).Trim().ToString();
                    }
                    else
                    {
                        grade = line.Substring(loc).Trim().ToString();
                    }
                    loc += 5;
                    if (semester == nextSemester)
                    {
                        course crs = crsDB.getCourse(crsID);
                        std.addClassToNext(crs);
                        crs.enrollUser(std);
                    }
                    else if (semester == "F14")
                    {
                        previousCourse pcrs = new previousCourse(username, crsID, semester, credit, grade);
                        std.addClassToCurrent(pcrs);
                    }
                    else
                    {
                        previousCourse currentCourse = new previousCourse(username, crsID, semester, credit, grade);
                        std.addClassToPast(currentCourse);
                    }
                }
            }
            input.Close();
            foreach (student std in stdLst)
            {
                std.calculateGPA();
            }
        }
コード例 #5
0
 public void dropCrsFromStd(string courseID, ref courseDatabase courseDB, student currentStudent)
 {
     foreach (course crs in courseDB.getCourseList())
     {
         if (courseID.Trim() == crs.crsID.Trim())
         {
             currentStudent.dropCrsFromNext(crs);
             crs.disenrollUser(currentStudent);
             return;
         }
     }
 }
コード例 #6
0
 // Change the database
 //----------------------------------------
 public void addCrsToStd(string crsID, string nextSemester, ref courseDatabase crsDB, student currentStudent)
 {
     foreach (course crs in crsDB.getCourseList())
     {
         if (crsID.Trim() == crs.crsID.Trim())
         {
             course selectedCourse = crs;
             selectedCourse.enrollUser(currentStudent);
             course courseAdding = selectedCourse;
             currentStudent.addClassToNext(courseAdding);
             return;
         }
     }
 }
コード例 #7
0
 public void changeTime(string crsID, string instructor, courseDatabase crsDB)
 {
     foreach (faculty fac in facLst)
     {
         if (fac.username == instructor.Trim())
         {
             foreach (course crs in fac.nextSemesterCourses)
             {
                 if (crs.crsID.Trim() == crsID.Trim())
                 {
                     course curCrs = crsDB.getCourse(crsID);
                     crs.timeBlocks = curCrs.timeBlocks;
                 }
             }
         }
     }
 }
コード例 #8
0
        public admCreateCrs(courseDatabase crsDB, userDatabase usrDB)
        {
            InitializeComponent();
            this.crsDB = crsDB;
            this.usrDB = usrDB;


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

            foreach (faculty fac in usrDB.getFacultyList())
            {
                facDropDown.Items.Add(fac.fname + " " + fac.lname);
                facDropDown.AutoCompleteCustomSource.Add(fac.fname + " " + fac.lname);
            }
        }
コード例 #9
0
 // For changing courses. Needs a direct access to user database
 public void changeInstrutor(courseDatabase crsDB, string newInstructor, string oldInstructor, string crsID)
 {
     foreach (faculty fac in facLst)
     {
         bool newI = false;
         bool oldI = false;
         if (!newI)
         {
             if (fac.username.Trim() == newInstructor.Trim())
             {
                 course crs = crsDB.getCourse(crsID);
                 fac.nextSemesterCourses.Add(crs);
                 newI = true;
             }
         }
         if (!oldI)
         {
             if (fac.username.Trim() == oldInstructor.Trim())
             {
                 foreach (course crs in fac.nextSemesterCourses)
                 {
                     if (crs.crsID == crsID.Trim())
                     {
                         fac.nextSemesterCourses.Remove(crs);
                         oldI = true;
                         break;
                     }
                 }
             }
         }
         if (oldI && newI)
         {
             break;
         }
     }
 }
コード例 #10
0
ファイル: Login.cs プロジェクト: coebooker/runtimestuds
        private void loginClick(object sender, EventArgs e)
        {
            uname = username.Text.Trim().ToLower();
            utype = "student";
            string password = this.password.Text.Trim();

            if (usrDB.isValidUser(uname, password, ref utype))
            {
                Hide();
                if (utype == "admin" || utype == "manager")
                {
                    if (!flag)
                    {
                        var form = new admMainpage(usrDB, @"..\..\historyDB.in", utype);
                        form.ShowDialog();
                        usrDB = form.usrDB;
                        crsDB = form.crsDB;
                        usrDB.updateDatabase();
                    }
                    else
                    {
                        var form = new admMainpage(usrDB, crsDB, utype);
                        form.ShowDialog();
                        usrDB = form.usrDB;
                        crsDB = form.crsDB;
                    }
                }
                else
                {
                    if (utype == "faculty")
                    {
                        if (!flag)
                        {
                            var form = new facMainpage(uname, usrDB);
                            form.ShowDialog();
                            usrDB = form.usrDB;
                            crsDB = form.crsDB;
                        }
                        else
                        {
                            var form = new facMainpage(uname, usrDB, crsDB);
                            form.ShowDialog();
                            usrDB = form.usrDB;
                            crsDB = form.crsDB;
                        }
                    }
                    else
                    {
                        if (!flag)
                        {
                            var form = new stdMainpage(uname, usrDB);
                            form.ShowDialog();
                            usrDB = form.usrDB;
                            crsDB = form.crsDB;
                        }
                        else
                        {
                            var form = new stdMainpage(uname, usrDB, crsDB);
                            form.ShowDialog();
                            usrDB = form.usrDB;
                            crsDB = form.crsDB;
                        }
                    }
                }
                username.Text              = "Username";
                username.ForeColor         = Color.Silver;
                this.password.Text         = "Password";
                this.password.PasswordChar = '\0';
                this.password.ForeColor    = Color.Silver;

                flag = true;
                Show();
            }
            else
            {
                MessageBox.Show("Your username or password is incorrect.",
                                "Invalid Credential",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Question);
                this.password.Text         = "";
                this.password.PasswordChar = '*';
                this.password.ForeColor    = Color.White;
            }
        }