protected void TermSelect_SelectedIndexChanged(object sender, EventArgs e) { ClassSelect.Enabled = true; using (WebhostEntities db = new WebhostEntities()) { int tid = Convert.ToInt32(TermSelect.SelectedValue); int sid = this.user.ID; Student student = db.Students.Where(s => s.ID == sid).Single(); List <int> sectionIds = new List <int>(); foreach (StudentComment comment in student.StudentComments.ToList()) { if (comment.CommentHeader.TermIndex == tid) { sectionIds.Add(comment.CommentHeader.SectionIndex); } } ClassSelect.DataSource = SectionListItem.GetDataSource(sectionIds); ClassSelect.DataTextField = "Text"; ClassSelect.DataValueField = "ID"; ClassSelect.DataBind(); ReadonlyCommentViewer1.Visible = false; } }
private void LoadSections() { spSections.Children.Clear(); foreach (Models.Section section in Page.Sections) { SectionListItem pageListItem = new SectionListItem(section, Studio); spSections.Children.Add(pageListItem); } }
private static void AddSectionsToCanvas(double ellipseNormalSize, Canvas canvas, ScaleTransform trans, SectionListItem section) { var el = new Ellipse() { Width = ellipseNormalSize, Height = ellipseNormalSize, Fill = Brushes.Red, Stroke = Brushes.Gray, Tag = "section", RenderTransform = trans, RenderTransformOrigin = new Point(0.5, 0.5), DataContext = section, }; Panel.SetZIndex(el, counterLevel); canvas.Children.Add(el); Canvas.SetLeft(el, section.FromCoord.X - el.Width / 2); Canvas.SetTop(el, section.FromCoord.Y - el.Height / 2); //--------------------------------------------------------------- el = new Ellipse() { Width = ellipseNormalSize, Height = ellipseNormalSize, Fill = Brushes.Green, Stroke = Brushes.Gray, Tag = "section", RenderTransform = trans, RenderTransformOrigin = new Point(0.5, 0.5), DataContext = section, }; Panel.SetZIndex(el, counterLevel); canvas.Children.Add(el); Canvas.SetLeft(el, section.ToCoord.X - el.Width / 2); Canvas.SetTop(el, section.ToCoord.Y - el.Height / 2); }
new protected void Page_Init(object sender, EventArgs e) { base.Page_Init(sender, e); int uid = user.ID; using (WebhostEntities db = new WebhostEntities()) { Faculty faculty = db.Faculties.Find(uid); if (faculty == null) { LogError("Unable to locate faculty id {0}", uid); return; } int term = Import.GetCurrentOrLastTerm(); List <Section> currentSections = faculty.Sections.Where(sec => sec.Terms.Where(t => t.id == term).Count() > 0).ToList(); State.log.WriteLine("{1} {0}: Found {2} current sections.", DateTime.Now.ToLongTimeString(), DateTime.Today.ToShortDateString(), currentSections.Count); if (SectionId == -1) { int currentBlockId = -1; Dictionary <DateRange, int> data = DateRange.BlockIdsByTime(DateTime.Today); foreach (DateRange classtime in data.Keys) { if (classtime.Contains(DateTime.Now)) { currentBlockId = data[classtime]; if (currentSections.Where(sec => sec.BlockIndex == currentBlockId).Count() > 0) { SectionId = currentSections.Where(sec => sec.BlockIndex == currentBlockId).ToList().First().id; break; } } } if (SectionId == -1) { foreach (DateRange classtime in data.Keys) { if (classtime.Intersects(DateTime.Now.AddMinutes(-30), DateTime.Now)) { currentBlockId = data[classtime]; if (currentSections.Where(sec => sec.BlockIndex == currentBlockId).Count() > 0) { SectionId = currentSections.Where(sec => sec.BlockIndex == currentBlockId).ToList().First().id; break; } } } } } ClassSelectCB.DataSource = SectionListItem.GetDataSource(currentSections.Select(sec => sec.id).ToList()); ClassSelectCB.DataTextField = "Text"; ClassSelectCB.DataValueField = "ID"; ClassSelectCB.DataBind(); TodayCB.Visible = false; DateInput.Visible = false; DateSelectBtn.Visible = false; SubmitBtn.Visible = false; } if (this.SectionId != -1) { LoadInfo(SectionId, AttendanceDate); } }
new protected void Page_Init(object sender, EventArgs e) { base.Page_Init(sender, e); int uid = user.ID; using (WebhostEntities db = new WebhostEntities()) { Faculty faculty = db.Faculties.Find(MasqId == -1 ? uid : MasqId); if (faculty == null) { LogError("Unable to locate faculty id {0}", uid); return; } int term = DateRange.GetCurrentOrLastTerm(); List <Section> currentSections = faculty.Sections.Where(sec => sec.Terms.Where(t => t.id == term).Count() > 0).ToList(); State.log.WriteLine("{1} {0}: Found {2} current sections.", DateTime.Now.ToLongTimeString(), DateTime.Today.ToShortDateString(), currentSections.Count); if (SectionId == -1) { int currentBlockId = -1; Dictionary <DateRange, int> data = DateRange.BlockIdsByTime(DateTime.Today); foreach (DateRange classtime in data.Keys) { if (classtime.Contains(DateTime.Now)) { currentBlockId = data[classtime]; if (currentSections.Where(sec => sec.BlockIndex == currentBlockId).Count() > 0) { SectionId = currentSections.Where(sec => sec.BlockIndex == currentBlockId).ToList().First().id; break; } } } if (SectionId == -1) { foreach (DateRange classtime in data.Keys) { if (classtime.Intersects(DateTime.Now.AddMinutes(-30), DateTime.Now)) { currentBlockId = data[classtime]; if (currentSections.Where(sec => sec.BlockIndex == currentBlockId).Count() > 0) { SectionId = currentSections.Where(sec => sec.BlockIndex == currentBlockId).ToList().First().id; break; } } } } } ClassSelectCB.DataSource = SectionListItem.GetDataSource(currentSections.Select(sec => sec.id).ToList()); ClassSelectCB.DataTextField = "Text"; ClassSelectCB.DataValueField = "ID"; ClassSelectCB.DataBind(); foreach (ListItem classItem in ClassSelectCB.Items) { int sectionId = Convert.ToInt32(classItem.Value); Section section = db.Sections.Find(sectionId); if (DateTime.Today.DayOfWeek.Equals(DayOfWeek.Saturday) || DateTime.Today.DayOfWeek.Equals(DayOfWeek.Sunday)) { continue; } bool attendanceTaken = true; foreach (Student student in section.Students.ToList()) { if (section.AttendanceMarkings.Where(att => att.AttendanceDate.Equals(DateTime.Today) && att.StudentID.Equals(student.ID)).Count() <= 0) { attendanceTaken = false; break; } } bool meetsThisDay = false; switch (DateTime.Today.DayOfWeek) { case DayOfWeek.Monday: meetsThisDay = section.Block.MeetsMonday; break; case DayOfWeek.Tuesday: meetsThisDay = section.Block.MeetsTuesday; break; case DayOfWeek.Wednesday: if (!section.Block.MeetsWednesday) { meetsThisDay = false; } else if (section.Block.IsSpecial || db.WednesdaySchedules.Where(w => w.Day.Equals(DateTime.Today)).Count() <= 0) { meetsThisDay = section.Block.MeetsWednesday; } else { meetsThisDay = DateRange.BlockOrderByDayOfWeek(DateTime.Today).Contains(section.Block.Name[0]); } break; case DayOfWeek.Thursday: meetsThisDay = section.Block.MeetsThursday; break; case DayOfWeek.Friday: meetsThisDay = section.Block.MeetsFriday; break; default: break; } if (attendanceTaken) { classItem.Text += " [Done]"; } else if (!meetsThisDay) { classItem.Text += " [No Meeting Today]"; } else { classItem.Text += " [Incomplete]"; } } TodayCB.Visible = false; DateInput.Visible = false; DateSelectBtn.Visible = false; SubmitBtn.Visible = false; } if (this.SectionId != -1) { LoadInfo(SectionId, AttendanceDate); } }
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); } } }