16,000,371 members
See more: , +
Hi,
This is Bala, i am very new to .net window applications. i am using .net framework 3.5 with c# language and sql server 2005 now i am developing a project for hotel management in window application. modules are, booking of room and vacate a room based on the time not day. now i have completed booking of room by reducing number of rooms in database. my doubt is vacate a room based on the time.

customer request is,
1) if a customer stayed at 24 hours means, that must be considered as 1 day.
2) if a customer stayed at 25 hours means, that must be considered as 1 day.
3) if a customer stayed at more than 25 hours means, that should be considered as 2 days.

can anyone help for me????
Posted
Updated 7-Jun-13 23:09pm
v4

## Solution 2

Try:
C#
```DateTime startBooking = ...
DateTime vacated = DateTime.Now;
TimeSpan roomHeldFor = vacated - startBooking;
int heldTime = (int) roomHeldFor.TotalMinutes;
Console.WriteLine(heldTime > (25 * 60) ? "Two days" : "One day");
```

## Solution 1

Usually people must vacate the room before 13:00 otherwise it is put on their account.

Balasubramanian T 11-May-13 7:07am
Thanks to OriginalGriff...
but if we book a room more than 5 or 10 days, the solution will be????

## Solution 3

int Days = 0;
DateTime bookingTime = ----;
DateTime vacateTime = ---;
TimeSpan roomHeldFor = vacateTime - bookingTime;
decimal heldTime = Math.Ceiling(((decimal)roomHeldFor.TotalHours));
if (heldTime <= 25)
{
Days = 1;
}
else
{
int D1 = Convert.ToInt32(Math.Floor(Convert.ToDecimal(heldTime / 24)));
decimal remainingHours = heldTime % 24;
if (remainingHours > 1)
{
Days = D1 + 1;
}
else
{
Days = D1;
}
}