Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Flight Log Book

0.00/5 (No votes)
21 Apr 2004 1  
Log Book for Flight Planner.

Sample Image - FlightLogBook.jpg

Introduction

Hi, I am new to Pocket PC development, and I wished to have a logbook for my flights in Flight Simulator. This logbook was developed in C# using .NET Compact Framework and SQL Server CE 2.0.

Resources

The only resource that I have found is for using SQL Server CE. I found a walkthrought in MSDN.
Sorry for my poor english...

How I do that ?

It simple. I have three forms: one for main application entry point that creates the database if it doesn't exists, and show its content :

private void Form1_Load(object sender, System.EventArgs e)
{
    try 
    {
        // If the database doesn't exists, create it

        if (!File.Exists ("Flight.sdf")) 
        {
            SqlCeEngine engine = new SqlCeEngine ("Data Source = Flight.sdf");
            engine.CreateDatabase ();
            conn = new SqlCeConnection ("Data Source = Flight.sdf");
            conn.Open();
            cmd = conn.CreateCommand();
            cmd.CommandText = "CREATE TABLE " +
                  "Flights(ID int PRIMARY KEY IDENTITY(1,1), Departure ntext," +
                  "Arrival ntext, Date datetime, Weather ntext, Summary ntext)";
            cmd.ExecuteNonQuery();
            conn.Close();
        } 
        else // else initialize the connection
        {
            conn = new SqlCeConnection ("Data Source = Flight.sdf");
            cmd = conn.CreateCommand();
            UpdateLView();
        }
    }
    catch (SqlCeException ex) 
    {
    
    }
}
public void UpdateLView() //This function updates the main listview
{
    lVFlights.Items.Clear();
    conn.Open();
    cmd.CommandText = "SELECT * FROM Flights ORDER BY Date DESC;";
    SqlCeDataReader rdr = cmd.ExecuteReader();
    ListViewItem lvi = null;
    while(rdr.Read())
    {
        lvi = new ListViewItem(rdr.GetInt32(0).ToString());
        lvi.SubItems.Add(rdr.GetDateTime(3).ToShortDateString());
        lvi.SubItems.Add(rdr.GetString(1));
        lvi.SubItems.Add(rdr.GetString(2));
        lvi.SubItems.Add(rdr.GetString(4));
        lvi.SubItems.Add(rdr.GetString(5));
        lVFlights.Items.Add(lvi);
    }
    lVFlights.Refresh();
    conn.Close();
}

Two others forms that permit to add a new entry, and the other to modify it.

Test It !

The only thing you must do for testing my app, is to compile with Visual Studio .NET 2003.
Remember that you must have PocketPC 2003 SDK installed on your machine.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here