private void dataGridView_schedule_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            int r = dataGridView_schedule.CurrentCell.RowIndex;
            int c = dataGridView_schedule.CurrentCell.ColumnIndex;

            string[] days = { "Hours", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday" };

            string   Hour = dataGridView_schedule.Rows[r].Cells[0].Value.ToString();
            DateTime dt   = System.Convert.ToDateTime(Hour);

            if (selected_Lecturer != null)
            {
                selected_lesson = selected_Lecturer.getLessonByDayAndHour(days[c], dt.Hour);
            }
            else if (selected_Practitioner != null)
            {
                selected_lesson = selected_Practitioner.geLessonByDayAndHour(days[c], dt.Hour);
            }
            else
            {
                selected_lesson = null;
            }

            if (selected_lesson != null)
            {
                string[] hoursItem = new string[2];
                hoursItem[0] = "";
                hoursItem[1] = GeneralFuntion.formatTime(selected_lesson.Start);
                txt_CB_TimeStart.DataSource = hoursItem;

                string[] AllDays = { "", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday" };
                txt_CB_days.DataSource = AllDays;

                txt_CB_TimeStart.Text  = hoursItem[1];
                txt_TB_infoLesson.Text = selected_lesson.InfoLesson;
                txt_CB_type.Text       = selected_lesson.Type;

                lbl_TB_End.Text = GeneralFuntion.formatTime(selected_lesson.End);

                int index = -1;
                for (int i = 0; i < list_ApprovedCourses.Count; i++)
                {
                    if (list_ApprovedCourses.ElementAt(i).ID == selected_lesson.LCourseID)
                    {
                        index           = i;
                        selected_course = list_ApprovedCourses.ElementAt(i);
                        break;
                    }
                }
                if (index >= 0)
                {
                    txt_CB_coursesApproved.Text = txt_CB_coursesApproved.Items[index + 1].ToString();
                }
                txt_CB_days.Text = selected_lesson.Day;

                list_classes = dal.class_rooms.Where(x => x.building.Equals(selected_lesson.building) && x.number == selected_lesson.number).ToList <ClassRoom>();
                setListViewClasses();
                if (list_classes != null && list_classes.Count > 0)
                {
                    txt_TB_NumStudents.Text = list_classes.ElementAt(0).maxStudents.ToString();
                }
            }
            updateComponents();
        }
        private void updateButtons()
        {
            if (selected_lesson != null)
            {
                if (checkBox_LessonsOfStudentSelected.Checked != true)
                {
                    btn_Add.Enabled          = true;
                    btn_RemoveLesson.Enabled = false;
                }
                else
                {
                    btn_Add.Enabled          = false;
                    btn_RemoveLesson.Enabled = true;
                }

                checkBox_Lesson.Checked = true;
                txt_lbl_day.Text        = selected_lesson.Day;
                txt_lbl_End.Text        = GeneralFuntion.formatTime(selected_lesson.End);
                txt_lbl_Start.Text      = GeneralFuntion.formatTime(selected_lesson.Start);
                txt_lbl_Type.Text       = selected_lesson.Type;
                txt_TB_infoLesson.Text  = selected_lesson.InfoLesson;
                string nameTeacher    = "";
                int    amountStudent  = 0;
                int    maxStudInClass = 0;

                ClassRoom classroom = dal.class_rooms.Where(x => x.building.Equals(selected_lesson.building) && x.number == selected_lesson.number).FirstOrDefault();

                if (classroom != null)
                {
                    maxStudInClass = classroom.maxStudents;
                }

                if (selected_lesson.Type.Equals("Lecture"))
                {
                    Lecturer l = dal.lecturers.Find(selected_lesson.LTeacherID);
                    if (l != null)
                    {
                        nameTeacher = "L" + l.ID.ToString() + " : " + l.Name;
                    }
                    if (secretary != null)
                    {
                        Lecture lecture = secretary.geLectureFromLesson(selected_lesson);
                        if (lecture != null)
                        {
                            amountStudent = lecture.NumStudent;
                        }
                    }
                    else if (admin != null)
                    {
                        Lecture lecture = admin.geLectureFromLesson(selected_lesson);
                        if (lecture != null)
                        {
                            amountStudent = lecture.NumStudent;
                        }
                    }
                    else if (student != null)
                    {
                        Lecture lecture = SettingDatabase.geLectureFromLesson(selected_lesson);
                        if (lecture != null)
                        {
                            amountStudent = lecture.NumStudent;
                        }
                    }
                }
                else
                {
                    Practitioner p = dal.practitiners.Find(selected_lesson.LTeacherID);
                    if (p != null)
                    {
                        nameTeacher = "P" + p.ID.ToString() + " : " + p.Name;
                    }
                    if (secretary != null)
                    {
                        if (selected_lesson.Type.Equals("Practise"))
                        {
                            Practise Practise = secretary.getPractiseFormLesson(selected_lesson);
                            if (Practise != null)
                            {
                                amountStudent = Practise.NumStudent;
                            }
                        }
                        else if (selected_lesson.Type.Equals("Lab"))
                        {
                            Lab lab = secretary.geLabFromLesson(selected_lesson);
                            if (lab != null)
                            {
                                amountStudent = lab.NumStudent;
                            }
                        }

                        else if (student != null)
                        {
                            Lab lab = SettingDatabase.geLabFromLesson(selected_lesson);
                            if (lab != null)
                            {
                                amountStudent = lab.NumStudent;
                            }
                        }
                    }
                    else if (admin != null)
                    {
                        if (selected_lesson.Type.Equals("Practise"))
                        {
                            Practise Practise = admin.getPractiseFormLesson(selected_lesson);
                            if (Practise != null)
                            {
                                amountStudent = Practise.NumStudent;
                            }
                        }
                        else if (selected_lesson.Type.Equals("Lab"))
                        {
                            Lab lab = admin.geLabFromLesson(selected_lesson);
                            if (lab != null)
                            {
                                amountStudent = lab.NumStudent;
                            }
                        }
                    }
                }

                txt_lbl_teacher.Text = nameTeacher;
                if (maxStudInClass == 0)
                {
                    maxStudInClass = amountStudent;
                }
                txt_lbl_NumCurrentStudents.Text = amountStudent.ToString() + " / " + maxStudInClass.ToString();
            }
            else
            {
                btn_RemoveLesson.Enabled        = false;
                btn_Add.Enabled                 = false;
                txt_lbl_day.Text                = "";
                txt_lbl_End.Text                = "";
                txt_lbl_Start.Text              = "";
                txt_lbl_Type.Text               = "";
                txt_lbl_teacher.Text            = "";
                txt_lbl_NumCurrentStudents.Text = "";
            }
        }