i have Rates table with Fields in my Autotstop.mdb.
Car_id 2_6DaysLowSeason 7_13DaysLowSeason 14+DaysLowSeason
4 22 20 18
I have a web page from where i select startdate and End date from calendar in "txtstart" and "txtend" textboxes.
my Question is that if user select for example txtstart=2/10/2008 and txtend=7/10/2008
how i calculate the total days for rent acording to price
which is above mentioned i.e"2-6dayslowseason"= rent is 22
7-13daysLow season = rent is 20
How many days?
How much totalrent?
Very Very Thanks if Solved.
AlanPosted Oct 20, 2008, 10:57 AM
Something like this perhaps:
DateTime start = DateTime.Parse(txtStart.Text);
DateTime end = DateTime.Parse(txtEnd.Text);
int days = (end - start).Days + 1;
int rent = totalRent = 0;
if (days <= 1)
{
txtDays.Text = "ERROR";
txtDailyRent.Text = "ERROR";
txtTotalRent.Text = "ERROR";
}
else
{
txtDays.Text = days.ToString();
if (days >= 2 && days <= 6)
{
rent = 22;
}
else if (days >= 7 && days <= 13)
{
rent = 20;
}
else
{
rent = 18;
}
txtDailyRent.Text = rent.ToString();
totalRent = rent * days;
txtTotalRent.Text = totalRent.ToString();
}