Click here to Skip to main content
15,850,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am developing one winforms application for which i want to generate monthly, weekly, yearly reports automatically at the end of the week, month, year. and if user changes the date it should not generate report.

I can generate on button click(manually) but i want it to generate at the end of week, month, year how should i do it?

Thanks in advance.
Updated 15-Feb-13 3:26am
Dave Kreskowiak 15-Feb-13 8:14am    
Congratulations! So what's the question?
javedsmart 15-Feb-13 8:25am    
problem is that reports can be generated manually on button click but i want it to generate automatically on month end or year end. how should i do it? do i use timer? it eat up more memory.
Dave Kreskowiak 15-Feb-13 9:27am    
OK, so are you saying you want these reports printed?? Are you talking about saving a PDF of the report somewhere, or what??
Dave Kreskowiak 15-Feb-13 9:39am    
You can't guarantee that your WinForms app is going to be running at these times, so you'll need an app that does run at these times. That means either writing a Windows Service or writing a simpler console app that runs as a scheduled task, either of which would be running on your server.
javedsmart 26-Feb-13 5:34am    
Thanks Dave. I dont know how to create scheduled task can you tell me?

1. Enhance your program to accept a commandline parameter that tells it which report to generate without requiring user interaction.

2. For each type of report, create an item in the Windows Task Scheduler to run your program with an appropriate commandline parameter at the required frequency. Windows Task Scheduler is available on Windows client PCs and Windows Servers. You need to discuss with your client where to run the scheduled tasks is the best option. I have some that run on the server. I have some that run on a client. It depends....

I also have applications where it is the user's responsibility to generate the weekly, monthly, annual reports. Why? Because they may not be done entering all the data for that time period at the time when I would have scheduled the report to run automatically. All of my report generation routines are designed so that they can be generated for a desired time period anytime during or after that time period. That way, if they forget, they can generate the report for the required timeframe at any later time.
Share this answer
javedsmart 26-Feb-13 5:37am    
Hi Mike, Thanks for the answer. I am a newbie so, can you please tell me how should i create item in the Windows Task Scheduler to run the program with commandline parameter.
Mike Meinz 26-Feb-13 8:41am    
Windows Task Scheduler is either in Administrative Tools or Windows Accessories. If you have trouble finding it there, you can probably start it by entering this in the Start, Run textbox: control schedtasks Within Windows Task Scheduler, you can create a new item and set the frequency that it is to run. Using Google Search, I found several articles on Windows Task Scheduler. This one has some detail and some references to other articles. This one shows how to add a command line argument in a Task Scheduler item. Experiment a bit and you will learn how to do it.
You can generate report when your application starts. Every time the application starts, it should check if report of the last week, month or year has been generated or not. For that you can store a flag values in db or a in a file for week, month and year. When the report is generated, change the respective flag value.
Share this answer

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