Click here to Skip to main content
15,885,032 members
Articles / Mobile Apps / Windows Mobile

Flight Log Book

Rate me:
Please Sign up or sign in to vote.
3.24/5 (40 votes)
21 Apr 2004CPOL 44.4K   186   18  
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 :

C#
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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
France France
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
-- There are no messages in this forum --