I’m using ASP.NET MVC4 and SQL Server 2008.
I’ve got a business requirement that requires equipment to be service after X amount of time. Different equipment items require different amounts of lengths of time before servicing.
In the database, I need to store the period in which equipment needs to be serviced, as well as the next service date.
On the equipment edit screen, I need a dropdown box with options to allow the user to select a ServiceInterval. It would actually be preferable not to have a fixed dropdown with times, but I’m not sure how else to do this.
- 3 Months
- 6 Months
- 9 Months
- 1 Year
- 1.5 years
- 2 years
- 3 years
- 4 years
- 5 years
Clicking on a “Serviced” button should Add the ServiceInterval to the current date and put that in the NextServiceDue field.
What is the best way to store this information, and is there a good way to do this?
Thank you,
Mike
It depends on what level of granularity you want, but you create a table in the database with the name and the number of seconds or days.
From there, when the user selects the item, just date
DateTime.Now.AddDays(userInput);orDateTime.Now.AddSeconds(userInput);. You can store the interval period along with the serviceable item as well.