Ejemplo n.º 1
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();
            }
        }
Ejemplo n.º 2
0
 private void viewEnrolledStdsClick(object sender, EventArgs e)
 {
     if (facSch.SelectedRows.Count == 0)
     {
         MessageBox.Show("Select a class from the schedule list",
                         "No class selected",
                         MessageBoxButtons.OK,
                         MessageBoxIcon.Error);
     }
     else
     {
         string crsID = facSch.SelectedRows[0].Cells["Course ID"].Value.ToString();
         course crs   = crsDB.getCourse(crsID);
         new admEnrolledStd(crs).Show();
     }
 }
Ejemplo n.º 3
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;
                 }
             }
         }
     }
 }
Ejemplo n.º 4
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;
         }
     }
 }
Ejemplo n.º 5
0
        // Event handlers
        private void addCrsClick(object sender, EventArgs e)
        {
            int count = addCrsLst.Count;

            if (count == 0)
            {
                MessageBox.Show("Select classes",
                                "No class selected",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
            else
            {
                foreach (string crsID in addCrsLst)
                {
                    Dictionary <string, float> gradeDict = new Dictionary <string, float>()
                    {
                        { "A", 4.0f },
                        { "A-", 3.7f },
                        { "B+", 3.3f },
                        { "B", 3.0f },
                        { "B-", 2.7f },
                        { "C+", 2.3f },
                        { "C", 2.0f },
                        { "C-", 1.7f },
                        { "D+", 1.3f },
                        { "D", 1.0f },
                        { "D-", 0.7f }
                    };
                    course        crs       = crsDB.getCourse(crsID);
                    bool          preReq    = true;
                    List <string> preReqLst = crs.preReqLst;
                    foreach (string courseID in preReqLst)
                    {
                        bool temp = false;
                        foreach (previousCourse pcrs in std.pastCrs)
                        {
                            if (courseID == pcrs.crsID.Substring(0, courseID.Length) && gradeDict.ContainsKey(pcrs.grade))
                            {
                                temp = true;
                                break;
                            }
                        }
                        if (!temp)
                        {
                            foreach (previousCourse pcrs in std.currentCrs)
                            {
                                if (courseID == pcrs.crsID.Substring(0, courseID.Length))
                                {
                                    temp = true;
                                    break;
                                }
                            }
                            if (!temp)
                            {
                                preReq = false;
                                break;
                            }
                        }
                    }
                    if (!preReq)
                    {
                        MessageBox.Show("You're missing prerequisites.", "Requirement", MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                        return;
                    }
                    validity v = std.isValidAdd(crs);
                    if (v.valid)
                    {
                        if (v.warning)
                        {
                            MessageBox.Show(crsID + "\n" + v.message, "Warning",
                                            MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                        // Add the course to the student
                        usrDB.addCrsToStd(crsID, "S15", ref crsDB, std);

                        // Update the course list and student schedule
                        foreach (DataGridViewRow row in crsLst.Rows)
                        {
                            if (row.Cells["Course ID"].Value.ToString().ToString() == crsID)
                            {
                                if (row.Visible)
                                {
                                    crs = crsDB.getCourse(crsID);
                                    row.Cells["Seats"].Value = crs.seats + " / " + crs.maxSeats;
                                    DataTable table = (DataTable)stdSch.DataSource;
                                    table.Rows.Add(crs.crsID, crs.title, crs.instructor, crs.credit, crs.getBlocks());
                                    break;
                                }
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show(crsID + "\n" + v.message + "\n" + "The course was not added.", "Invalid add",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                        continue;
                    }
                }

                crsLst.AutoSizeColumnsMode       = DataGridViewAutoSizeColumnsMode.None;
                crsLst.AutoSizeColumnsMode       = DataGridViewAutoSizeColumnsMode.AllCells;
                crsLst.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
                int width = crsLst.Columns["Schedule"].GetPreferredWidth(DataGridViewAutoSizeColumnMode.AllCells, true);
                crsLst.Columns["Schedule"].AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
                crsLst.AutoSizeRowsMode          = DataGridViewAutoSizeRowsMode.DisplayedCells;
                crsLst.Columns["Schedule"].Width = width;

                crsLst.ClearSelection();
                for (int i = 0; i < crsLst.Rows.Count; i++)
                {
                    crsLst.Rows[i].Cells["Add"].Value = null;
                }
                addCrsLst.Clear();
                MessageBox.Show("The process completed.",
                                "Done",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
            }
        }