protected void btnSaveClass_Click(object sender, EventArgs e) { Instructor instructor = (Instructor)Session["Instructor"]; Class classes = new Class(); List <Student> studentList = new List <Student>(); List <TermClass> tClassList = new List <TermClass>(); Guid departmentId = new Guid(ddlDepartment.SelectedValue); Guid classId = new Guid(ddlSelectClass.SelectedValue); Guid sectionId = new Guid(ddlSections.SelectedValue); if (ddlDepartment != null && ddlSelectClass != null) { DataTable dt = Session["SaveTable"] as DataTable; foreach (DataRow row in dt.Rows) { Student student = new Student(); student.FirstName = row[0].ToString(); student.LastName = row[1].ToString(); student.FullName = student.FirstName + " " + student.LastName; student.DepartmentId = departmentId; student.Save(); studentList.Add(student); } foreach (Student students in studentList) { TermClass termclass = new TermClass(); termclass.ClassId = classId; termclass.InstructorId = instructor.Id; termclass.StudentId = students.Id; termclass.SectionId = sectionId; termclass.Save(); tClassList.Add(termclass); } } lblStatus1.Text = "Class Successfully saved!"; lblStatus1.Visible = true; lblStatus2.Text = "Here's a preview of your class.."; lblStatus2.Visible = true; ShowTable(tClassList); }
protected void ddlSections_SelectedIndexChanged(object sender, EventArgs e) { Instructor instructor = (Instructor)Session["Instructor"]; TermClass termclass = new TermClass(); Student student = new Student(); Section section = new Section(); Class clas = new Class(); TermClassList tClassList = new TermClassList(); DataTable dt = new DataTable(); tClassList = tClassList.GetAll(); // Get Term classes dt.Columns.Add("Student Name"); dt.Columns.Add("Class Name"); dt.Columns.Add("Instructor Name"); dt.Columns.Add("Section Name"); Guid sectionID = new Guid(ddlSections.SelectedValue); foreach (TermClass tc in tClassList.List) { if (tc.InstructorId == instructor.Id) { if (tc.SectionId == sectionID) { clas = clas.GetById(tc.ClassId); student = student.GetById(tc.StudentId); string className = clas.Name; string instructorName = instructor.FirstName + " " + instructor.LastName; string studentName = student.FirstName + " " + student.LastName; string sectionName = ddlSections.SelectedItem.ToString(); dt.Rows.Add(studentName, className, instructorName, sectionName); } } ShowTable(dt); } }
protected void btnEditAttendance_Click(object sender, EventArgs e) { Instructor instructor = (Instructor)Session["Instructor"]; TermClass termclass = new TermClass(); Student student = new Student(); Section section = new Section(); Class clas = new Class(); Attendance attendance = new Attendance(); List <Student> sList = new List <Student>(); TermClassList tClassList = new TermClassList(); StudentList studentList = new StudentList(); DataTable dt = new DataTable(); tClassList = tClassList.GetAll(); // Get Term classes studentList = studentList.GetAll(); dt.Columns.Add("Student Name"); dt.Columns.Add("Class Name"); dt.Columns.Add("Instructor Name"); dt.Columns.Add("Section Name"); dt.Columns.Add("Total Absences"); //dt.Columns.Add(new DataColumn("Absent", typeof(CheckBox))); Guid sectionID = new Guid(ddlSections.SelectedValue); Guid classID = new Guid(ddlSelectClass.SelectedValue); foreach (TermClass tc in tClassList.List) { if (tc.InstructorId == instructor.Id) { if (tc.SectionId == sectionID) { if (tc.ClassId == classID) { clas = clas.GetById(tc.ClassId); student = student.GetById(tc.StudentId); attendance = attendance.GetByStudentId(tc.StudentId); string className = clas.Name; string instructorName = instructor.FirstName + " " + instructor.LastName; string studentName = student.FullName; string sectionName = ddlSections.SelectedItem.ToString(); int totalAbsences = attendance.TotalAbsences; dt.Rows.Add(studentName, className, instructorName, sectionName, totalAbsences); foreach (Student stud in studentList.List) { if (stud.Id == tc.StudentId) { sList.Add(stud); } } } } } } if (sList != null) { ddlSelectStudent.DataSource = sList; ddlSelectStudent.DataBind(); ddlSelectStudent.Items.Add("Choose Student"); ddlSelectStudent.SelectedValue = "Choose Student"; ddlSelectStudent.Visible = true; btnMarkAbsent.Visible = true; } Session["SaveTable"] = dt; GridView1.DataSource = dt; GridView1.DataBind(); }
private void RefreshTable() { Instructor instructor = (Instructor)Session["Instructor"]; TermClass termclass = new TermClass(); Student student = new Student(); Section section = new Section(); Class clas = new Class(); Attendance attendance = new Attendance(); AttendanceList aList = new AttendanceList(); TermClassList tClassList = new TermClassList(); StudentList studentList = new StudentList(); DataTable dt = new DataTable(); tClassList = tClassList.GetAll(); // Get Term classes dt.Columns.Add("Student Name"); dt.Columns.Add("Class Name"); dt.Columns.Add("Instructor Name"); dt.Columns.Add("Section Name"); dt.Columns.Add("Total Absences"); Guid sectionID = new Guid(ddlSections.SelectedValue); Guid classID = new Guid(ddlSelectClass.SelectedValue); foreach (TermClass tc in tClassList.List) { if (tc.InstructorId == instructor.Id) { if (tc.SectionId == sectionID) { if (tc.ClassId == classID) { clas = clas.GetById(tc.ClassId); student = student.GetById(tc.StudentId); attendance = attendance.GetByStudentId(tc.StudentId); string className = clas.Name; string instructorName = instructor.FirstName + " " + instructor.LastName; string studentName = student.FullName; string sectionName = ddlSections.SelectedItem.ToString(); int totalAbsences = attendance.TotalAbsences; aList.GetAttendanceByStudentID(student.Id); foreach (Attendance a in aList.List) { totalAbsences = totalAbsences + 1; } dt.Rows.Add(studentName, className, instructorName, sectionName, totalAbsences); } } } } GridView1.DataSource = dt; GridView1.DataBind(); }