Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# SQL-Server VB.NET WinForm , +
Hi,
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
Edited 15-Feb-13 2:26am
v2
Comments
Dave Kreskowiak at 15-Feb-13 8:14am
   
Congratulations! So what's the question?
javedsmart at 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 at 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 at 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 at 26-Feb-13 5:34am
   
Thanks Dave. I dont know how to create scheduled task can you tell me?
Dave Kreskowiak at 26-Feb-13 7:55am
   
Start -> Help and Support -> "Schedule a task". The first link spells it all out.
Rate this: bad
good
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.
  Permalink  
v2
Comments
javedsmart at 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 at 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.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Hi,
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.
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 530
1 Sergey Alexandrovich Kryukov 330
2 BillWoodruff 299
3 PIEBALDconsult 230
4 CPallini 220
0 Sergey Alexandrovich Kryukov 10,615
1 Maciej Los 5,354
2 OriginalGriff 5,254
3 CPallini 3,719
4 BillWoodruff 3,476


Advertise | Privacy | Mobile
Web02 | 2.8.141029.1 | Last Updated 15 Feb 2013
Copyright © CodeProject, 1999-2014
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