Click here to Skip to main content
12,946,816 members (48,255 online)
Rate this:
Please Sign up or sign in to vote.
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.
Posted 15-Feb-13 2:04am
Updated 15-Feb-13 2: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?
Dave Kreskowiak 26-Feb-13 7:55am
Start -> Help and Support -> "Schedule a task". The first link spells it all out.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.
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 <A HREF="" target=XXX">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.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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.

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

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 5,059
CHill60 3,235
Maciej Los 2,538
Jochen Arndt 1,935
ppolymorphe 1,795

Advertise | Privacy | Mobile
Web01 | 2.8.170518.1 | Last Updated 15 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100