/* * Method: GenerateGridData * Areguments: none * Return: none * Des: this method is to fill the GridView with data */ protected void GenerateGridData() { DataTable table = new DataTable(); // declare and instantiate DataTable object /* * Add Columns to the data table */ table.Columns.Add("Course Id"); table.Columns.Add("Section Id"); table.Columns.Add("Course Name"); table.Columns.Add("Instructor Name"); table.Columns.Add("Mark"); foreach (SectionStudent sectionStudent in sectionStudentList.List) { /* * Foreach Element in the sectionStudentList */ section = new Section(sectionStudent.SectionID); // create new section object and pass the section id to it sectionList.Populate(section); // populate the section object instructor = new Instructor(section.InstructorID); // create new instructor object and pass the id to it instructorList.Populate(instructor); // populate the instructor object taughtCourses = new TaughtCourse(section.TaughtCourseID); // create new TaughtCourse object and pass the TaughtCourse id to it taughtCoursesList.Populate(taughtCourses); // populate TaughtCourse course = new Course(taughtCourses.CourseID); // create new course object and pass the course id to it courseList.Populate(course); //populate the course object table.Rows.Add(course.getID(), section.getID(), course.Title, instructor.FirstName + " " + instructor.LastName, sectionStudent.Grade); // add a row to the dataTable object with the information from the above objects } MarksGrid.DataSource = table; // set the dataTable object as the dataSource of the GidView element MarksGrid.DataBind(); // bind the data }
private void AddTaughtCourse_Load(object sender, EventArgs e) { //set the next avaiable id in the text box nextID(); //populate the courses combobox courses.Populate(); this.cmbCourseID.DataSource = courses.List; this.cmbCourseID.SelectedIndex = -1; }
/* * Method: GenerateGridView * Areguments: none * Return: none * Des: this method is to fill the GridView with data */ protected void GenerateGridView() { DataTable table = new DataTable(); // create new DataTable object /* Fill the table with Columns and rows */ table.Columns.Add("Time"); table.Columns.Add("Saturday"); table.Columns.Add("Sunday"); table.Columns.Add("Monday"); table.Columns.Add("Tuesday"); table.Columns.Add("Wednesday"); table.Columns.Add("Thursday"); table.Columns.Add("Friday"); table.Rows.Add("8", "", "", "", "", "", "", ""); table.Rows.Add("9", "", "", "", "", "", "", ""); table.Rows.Add("10", "", "", "", "", "", "", ""); table.Rows.Add("11", "", "", "", "", "", "", ""); table.Rows.Add("12", "", "", "", "", "", "", ""); table.Rows.Add("1", "", "", "", "", "", "", ""); table.Rows.Add("2", "", "", "", "", "", "", ""); table.Rows.Add("3", "", "", "", "", "", "", ""); table.Rows.Add("4", "", "", "", "", "", "", ""); table.Rows.Add("5", "", "", "", "", "", "", ""); timeTableGridView.DataSource = table; // add the table as data source for the gridview timeTableGridView.DataBind(); // bind the data foreach (SectionStudent sectionStudent in SectionStudentList.List) { /* ForEach element in the sectionstudentList */ Section section = new Section(sectionStudent.getID()); // create new student object and pass the id SectionList.Populate(section); // populate the section object TaughtCourse taught = new TaughtCourse(section.TaughtCourseID); // create new TaughtCourse object and pass the id taughtCoursesList.Populate(taught); // populate the TaughtCourse object Course course = new Course(taught.CourseID); // create new Course object and pass the id courseList.Populate(course); // populate the Course object scheduleList.Filter("SectionID", sectionStudent.getID()); // filter the schedule list according to section id foreach (Schedule schedule in scheduleList.List) { /* ForEeach Element in sechedule List */ AddToGridByDayAndTime(section, course, schedule); // call AddToGridByDayAndTime to add the schedule information to the gridView while (Convert.ToInt32(schedule.Duration) > 1) { /* While the schedule duration is more than 1 do*/ int newTime = Convert.ToInt32(schedule.Time) + 1; //get the old time and add 1 and assign it to var schedule.Time = newTime.ToString(); // set the schedule object time to the new time AddToGridByDayAndTime(section, course, schedule); // call AddToGridByDayAndTime to add the schedule information to the gridView int duration = Convert.ToInt32(schedule.Duration) - 1; // get the duration and abstract 1 schedule.Duration = duration.ToString(); // assign the new duration to the schedule duration } } } }
private void EditTaughtCourse_Load(object sender, EventArgs e) { //populate the lists and combo oxes taughtCourses.Populate(); this.cmbTaughtCourse.DataSource = taughtCourses.List; this.cmbTaughtCourse.SelectedIndex = -1; courses.Populate(); this.cmbCourse.DataSource = courses.List; this.cmbCourse.SelectedIndex = -1; this.txtYear.Text = ""; this.cmbSemester.SelectedIndex = -1; }
//Instantiates all objects to be used and adds the table names to the tables combobox private void TotalHours_Load(object sender, EventArgs e) { scheduleList = new ScheduleList(); locationList = new LocationList(); locationList.Populate(); sectionList = new SectionList(); sectionList.Populate(); instructorList = new InstructorList(); instructorList.Populate(); courseList = new CourseList(); courseList.Populate(); studentList = new StudentList(); studentList.Populate(); //Adds the tables of wanted data to be selected from in an Array String[] tables = { "Location", "Section", "Instructor", "Course", "Student", "All" }; //Make above array the datasource of the tables combobox comboBoxBy.DataSource = tables; }
private void cmbListBy_SelectedIndexChanged(object sender, EventArgs e) { //a switch case to check the selection of the 'by' combobox switch (this.cmbListBy.SelectedItem.ToString()) { //for each selection, the appropiate list is populated in the 'for' combobox case "Section": sections.Populate(); this.cmbListFor.DataSource = sections.List; this.cmbListFor.SelectedIndex = -1; this.txtAvgGrade.Text = ""; break; case "Student": students.Populate(); this.cmbListFor.DataSource = students.List; this.cmbListFor.SelectedIndex = -1; this.txtAvgGrade.Text = ""; break; case "Course": courses.Populate(); this.cmbListFor.DataSource = courses.List; this.cmbListFor.SelectedIndex = -1; this.txtAvgGrade.Text = ""; break; //to show the average grade for all the students in all sections case "Collage (All grades)": this.txtAvgGrade.Text = secStuds.AverageValue("Grade").ToString(); this.cmbListFor.Items.Clear(); break; //the default will show the average for the all of students in collage default: this.txtAvgGrade.Text = secStuds.AverageValue("Grade").ToString(); this.cmbListFor.Items.Clear(); break; } }
//Populate both the course list and fields when the page is loaded private void EditCourse_Load(object sender, EventArgs e) { courseList = new CourseList(); courseList.Populate(); PopulateCourses(); }
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["cls"] == null) { /* check if there is no query string then */ Response.Write("Error No class requested"); // show error message Response.End(); // stop page excution } else { sectionList = new SectionList(); // this is needed to check if the section id is valid so we instantiate it before the rest sectionList.Filter("SectionID", Request.QueryString["cls"]); // filter the section with the section id to check if the section id exist } /* * check if the user session exist and Account session value is Instructor and the sectionID is valid */ if (Session["User"] != null && Session["Account"].ToString() == "Instructor" && sectionList.List.Count != 0) { /* * instantiate classes when the page loads */ sectionStudentList = new SectionStudentList(); studentList = new StudentList(); taughtCoursesList = new TaughtCourseList(); courseList = new CourseList(); sectionId = Request.QueryString["cls"]; // get the section id passed in the page url and assign it to secionId var sectionList.Filter("SectionID", sectionId); // filter the sectionList with the sectionID section = (Section)sectionList.List.ElementAt(0); // get the first element in the list and cast it to (Section) taughtCoursesList.Filter("TaughtCourseID", section.TaughtCourseID); // filter the taughtCoursesList with the TaughtCourseID taughtCourses = (TaughtCourse)taughtCoursesList.List.ElementAt(0); // get the first element in the list and cast it to (TaughtCourse) course = new Course(); // create new Course object course.setID(taughtCourses.CourseID.ToString()); // set the id of the course object to the value from the taughtCourse object courseList.Populate(course); //populate object sectionStudentList.Filter("SectionID", sectionId); //filter the sectionstudentList with sectionId SectionIdLbl.Text = section.getID(); // set the sectionLable text to the section id CourseID.Text = taughtCourses.CourseID; // set the courseid lable text to the course id CourseName.Text = course.Title; // set courseName lable text to the course title GenerateTable(); // call GenerateTable method to fill the grid view with data } else if (Session["User"] != null && Session["Account"].ToString() != "Instructor") { /* * else if the user session exist but the account session value is not student show error message */ Response.Write("Error You are not allowed to be here"); // show error message Response.End(); // stop page excution } else if (Session["User"] != null && Session["Account"].ToString() == "Instructor" && sectionList.List.Count == 0) { /* else if the user session exist and Account session value is Instructor and the sectionID is not valid */ Response.Write("Error Class not found"); // show error message Response.End(); // stop page excution } else { /* * else show error message */ Response.Write("Error please log in before trying to Access this page..!"); // show error message Response.End(); // stop page excution } }