protected void Page_Load(object sender, EventArgs e) { User currentUser = (User)Session["currentUser"]; if (currentUser == null) { Response.Redirect("Login.aspx"); } else { 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 (superuser || course_creator) { if (!IsPostBack) { int categoryID = Convert.ToInt32(Request.QueryString["id"]); Course_elearnCategoryDAO cecDAO = new Course_elearnCategoryDAO(); CourseCategory currentCategory = cecDAO.getCategoryByID(categoryID); if (currentCategory.status.Equals("active")) { btnDeactivate.Visible = true; btnActivate.Visible = false; } else { btnDeactivate.Visible = false; btnActivate.Visible = true; } txtCategory.Text = currentCategory.category; lblHiddenID.Text = currentCategory.categoryID.ToString(); } } else { Response.Redirect("errorPage.aspx"); } } }
protected void btnCfmActivate_Click(object sender, EventArgs e) { //to do validation int categoryID = Convert.ToInt32(lblHiddenID.Text); Course_elearnCategoryDAO cecDAO = new Course_elearnCategoryDAO(); cecDAO.activateCategory(categoryID); //set audit User currentUser = (User)Session["currentUser"]; setAudit(currentUser, "course category", "activate", categoryID.ToString(), "category name: " + txtCategory.Text); Response.Redirect("manageCategories.aspx"); }
protected void btnModuleCategory_Click(object sender, EventArgs e) { LinkButton btn = (LinkButton)(sender); string value = btn.CommandArgument; Course_elearnCategoryDAO cecDAO = new Course_elearnCategoryDAO(); CourseCategory cc = cecDAO.getCategoryByID(Convert.ToInt32(value)); lblModuleCategory.Text = cc.category + " Courses"; SqlDataSourceCourse.SelectCommand = $"SELECT * FROM [Elearn_course] WHERE categoryID = {value} and status='active' and start_date<=getDate() and expiry_date>=getDate()"; gvCourse.DataSource = SqlDataSourceCourse; gvCourse.DataBind(); gvCourse.UseAccessibleHeader = true; if (gvCourse.Rows.Count > 0) { gvCourse.HeaderRow.TableSection = TableRowSection.TableHeader; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { User currentUser = (User)Session["currentUser"]; int categoryID = Convert.ToInt32(Request.QueryString["id"]); Course_elearnCategoryDAO cecDAO = new Course_elearnCategoryDAO(); CourseCategory currentCategory = cecDAO.getCategoryByID(categoryID); if (currentCategory.status.Equals("active")) { btnDeactivate.Visible = true; btnActivate.Visible = false; } else { btnDeactivate.Visible = false; btnActivate.Visible = true; } txtCategory.Text = currentCategory.category; lblHiddenID.Text = currentCategory.categoryID.ToString(); } }
protected void btnConfirmSubmit_Click(object sender, EventArgs e) { //to do validation Course_elearnCategoryDAO cecDAO = new Course_elearnCategoryDAO(); CourseCategory cc = new CourseCategory(); cc.category = txtCategory.Text; cc.status = "active"; int createdCourseCattID = cecDAO.createCategory(cc); //set audit User currentUser = (User)Session["currentUser"]; Audit a = new Audit(); AuditDAO aDAO = new AuditDAO(); a.userID = currentUser.getUserID(); a.functionModified = "course category"; a.operation = "create"; a.id_of_function = createdCourseCattID.ToString(); a.dateModified = DateTime.Now; a.remarks = "category name: " + txtCategory.Text; aDAO.createAudit(a); }