Ejemplo n.º 1
0
 public Flight(Family assignedFamily, Pilot pilot, double maxWeight, int numberOfSeats,
         string notes)
 {
     AssignedFamily = assignedFamily;
     AssignedPilot = pilot;
     MaxWeight = maxWeight;
     NumberOfSeats = numberOfSeats;
     Notes = notes;
 }
Ejemplo n.º 2
0
        /// <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;
        }