Example #1
0
        protected void LoadAdminPanel(WebhostEntities db, Faculty teacher, int curTerm)
        {
            PingBtn.Visible = false;
            if (teacher.Permissions.Where(p => p.Name.Contains("Admin") && p.AcademicYear == DateRange.GetCurrentAcademicYear()).Count() > 0)
            {
                PingBtn.Visible              = true;
                TeacherSelect.DataSource     = FacultyListItem.GetDataSource(db.Faculties.Where(f => f.isActive).OrderBy(f => f.LastName).ThenBy(f => f.FirstName).Select(f => f.ID).ToList());
                TeacherSelect.DataTextField  = "Text";
                TeacherSelect.DataValueField = "ID";
                TeacherSelect.DataBind();

                StudentSelect.DataSource     = StudentListItem.GetDataSource(db.Students.Where(s => s.isActive).OrderBy(f => f.LastName).ThenBy(f => f.FirstName).Select(s => s.ID).ToList());
                StudentSelect.DataTextField  = "Text";
                StudentSelect.DataValueField = "ID";
                StudentSelect.DataBind();
            }
            else if (db.Departments.Where(d => d.DeptHeadId == teacher.ID).Count() > 0)
            {
                List <int> facids = new List <int>();
                Term       term   = db.Terms.Find(curTerm);
                foreach (Department dept in teacher.Departments.ToList())
                {
                    foreach (Section section in term.Sections.Where(s => s.Course.DepartmentID == dept.id).ToList())
                    {
                        foreach (Faculty t in section.Teachers.ToList())
                        {
                            if (!facids.Contains(t.ID))
                            {
                                facids.Add(t.ID);
                            }
                        }
                    }
                }

                TeacherSelect.DataSource     = FacultyListItem.GetDataSource(facids);
                TeacherSelect.DataTextField  = "Text";
                TeacherSelect.DataValueField = "ID";
                TeacherSelect.DataBind();

                StudentSelect.DataSource     = StudentListItem.GetDataSource(teacher.Students.Where(s => s.isActive).Select(s => s.ID).ToList());
                StudentSelect.DataTextField  = "Text";
                StudentSelect.DataValueField = "ID";
                StudentSelect.DataBind();
            }
            else
            {
                TeacherSelect.DataSource = FacultyListItem.GetDataSource(new List <int>()
                {
                    user.ID
                });
                TeacherSelect.DataTextField  = "Text";
                TeacherSelect.DataValueField = "ID";
                TeacherSelect.DataBind();

                StudentSelect.DataSource     = StudentListItem.GetDataSource(teacher.Students.Where(s => s.isActive).Select(s => s.ID).ToList());
                StudentSelect.DataTextField  = "Text";
                StudentSelect.DataValueField = "ID";
                StudentSelect.DataBind();
            }
        }
Example #2
0
        protected void SelectCR_Click(object sender, EventArgs e)
        {
            using (WebhostEntities db = new WebhostEntities())
            {
                LoadedId = -1;
                int crid = Convert.ToInt32(CourseRequestDDL.SelectedValue);
                WebhostMySQLConnection.CourseRequest courseRequest = db.CourseRequests.Where(cr => cr.id == crid).Single();

                RequestedCourseName.Text = courseRequest.RequestableCourse.Course.Name;


                int     sid     = Convert.ToInt32(StudentSelectDDL.SelectedValue);
                Student student = db.Students.Where(s => s.ID == sid).Single();

                int        termId         = DateRange.GetCurrentOrLastTerm();
                List <int> currentClasses = student.Sections.Where(sec => sec.Terms.Select(t => t.id).Contains(termId)).Select(sec => sec.id).ToList();
                CurrentCourseDDL.DataSource     = SectionListItem.GetDataSource(currentClasses);
                CurrentCourseDDL.DataTextField  = "Text";
                CurrentCourseDDL.DataValueField = "ID";
                CurrentCourseDDL.DataBind();


                SecondaryCourseDDL.DataSource     = SectionListItem.GetDataSource(currentClasses);
                SecondaryCourseDDL.DataTextField  = "Text";
                SecondaryCourseDDL.DataValueField = "ID";
                SecondaryCourseDDL.DataBind();

                int year = DateRange.GetCurrentAcademicYear();

                GradeTable stdaf = db.GradeTables.Where(gt => gt.AcademicYearID == year && gt.Name.Equals("Standard A-F Scale")).Single();

                CurrentCourseGradeDDL.DataSource     = stdaf.GradeTableEntries.ToList();
                CurrentCourseGradeDDL.DataTextField  = "Name";
                CurrentCourseGradeDDL.DataValueField = "id";
                CurrentCourseGradeDDL.DataBind();

                SecondaryCourseGradeDDL.DataSource     = stdaf.GradeTableEntries.ToList();
                SecondaryCourseGradeDDL.DataTextField  = "Name";
                SecondaryCourseGradeDDL.DataValueField = "id";
                SecondaryCourseGradeDDL.DataBind();

                List <int> facultyIds = db.Faculties.Select(f => f.ID).ToList();

                CurrentTeacherDDL.DataSource     = FacultyListItem.GetDataSource(facultyIds);
                CurrentTeacherDDL.DataTextField  = "Text";
                CurrentTeacherDDL.DataValueField = "ID";
                CurrentTeacherDDL.DataBind();

                DeptHeadDDL.DataSource     = FacultyListItem.GetDataSource(facultyIds);
                DeptHeadDDL.DataTextField  = "Text";
                DeptHeadDDL.DataValueField = "ID";
                DeptHeadDDL.DataBind();

                GradeTable approval = db.GradeTables.Where(gt => gt.AcademicYearID == year && gt.Name.Equals("AP Approval")).Single();

                ApprovalDDL.DataSource     = approval.GradeTableEntries.ToList();
                ApprovalDDL.DataTextField  = "Name";
                ApprovalDDL.DataValueField = "id";
                ApprovalDDL.DataBind();

                ApprovalPanel.Visible = true;

                if (courseRequest.APRequests.Count > 0)
                {
                    APRequest apcr = courseRequest.APRequests.FirstOrDefault();
                    LoadedId = apcr.id;
                    if (apcr.Sections.Count > 0)
                    {
                        List <Section> secs = apcr.Sections.ToList();
                        CurrentCourseDDL.ClearSelection();
                        CurrentCourseDDL.SelectedValue = Convert.ToString(secs[0].id);
                        if (student.StudentComments.Where(com => com.CommentHeader.SectionIndex == secs[0].id && com.CommentHeader.TermIndex == termId).Count() > 0)
                        {
                            StudentComment comment = student.StudentComments.Where(com => com.CommentHeader.SectionIndex == secs[0].id && com.CommentHeader.TermIndex == termId).Single();
                            CurrentCourseGradeDDL.ClearSelection();
                            CurrentCourseGradeDDL.SelectedValue = Convert.ToString(comment.FinalGradeID);
                        }
                        if (secs.Count > 1)
                        {
                            SecondaryCourseDDL.ClearSelection();
                            SecondaryCourseDDL.SelectedValue = Convert.ToString(secs[1].id);
                            if (student.StudentComments.Where(com => com.CommentHeader.SectionIndex == secs[1].id && com.CommentHeader.TermIndex == termId).Count() > 0)
                            {
                                StudentComment comment = student.StudentComments.Where(com => com.CommentHeader.SectionIndex == secs[1].id && com.CommentHeader.TermIndex == termId).Single();
                                SecondaryCourseGradeDDL.ClearSelection();
                                SecondaryCourseGradeDDL.SelectedValue = Convert.ToString(comment.FinalGradeID);
                            }
                        }
                    }

                    CurrentTeacherDDL.ClearSelection();
                    CurrentTeacherDDL.SelectedValue = Convert.ToString(apcr.TeacherSignedBy);

                    DeptHeadDDL.ClearSelection();
                    DeptHeadDDL.SelectedValue = Convert.ToString(apcr.DeptHeadSignedBy);

                    ApprovalDDL.ClearSelection();
                    ApprovalDDL.SelectedValue = Convert.ToString(apcr.ApprovalId);
                }
            }
        }