public Flight(Family assignedFamily, Pilot pilot, double maxWeight, int numberOfSeats, string notes) { AssignedFamily = assignedFamily; AssignedPilot = pilot; MaxWeight = maxWeight; NumberOfSeats = numberOfSeats; Notes = notes; }
/// <summary> /// Returns a list of all pilots in the database /// </summary> /// <returns></returns> public List<Pilot> GetPilots() { List<Pilot> pilots = new List<Pilot>(); try { using (SqlCeConnection dbConnection = new SqlCeConnection( "Data Source=\"SKDDatabase.sdf\"")) { dbConnection.Open(); SqlCeCommand dbCommand = new SqlCeCommand(@"SELECT * FROM pilot", dbConnection); SqlCeDataReader dbReader = dbCommand.ExecuteReader(); while (dbReader.Read()) { Pilot pilot = new Pilot(dbReader.IsDBNull(0)? null : dbReader.GetString(0), dbReader.IsDBNull(1)? null : dbReader.GetString(1), dbReader.IsDBNull(4)? null : dbReader.GetString(4), dbReader.IsDBNull(3)? null : dbReader.GetString(3), dbReader.IsDBNull(2)? (Guid?) null : dbReader.GetGuid(2)); pilots.Add(pilot); } dbConnection.Close(); } } catch (Exception e) { Console.WriteLine("Unexpected error: " + e.Message); } return pilots; }