コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //Response.Write(DateTime.Now.ToShortDateString());
            Course_elearnDAO cdao   = new Course_elearnDAO();
            string           id_str = null;

            if (Request.QueryString["id"] != null)
            {
                id_str = Request.QueryString["id"];
                int id_num = int.Parse(id_str);
                current = cdao.get_course_by_id(id_num);
                TestimonialDAO t = new TestimonialDAO();
                testimonials = t.get_testimonials_by_course(current);
            }
            else
            {
                return;
            }

            if (!IsPostBack)
            {
                int id_num = int.Parse(id_str);
                current = cdao.get_course_by_id(id_num);
                lblCourseNameHeader.Text     = current.getCourseName();
                lblBreadcrumbCourseName.Text = current.getCourseName();
                lblCourseName.Text           = current.getCourseName();
                lblCourseDescription.Text    = current.getDescription();
                hoursOutput.Text             = current.getHoursAwarded().ToString();
                if (!current.getTargetAudience().Equals(""))
                {
                    lblTargetAudience.Text = current.getTargetAudience();
                }
                else
                {
                    lblTargetAudience.Text = "-";
                }
                lblCoursePeriodStart.Text = "Start: " + current.getStartDate().ToLongDateString();
                lblCoursePeriodEnd.Text   = "End: " + current.getExpiryDate().ToLongDateString();
                DateTime currentDateTime = DateTime.Now;

                if (current.getStatus().Equals("Inactive") || !(DateTime.Compare(current.getStartDate(), currentDateTime) < 0 && DateTime.Compare(current.getExpiryDate(), currentDateTime) > 0))
                {
                    panelInactive.Visible = true;
                }
                Page.Form.Attributes.Add("enctype", "multipart/form-data");
            }
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //Response.Write(DateTime.Now.ToShortDateString());
            Course_elearnDAO cdao   = new Course_elearnDAO();
            string           id_str = null;

            if (Request.QueryString["id"] != null)
            {
                id_str = Request.QueryString["id"];
                int id_num = int.Parse(id_str);
                current = cdao.get_course_by_id(id_num);
                TestimonialDAO t = new TestimonialDAO();
                testimonials = t.get_testimonials_by_course(current);
            }
            else
            {
                return;
            }

            if (!IsPostBack)
            {
                int id_num = int.Parse(id_str);
                current = cdao.get_course_by_id(id_num);
                lblCourseNameHeader.Text     = current.getCourseName();
                lblBreadcrumbCourseName.Text = current.getCourseName();
                lblCourseName.Text           = current.getCourseName();
                lblCourseDescription.Text    = current.getDescription();
                hoursOutput.Text             = current.getHoursAwarded().ToString();
                if (!current.getTargetAudience().Equals(""))
                {
                    lblTargetAudience.Text = current.getTargetAudience();
                }
                else
                {
                    lblTargetAudience.Text = "-";
                }
                lblCoursePeriodStart.Text = "Start: " + current.getStartDate().ToLongDateString();
                lblCoursePeriodEnd.Text   = "End: " + current.getExpiryDate().ToLongDateString();
            }
        }
コード例 #3
0
        public Course_elearn create_elearnCourse(Course_elearn course)
        {
            SqlConnection conn     = new SqlConnection();
            Course_elearn toReturn = null;

            try
            {
                conn = new SqlConnection();
                string connstr = ConfigurationManager.ConnectionStrings["DBConnectionString"].ToString();
                conn.ConnectionString = connstr;
                conn.Open();
                SqlCommand comm = new SqlCommand();
                comm.Connection  = conn;
                comm.CommandText = "insert into [Elearn_course] " +
                                   "(elearn_courseName, elearn_courseProvider, entry_date, start_date, expiry_date, status, description, categoryID, courseCreator, hoursAwarded, targetAudience, courseType) OUTPUT INSERTED.elearn_courseID " +
                                   "values (@cName, @provider, Convert(datetime, @entry, 103), convert(datetime,@time,103), Convert(datetime,@expiry,103), @status, @desc, @category, @courseCreator, @hoursAwarded, @targetAudience, @courseType)";
                comm.Parameters.AddWithValue("@cName", course.getCourseName());
                if (course.getCourseProvider() != null)
                {
                    comm.Parameters.AddWithValue("@provider", course.getCourseProvider());
                }
                else
                {
                    comm.Parameters.AddWithValue("@provider", DBNull.Value);
                }

                comm.Parameters.AddWithValue("@entry", course.getEntryDate());
                if (course.getStartDate() == null)
                {
                    comm.Parameters.AddWithValue("@time", DBNull.Value);
                }
                else
                {
                    comm.Parameters.AddWithValue("@time", course.getStartDate());
                }
                if (course.getExpiryDate() == null)
                {
                    comm.Parameters.AddWithValue("@expiry", DBNull.Value);
                }
                else
                {
                    comm.Parameters.AddWithValue("@expiry", course.getExpiryDate());
                }
                comm.Parameters.AddWithValue("@status", course.getStatus());
                comm.Parameters.AddWithValue("@desc", course.getDescription());
                comm.Parameters.AddWithValue("@category", course.getCategoryID());
                comm.Parameters.AddWithValue("@courseCreator", course.getCourseCreator().getUserID());
                comm.Parameters.AddWithValue("@hoursAwarded", course.getHoursAwarded());
                comm.Parameters.AddWithValue("@targetAudience", course.getTargetAudience());
                comm.Parameters.AddWithValue("@courseType", course.getCourseType());
                int a = (Int32)comm.ExecuteScalar();
                //need new method to create pre-requisities here to store in seperate table (pre-req table)
                course.setCourseID(a);
                toReturn = course;
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                conn.Close();
            }
            return(toReturn);
        }
コード例 #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["currentUser"] == null)
            {
                Response.Redirect("Login.aspx");
            }
            else
            {
                User             currentUser    = (User)Session["currentUser"];
                Course_elearnDAO ceDAO          = new Course_elearnDAO();
                Course_elearn    currentCourse  = ceDAO.get_course_by_id(Convert.ToInt32(Request.QueryString["id"]));
                Boolean          superuser      = false;
                Boolean          course_creator = false;
                foreach (string s in currentUser.getRoles())
                {
                    if (s.Equals("superuser"))
                    {
                        superuser = true;
                    }
                    else if (s.Equals("course creator"))
                    {
                        course_creator = true;
                    }
                }
                if (currentUser.getUserID() != currentCourse.getCourseCreator().getUserID() && !(superuser || course_creator))
                {
                    Response.Redirect("errorPage.aspx");
                }
                else
                {
                    if (!IsPostBack)
                    {
                        moduleType.SelectedValue     = currentCourse.getCategoryID().ToString();
                        ddlCourseType.SelectedValue  = currentCourse.getCourseType();
                        nameOfModuleInput.Text       = currentCourse.getCourseName();
                        lblBreadcrumbCourseName.Text = currentCourse.getCourseName();
                        descriptionModuleInput.Text  = currentCourse.getDescription();
                        hoursInput.Text = currentCourse.getHoursAwarded().ToString();
                        if (currentCourse.getTargetAudience() != null)
                        {
                            txtTargetAudience.Text = currentCourse.getTargetAudience().ToString();
                        }
                        fromDateInput.Text = currentCourse.getStartDate().ToString("dd/MM/yyyy");
                        toDateInput.Text   = currentCourse.getExpiryDate().ToString("dd/MM/yyyy");

                        //prerequisites
                        ArrayList  allPrerequisites = currentCourse.getPrerequisite();
                        List <int> prereqIDlist     = new List <int>();
                        foreach (Course_elearn prereq in allPrerequisites)
                        {
                            prereqIDlist.Add(prereq.getCourseID());
                        }
                        Session["selectedPrereq"] = prereqIDlist;
                        var itemIDs = string.Join(",", ((IList <int>)Session["selectedPrereq"]).ToArray());

                        //postrequisites
                        List <int> postReqIDList      = getAllPostRequisiteCourses(currentCourse.getCourseID());
                        List <int> postReqIDListNoDup = new List <int>();
                        foreach (int postreqID in postReqIDList)
                        {
                            if (!postReqIDListNoDup.Contains(postreqID) && postReqIDList.Contains(postreqID))
                            {
                                postReqIDListNoDup.Add(postreqID);
                            }
                        }
                        Session["selectedPostreq"] = postReqIDListNoDup;
                        var itemIDs2 = string.Join(",", ((IList <int>)Session["selectedPostreq"]).ToArray());

                        //to load course list
                        var sqlQueryCourseList = "";
                        if (itemIDs.Length > 0 && itemIDs2.Length > 0)
                        {
                            sqlQueryCourseList = String.Format("SELECT * FROM [Elearn_course] ec INNER JOIN [Elearn_courseCategory] ecc ON ec.categoryID = ecc.categoryID WHERE ec.status='active' and ec.start_date<=getDate() and ec.expiry_date>=getDate() and ec.elearn_courseID NOT IN ({0}) and ec.elearn_courseID NOT IN ({1}) and ec.courseType='Online Learning' and ec.elearn_courseID != " + currentCourse.getCourseID(), itemIDs, itemIDs2);
                        }
                        else if (itemIDs.Length > 0 && itemIDs2.Length < 1)
                        {
                            sqlQueryCourseList = String.Format("SELECT * FROM [Elearn_course] ec INNER JOIN [Elearn_courseCategory] ecc ON ec.categoryID = ecc.categoryID WHERE ec.status='active' and ec.start_date<=getDate() and ec.expiry_date>=getDate() and ec.elearn_courseID NOT IN ({0}) and ec.courseType='Online Learning' and ec.elearn_courseID != " + currentCourse.getCourseID(), itemIDs);
                        }
                        else if (itemIDs.Length < 1 && itemIDs2.Length > 0)
                        {
                            sqlQueryCourseList = String.Format("SELECT * FROM [Elearn_course] ec INNER JOIN [Elearn_courseCategory] ecc ON ec.categoryID = ecc.categoryID WHERE ec.status='active' and ec.start_date<=getDate() and ec.expiry_date>=getDate() and ec.elearn_courseID NOT IN ({0}) and ec.courseType='Online Learning' and ec.elearn_courseID != " + currentCourse.getCourseID(), itemIDs2);
                        }
                        else
                        {
                            sqlQueryCourseList = String.Format("SELECT * FROM [Elearn_course] ec INNER JOIN [Elearn_courseCategory] ecc ON ec.categoryID = ecc.categoryID WHERE ec.status='active' and ec.start_date<=getDate() and ec.expiry_date>=getDate() and ec.courseType='Online Learning' and ec.elearn_courseID != " + currentCourse.getCourseID());
                        }
                        SqlDataSource1.SelectCommand = sqlQueryCourseList;
                        gvPrereq.DataSource          = SqlDataSource1;
                        gvPrereq.DataBind();

                        gvPrereq.UseAccessibleHeader = true;

                        if (gvPrereq.Rows.Count > 0)
                        {
                            gvPrereq.HeaderRow.TableSection = TableRowSection.TableHeader;
                        }

                        //to load prereq cart

                        var sqlQuery = "";
                        if (itemIDs.Length > 0)
                        {
                            sqlQuery = String.Format("SELECT * FROM [Elearn_course] WHERE [elearn_courseID] IN ({0}) and elearn_courseID != " + currentCourse.getCourseID(), itemIDs);
                        }
                        else
                        {
                            sqlQuery = "SELECT * FROM [Elearn_course] WHERE [elearn_courseID] = -1";
                        }

                        SqlDataSourcePrereqCart.SelectCommand = sqlQuery;
                        gvPrereqCart.DataSource = SqlDataSourcePrereqCart;
                        gvPrereqCart.DataBind();
                        Session["currentMod"] = nameOfModuleInput.Text;
                    }
                }
            }
        }