private void EditSchedule_Load(object sender, EventArgs e) { //load all the objects in the comboboxes schedules.Populate(); this.cmbSchedules.DataSource = schedules.List; this.cmbSchedules.SelectedIndex = -1; sections.Populate(); this.cmbSections.DataSource = sections.List; this.cmbSections.SelectedIndex = -1; locations.Populate(); this.cmbLocations.DataSource = locations.List; this.cmbLocations.SelectedIndex = -1; //set the days in the combobox so the user won't enter them manually string[] days = { "Sunday", "Monday", "Tuesday", "Wensday", "Thursday", "Friday", "Saturday" }; foreach (string day in days) { this.cmbDays.Items.Add(day); } this.cmbDays.SelectedIndex = -1; this.txtDuration.Text = ""; this.txtTime.Text = ""; }
/* * 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 }
/* * 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 EditSection_Load(object sender, EventArgs e) { sections.Populate(); this.cmbSecID.DataSource = sections.List; this.cmbSecID.SelectedIndex = -1; instructors.Populate(); this.cmbInstructor.DataSource = instructors.List; this.cmbInstructor.SelectedIndex = -1; tCourses.Populate(); this.cmbTCourse.DataSource = tCourses.List; this.cmbTCourse.SelectedIndex = -1; this.txtCapacity.Text = ""; }
private void AddSchedule_Load(object sender, EventArgs e) { //show the next avaiable id in the text box nextID(); //populating all sections list and adding their IDs in the combobox sections.Populate(); this.cmbSections.DataSource = sections.List; this.cmbSections.SelectedIndex = -1; //populating all locations list and adding their IDs in the combobox locations.Populate(); this.cmbLocations.DataSource = locations.List; this.cmbLocations.SelectedIndex = -1; //adding the days of the week in the system to minimize user input string[] days = { "Sunday", "Monday", "Tuesday", "Wensday", "Thursday", "Friday", "Saturday" }; foreach (string day in days) { this.cmbDays.Items.Add(day); } this.cmbDays.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; } }
private void PopulateSections() { sectionList.Populate(); cmbSectionID.DataSource = sectionList.List; }
protected void EnrollMeBtn_Click(object sender, EventArgs e) { /* * This method is called when enroll me button is clicked */ /* * Declare variables and classes and instantiate them */ bool exist = false; bool alreadyExist = false; string scheduleID = ""; GridViewRow row = classListGrid.SelectedRow; // get the selected gidview row string sectionId = row.Cells[2].Text.ToString(); // get the section id string studentID = Session["User"].ToString(); // assign the student id from User session Section section = new Section(sectionId); sectionsList.Populate(section); // populate the section object Student student = new Student(studentID); studentList.Populate(student); // populate the student object // get the total hours of the student //int totalHours = scheduleList.TotalValue("Duration", "Section", "Schedule.SectionID", "Section.SectionID", "SectionStudent", "Section.SectionID", "SectionStudent.SectionID", "StudentID", student.getID()); //get the total hours of the student //This line calls the new total value with the less parameters int totalHours = scheduleList.TotalValue("Duration", "Section", "SectionID", "SectionID", "SectionStudent", "StudentID", student.getID()); int sectionTotalHours = scheduleList.TotalValue("Duration", "SectionID", sectionId); // get the total hours of the section per week if (totalHours < 20) // check if the student registerd hours are less than 20 hours { if (totalHours + sectionTotalHours > 20) { /* * if the section hours and student registerd hours are more than 20 hours then display error message in a popup * */ ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Error", "alert('You can't SignUP for more than 20 hours !')", true); } else { scheduleList.Filter("SectionID", section.getID()); // filter schedual list by the sectionId taken from the section object foreach (Schedule schedule in scheduleList.List) { /* forEach element in the scheduleList */ // exist = scheduleList.Exist("Section", "Schedule.SectionID", "Section.SectionID", "SectionStudent", "Section.SectionID", "SectionStudent.SectionID", "Day", schedule.Day, "Time", schedule.Time, "StudentID", student.getID()); //check if the student has a class in that day and time -- //this is the 12 parameter method exist = scheduleList.Exist("Section", "SectionID", "SectionID", "SectionStudent", "Day", schedule.Day, "Time", schedule.Time, "StudentID", student.getID()); //check if the student has a class in that day and time -- this is the less parameters method scheduleID = schedule.getID(); // get the schedule id while (Convert.ToInt32(schedule.Duration) > 1 && !exist) { /* * while schedual duration more than 1 and the exit var is false */ int newTime = Convert.ToInt32(schedule.Time) + 1; // get the new time by the adding 1 to the schedule time schedule.Time = newTime.ToString(); // assign the new time to the schedule object time // exist = scheduleList.Exist("Section", "Schedule.SectionID", "Section.SectionID", "SectionStudent", "Section.SectionID", "SectionStudent.SectionID", "Day", schedule.Day, "Time", schedule.Time, "StudentID", student.getID()); //check if the student has a class in that day and time -- //this is the 12 parameter method exist = scheduleList.Exist("Section", "SectionID", "SectionID", "SectionStudent", "Day", schedule.Day, "Time", schedule.Time, "StudentID", student.getID()); //check if the student has a class in that day and time -- this is the less parameters method int duration = Convert.ToInt32(schedule.Duration) - 1; // decrease the duration by 1 schedule.Duration = duration.ToString(); // assign the new duration to the schedule object } if (exist) { /* if the exist var true make the alreadyExist var true */ alreadyExist = true; } } if (alreadyExist) { /* if the alreadyExist var true display a message saying you already have class in that time in a popup */ ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Error", "alert('You already have a class in that time !')", true); } else { /* else */ sectionStudentList.Filter("SectionID", sectionId); // filter sectionstudentList by section id int total = sectionStudentList.List.Count; // get the count of the students that already registerd in the section total = total + 1; // add one to the count if (Convert.ToInt32(section.Capacity) >= total) { /* if the loccation capicty greater or equal to toatal var then add student to the section */ SectionStudent sectionStudent = new SectionStudent(sectionId, studentID); // create new sectionStudent object SectionStudentList sectionStudentList = new SectionStudentList(); // create new sectionStudentList sectionStudentList.Add(sectionStudent); // add the new object to the list ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Section Added", "alert('You have been Enrolled to this section !')", true); // show a message in a popup } else { /* else show a message that the section is already full */ ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Error", "alert('The Section is Already Full !')", true); } } } } else { /* else show a messagw that you can signup for more than 20h in a popup */ ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Error", "alert('You can't SignUP for more than 20 hours !')", true); } }