Beispiel #1
0
        protected void AddRequestBtn_Click(object sender, EventArgs e)
        {
            using (WebhostEntities db = new WebhostEntities())
            {
                if (db.CourseRequests.Where(cr => cr.TermId == termId && cr.StudentId == SelectedStudentId && cr.CourseId == NewCourseRequestSelector.RequestedCourseId).Count() > 0)
                {
                    LogError("Multiple Course Requests for the Same class detected.");
                    ErrorLabel.Text    = "You have already submitted a course request for this student for this class.";
                    ErrorPanel.Visible = true;
                    return;
                }

                int crn = db.CourseRequests.Count() > 0 ? db.CourseRequests.OrderBy(cr => cr.id).ToList().Last().id + 1 : 0;

                WebhostMySQLConnection.CourseRequest request = new WebhostMySQLConnection.CourseRequest()
                {
                    CourseId          = NewCourseRequestSelector.RequestedCourseId,
                    id                = crn,
                    IsGlobalAlternate = NewCourseRequestSelector.Priority == 2,
                    IsSecondary       = NewCourseRequestSelector.Priority == 1,
                    StudentId         = SelectedStudentId,
                    TermId            = termId
                };

                db.CourseRequests.Add(request);
                db.SaveChanges();

                State.log.WriteLine("Added new Course Request:");
                State.log.WriteLine("{0} - {1}", SelectedStudentId, request.CourseId);
            }

            Response.Redirect(Request.RawUrl);
        }
Beispiel #2
0
 protected void DeleteRequestBtn_Click(object sender, EventArgs e)
 {
     using (WebhostEntities db = new WebhostEntities())
     {
         WebhostMySQLConnection.CourseRequest request = db.CourseRequests.Where(cr => cr.id == CourseRequestId).Single();
         request.APRequests.Clear();
         db.CourseRequests.Remove(request);
         //LogWarning("Deleted Course Request of {2} for {0} {1}.", request.Student.FirstName, request.Student.LastName, request.RequestableCourse.Course.Name);
         db.SaveChanges();
         Response.Redirect(Request.RawUrl);
     }
 }
Beispiel #3
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);
                }
            }
        }
        protected void SubmitBtn_Click(object sender, EventArgs e)
        {
            using (WebhostEntities db = new WebhostEntities())
            {
                int     newCRN  = db.CourseRequests.Count() > 0? db.CourseRequests.OrderBy(c => c.id).ToList().Last().id : -1;
                Student student = db.Students.Where(s => s.ID == SelectedStudentId).Single();
                List <WebhostMySQLConnection.CourseRequest> coursereqs = student.CourseRequests.Where(cr => cr.TermId == termId).ToList();
                foreach (WebhostMySQLConnection.CourseRequest cr in coursereqs)
                {
                    if (cr.APRequests.Count > 0)
                    {
                        foreach (APRequest req in cr.APRequests)
                        {
                            req.Sections.Clear();
                        }
                        db.APRequests.RemoveRange(cr.APRequests);
                        cr.APRequests.Clear();
                    }
                }
                db.CourseRequests.RemoveRange(coursereqs);

                if (SeniorProjectCB.Checked)
                {
                    WebhostMySQLConnection.CourseRequest sp = new WebhostMySQLConnection.CourseRequest()
                    {
                        id                = ++newCRN,
                        StudentId         = SelectedStudentId,
                        CourseId          = 1995,
                        IsSecondary       = false,
                        IsGlobalAlternate = false,
                        TermId            = termId
                    };

                    db.CourseRequests.Add(sp);
                }

                if (LSP.Checked)
                {
                    WebhostMySQLConnection.CourseRequest sp = new WebhostMySQLConnection.CourseRequest()
                    {
                        id                = ++newCRN,
                        StudentId         = SelectedStudentId,
                        CourseId          = 2057,
                        IsSecondary       = false,
                        IsGlobalAlternate = false,
                        TermId            = termId
                    };

                    db.CourseRequests.Add(sp);
                }

                if (ESL.Checked)
                {
                    WebhostMySQLConnection.CourseRequest sp = new WebhostMySQLConnection.CourseRequest()
                    {
                        id                = ++newCRN,
                        StudentId         = SelectedStudentId,
                        CourseId          = student.GraduationYear > 2018 ? 2058 : 2059,
                        IsSecondary       = false,
                        IsGlobalAlternate = false,
                        TermId            = termId
                    };

                    db.CourseRequests.Add(sp);
                }

                // Ignore if already enrolled in English Full Year class.
                if (!EnglishFullYearCB.Checked)
                {
                    WebhostMySQLConnection.CourseRequest eng1 = new WebhostMySQLConnection.CourseRequest()
                    {
                        id                = ++newCRN,
                        StudentId         = SelectedStudentId,
                        CourseId          = Convert.ToInt32(English1DDL.SelectedValue),
                        IsSecondary       = false,
                        IsGlobalAlternate = false,
                        TermId            = termId
                    };

                    db.CourseRequests.Add(eng1);

                    if (English2DDL.SelectedIndex >= 0)
                    {
                        WebhostMySQLConnection.CourseRequest eng2 = new WebhostMySQLConnection.CourseRequest()
                        {
                            id                = ++newCRN,
                            StudentId         = SelectedStudentId,
                            CourseId          = Convert.ToInt32(English2DDL.SelectedValue),
                            IsSecondary       = EnglishSelectionPriority.SelectedIndex == 0,
                            IsGlobalAlternate = false,
                            TermId            = termId
                        };

                        db.CourseRequests.Add(eng2);
                    }
                }

                if (!HistoryFullYearCB.Checked)
                {
                    if (History1DDL.SelectedIndex >= 0)
                    {
                        WebhostMySQLConnection.CourseRequest hist1 = new WebhostMySQLConnection.CourseRequest()
                        {
                            id                = ++newCRN,
                            StudentId         = SelectedStudentId,
                            CourseId          = Convert.ToInt32(History1DDL.SelectedValue),
                            IsSecondary       = false,
                            IsGlobalAlternate = false,
                            TermId            = termId
                        };

                        db.CourseRequests.Add(hist1);

                        if (History2DDL.SelectedIndex >= 0)
                        {
                            WebhostMySQLConnection.CourseRequest hist2 = new WebhostMySQLConnection.CourseRequest()
                            {
                                id                = ++newCRN,
                                StudentId         = SelectedStudentId,
                                CourseId          = Convert.ToInt32(History2DDL.SelectedValue),
                                IsSecondary       = HistorySelectionPriority.SelectedIndex == 0,
                                IsGlobalAlternate = false,
                                TermId            = termId
                            };

                            db.CourseRequests.Add(hist2);
                        }
                    }
                }

                if (!MathFullYear.Checked)
                {
                    if (Math1DDL.SelectedIndex >= 0)
                    {
                        WebhostMySQLConnection.CourseRequest math1 = new WebhostMySQLConnection.CourseRequest()
                        {
                            id                = ++newCRN,
                            StudentId         = SelectedStudentId,
                            CourseId          = Convert.ToInt32(Math1DDL.SelectedValue),
                            IsSecondary       = false,
                            IsGlobalAlternate = false,
                            TermId            = termId
                        };

                        db.CourseRequests.Add(math1);

                        if (Math2DDL.SelectedIndex >= 0)
                        {
                            WebhostMySQLConnection.CourseRequest math2 = new WebhostMySQLConnection.CourseRequest()
                            {
                                id                = ++newCRN,
                                StudentId         = SelectedStudentId,
                                CourseId          = Convert.ToInt32(Math2DDL.SelectedValue),
                                IsSecondary       = MathPriority.SelectedIndex == 0,
                                IsGlobalAlternate = MathPriority.SelectedIndex == 2,
                                TermId            = termId
                            };

                            db.CourseRequests.Add(math2);
                        }
                    }
                }

                if (!WorldLanguageSkip.Checked)
                {
                    if (WorldLang1DDL.SelectedIndex >= 0)
                    {
                        WebhostMySQLConnection.CourseRequest wl1 = new WebhostMySQLConnection.CourseRequest()
                        {
                            id                = ++newCRN,
                            StudentId         = SelectedStudentId,
                            CourseId          = Convert.ToInt32(WorldLang1DDL.SelectedValue),
                            IsSecondary       = false,
                            IsGlobalAlternate = false,
                            TermId            = termId
                        };

                        db.CourseRequests.Add(wl1);

                        if (WorldLang2DDL.SelectedIndex >= 0)
                        {
                            WebhostMySQLConnection.CourseRequest wl2 = new WebhostMySQLConnection.CourseRequest()
                            {
                                id                = ++newCRN,
                                StudentId         = SelectedStudentId,
                                CourseId          = Convert.ToInt32(WorldLang2DDL.SelectedValue),
                                IsSecondary       = MathPriority.SelectedIndex == 0,
                                IsGlobalAlternate = MathPriority.SelectedIndex == 2,
                                TermId            = termId
                            };

                            db.CourseRequests.Add(wl2);
                        }
                    }
                }

                if (Tech1DDL.SelectedIndex >= 0)
                {
                    WebhostMySQLConnection.CourseRequest tech1 = new WebhostMySQLConnection.CourseRequest()
                    {
                        id                = ++newCRN,
                        StudentId         = SelectedStudentId,
                        CourseId          = Convert.ToInt32(Tech1DDL.SelectedValue),
                        IsSecondary       = false,
                        IsGlobalAlternate = false,
                        TermId            = termId
                    };

                    db.CourseRequests.Add(tech1);
                    if (Tech2DDL.SelectedIndex >= 0)
                    {
                        WebhostMySQLConnection.CourseRequest tech2 = new WebhostMySQLConnection.CourseRequest()
                        {
                            id                = ++newCRN,
                            StudentId         = SelectedStudentId,
                            CourseId          = Convert.ToInt32(Tech2DDL.SelectedValue),
                            IsSecondary       = TechPriority.SelectedIndex == 0,
                            IsGlobalAlternate = TechPriority.SelectedIndex == 2,
                            TermId            = termId
                        };

                        db.CourseRequests.Add(tech2);
                    }
                }

                if (!ScienceFullYearCB.Checked)
                {
                    if (Science1DDL.SelectedIndex >= 0)
                    {
                        WebhostMySQLConnection.CourseRequest sci1 = new WebhostMySQLConnection.CourseRequest()
                        {
                            id                = ++newCRN,
                            StudentId         = SelectedStudentId,
                            CourseId          = Convert.ToInt32(Science1DDL.SelectedValue),
                            IsSecondary       = false,
                            IsGlobalAlternate = false,
                            TermId            = termId
                        };

                        db.CourseRequests.Add(sci1);
                        if (Science2DDL.SelectedIndex >= 0)
                        {
                            WebhostMySQLConnection.CourseRequest sci2 = new WebhostMySQLConnection.CourseRequest()
                            {
                                id                = ++newCRN,
                                StudentId         = SelectedStudentId,
                                CourseId          = Convert.ToInt32(Science2DDL.SelectedValue),
                                IsSecondary       = SciencePriority.SelectedIndex == 0,
                                IsGlobalAlternate = SciencePriority.SelectedIndex == 2,
                                TermId            = termId
                            };

                            db.CourseRequests.Add(sci2);
                        }

                        if (Science3DDL.SelectedIndex >= 0)
                        {
                            WebhostMySQLConnection.CourseRequest sci3 = new WebhostMySQLConnection.CourseRequest()
                            {
                                id                = ++newCRN,
                                StudentId         = SelectedStudentId,
                                CourseId          = Convert.ToInt32(Science3DDL.SelectedValue),
                                IsSecondary       = true,
                                IsGlobalAlternate = true,
                                TermId            = termId
                            };

                            db.CourseRequests.Add(sci3);
                        }
                    }
                }

                if (Art1DDL.SelectedIndex >= 0)
                {
                    WebhostMySQLConnection.CourseRequest art1 = new WebhostMySQLConnection.CourseRequest()
                    {
                        id                = ++newCRN,
                        StudentId         = SelectedStudentId,
                        CourseId          = Convert.ToInt32(Art1DDL.SelectedValue),
                        IsSecondary       = false,
                        IsGlobalAlternate = false,
                        TermId            = termId
                    };

                    db.CourseRequests.Add(art1);

                    if (Art2DDL.SelectedIndex >= 0)
                    {
                        WebhostMySQLConnection.CourseRequest art2 = new WebhostMySQLConnection.CourseRequest()
                        {
                            id                = ++newCRN,
                            StudentId         = SelectedStudentId,
                            CourseId          = Convert.ToInt32(Art2DDL.SelectedValue),
                            IsSecondary       = ArtPriority.SelectedIndex == 0,
                            IsGlobalAlternate = ArtPriority.SelectedIndex == 2,
                            TermId            = termId
                        };

                        db.CourseRequests.Add(art2);
                    }
                    if (Art3DDL.SelectedIndex >= 0)
                    {
                        WebhostMySQLConnection.CourseRequest art2 = new WebhostMySQLConnection.CourseRequest()
                        {
                            id                = ++newCRN,
                            StudentId         = SelectedStudentId,
                            CourseId          = Convert.ToInt32(Art3DDL.SelectedValue),
                            IsSecondary       = Art3Priority.SelectedIndex == 1,
                            IsGlobalAlternate = Art3Priority.SelectedIndex == 0,
                            TermId            = termId
                        };

                        db.CourseRequests.Add(art2);
                    }
                }

                if (student.CourseRequestComments.Where(crn => crn.TermId == termId).Count() > 0)
                {
                    CourseRequestComment crn = student.CourseRequestComments.Where(c => c.TermId == termId).Single();
                    crn.Notes = NotesInput.Text;
                }
                else
                {
                    int crnid = db.CourseRequestComments.Count() > 0?db.CourseRequestComments.OrderBy(c => c.id).ToList().Last().id + 1:0;
                    CourseRequestComment crn = new CourseRequestComment()
                    {
                        id        = crnid,
                        Notes     = NotesInput.Text,
                        StudentId = SelectedStudentId,
                        TermId    = termId
                    };

                    db.CourseRequestComments.Add(crn);
                }

                db.SaveChanges();
                Response.Redirect("~/CourseRequestConfirmed.aspx");
            }
        }