Hello people, how are you? I am fine, thank you.
Mobiles have become an integral part of our lives. They have become better than our better halves acting as schedulers, reminders, organizers, file sharers, personalized music systems and much much more than one can expect. I am myself a phone freak. For 3 years, I was a Nokia fan (Symbian OS) and now I am a Windows mobile fan.
Owning a Windows Mobile offers a lot to a Windows developer. If you know .NET coding, you can create cool customized applications for your phone.
How It Works
I am suffering a birthday memory loss and often get beaten up by my wife, embarrassed by friends for forgetting their birthdays. To overcome this tendency of mine, I made this cool tool for my rescue.
My code in the phone scans the application database filled with people’s information for their birthdate to match with the current date. If it matches, the code sends an SMS to the person’s mobile number and to the owner mobile as well (for owner’s reminder) automatically. Now no need to remember any birthday, just feed it once in the application and forget it. The code will take care of the rest.
You need a phone that supports .NET Compact Framework (.NET CF) 3.0 and SQL Server CE (Compact Edition). Windows mobile 6.0 above supports it by default. For Symbian mobiles, .NET CF was available from Red Five Labs but these days, I don’t know why, their website is not working so you need to Google a bit to find out from where you can download that.
List of files explicitly required to be installed on phone are:
(You will find these files (1 to 4) in the SQL Server 2005 CE folder.)
- Scheduler (attached with the article)
For development, you need Visual Studio 2005/2008 IDE and Smartphone development SDKs.
You can download the following for development purposes:
Preparing User Interface
Well that’s a piece of cake; all you need is a little creativity as the phone screen is relatively smaller than a computer/laptop. Tabbed control is very useful as you can segregate your functionality in multiple tabs so the screen breathes with space and doesn’t look jammed up.
I am posting pictures of UI I used in my application. Feel free to customize it the way you want.
To create a mobile application, open Visual Studio 2005/2008 and create a new project. This will open a New Project Window. Select Smart Device under your preferred language.
Clicking OK will further open a screen for choosing smart phone platform type.
Select Device Application here.
Screen #1 Detailed View
Here we get per record detail for each field. Forget the “Stop the Timer” button as of now, I will explain it later.
Screen #2 Grid View
Shows all the records on one screen.
Screen #3 Message window
This screen shows a Text box which contains the message that will be sent automatically to the birthday boy/girl.
Screen #4 About screen, not important for you.
I deserve to have credits for my work after getting those brutal beatings from my wife.
The controls used here are no different than the ones used in .NET Windows applications, a little bit of change in the way they are coded and few reduced functionalities (as mobile has limited memory and resources).
Nothing techy, here is the walkthrough:
- Prepare the table structure. Open SQL Sever Management studio and create a new table. It will save the database at your selected location with SDF extension. Example – abc.sdf
The field “
sno” is auto generated primary key.
- Add this newly create table inside “sdf” file database into your application. Adding the database will prompt you for creating
DataSet. Go ahead and create it. This will add Dataset Table Adapter and binding source to your project.
All set, now we are ready to roll. The Table Adapter is very useful as it makes life easier for performing the DML (Data Manipulation Language) tasks, like for deleting a record you just need to write this piece of following code:
BirthDayInfoTableAdapter.Delete(<primary key value to be deleted>)
Now in the above code we first delete the record, refill the dataset (kind of refresh the dataset).
The main code for checking the birthday is:
For i = 0 To BirthDayInfoDataSet.BirthDayInfo.Rows.Count - 1
If BirthDayInfoDataSet.BirthDayInfo(i).dateOfBirth.Day = Date.Now.Day And _
BirthDayInfoDataSet.BirthDayInfo(i).dateOfBirth.Date.Month = Date.Now.Month Then
Dim sms As New SmsMessage(BirthDayInfoDataSet.BirthDayInfo(i).mobileNumber,
_ "Hi " & BirthDayInfoDataSet.BirthDayInfo(i).fullName & vbCrLf & txtMessage.Text)
Dim sms2 As New SmsMessage("mobile number", _
"Hi " & BirthDayInfoDataSet.BirthDayInfo(i).fullName & vbCrLf & txtMessage.Text)
It matched, all the birthdates and months are stored in table with the current date and month. If matched, send SMS, else skip.
SmsMessage is an inbuilt library for sending messages.
So this is the main recipe for the project and to add a dessert, I added the “Stop the Timer” button. When the code fires, the window will remain open and consume your phone's valuable memory and hence drain battery, so I added a timer which automatically closes the application after 10 seconds. So when you put the application in scheduler (by using the Scheduler application attached in the article), the code will run at your specified time and day of the week, check birthdays, sends SMS to deserving entries and close automatically. So as the application closes automatically, I added that “Stop the timer” button which if you click within 10 seconds will disable closing of the application (for that time only).
So after this long article, I have covered the main bits of the application. You can find the rest of the goodies in the code attached. I hope you find this code interesting to use, if you don’t, feel free to abuse me with all your heart.
I am module lead with experience in Microsoft Technologies like .NET, SharePoint etc.