Click here to Skip to main content
16,000,371 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
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

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");
 
Share this answer
 
Usually people must vacate the room before 13:00 otherwise it is put on their account.
 
Share this answer
 
Comments
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????
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;
}
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900