protected void Page_Load(object sender, EventArgs e) { List <School> allSchools = null; List <StaffMember> allStaff = null; String dbConnectionString = ConfigurationManager.ConnectionStrings["SchoolLogicDatabase"].ConnectionString; using (SqlConnection connection = new SqlConnection(dbConnectionString)) { allSchools = School.loadAllSchools(connection); allStaff = StaffMember.loadAllStaff(connection); } panel_TablePanel.Controls.Clear(); panel_TablePanel.Controls.Add(buildStaffTable(new School("No School", "0", "0", "", "default_logo.gif"), allStaff)); foreach (School school in allSchools) { panel_TablePanel.Controls.Add(buildStaffTable(school, allStaff)); } }
protected void Page_Load(object sender, EventArgs e) { List <Student> allStudents = new List <Student>(); List <School> allSchools = new List <School>(); List <StaffMember> allStaff = new List <StaffMember>(); float numStudents = allStudents.Count; float numMales = 0; float numFemales = 0; float numBirthdaysToday = 0; float numBirthdaysTomorrow = 0; float numBirthadysThisMonth = 0; List <String> allCities = new List <String>(); List <String> allRegions = new List <String>(); String dbConnectionString = ConfigurationManager.ConnectionStrings["SchoolLogicDatabase"].ConnectionString; using (SqlConnection connection = new SqlConnection(dbConnectionString)) { allStudents = Student.loadAllStudents(connection); allSchools = School.loadAllSchools(connection); allStaff = StaffMember.loadAllStaff(connection); } foreach (Student student in allStudents) { if (student.getGender().ToLower() == "male") { numMales++; } if (student.getGender().ToLower() == "female") { numFemales++; } if ( (student.getDateOfBirth().Day == DateTime.Now.Day) && (student.getDateOfBirth().Month == DateTime.Now.Month) ) { numBirthdaysToday++; } if ( (student.getDateOfBirth().Month == DateTime.Now.Month) && (student.getDateOfBirth().Day == DateTime.Now.AddDays(1).Day) ) { numBirthdaysTomorrow++; } if (student.getDateOfBirth().Month == DateTime.Now.Month) { numBirthadysThisMonth++; } if (!allCities.Contains(student.getCity())) { allCities.Add(student.getCity()); } if (!allRegions.Contains(student.getRegion())) { allRegions.Add(student.getRegion()); } } /* Generate XML */ Response.Clear(); Response.ContentEncoding = Encoding.UTF8; Response.ContentType = "text/xml; charset=utf-8"; Response.Write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); Response.Write("<SchoolLogicStats>"); Response.Write("<Schools>"); Response.Write("<SchoolCount>" + allSchools.Count + "</SchoolCount>"); Response.Write("<RegionCount>" + allRegions.Count + "</RegionCount>"); Response.Write("</Schools>"); Response.Write("<Students>"); Response.Write("<Total>" + allStudents.Count + "</Total>"); Response.Write("<Male>" + numMales + "</Male>"); Response.Write("<Female>" + numFemales + "</Female>"); Response.Write("<Birthdays>"); Response.Write("<Today>" + numBirthdaysToday + "</Today>"); Response.Write("<Tomorrow>" + numBirthdaysTomorrow + "</Tomorrow>"); Response.Write("<ThisMonth>" + numBirthadysThisMonth + "</ThisMonth>"); Response.Write("</Birthdays>"); Response.Write("</Students>"); Response.Write("<Staff>"); Response.Write("<Total>" + allStaff.Count + "</Total>"); Response.Write("</Staff>"); Response.Write("</SchoolLogicStats>"); Response.End(); }
protected void Page_Load(object sender, EventArgs e) { // Load data for the statistics box List <Student> allStudents = new List <Student>(); List <School> allSchools = new List <School>(); List <StaffMember> allStaff = new List <StaffMember>(); using (SqlConnection connection = new SqlConnection(dbConnectionString)) { allStudents = Student.loadAllStudents(connection); allSchools = School.loadAllSchools(connection); allStaff = StaffMember.loadAllStaff(connection); } float numStudents = allStudents.Count; float numMales = 0; float numFemales = 0; float numBirthdays = 0; List <String> allCities = new List <String>(); List <String> allRegions = new List <String>(); foreach (Student student in allStudents) { if (student.getGender().ToLower() == "male") { numMales++; } if (student.getGender().ToLower() == "female") { numFemales++; } if ( (student.getDateOfBirth().Day == DateTime.Now.Day) && (student.getDateOfBirth().Month == DateTime.Now.Month) ) { numBirthdays++; } if (!allCities.Contains(student.getCity())) { allCities.Add(student.getCity()); } if (!allRegions.Contains(student.getRegion())) { allRegions.Add(student.getRegion()); } } lblActiveStudentCount.Text = numStudents.ToString(); lblSchoolCount.Text = allSchools.Count.ToString(); lblStaffCount.Text = allStaff.Count.ToString(); lblMaleCount.Text = numMales.ToString(); lblFemaleCount.Text = numFemales.ToString(); lblBirthdayCount.Text = numBirthdays.ToString(); lblMalePercent.Text = Math.Round((float)((numMales / numStudents) * 100)) + "%"; lblFemalePercent.Text = Math.Round((float)((numFemales / numStudents) * 100)) + "%"; lblCities.Text = allCities.Count().ToString(); lblRegions.Text = allRegions.Count().ToString(); }
protected void Page_Load(object sender, EventArgs e) { List <Student> allStudents = new List <Student>(); List <School> allSchools = new List <School>(); List <StaffMember> allStaff = new List <StaffMember>(); float numStudents = allStudents.Count; float numMales = 0; float numFemales = 0; float numBirthdaysToday = 0; float numBirthdaysTomorrow = 0; float numBirthadysThisMonth = 0; List <String> allCities = new List <String>(); List <String> allRegions = new List <String>(); String dbConnectionString = ConfigurationManager.ConnectionStrings["SchoolLogicDatabase"].ConnectionString; using (SqlConnection connection = new SqlConnection(dbConnectionString)) { allStudents = Student.loadAllStudents(connection); allSchools = School.loadAllSchools(connection); allStaff = StaffMember.loadAllStaff(connection); } foreach (Student student in allStudents) { if (student.getGender().ToLower() == "male") { numMales++; } if (student.getGender().ToLower() == "female") { numFemales++; } if ( (student.getDateOfBirth().Day == DateTime.Now.Day) && (student.getDateOfBirth().Month == DateTime.Now.Month) ) { numBirthdaysToday++; } if ( (student.getDateOfBirth().Month == DateTime.Now.Month) && (student.getDateOfBirth().Day == DateTime.Now.AddDays(1).Day) ) { numBirthdaysTomorrow++; } if (student.getDateOfBirth().Month == DateTime.Now.Month) { numBirthadysThisMonth++; } if (!allCities.Contains(student.getCity())) { allCities.Add(student.getCity()); } if (!allRegions.Contains(student.getRegion())) { allRegions.Add(student.getRegion()); } } /* Generate XML */ Response.Clear(); Response.ContentEncoding = Encoding.UTF8; Response.ContentType = "application/json; charset=utf-8"; Response.Write("{"); Response.Write("\"Schools\": {"); Response.Write("\"SchoolCount\": " + allSchools.Count + ","); Response.Write("\"RegionCount\": " + allRegions.Count + ""); Response.Write("},"); Response.Write("\"Students\": {"); Response.Write("\"Total\": " + allStudents.Count + ","); Response.Write("\"Male\": " + numMales + ","); Response.Write("\"Female\": " + numFemales + ","); Response.Write("\"BirthdaysToday\": " + numBirthdaysToday + ","); Response.Write("\"BirthdaysTomorrow\": " + numBirthdaysTomorrow + ","); Response.Write("\"BirthdaysThisMonth\": " + numBirthadysThisMonth + ""); Response.Write("},"); Response.Write("\"Staff\": {"); Response.Write("\"Total\": " + allStaff.Count + ""); Response.Write("}"); Response.Write("}"); Response.End(); }