Esempio n. 1
0
    } /* end of the function when the page loads */

    protected void Ddl_LevelOfCourse_SelectedIndexChanged(object sender, EventArgs e) /* when the level of course dropdown box is selected which doesn't return anything*/
    {
        SubjectArea LevelOfCourse = Cache[cacheKey] as SubjectArea;                   /* creating a new instance of the object under the class SubjectArea called LevelOfCourse */

        SubjectAreaId = Convert.ToInt32(Request.QueryString.Get("SubjectAreaId"));    /*setting SubjectArea depending on the SubjectAreaId passed from the previous variable */
        int level = Convert.ToInt32(Ddl_LevelOfCourse.SelectedValue);                 /* setting the level of the course by an integer by converting value from drop down box */

        // creating a new instance of class by calling the object myEntities
        using (HigherEducationChesterfieldCollegeEntities myEntities = new HigherEducationChesterfieldCollegeEntities())
        {
            // statement updates the level of courses;
            var levelOfCourseReviews = from course in myEntities.Courses
                                       orderby course.Name_Course ascending
                                       where course.SubjectAreaID == SubjectAreaId
                                       where course.LevelOfCourse == level
                                       select course;
            Repeater1.DataSource = levelOfCourseReviews.ToList();  // outputting repeater to pass variable through to the page
            Repeater1.DataBind();
            LevelOfCourse = (from r in myEntities.SubjectAreas     // outputting the courses that changes depending on the level of course that is selected
                             where r.ID == SubjectAreaId
                             select r).SingleOrDefault();
            if (LevelOfCourse != null)                                                                                                 // when the level of course is nothing
            {
                Cache.Insert(cacheKey, LevelOfCourse, null, DateTime.Now.AddSeconds(1), System.Web.Caching.Cache.NoSlidingExpiration); // updates the page every second
            }
        }
        // updating page infromation below just in case an administrator has changed information on the web page
        TitleLabel.Text = LevelOfCourse.Name_SA;
        BodyLabel.Text  = LevelOfCourse.AdditionalInformation;
        Title           = LevelOfCourse.Name_SA;
    } /* end of level of course dropdown box method */
Esempio n. 2
0
    } /* end of level of course dropdown box method */

    protected void Ddl_TypeOfCourse_SelectedIndexChanged(object sender, EventArgs e) // start of the type of course selected item method
    {
        SubjectArea TypeOfCourse = Cache[cacheKey] as SubjectArea;                                                       /* creating a new instance of the object under the class SubjectArea called TypeOfCourse */

        SubjectAreaId = Convert.ToInt32(Request.QueryString.Get("SubjectAreaId"));                                       /*setting SubjectArea depending on the SubjectAreaId passed from the previous variable */
        string typeOfCourse = Ddl_TypeOfCourse.SelectedValue;                                                            // selecting  the value based on the part time of full time course selected

        using (HigherEducationChesterfieldCollegeEntities myEntities = new HigherEducationChesterfieldCollegeEntities()) // creating a new instance of class by calling the object myEntities
        {
            // statement updates the type of course and outputs it onto the subject area page
            var levelOfCourseReviews = from course in myEntities.Courses
                                       orderby course.Name_Course ascending
                                       where course.SubjectAreaID == SubjectAreaId && course.PartFullTime == typeOfCourse
                                       select course;

            Repeater1.DataSource = levelOfCourseReviews.ToList();
            Repeater1.DataBind();

            // selecting the subject areas again just in case they have been updated
            TypeOfCourse = (from r in myEntities.SubjectAreas
                            where r.ID == SubjectAreaId
                            select r).SingleOrDefault();
            if (TypeOfCourse != null)                                                                                                 // when the type of null is not nothing
            {
                Cache.Insert(cacheKey, TypeOfCourse, null, DateTime.Now.AddSeconds(1), System.Web.Caching.Cache.NoSlidingExpiration); // updates the information every second
            }
        }
        // updating page infromation below just in case an administrator has changed information on the web page
        TitleLabel.Text = TypeOfCourse.Name_SA;
        BodyLabel.Text  = TypeOfCourse.AdditionalInformation;
        Title           = TypeOfCourse.Name_SA;
    } //end of the type of course selected item method
 protected void Page_Load(object sender, EventArgs e) /* start of pageLoad method */
 {
     /* new instance of class as an object called tables */
     using (HigherEducationChesterfieldCollegeEntities tables = new HigherEducationChesterfieldCollegeEntities())
     {
         /* var for authorised reviews is for all subject areas to be liste dinto the reepater */
         var authorizedReviews = from subjectArea in tables.SubjectAreas orderby subjectArea.Name_SA ascending
                                 select subjectArea;
         Repeater1.DataSource = authorizedReviews.ToList();
         Repeater1.DataBind();
     }
 }
Esempio n. 4
0
    public string cacheKey;                                                        /* string called cacheKey is public */

    protected void Page_Load(object sender, EventArgs e)                           /* start of the function when the page first loads which doesn't return anything */
    {
        SubjectAreaId = Convert.ToInt32(Request.QueryString.Get("SubjectAreaId")); /* converts the passed variable through url into an integer */
        cacheKey      = "SubjectArea" + SubjectAreaId.ToString();                  /*setting the cache key */
        SubjectArea mySubjectArea = Cache[cacheKey] as SubjectArea;                /* creating a new instance of class by calling the object mySubjectArea */

        if (mySubjectArea == null)                                                 // when mySubejctArea is null
        {
            // creating a new instance of class by calling the object myEntities
            using (HigherEducationChesterfieldCollegeEntities myEntities = new HigherEducationChesterfieldCollegeEntities())
            {
                // statement below outputs all the courses that are part of that subject area
                var authorizedReviews = from course in myEntities.Courses
                                        orderby course.Name_Course ascending
                                        where course.SubjectAreaID == SubjectAreaId
                                        select course;
                Repeater1.DataSource = authorizedReviews.ToList(); // output courses to the page
                Repeater1.DataBind();
                mySubjectArea = (from r in myEntities.SubjectAreas // used to output data based on that subject area
                                 where r.ID == SubjectAreaId
                                 select r).SingleOrDefault();
                if (mySubjectArea != null)  // when mySubjectArea is not empty
                {
                    Cache.Insert(cacheKey, mySubjectArea, null, DateTime.Now.AddSeconds(1), System.Web.Caching.Cache.NoSlidingExpiration);
                    // updates changes every second, not possible to set it to 0
                }
            }
        }

        if (mySubjectArea != null)                                                               // when mySubjectArea is not empty
        {
            TitleLabel.Text = mySubjectArea.Name_SA;                                             // title label is set dynamically depending on what subject area is selected

            BodyLabel.Text = mySubjectArea.AdditionalInformation;                                // setting BodyLabel.Text to what information from the database
            Title          = "Higher Education Chesterfield College - " + mySubjectArea.Name_SA; // setting the title of the page which depends on whcih subject area is selected */
        }
    } /* end of the function when the page loads */
Esempio n. 5
0
    public string cacheKey;                              /* string called cacheKey is public */
    protected void Page_Load(object sender, EventArgs e) // start of method whe the page first loads
    {
        // sql connection for connecting the database
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["HigherEducationChesterfieldCollegeConnectionString"].ConnectionString);

        con.Open();                                                                                   // database is connection is open
        SqlCommand cmd = new SqlCommand("SELECT * FROM [UserLogin] WHERE [LoggedOn]=@LoggedOn", con); // sql command where the all rows are seleted when the user has logged on

        cmd.Parameters.AddWithValue("@LoggedOn", 1);                                                  // replaced @LoggedOn value with 1 in the statement above
        SqlDataAdapter da = new SqlDataAdapter(cmd);                                                  // outputting the data into the sql data adapter
        DataTable      dt = new DataTable();                                                          // creating new instance of class DataTable as an object dt

        da.Fill(dt);                                                                                  // fills the data adapter with the data table
        if (dt.Rows.Count > 0)                                                                        // when their are rows of data when the sql command has been done
        {
            TurnOnFavCourses.Visible  = true;                                                         // turn on favourite courses to be visible
            TurnOffFavCourses.Visible = false;                                                        // turn off favourite courses is not to be visible
        }
        else // otherwise
        {
            TurnOnFavCourses.Visible  = false;                                      // turn on favourite courses not to be visible
            TurnOffFavCourses.Visible = false;                                      // turn off favourite courses not to be visible
        }
        courseId            = Convert.ToInt32(Request.QueryString.Get("CourseId")); // courseId is set to the variable set through as a session variable converted to an integer
        Session["CourseID"] = courseId;                                             // courseId value is from the value passed form the previous page
        cacheKey            = "Course" + courseId.ToString();                       // when the cache is key is the course plus the courseId
        Course myReview = Cache[cacheKey] as Course;                                // new instance of the class course when object is called myreview

        if (myReview == null)                                                       // when myReview statement doesn't contain any data
        {
            // creating a new instance of class by calling the object myEntities
            using (HigherEducationChesterfieldCollegeEntities myEntities = new HigherEducationChesterfieldCollegeEntities())
            {
                // outputComment which is a general variable used to store an sql command to select the comments linked to that course page and output to that page
                var outputComments = from comment in myEntities.Comments
                                     orderby comment.ID descending
                                     where comment.CourseID == courseId
                                     select comment;

                Repeater2.DataSource = outputComments.ToList();
                Repeater2.DataBind();

                // when myReview updates the courses in the subject area

                myReview = (from r in myEntities.Courses
                            where r.ID == courseId
                            select r).SingleOrDefault();
                if (myReview != null)
                {
                    Cache.Insert(cacheKey, myReview, null, DateTime.Now.AddSeconds(1), System.Web.Caching.Cache.NoSlidingExpiration); // updates values vevery second
                }
            }
        }

        if (myReview != null)                                                                                // when the review is not null
        {
            Title                 = "Higher Education Chesterfield College - " + myReview.Name_Course;       // set the title of the web page to the title of the coruse
            TitleLabel.Text       = myReview.Name_Course;                                                    // title label is set to the title of the course
            FullPartTime.Text     = "<b>Type Of Course: </b>" + myReview.PartFullTime;                       // full part time label sets to the partFullTime selected from the database
            LevelOfCourse.Text    = "<b>Level Of Course:   </b>" + Convert.ToString(myReview.LevelOfCourse); // LevelOfCourse label sets to the LevelOfCourse selected from the database
            BriefInformation.Text = "<b> Other Information: </b>" + myReview.AdditionalInformation;          // Brief information label sets to the AdditionalInformation selected from the database
        }
    }