Click here to Skip to main content
15,886,026 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys,

I have to create one REMINDER in my project,

the scenario is: my project is related to chemical inventory, where i have to create a reminder for the chemicals which are about to expire.

Can anyone plz suggest me, how can i create a reminder for '5days before the expiry of chemical' comparing with current date/expiry date...

Regards,
Posted
Comments
Kornfeld Eliyahu Peter 12-Jan-14 5:09am    
Not clear...
1. do you want to show some alert on login or
2. add alert to existing list of inventory
Torakami 12-Jan-14 5:10am    
Did you mean you have to send any email or something like that .

If thats the answer you can either create one windows service for that or you can create SQL reminders which will automatically send you an email

Try:
C#
DateTime expiryDate = new DateTime(2014, 1, 17);
if (DateTime.Now.AddDays(5) >= expiryDate)
    {
    Console.WriteLine("Expired");
    }
 
Share this answer
 
You may do something like this (pseudo code):
C#
class Chemical
{
  ...
}
...
void ReportExpiredChemicals(int leadTimeInDays, Action<Chemical> report)
{
    var cutoff = Today + leadTimeInDays; // some magic Today property
    DataContext dc = ...                 // some data context that provices that data table for chemicals
    var query = from c in dc.GetTable<Chemical>
                where c.ExpireDate < cutoff
                select c;
    foreach(var c in query) report(c);
}
...
void SendEmailForExpiredChemical(Chemical chemical) { ... }
...
const int twoWeeks = 14; // days;
ReportExpiredChemicals(twoWeeks, SendEmailForExpiredChemical);


Cheers
Andi
 
Share this answer
 
v3

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900