|
-
Sep 30th, 2012, 10:14 PM
#1
Thread Starter
Addicted Member
how to create a reminder pop up message?
I am developing windows application using c# and sql server 2008.
i have a table with a name: todolistTable with columns, id,reminderDesc,date
i will have an entry form for reminderdescription and date of the reminder.
then i want to show me pop up message of the work i added in the table to remind me when the difference time between today and the date on the table is 3.
could you show me on how to code it please. thanks
-
Oct 1st, 2012, 12:33 AM
#2
Re: how to create a reminder pop up message?
When you start the application, retrieve the DateTime value from the database. That is done just like any other data retrieval so there are plenty of examples around of that. You can then subtract the current date and time (DateTime.Now) from that value to get a TimeSpan that represents the difference. If the TotalDays property of that TimeSpan is 3.0 or less then you display your reminder immediately.
If it's greater than 3.0 then you would basically set an alarm, which you would do with a Timer. First, subtract 3 days from the TimeSpan to get the exact alarm time. Create a Timer and set its Interval to the rounded TotalMilliseconds property value of the TimeSpan and Start the Timer. The Timer will then raise its Tick event 3 days before the date in the database. You would Stop the Timer and then display your notification.
Note that the maximum possible value for the Interval property equates to about 24 and a half days. If your alarm needs to occur later than that then you can simply set the Interval to the maximum and then, when the Tick event is raised, recalculate the alarm time and Start the Timer again.
Note also that it doesn't matter if you close the app before the alarm time because the whole thing will happen again when you start the app next, so a new alarm will be set if required. Just note that you may have to record somewhere permanently when a notification is displayed so that you don't get repeats. That would probably mean in the database.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|