membership desc=silver,gold,platinum
fine_per day=30,20,10
from book_due date and returned_date as number of days in which fine is added to get the fine............
how this can b done in c#
i think the calculation is done as(book_due_date)-(book_returned_on)*30 or 20 or10
how to do all this in c# to get fine in textbox

Recommended Answers

All 2 Replies

To do this task you have to calculate the difference between book_due date and returned_date then you can calculate the due.

you have to take datetimepicker the following code will calculate the difference between issued_date with current date.

Here is code to calculate the difference between two dates:

DateTime dt = (dateTimePicker1.Value);
            TimeSpan ts = DateTime.Now - dt;  
 textBox1.Text = ts.Days.ToString();

NO.
You cannot subtract or sum dateValues. You have to use TimeSpan`s method called Subtract.
like:

DateTime dt = (dateTimePicker1.Value);
TimeSpan ts = DateTime.Now.Subtract(dt);
textBox1.Text = (ts.Days * 30).ToString(); //or 20, or 10
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.