public static List <ReportPeriod> loadReportPeriodsFromThisSchool(SqlConnection connection, School school) { List <ReportPeriod> returnMe = new List <ReportPeriod>(); SqlCommand sqlCommand = new SqlCommand(); sqlCommand.Connection = connection; sqlCommand.CommandType = CommandType.Text; sqlCommand.CommandText = "SELECT * FROM ReportPeriod WHERE iSchoolID=" + school.getSchoolLogicID() + ""; sqlCommand.Connection.Open(); SqlDataReader dataReader = sqlCommand.ExecuteReader(); if (dataReader.HasRows) { while (dataReader.Read()) { returnMe.Add(new ReportPeriod( int.Parse(dataReader["iReportPeriodID"].ToString().Trim()), dataReader["cName"].ToString().Trim(), DateTime.Parse(dataReader["dStartDate"].ToString()), DateTime.Parse(dataReader["dEndDate"].ToString()), int.Parse(dataReader["iSchoolID"].ToString().Trim()), int.Parse(dataReader["iTermID"].ToString().Trim()) )); } } sqlCommand.Connection.Close(); foreach (ReportPeriod rp in returnMe) { rp.loadReportPeriodSettings(connection); } return(returnMe); }
public static List <Student> loadReserveStudentsFromThisSchool(SqlConnection connection, School school) { List <Student> returnMe = new List <Student>(); SqlCommand sqlCommand = new SqlCommand(); sqlCommand.Connection = connection; sqlCommand.CommandType = CommandType.Text; sqlCommand.CommandText = "SELECT * FROM LSKY_ActiveStudents WHERE ResideOnReserve=1 AND SchoolID=@SchoolID ORDER BY SchoolID ASC, Grade ASC;"; sqlCommand.Parameters.AddWithValue("@SchoolID", school.getGovIDAsString()); sqlCommand.Connection.Open(); SqlDataReader dataReader = sqlCommand.ExecuteReader(); if (dataReader.HasRows) { while (dataReader.Read()) { string HomeRoom = dataReader["HomeRoom"].ToString().Trim(); string HRT_Title = dataReader["HomeRoomTeacherTitle"].ToString().Trim(); string HRT_First = dataReader["HomeRoomTeacherFirstName"].ToString().Trim(); string HRT_Last = dataReader["HomeRoomTeacherLastName"].ToString().Trim(); if ((!string.IsNullOrEmpty(HRT_First)) && (!string.IsNullOrEmpty(HRT_Last))) { HomeRoom = HomeRoom + " ("; if ((!string.IsNullOrEmpty(HRT_Title))) { HomeRoom = HomeRoom + HRT_Title; } else { HomeRoom = HomeRoom + HRT_First; } HomeRoom = HomeRoom + " " + HRT_Last + ")"; } bool hasPhoto = false; if (!string.IsNullOrEmpty(dataReader["PhotoType"].ToString())) { hasPhoto = true; } int credits = 0; int.TryParse(dataReader["Credits"].ToString(), out credits); Student newStudent = new Student( dataReader["FirstName"].ToString().Trim(), dataReader["LastName"].ToString().Trim(), dataReader["LegalFirstName"].ToString().Trim(), dataReader["LegalLastName"].ToString().Trim(), dataReader["LegalMiddleName"].ToString(), dataReader["StudentNumber"].ToString().Trim(), dataReader["GovernmentIDNumber"].ToString().Trim(), dataReader["School"].ToString().Trim(), dataReader["SchoolID"].ToString().Trim(), dataReader["Grade"].ToString().Trim(), dataReader["Region"].ToString().Trim(), dataReader["City"].ToString().Trim(), dataReader["Street"].ToString().Trim(), dataReader["HouseNo"].ToString().Trim(), dataReader["ApartmentNo"].ToString().Trim(), dataReader["PostalCode"].ToString().Trim(), dataReader["Phone"].ToString().Trim(), dataReader["Gender"].ToString().Trim(), dataReader["InStatus"].ToString().Trim(), dataReader["InStatusCode"].ToString().Trim(), dataReader["HomeRoom"].ToString().Trim(), DateTime.Parse(dataReader["InDate"].ToString()), DateTime.Parse(dataReader["DateOfBirth"].ToString()), dataReader["BandNo"].ToString().Trim(), dataReader["BandName"].ToString().Trim(), dataReader["ReserveName"].ToString().Trim(), dataReader["ReserveHouse"].ToString().Trim(), dataReader["StatusNo"].ToString().Trim(), bool.Parse(dataReader["ResideOnReserve"].ToString()), int.Parse(dataReader["TrackID"].ToString()), hasPhoto, dataReader["cUserName"].ToString().Trim(), credits, int.Parse(dataReader["iActive_StudentStatusID"].ToString()), dataReader["AboriginalStatus"].ToString().Trim(), dataReader["LanguageHome"].ToString().Trim(), dataReader["ParkingPermit"].ToString().Trim(), dataReader["cLockerNumber"].ToString().Trim(), dataReader["cLockerCombination"].ToString().Trim() ); returnMe.Add(newStudent); } } sqlCommand.Connection.Close(); return(returnMe); }