예제 #1
0
        private void open_from_file() //reads any course info that is already entered into the list and listview
        {
            using (var file = new System.IO.StreamReader(@"saves\StudentClassInfo.txt"))
            {
                string line;

                while ((line = file.ReadLine()) != null)
                {
                    Classinfo course = new Classinfo();

                    course.Classname = line;
                    line             = file.ReadLine();
                    course.Profname  = line;
                    line             = file.ReadLine();
                    course.Profemail = line;
                    line             = file.ReadLine();
                    course.Time      = line;
                    line             = file.ReadLine();
                    course.Classdays = line;

                    viewClassList.Items.Add(course);
                    MyClasses.Add(course);
                }
                file.Close();
            }
        }
예제 #2
0
        public override Classinfo Class_build(string className, string profName, string profEmail, string time, string classDays)
        {
            Classinfo course = new Classinfo();

            course.Classname = className;
            course.Profname  = profName;
            course.Profemail = profEmail;
            course.Time      = time;
            course.Classdays = classDays;

            return(course);
        }
예제 #3
0
        private void delete_Click(object sender, RoutedEventArgs e) //when clicked, deletes the class the user has selected
        {
            if (viewClassList.SelectedItems.Count == 0)             //makes sure something is selected, avoiding null case
            {
                MessageBox.Show("Nothing Selected");
                return;
            }

            Classinfo course = (Classinfo)viewClassList.SelectedItems[0];

            MessageBoxResult result = MessageBox.Show("Are you sure you want to remove " + course.Classname + " from your schedule? (This will remove all assignments associated with this class once changes are saved.)", "Important Message", MessageBoxButton.OKCancel);

            if (result == MessageBoxResult.Cancel)
            {
                return;
            }
            //after assignments have been fixed up, this function needs to loop through the file where assignments are saved and delete any assocaiated with the selected class
            MyClasses.Remove(course);
            viewClassList.Items.Remove(course);
        }
예제 #4
0
        public void addclass_Click(object sender, RoutedEventArgs e) //reads what the user has typed into the textboxes and saves them to the list while adding them to the listview
        {
            Builder build = new Info_Builder();

            if (className.Text == "" || profName.Text == "")
            {
                MessageBox.Show("Required field left blank.");
                return;
            }

            if (profEmail.Text == "")
            {
                profEmail.Text = "-";
            }

            if (HourBox.Text == "")
            {
                HourBox.Text   = "-";
                MinuteBox.Text = "--";
            }
            else if (MinuteBox.Text == "")
            {
                MinuteBox.Text = "00";
            }

            string time = HourBox.Text + ":" + MinuteBox.Text + " " + TimeBox.Text;
            string days = "";

            if (Monday.IsChecked ?? false)
            {
                days += "M ";
            }
            if (Tuesday.IsChecked ?? false)
            {
                days += "T ";
            }
            if (Wednesday.IsChecked ?? false)
            {
                days += "W ";
            }
            if (Thursday.IsChecked ?? false)
            {
                days += "R ";
            }
            if (Friday.IsChecked ?? false)
            {
                days += "F ";
            }

            Classinfo course = build.Class_build(className.Text, profName.Text, profEmail.Text, time, days);

            viewClassList.Items.Add(course);
            MyClasses.Add(course);

            className.Text      = "";
            profName.Text       = "";
            profEmail.Text      = "";
            HourBox.Text        = "";
            MinuteBox.Text      = "";
            TimeBox.Text        = "";
            addclass.Content    = "Add Class";
            Monday.IsChecked    = false;
            Tuesday.IsChecked   = false;
            Wednesday.IsChecked = false;
            Thursday.IsChecked  = false;
            Friday.IsChecked    = false;
        }
예제 #5
0
        private void edit_Click(object sender, RoutedEventArgs e) //allows the user to edit the course selected
        {
            if (viewClassList.SelectedItems.Count == 0)
            {
                MessageBox.Show("Nothing Selected");
                return;
            }

            MessageBox.Show("Save changes after they have been made.");

            addclass.Content = "Save Changes";

            Classinfo course = (Classinfo)viewClassList.SelectedItems[0];

            className.Text = course.Classname;
            profName.Text  = course.Profname;
            if (course.Profemail == "-")
            {
                profEmail.Text = "";
            }
            else
            {
                profEmail.Text = course.Profemail;
            }

            if (course.Time == "-:--")
            {
                HourBox.Text   = "";
                MinuteBox.Text = "";
                TimeBox.Text   = "";

                viewClassList.Items.Remove(course);
                MyClasses.Remove(course);

                return;
            }

            if (course.Classdays.Contains("M"))
            {
                Monday.IsChecked = true;
            }
            if (course.Classdays.Contains("T"))
            {
                Tuesday.IsChecked = true;
            }
            if (course.Classdays.Contains("W"))
            {
                Wednesday.IsChecked = true;
            }
            if (course.Classdays.Contains("R"))
            {
                Thursday.IsChecked = true;
            }
            if (course.Classdays.Contains("F"))
            {
                Friday.IsChecked = true;
            }

            int    count  = 0;
            string time   = course.Time;
            string hour   = "";
            string minute = "";

            foreach (char c in time)
            {
                count++;
                if (c != ':' && count < 3)
                {
                    hour += c;
                    time  = time.Remove(0, 1);
                }
            }
            time   = time.Remove(0, 1);
            minute = time.Substring(0, 2);
            time   = time.Remove(0, 3);

            HourBox.Text   = hour;
            MinuteBox.Text = minute;
            TimeBox.Text   = time;

            viewClassList.Items.Remove(course);
            MyClasses.Remove(course);
        }
예제 #6
0
        private void open_classes_file() //opens classes file to see the days the user has classes
        {
            using (var file = new System.IO.StreamReader(@"saves\StudentClassInfo.txt"))
            {
                string line;

                while ((line = file.ReadLine()) != null)
                {
                    Classinfo course = new Classinfo();

                    course.Classname = line;
                    line             = file.ReadLine();
                    course.Profname  = line;
                    line             = file.ReadLine();
                    course.Profemail = line;
                    line             = file.ReadLine();
                    course.Time      = line;
                    line             = file.ReadLine();
                    course.Classdays = line;

                    if (course.Classdays.Contains("T"))
                    {
                        Tuesday.Items.Add(course);
                    }
                    if (course.Classdays.Contains("W"))
                    {
                        Wednesday.Items.Add(course);
                    }
                    if (course.Classdays.Contains("M"))
                    {
                        Monday.Items.Add(course);
                    }
                    if (course.Classdays.Contains("F"))
                    {
                        Friday.Items.Add(course);
                    }
                    if (course.Classdays.Contains("R"))
                    {
                        Thursday.Items.Add(course);
                    }
                }

                if (Monday.Items.Count == 0)
                {
                    Assignment homework = new Assignment();
                    homework.ClassName = "No classes";
                    Monday.Items.Add(homework);
                }
                if (Tuesday.Items.Count == 0)
                {
                    Assignment homework = new Assignment();
                    homework.ClassName = "No classes";
                    Tuesday.Items.Add(homework);
                }
                if (Wednesday.Items.Count == 0)
                {
                    Assignment homework = new Assignment();
                    homework.ClassName = "No classes";
                    Wednesday.Items.Add(homework);
                }
                if (Thursday.Items.Count == 0)
                {
                    Assignment homework = new Assignment();
                    homework.ClassName = "No classes";
                    Thursday.Items.Add(homework);
                }
                if (Friday.Items.Count == 0)
                {
                    Assignment homework = new Assignment();
                    homework.ClassName = "No classes";
                    Friday.Items.Add(homework);
                }

                file.Close();
            }
        }