protected void Page_Load(object sender, EventArgs e) { List<ReportPeriod> allReportPeriods = new List<ReportPeriod>(); List<Term> allTerms = new List<Term>(); List<Track> allTracks = new List<Track>(); List<School> allSchools = new List<School>(); using (SqlConnection connection = new SqlConnection(LSKYCommon.dbConnectionString_SchoolLogic)) { allReportPeriods = ReportPeriod.loadAllReportPeriods(connection); allTracks = Track.loadAllTracks(connection); allTerms = Term.loadAllTerms(connection); allSchools = School.loadAllSchools(connection); } allReportPeriods.Sort(); foreach (ReportPeriod rp in allReportPeriods) { // Find this report period's term string termString = "Unknown"; string schoolString = ""; foreach (Term term in allTerms) { if (term.ID == rp.termID) { foreach (Track track in allTracks) { if (term.trackID == track.ID) { termString = track.name + " - " + term.name; } } } } // Find the school foreach (School school in allSchools) { if (rp.schoolID == int.Parse(school.getSchoolLogicID())) { schoolString = school.getName(); } } tblReportPeriodsUpcoming.Rows.Add(addReportPeriodRow(rp, termString, schoolString)); } }
protected void Page_Load(object sender, EventArgs e) { List <ReportPeriod> allReportPeriods = new List <ReportPeriod>(); List <Term> allTerms = new List <Term>(); List <Track> allTracks = new List <Track>(); List <School> allSchools = new List <School>(); using (SqlConnection connection = new SqlConnection(LSKYCommon.dbConnectionString_SchoolLogic)) { allReportPeriods = ReportPeriod.loadAllReportPeriods(connection); allTracks = Track.loadAllTracks(connection); allTerms = Term.loadAllTerms(connection); allSchools = School.loadAllSchools(connection); } allReportPeriods.Sort( delegate(ReportPeriod first, ReportPeriod next) { return(first.DateCloses.CompareTo(next.DateCloses)); } ); foreach (ReportPeriod rp in allReportPeriods) { // Find this report period's term string termString = "Unknown"; string schoolString = ""; foreach (Term term in allTerms) { if (term.ID == rp.termID) { foreach (Track track in allTracks) { if (term.trackID == track.ID) { termString = track.name + " - " + term.name; } } } } // Find the school foreach (School school in allSchools) { if (rp.schoolID == int.Parse(school.getSchoolLogicID())) { schoolString = school.getName(); } } if ((DateTime.Today >= rp.DateOpens) && (DateTime.Today <= rp.DateCloses)) { tblOpenReportPeriods.Rows.Add(addOpenReportPeriodRow(rp, termString, schoolString)); } else if (rp.DateOpens > DateTime.Today) { tblReportPeriodsUpcoming.Rows.Add(addUpcomingReportPeriodRow(rp, termString, schoolString)); } else { tblReportPeriodsCompleted.Rows.Add(addCompletedReportPeriodRow(rp, termString, schoolString)); } } }