protected void Page_Load(object sender, EventArgs e) { Page.Title = "Create New Report - eCMR"; if (HttpContext.Current.Session["RoAccessLevel"] != null && HttpContext.Current.Session["RoAccessLevel"].ToString() == "5") { currentCourseCode = Request.QueryString["Code"]; this.dbm = new DatabaseMgmt(); course = dbm.IsExistCourseCode(currentCourseCode); if (course != null) { if(!IsPostBack) { rt = dbm.ListReportTypes(); string[]defaultData = rt[0].reTyFieldName; HttpContext.Current.Session["ReportTypeID"] = rt[0].reTyID.ToString(); reporttypesDropDownList.DataTextField = "reTyName"; reporttypesDropDownList.DataValueField = "reTyID"; reporttypesDropDownList.DataSource = rt; reporttypesDropDownList.DataBind(); RepeaterReport.DataSource = defaultData; RepeaterReport.DataBind(); } } else { Response.Redirect("CL-Dashboard.aspx"); } } else { Response.Redirect("Login.aspx"); } }
protected void Page_Load(object sender, EventArgs e) { Page.Title = "Adminitrators's Dashboard - eCMR"; if (HttpContext.Current.Session["RoAccessLevel"] != null && HttpContext.Current.Session["RoAccessLevel"].ToString() == "1") { courseID = Request.QueryString["CourseID"]; this.dbm = new DatabaseMgmt(); if (!IsPostBack) { this.course = dbm.FindCourseByID(courseID); if (course != null) { courseCode.Value = course.coCode; courseName.Value = course.coName; courseDescription.Value = course.coDescription; facultyID.InnerText = course.faID.ToString(); courseLeaderID.InnerText = course.coCL.ToString(); courseModeratorID.InnerText = course.coCM.ToString(); this.listFaculties = dbm.ListFaculties(); loadfacultiesDropDownList(); this.listCLs = dbm.ListCourseLeader(); loadCourseLeaderDropDownList(); this.listCMs = dbm.ListCourseModerator(); loadCourseModeratorDropDownList(); } else { Response.Redirect("ADM-CourseMgmt.aspx"); } } } else { Response.Redirect("Login.aspx"); } }
public List<Course> ListCourses() { DataTable dt; List<Course> courseList = new List<Course>(); try { dt = new DataTable(); this.conn.Open(); string cmdString = "SELECT * FROM Courses "; this.command = new SqlCommand(cmdString, conn); dt.Load(this.command.ExecuteReader()); if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { int? coID = Convert.ToInt32(dt.Rows[i]["CoID"]); string coCode = dt.Rows[i]["CoCode"].ToString(); string coName = dt.Rows[i]["CoName"].ToString(); string coDescription = dt.Rows[i]["CoDescription"].ToString(); int? faID = Convert.ToInt32(dt.Rows[i]["FaID"]); int? coCL = Convert.ToInt32(dt.Rows[i]["CoCL"]); int? coCM = Convert.ToInt32(dt.Rows[i]["CoCM"]); Course c = new Course(coID, coCode, coName, coDescription, faID, coCL, coCM); courseList.Add(c); } } return courseList; } catch (Exception) { return null; throw; } finally { this.conn.Close(); } }
public Course IsExistCourseCode(string coCode) { DataTable dt; try { dt = new DataTable(); this.conn.Open(); string cmdString = "SELECT * FROM Courses "; cmdString += "WHERE CoCode ='" + coCode + "' "; this.command = new SqlCommand(cmdString, conn); dt.Load(this.command.ExecuteReader()); if (dt.Rows.Count > 0) { int? coID = Convert.ToInt32(dt.Rows[0]["CoID"]); string coName = dt.Rows[0]["CoName"].ToString(); string coDescription = dt.Rows[0]["CoDescription"].ToString(); int? faID = Convert.ToInt32(dt.Rows[0]["FaID"]); int? coCL = Convert.ToInt32(dt.Rows[0]["CoCL"]); int? coCM = Convert.ToInt32(dt.Rows[0]["CoCM"]); Course c = new Course(coID, coCode, coName, coDescription, faID, coCL, coCM); return c; } return null; } catch (Exception) { return null; throw; } finally { this.conn.Close(); } }
public void UpdateCourse(Course c) { try { this.conn.Open(); string cmdString = "UPDATE Courses"; cmdString += " SET CoCode = @CoCodeN, CoName = @CoNameN, CoDescription = @CoDescriptionN, FaID = @FaIDN, CoCL = @CoCLN, CoCM = @CoCMN"; cmdString += " WHERE CoID = @CoIDN"; this.command = new SqlCommand(cmdString, conn); this.command.Parameters.AddWithValue("@CoIDN", c.coID); this.command.Parameters.AddWithValue("@CoCodeN", c.coCode); this.command.Parameters.AddWithValue("@CoNameN", c.coName); this.command.Parameters.AddWithValue("@CoDescriptionN", c.coDescription); this.command.Parameters.AddWithValue("@FaIDN", c.faID); this.command.Parameters.AddWithValue("@CoCLN", c.coCL); this.command.Parameters.AddWithValue("@CoCMN", c.coCM); this.command.ExecuteNonQuery(); } catch (Exception) { throw; } finally { this.conn.Close(); } }
protected void updateCourse_Click(object sender, EventArgs e) { string currentCoID = courseID; string currentCoCode = courseCode.Value; string currentCoName = courseName.Value; string currentFaID = facultyID.InnerText; string currentCLID = courseLeaderID.InnerText; string currentCMID = courseModeratorID.InnerText; string currentDescription = courseDescription.Value; Course courseUpdate = new Course(Int32.Parse(currentCoID), currentCoCode, currentCoName, currentDescription, Int32.Parse(currentFaID), Int32.Parse(currentCLID), Int32.Parse(currentCMID)); this.dbm.UpdateCourse(courseUpdate); Response.Redirect("ADM-CourseMgmt.aspx"); }