Example #1
0
        protected void btn_delete_Click(object sender, EventArgs e)
        {
            var programid = Convert.ToInt32(ProgramList.SelectedValue);
            var courseid  = txt_courseid.Text;
            CoursesController coursesController = new CoursesController();
            var course = coursesController.Courses_GetCourse(courseid);

            if (course == null)
            {
                return;
            }

            ProgramCoursesController programCoursesController = new ProgramCoursesController();
            var programCourse = programCoursesController.ProgramCourses_FindByProgramAndCourse(programid, courseid).FirstOrDefault();

            if (programCourse == null)
            {
                return;
            }

            programCoursesController.RemoveProgramCourse(programCourse);
            coursesController.RemoveCourse(course);

            FindPrograms_Click(null, null);
        }
Example #2
0
        protected void Select_Click(object sender, EventArgs e)
        {
            //use the program and course to find programcourse
            //fill individual web controls with the programcourse record

            //test if set info has any records
            //  info.Count() == 0 bad else good
            if (CoursesList.SelectedIndex == 0)
            {
                errormsgs.Add("Select a courses.");
                LoadMessageDisplay(errormsgs, "alert a alert-info");
            }
            //once you have made your call to get your record
            //info[0] is tyhe first record
            // ProgramCourseID.Text = info[0].ProgramCourseId;
            else
            {
                try
                {
                    ProgramCoursesController sysmgr = new ProgramCoursesController();
                    List <ProgramCourses>    info   = sysmgr.ProgramCourses_FindByProgramAndCourse(int.Parse(ProgramList.SelectedValue), CoursesList.SelectedValue);
                    if (info.Count == 0)
                    {
                        errormsgs.Add("No data found for the Program");
                        LoadMessageDisplay(errormsgs, "alert alertt-info");
                        ProgramCoursesGridView.DataSource = null;
                        ProgramCoursesGridView.DataBind();
                    }
                    else
                    {
                        info.Sort((x, y) => x.ProgramCourseID.CompareTo(y.ProgramCourseID));
                        ProgramCoursesGridView.DataSource = info;
                        ProgramCoursesGridView.DataBind();
                    }
                }
                catch (Exception ex)
                {
                    errormsgs.Add(GetInnerException(ex).ToString());
                    LoadMessageDisplay(errormsgs, "alert alert-danger");
                }
            }
        }