on a new year reset property number

Posted on 2011-10-31
Last Modified: 2012-05-12

I'm kind of in a brainless state right now :D

But I have kind of an issue which first off I thought to be easy but now that I think about it, I'm not sure how to start.

So I have a client class which has a property amountOfRents. Now This number should be resetted each 31dec 23:59:59.

I mean, how can this be solved? And when do you need to check for this?
Question by:Mutsop
    LVL 74

    Expert Comment

    by:käµfm³d 👽
    What kind of application is this? How often is it executed?
    LVL 3

    Author Comment

    Well I found a project list to get some ideas for a project from dreamincode: A limosine rental service.
    Now my idea was each time a client rents a Limosine, "amountOfRents" increase with one. After for example 2 rents he gets 5% discount, after 10 rents he gets 10%, and so on....

    I would like to reset that number each end of the year.
    LVL 40

    Accepted Solution

    I have the following in one of my applications that needs to trigger a reset when the year change:
    If CurrentStatus.YearlyReset < Date.Today.Year Then
        If MessageBox.Show("Ready for the annual reset?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
        CurrentStatus.YearlyReset = Date.Today.Year
    End If

    Open in new window

    This code runs at the start of the application. CurrentStatus is a class whose values are stored in a file (that is what Save does) and is loaded just before i run this code. Its YearlyReset property is changed to the current year whenever the reset has been triggered, so it won't be triggered again during that year.

    If your application is running full time, a similar procedure could be called at a regular interval from a timer.

    The year can be recorded in different places: Windows registry, user configuration setting, database, etc. If you call the method only when the application starts, it does not matter much. If you call it every minute or so however, a user configuration setting or a class that stays in memory (as I do) will increase performance, because the value is readily available when the application makes the check.

    Depending on where amountOfRents is located and how it is accessed by your application, you might also have a Scheduled Task recorded in Windows that would call a small application yearly at the given time to update the value.
    LVL 74

    Expert Comment

    by:käµfm³d 👽
    For application type, I was referring to Forms, Console, or web application  : )

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now