Click here to Skip to main content
15,893,487 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi Guys, i have a tricky problem..
Assume the user has an option to choose when should his bank account be deducted each month thus:15th ,20th,25th and 30th of each month. Now you have to set a debit order date... bearing this rule in mind...
C#
If today is 30 November 2011 the DebitStartDate can only be the 1st – 31st of January 2012
If today is 19 November 2011 the DebitStartDate can only be the 1st – 31st of December 2011

If the user selects 15th a different date must be set and so and on for all option.. i would like to hear your ideas please..
Posted
Comments
Richard MacCutchan 1-Dec-11 11:47am    
Since both of those dates have now passed it's safe to ignore that part of the rule.
Mninawa 1-Dec-11 11:51am    
Hi Richard,its only an example, i can back-date my solution to accommodate that.
Richard MacCutchan 1-Dec-11 12:17pm    
I was being facetious; you know what is required so you need to write a set of rules to match that requirement. Converting requirements to code should not be too difficult.
Mninawa 1-Dec-11 12:20pm    
i did something,that meet those.. it would be great another approach...
Richard MacCutchan 1-Dec-11 12:47pm    
See below.

1 solution

Get date from user
If day is not one of (15, 20, 25, 30)
    Throw exception
If today is greater than (some limit value) AND
    Month is less than this month plus (some limit value)
        Throw exception
If date is valid
    Set date in Target
Else
    Throw exception

I leave you to fill in the details.
 
Share this answer
 
Comments
Mninawa 1-Dec-11 12:51pm    
ha ha ha ha..pseudocode...i like...
Richard MacCutchan 1-Dec-11 12:52pm    
Given the detail in your question what are you expecting?
Mninawa 1-Dec-11 12:55pm    
i like the idea you have provided..

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