Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to change database data and get a reminder when the doc. expire 1

Status
Not open for further replies.

taree

Technical User
May 31, 2008
316
US
I have a gridview that display some data and I have a Issue date, expired date, status fields that I display in the gridview. The expiration date for some of the documents is in the future and my attempt is to get a reminder when the expiration date in the document equals to the current date. As soon as the document is expired I would like to change the status from active to expire. How can I approach this.

thank you
 
expiring the document isn't a GUI concern, it's a logical concern. this should be done outside of any reference to GUI objects.

the logic is simple enough
Code:
public class Issue
{
   public DateTime issue_date {get;set;}
   public DateTime expires_on {get;set;}
   public Status status
   {
       get
       {
           if(expires_on <= DateTime.Now) return Status.Expired;
           return Status.Active;
       }
   }
}

public enum Status
{
    Active,
    Expired
}

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Just a follow up question. How can I send a reminder for myself when this expires_on <= DateTime.Now is true.thank you for the help.
 
this is another matter. It cannot relate to asp.net or webforms in any way. a website can stop/shutdown if no one is actively using the website. You would need a windows service running in the background which queries for expired orders and sends an email. the sql query and code are simple enough.
Code:
select [fields] from [table] where expires_on <= DateTime.Now && a_flag_stating_the_message_has_not_been_sent_already

var server = new SmtpClient();
foreach(var row in results_from_sql)
{
   server.Send(create_message_from(row));
}

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Jason,

I thank you for your help so far but i am still confused a little bit. for your above example to work for me do I have to create a separate page as an exe file for the windows service to run. Is this the function I am supposed to create? create_message_from(row)) please clarify it for me. thank you for your time and help.
 
for your above example to work for me do I have to create a separate page as an exe file for the windows service to run.
no, this has nothing to do with web development. this is a an entirely new project (within the same solution, if desired). research creating windows services from VS.

Is this the function I am supposed to create? create_message_from(row))
yes, create_message_from(...) will return a mail message. you can then pass that message to the stmp client to send the email.


Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Thank you Jason for clarifying that for me.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top