0

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

3
Contributors
2
Replies
6
Views
6 Years
Discussion Span
Last Post by Mitja Bonca
0

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();

Edited by virusisfound: n/a

0

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
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.