protected void Page_Load(object sender, EventArgs e)
        {
            msgLabel.Text = "";
            try
            {
                List<Course> courses = new List<Course>();
                List<Department> departments = new List<Department>();
                departmentDropDownList.DataTextField = "DepartmentCode";
                departmentDropDownList.DataValueField = "departmentId";
                courseDropDownList.DataTextField = "courseCode";
                courseDropDownList.DataValueField = "courseId";
                if (!IsPostBack)
                {
                    aDepartmentManager = new DepartmentManager();
                    departments = aDepartmentManager.GetAllDepartments();
                    aCourseManager = new CourseManager();
                    courses = aCourseManager.GetAllCourses();
                    departmentDropDownList.DataSource = departments;
                    departmentDropDownList.DataBind();
                    courseDropDownList.DataSource = courses;
                    courseDropDownList.DataBind();
                }
            }
            catch (SqlException sqlException)
            {
                msgLabel.ForeColor = Color.Red;
                msgLabel.Text = "Database error.See details error: " + sqlException.Message;

            }
            catch (Exception exception)
            {
                msgLabel.ForeColor = Color.Red;
                string errorMessage = "Unknow error occured.";
                errorMessage += exception.Message;
                if (exception.InnerException != null)
                {
                    errorMessage += exception.InnerException.Message;
                }
                msgLabel.Text = errorMessage;
            }
        }
        private bool DoesThisCourseExist(TeacherCourse aTeacherCourse)
        {
            int           status         = 0;
            List <Course> courses        = new List <Course>();
            CourseManager aCourseManager = new CourseManager();

            courses = aCourseManager.GetAllCourses();
            foreach (Course course in courses)
            {
                if (aTeacherCourse.CourseId == course.CourseId && course.CourseStatus == 1)
                {
                    status = 1;
                }
            }

            if (status == 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        private bool DoesThisCourseExist(TeacherCourse aTeacherCourse)
        {
            int status = 0;
            List<Course> courses = new List<Course>();
            CourseManager aCourseManager = new CourseManager();
            courses = aCourseManager.GetAllCourses();
            foreach (Course course in courses)
            {
                if (aTeacherCourse.CourseId == course.CourseId && course.CourseStatus == 1)
                {
                    status = 1;
                }
            }

            if (status == 1)
                return true;
            else
            {
                return false;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            msgLabel.Text = "";

            try
            {
                departmentDropDownList.DataTextField = "DepartmentCode";
                departmentDropDownList.DataValueField = "departmentId";
                semesterDropDownList.DataTextField = "SemesterName";
                semesterDropDownList.DataValueField = "SemesterId";
                dayDropDownList.DataTextField = "dayName";
                dayDropDownList.DataValueField = "dayId";
                buildingDropDownList.DataTextField = "buildingName";
                buildingDropDownList.DataValueField = "buildingId";
                courseDropDownList.DataTextField = "courseCode";
                courseDropDownList.DataValueField = "courseId";
                roomDropDownList.DataTextField = "roomName";
                roomDropDownList.DataValueField = "roomId";

                if (!IsPostBack)
                {

                    List<Course> courses = new List<Course>();
                    List<Day> days = new List<Day>();
                    List<Department> departments = new List<Department>();
                    List<Semester> semester = new List<Semester>();
                    List<Building> buildings = new List<Building>();
                    aDepartmentManager = new DepartmentManager();
                    departments = aDepartmentManager.GetAllDepartments();
                    SemesterManager aSemesterManager = new SemesterManager();
                    semester = aSemesterManager.GetAllSemesters();
                    aScheduleManager = new ScheduleManager();
                    buildings = aScheduleManager.GetAllBuildings();
                    days = aScheduleManager.GetAllDays();
                    aCourseManager = new CourseManager();
                    courses = aCourseManager.GetAllCourses();
                    dayDropDownList.DataSource = days;
                    dayDropDownList.DataBind();
                    departmentDropDownList.DataSource = departments;
                    departmentDropDownList.DataBind();
                    semesterDropDownList.DataSource = semester;
                    semesterDropDownList.DataBind();
                    buildingDropDownList.DataSource = buildings;
                    buildingDropDownList.DataBind();
                    courseDropDownList.DataSource = courses;
                    courseDropDownList.DataBind();
                }
            }
            catch (Exception exception)
            {
                msgLabel.ForeColor = Color.Red;
                msgLabel.Text = exception.Message;
            }
        }