예제 #1
0
        public bool addconstraint(constraints addthis)
        {
            SqlConnection con        = new SqlConnection(constring);
            SqlCommand    newcommand = new SqlCommand("INSERT INTO dbo.Constraints (StartTime,EndTime,Day,CourseID,LecturerID,Lecture_type,ClassID,CourseName,LecturerName,Year,Semester) VALUES (@StartTime,@EndTime,@Day,@CourseID,@LecturerID,@Lecture_type,@ClassID,@CourseName,@LecturerName,@Year,@Semester)", con);

            newcommand.Parameters.Add("@StartTime", addthis.getStart());
            newcommand.Parameters.Add("@EndTime", addthis.getEnd());
            newcommand.Parameters.Add("@Day", addthis.getday());
            newcommand.Parameters.Add("@CourseID", addthis.getcourseid());
            newcommand.Parameters.Add("@LecturerID", addthis.getlecturerid());
            newcommand.Parameters.Add("@Lecture_type", addthis.gettype());
            newcommand.Parameters.Add("@ClassID", addthis.getclassroom());
            newcommand.Parameters.Add("@CourseName", addthis.getcoursename());
            newcommand.Parameters.Add("@LecturerName", addthis.getlecturer());
            newcommand.Parameters.Add("@Year", addthis.getyear());
            newcommand.Parameters.Add("@Semester", addthis.getsemester());
            con.Open();
            if (con.State == System.Data.ConnectionState.Open)
            {
                newcommand.ExecuteNonQuery();
                con.Close();
                return(true);
            }
            return(false);
        }
예제 #2
0
 private bool initialise_new_event(constraints initThis)
 {
     initThis.textbox.Multiline = true;
     initThis.textbox.Dock      = DockStyle.Fill;
     initThis.textbox.ReadOnly  = true;
     initThis.textbox.BackColor = Color.LightBlue;
     tableLayoutPanel1.Controls.Add(initThis.textbox, initThis.getday() - 64, initThis.getStart() - 7);
     tableLayoutPanel1.SetRowSpan(initThis.textbox, initThis.getEnd() - initThis.getStart());
     return(false);
 }
예제 #3
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();
        }