예제 #1
0
        private void chosen_event_form_Load(object sender, EventArgs e)
        {
            this.constCourse.Text    = this.recived.getcoursename();
            this.Constclassroom.Text = this.recived.getclassroom();
            this.constDay.Text       = this.recived.getday().ToString();
            this.Conststart.Text     = this.recived.getStart().ToString() + ":00";
            this.Constend.Text       = this.recived.getEnd().ToString() + ":00";
            this.constID.Text        = this.recived.get_id().ToString();
            this.constType.Text      = this.recived.gettype();
            allconstraints           = constraints.getallconstraints();
            Teachers    = newconnection.get_un_by_course(recived.getcoursename());
            permissions = newconnection.get_permissions_by_un(Teachers);
            int ocupied;

            if (this.recived.gettype() == "Lecture")
            {
                for (int i = 0; i < Teachers.Count; i++)
                {
                    ocupied = 0;
                    if (Convert.ToInt32(permissions[i]) > 2)
                    {
                        for (int j = 0; j < allconstraints.Count; j++)
                        {
                            if ((allconstraints[j].getlecturer() == Teachers[i]) && recived.getday() == allconstraints[j].getday())
                            {
                                if ((allconstraints[j].getStart() == recived.getStart() ||
                                     (recived.getStart() < allconstraints[j].getStart() && recived.getEnd() > allconstraints[j].getStart()) ||
                                     recived.getStart() < allconstraints[j].getEnd() && recived.getEnd() >= allconstraints[j].getEnd()))
                                {
                                    ocupied = 1; break;
                                }
                            }
                        }

                        if (ocupied > 0)
                        {
                            continue;
                        }
                        Teacherscombox.Items.Add(Teachers[i]);
                    }
                }
            }
            else
            {
                for (int i = 0; i < Teachers.Count; i++)
                {
                    ocupied = 0;
                    if (Convert.ToInt32(permissions[i]) >= 2)
                    {
                        for (int j = 0; j < allconstraints.Count; j++)
                        {
                            if ((allconstraints[j].getlecturer() == Teachers[i]) && recived.getday() == allconstraints[j].getday())
                            {
                                if ((allconstraints[j].getStart() == recived.getStart() ||
                                     (recived.getStart() < allconstraints[j].getStart() && recived.getEnd() > allconstraints[j].getStart()) ||
                                     recived.getStart() < allconstraints[j].getEnd() && recived.getEnd() >= allconstraints[j].getEnd()))
                                {
                                    ocupied = 1; break;
                                }
                            }
                        }

                        if (ocupied > 0)
                        {
                            continue;
                        }
                        Teacherscombox.Items.Add(Teachers[i]);
                    }
                }
            }
            student_count.Text = recived.get_students_count().ToString();
        }