Click here to Skip to main content
Licence CPOL
First Posted 21 Apr 2004
Views 32,020
Downloads 65
Bookmarked 18 times

Flight Log Book

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

About the Author

Nicolas Gaillet

Web Developer

France France

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
-- There are no messages in this forum --
Permalink | Advertise | Privacy | Mobile
Web03 | 2.5.120528.1 | Last Updated 22 Apr 2004
Article Copyright 2004 by Nicolas Gaillet
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid