示例#1
0
        public static bool FacultyOverlap(string facUser, string courseToCheck)
        {
            bool result = false;
            linqtoregdbDataContext db = new linqtoregdbDataContext();
            var queryFacTimes         = from usr in db.users
                                        join crs in db.courses
                                        on usr.userID equals crs.instructor
                                        join crstb in db.course_timeblocks
                                        on crs.courseID equals crstb.courseID
                                        where usr.username == facUser
                                        select crstb.timeblock;
            var queryNewCourseTimes = from crs in db.courses
                                      join crstb in db.course_timeblocks
                                      on crs.courseID equals crstb.courseID
                                      where crs.courseName == courseToCheck
                                      select crstb.timeblock;

            //MessageBox.Show(TimeCheck.convertTime(queryNewCourseTimes.ToList()));

            foreach (var c in queryFacTimes)
            {
                if (TimeCheck.overlaps(TimeCheck.convertTime(queryNewCourseTimes.ToList()), TimeCheck.convertTime(queryFacTimes.ToList())))
                {
                    result = true;
                }
            }
            return(result);
        }
示例#2
0
        public EditTimeBlocksForm(BaseForm prevWindow, userstruct inUser, string courseNameIn)
        {
            InitializeComponent();
            prev       = prevWindow;
            courseName = courseNameIn;

            foreach (var c in TimeCheck.GetTimes(courseNameIn))
            {
                timeblocks.Add(c);
                listBox1.Items.Add(TimeShowFormat(c));
            }
        }
示例#3
0
        private void button2_Click(object sender, EventArgs e)
        {
            maskedTextBox1.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals;
            maskedTextBox2.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals;
            int timeblockIn, startTime, endTime;

            if (maskedTextBox1.Text == "" || maskedTextBox2.Text == "")
            {
                MessageBox.Show("Please enter times into both the start and end time boxes.");
            }
            else
            {
                try
                {
                    startTime = Convert.ToInt32(maskedTextBox1.Text);
                    endTime   = Convert.ToInt32(maskedTextBox2.Text);
                    if (startTime >= 2400 || endTime >= 2400 || !(startTime % 100 == 30 || startTime % 100 == 0) || !((endTime - startTime) % 100 == 0 || (endTime - startTime) % 100 == 30 || (endTime - startTime) % 100 == 70) || !(fridayCheckBox.Checked || mondayCheckBox.Checked || tuesdayCheckBox.Checked || wednesdayCheckBox.Checked || thursdayCheckBox.Checked) || startTime >= endTime)
                    {
                        MessageBox.Show("Improper input format! Make sure all times are in military time, and that classes begin and end on half hours, and that at least one day is selected.");
                    }
                    else if (endTime - startTime >= 500)
                    {
                        MessageBox.Show("Error. Classes may not go for more than 4 1/2 hours.");
                    }
                    else
                    {
                        timeblockIn = TimeCheck.ConvertToTime(startTime, endTime, mondayCheckBox.Checked, tuesdayCheckBox.Checked, wednesdayCheckBox.Checked, thursdayCheckBox.Checked, fridayCheckBox.Checked);
                        timeblocks.Add(timeblockIn);
                        listBox1.Items.Add(TimeShowFormat());

                        mondayCheckBox.Checked    = false;
                        tuesdayCheckBox.Checked   = false;
                        wednesdayCheckBox.Checked = false;
                        thursdayCheckBox.Checked  = false;
                        fridayCheckBox.Checked    = false;
                        maskedTextBox1.Text       = "";
                        maskedTextBox2.Text       = "";
                    }
                }
                catch (FormatException)
                {
                    MessageBox.Show("Improper input format! Make sure all times are in military time, and that classes begin and end on half hours, and that at least one day is selected.");
                }
            }
        }
示例#4
0
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            listBox2.Items.Clear();
            listBox3.Items.Clear();
            listBox4.Items.Clear();
            listBox5.Items.Clear();
            maskedTextBox1.Text = "";

            selectedIndex = listBox1.SelectedIndex;
            linqtoregdbDataContext db = new linqtoregdbDataContext();

            if (listBox1.SelectedIndex != -1)
            {
                listBox2.Items.AddRange((from prq in db.prereqs
                                         where prq.courseName == listBox1.SelectedItem.ToString()
                                         select prq.prereqName).ToArray());
                listBox3.Items.AddRange((from crs in db.courses
                                         select crs.courseName).ToArray());

                var queryGetCourse = (from crs in db.courses
                                      where crs.courseName == listBox1.SelectedItem.ToString()
                                      select crs).FirstOrDefault();
                textBox1.Text       = queryGetCourse.courseTitle;
                textBox3.Text       = queryGetCourse.numSeats.ToString();
                textBox4.Text       = queryGetCourse.courseCredit.ToString();
                maskedTextBox1.Text = queryGetCourse.semester;
                currSemester        = queryGetCourse.semester;
                var queryGetInstructor = (from usr in db.users
                                          where usr.userID == queryGetCourse.instructor
                                          select usr.username).FirstOrDefault();
                textBox2.Text = queryGetInstructor;

                richTextBox1.Text = "";
                foreach (var c in TimeCheck.GetTimes(listBox1.SelectedItem.ToString()))
                {
                    foreach (var d in TimeCheck.convertTime(c))
                    {
                        richTextBox1.Text += d.ToString() + "\n";
                    }
                }
                listBox4.Items.AddRange((from usrcrs in db.user_courses
                                         where usrcrs.courseName == listBox1.SelectedItem.ToString()
                                         select usrcrs.username).ToArray());
                var queryGetUsersNotInClass = from usr in db.users
                                              where usr.usertype == "student"
                                              select usr.username;
                foreach (var c in queryGetUsersNotInClass)
                {
                    if (!listBox4.Items.Contains(c))
                    {
                        listBox5.Items.Add(c);
                    }
                }
            }
            else
            {
                textBox1.Text     = "";
                textBox2.Text     = "";
                textBox3.Text     = "";
                textBox4.Text     = "";
                richTextBox1.Text = "";
                listBox4.Items.Clear();
                listBox5.Items.Clear();
            }
        }