Click here to Skip to main content
Click here to Skip to main content

Calendar of Events in Windows Phone

By , 15 Oct 2012
Rate this:
Please Sign up or sign in to vote.

Introduction

Nowadays, most people always have busy days with a lot of meetings and a lot of work to do, and they must ensure that they don't forget any of them. So, why not help these people by providing an application that helps them manage all their events. As people may need this app anywhere and at anytime, it will be just great if they could get it with them in their pocket! So this app will be a Mobile app. And as we want to learn about the Microsoft's Mobile OS, we will use Windows Phone 7 as a platform.

Installing Tools

To develop applications in Windows Phone 7, you will need to have Visual Studio Express for Windows Phone which you can download from here, or if you have Visual Studio 2010 already installed on your computer, just install the WP7's SDK.

Building the Database

In WP7, you have to use the LINQ technology to manipulate your database. So we will need to add a reference to System.Data.Linq and to add the System.Linq using. We will reference our database by this:

ScheduleDataContext EventsDB = new ScheduleDataContext(@"isostore:/EventsDB.sdf"); 

So now we could manipulate our database as it is an object. To create it, just use the CreateDatabase() method:

if (EventsDB.DatabaseExists() == false)
    try
    {
        EventsDB.CreateDatabase();
    }
    catch (Exception exc) { return false;} 

As shown in the following picture, Intellisense provides all given methods with a little description.

It's good to program using the MVVM pattern. The Model here is the Event object. Because I will store it into the database, I have to specify the columns to use and their properties using annotations. The attribute that is started with [Column] will be stored in a column with his name.

[Table]
    public class Event
    {
        [Column(IsPrimaryKey = true)]
        public int EventID
        {
            get;
            set;
        }
        [Column(CanBeNull = false)]
        public string EventName
        {
            get;
            set;
        }
        [Column(CanBeNull = false)]
        public DateTime DateFrom
        {
            get;
            set;
        }
    }  

Then, to add an Event object to the table, just use InsertOnSubmit(Event) and SubmitChanges() methods.

EventsDB.Events.InsertOnSubmit(evnt);
EventsDB.SubmitChanges();  

Deleting an Event is also so simple. Consider using DeleteOnSubmit(Event) to delete and SubmitChanges() to save modification.

Here is an image that shows how Intellisense can help you.

Download the Full Project

You can download the full application code from MSDN.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Houssem Dellai
Student
Tunisia Tunisia
Studying Software Engineering in the National Engineering School of Sfax (ENIS), IEEE ENIS SB co chair of publicity, DotNet Enis Club manager, ImagineCup2012 competitor.
I like spending my free time developing open source .NET applications. I want to be an architect.
Mail : houssem.dellai@ieee.org
Phone : +216 95 325 964

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web01 | 2.8.140415.2 | Last Updated 15 Oct 2012
Article Copyright 2012 by Houssem Dellai
Everything else Copyright © CodeProject, 1999-2014
Terms of Use
Layout: fixed | fluid