Esempio n. 1
0
 public static void RemoveStudentfromCourse(UserStudent S, Course C)
 {
     MessageBox.Show("Removing " + S.UserName + " from " + C.CourseName + " .");
     C.RemoveStudent(S);
     S.MyCourses.Remove(C.CourseName);
     MessageBox.Show("You are no longer registered for " + C.CourseName + " .");
 }
Esempio n. 2
0
        private void ActualRegButton_Click(object sender, EventArgs e)
        {
            if (state == adminstate.student)
            {
                if (studstate == studentstate.salcourses)
                {
                    thisCourse = Courses[dataGridView2.SelectedRows[0].Index];
                    benutil.AddStudenttoCourse(asthisstudent, thisCourse, admin);
                }

                if (studstate == studentstate.sadvisor)
                {
                    asthisstudent.Advisor = FacultyList[dataGridView2.SelectedRows[0].Index].UserName;
                    ActualRegButton.Hide();
                    dataGridView2.Hide();
                    IVS();
                }
            }
            if (state == adminstate.crs)
            {
                newNames.Add(FacultyList[dataGridView2.SelectedRows[0].Index].UserName);
                cadst = courseadminstate.credits;
                this.Text = "Changing a course.";
                DetailBox.Text = thisCourse.CourseName + "is worth " + thisCourse.credits + " credits.";
                showDetail();
                TrueNo.Show();
                dataGridView2.Hide();
                ActualRegButton.Hide();
                FastRegButton.Hide();
            }
        }
Esempio n. 3
0
 public static void AddStudenttoCourse(UserStudent S, Course C)
 {
     if (C.AddStudent(S))
     {
         S.MyCourses.Add(C.CourseName);
         MessageBox.Show("You've successfully registered for " + C.CourseName + " .");
     }
     else
     {
         if (C.Students >= C.Seats)
             MessageBox.Show("Class is Full!");
         if (S.MyCourses.Contains(C.CourseName))
             MessageBox.Show("You've Already Registered for this Course!");
     }
 }
Esempio n. 4
0
        public CourseParseForm(List<Course> C, List<UserAdmin> ad, List<UserFaculty> fac, List<UserStudent> std)
        {
            InitializeComponent();
            Courses = C;
            A = ad;
            F = fac;
            S = std;
            UserAdmin a = new UserAdmin("Automated","*****","B","P","B");
            try
            {
                filereader = new StreamReader("ClassInput.txt");

                line = filereader.ReadLine();
                while (line != null)
                {
                    List<String> timeblocks = new List<string>();
                    cName.Text = line.Substring(0, 11).Trim();
                    cTitle.Text = line.Substring(11, 16).Trim();
                    cInst.Text = line.Substring(27, 11).Trim();
                    cCred.Text = line.Substring(38, 5).Trim();
                    cSeat.Text = line.Substring(43, 4).Trim();
                    cNumTimes.Text = line.Substring(47, 2).Trim();
                    string timeline = line.Substring(49).Trim();
                    int numTimes = Convert.ToInt16(cNumTimes.Text);

                    for (int i = 0; i < numTimes; i++)
                    {
                        int begin = (0 + (i * 6)); //changed
                                        // Needed to add one for the space
                        timeblocks.Add(timeline.Substring(begin, 5));
                        //MessageBox.Show(cName.Text + " " + timeblocks[i]);
                    }

                    Course myCourse = new Course(cName.Text, cTitle.Text, cInst.Text,
                        Convert.ToDouble(cCred.Text), Convert.ToInt16(cSeat.Text), timeblocks);
                    Courses.Add(myCourse);

                    //MessageBox.Show("There are " + Courses.Count + " Courses.");

                    line = filereader.ReadLine();
                }
                filereader.Close();
                //MessageBox.Show("File is now complete.");

            }
            catch
            {
                //MessageBox.Show("There was an Error");
            }

            try
            {
                filereader = new StreamReader("HistoryInput.txt");
                line = filereader.ReadLine();
                int times;
                string name;
                string title;
                string term;
                double credit;
                string grade;

                while (line != null)
                {
                    bool studentfound = false;
                    name = line.Substring(0, 11).Trim();

                    UserStudent stud = new UserStudent();
                    foreach(UserStudent st in S)
                    {
                        if (name == st.UserName)
                        {
                            stud = st;
                            studentfound = true;
                            break;
                        }
                    }
                    if (!studentfound)
                    {
                        line = filereader.ReadLine();
                        continue;
                    }

                    times = int.Parse(line.Substring(11, 2).Trim());
                    int x = 13;
                    for (int i = 0; i < times; i++)
                    {
                        title = line.Substring(x, 11).Trim();
                        x += 11;
                        term = line.Substring(x, 4).Trim();
                        x += 4;
                        credit = double.Parse(line.Substring(x, 5));
                        x += 5;
                        grade = line.Substring(x, 4).Trim();
                        x += 4;

               //                     <user-name:10>S<num-courses:2>S
               // <course-name-1:10>S<term-1:3>S<course-credit-1:4>S<grade-1:3>…
               //S<course-name-N:10>S<term-N:3>S<course-credit-N:4>S<grade-N:3>

                        if (term == "S13")
                        {
                            foreach (Course Cn in Courses)
                            {
                                if (Cn.CourseName == title)
                                {
                                    benutil.AddStudenttoCourse(stud, Cn, a);
                                }
                            }

                        }
                        else
                        {
                            PastCourse pst = new PastCourse(term, title, grade, credit);
                            stud.MyPastCourses.Add(pst);
                        }
                    }
                    line = filereader.ReadLine();
                }
                //MessageBox.Show("Complete");
            }
            catch (EndOfStreamException)
            { }

            try
            {

            }
            catch (EndOfStreamException)
            { }

            LoginForm lgn = new LoginForm(A, F, S, C);
            if (lgn.ShowDialog() == DialogResult.OK)
            {
                Application.Run(new LoginForm(A, F, S, C));

            }
                this.Close();
        }
Esempio n. 5
0
        /// <summary>
        /// Returns true if there exists a conflict between the two courses and false otherwise.
        /// </summary>
        /// <param name="C">The course to compare meetings to.</param>
        /// <returns></returns>
        public bool checkConflict(Course C)
        {
            foreach (Meeting Mn in Meetings)
            {
                foreach (Char dayn in Mn.days)
                {
                    foreach (Meeting Mx in C.Meetings)
                    {
                        foreach (Char dayx in Mx.days)
                        {
                            if (dayx == dayn)
                            {
                                int t1 = int.Parse(Mn.ddttk.Substring(2));
                                int t2 = int.Parse(Mx.ddttk.Substring(2));
                                if (t1 == t2) //Does this course meet at exactly the same time
                                //on this day? If so: conflict.
                                {
                                    return true;
                                }

                                int tt1a = (t1 / 10);
                                int tt1b = (t1 / 10) + t1 % 10;
                                int tt2 = (t2 / 10);
                                if ((tt2 > tt1a) && (tt2 < tt1b))
                                {
                                    //Does C start inside Course's time on this day? If so: conflict.
                                    return true;
                                }

                                int tt2a = tt2;
                                int tt2b = tt2 + t2 % 10;
                                int tt1 = tt1a;
                                if ((tt1 > tt2a) && (tt1 < tt2b))
                                    //Does This course start inside C's time on this day? If so: conflict.
                                {
                                    return true;
                                }

                            }
                        }
                    }
                }
            }

            return false;
        }
Esempio n. 6
0
        private void killButton_Click(object sender, EventArgs e)
        {
            if (state == adminstate.student)
            {
                studstate = studentstate.skill;
                button1.Enabled = false;
                AdvisorButton.Enabled = false;
                int studentindex = dataGridView1.SelectedRows[0].Index;
                YesButton.Text = "Yes";
                NoButton.Text = "No";
                showDetail();
                DetailBox.Text = "Delete " + StudentList[studentindex].UserName + "?";
            }
            if (state == adminstate.faculty)
            {
                button1.Enabled = false;
                AdvisorButton.Enabled = false;
                asthisfaculty = FacultyList[dataGridView1.SelectedRows[0].Index];
                DetailBox.Text = "Delete " + asthisfaculty.UserName + "?";
                YesButton.Text = "Yes";
                NoButton.Text = "No";
                showDetail();

            }

            if (state == adminstate.crs)
            {
                button1.Enabled = false;
                AdvisorButton.Enabled = false;
                thisCourse = Courses[dataGridView1.SelectedRows[0].Index];
                DetailBox.Text = "Delete " + thisCourse.CourseTitle + "?";
                YesButton.Text = "Yes";
                NoButton.Text = "No";
                showDetail();
            }
        }
Esempio n. 7
0
        private void button1_Click(object sender, EventArgs e)
        {
            switch (state)
            {

                case adminstate.dflt: { } break; //Do nothing.
                case adminstate.student:
                    if (studstate == studentstate.sviewall)
                    {
                        asthisstudent = StudentList[dataGridView1.SelectedRows[0].Index];
                        //MessageBox.Show("Student : " + asthisstudent.FirstName + " " + asthisstudent.LastName);
                        studstate = studentstate.ssched;
                        this.Text = "View/Change " + asthisstudent.UserName + "'s course schedule.";
                        List<Course> StdCrs = new List<Course>();
                        foreach (Course C in Courses)
                        {
                            if (asthisstudent.MyCourses.Contains(C.CourseName))
                            {
                                StdCrs.Add(C);
                            }
                        }
                        dataGridView1.DataSource = StdCrs;
                        AdvisorButton.Hide();
                        button1.Text = "Student List";
                        FastRegButton.Text = "View all courses";
                        FastRegButton.Show();
                    }
                    else
                    {
                        //state = adminstate.dflt;
                        //AdvisorButton.Show();
                        //MessageBox.Show("State 2b");
                        IVS();

                    }
                    break;
                case adminstate.faculty:
                    {
                        asthisfaculty = FacultyList[dataGridView1.SelectedRows[0].Index];
                        List<String> myCrsStringList = asthisfaculty.MyClasses;

                        foreach (Course c in Courses)
                        {
                            if (c.Instructor == asthisfaculty.UserName)
                            {
                                facCourse.Add(c);
                            }
                        }
                        dataGridView2.DataSource = facCourse;
                        dataGridView2.Show();
                    }
                    break;
                case adminstate.crs:
                    {
                        newNames = new List<String>(); //This prevents a hilarious error.
                        cadst = courseadminstate.name;
                        thisCourse = Courses[dataGridView1.SelectedRows[0].Index];
                        DetailBox.Text = "Course Name = " + thisCourse.CourseName + ".";
                        YesButton.Text = "Change?";
                        NoButton.Text = "Cancel Changes";
                        TrueNo.Show();
                        showDetail();
                    }
                    break;
                default: //MessageBox.Show("CASE 3");
                    break;
            }
        }
Esempio n. 8
0
 public static void AddStudenttoCourse(UserStudent S, Course C, UserAdmin Me)
 {
     C.AddStudent(S, Me);
 }
Esempio n. 9
0
        public bool checkConflict(Course C)
        {
            foreach (Meeting meet in Meetings)
            {
                foreach (Meeting meet2 in C.Meetings)
                {
                    foreach (char day in meet.days)

                    {
                        if (meet2.days.Contains(day))
                        {
                            int start1 = int.Parse(meet.time.Substring(2, 2));
                            int end1 = start1 + int.Parse(meet.time.Substring(4));
                            int start2 = int.Parse(meet2.time.Substring(2, 2));
                            int end2 = start1 + int.Parse(meet2.time.Substring(4));
                            if (((start1 <= start2) && (end1 > start2)) || ((start2 <= start1) && (end2 > start1)))
                                return true;
                        }
                    }
                }
            }
            return false;
        }