for booking room of hotel in non booking date of the particular month

Posted by Sachi under ASP.NET on 10/9/2011 | Points: 10 | Views : 3330 | Status : [Member] | Replies : 3
i am doing project on tourism guide.. in that i m provide facility of booking hotel room for customer online..
but i m confused to how to get dates which are not book for a particular room...
my hotel table structure is like this :

hotel_mast
------------------
hotel_Code(p.k)
hotel_name
hotel_address
hotel_City

room_detail
-------------------
room_Code
hotel_Code(f.k)
room_Type
room_Rate
no_of_room
room_availability

booking_mast
-------------------
book_Code(p.k)
hotel_Code(f.k)
room_Code(f.k)
check_in_date
check_out_date
total_Amount


please.. help me to get date.. within 15 days my submission of my project is coming... so please help me..
Sachi ...




Responses

Posted by: Ndebata on: 10/9/2011 [Member] Starter | Points: 25

Up
0
Down
Declare @alldate table(d datetime)

Declare @StartDate datetime,@EndDate datetime

--Date range for which you want to see the availability generally its a calendar month

Set @StartDate='1/1/2011'
Set @EndDate='1/31/2011'

While @StartDate<=@EndDate
Begin
Insert into @alldate values (@StartDate)
set @StartDate=@StartDate+1
End
Select d AvailableDates from @alldate
LEFT JOIN booking_mast BM ON BM.Check_in_Date <= d AND BM.Check_out_Date > d
WHERE BM.book_code IS NULL
AND BM.room_code= 'room code you are searching for availability'
--you may also filter hotel code


Sachi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sachi on: 10/10/2011 [Member] Starter | Points: 25

Up
0
Down
thank you sir.. but i m working on asp.net with c#...
so can u help me sir..


Sachi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ndebata on: 10/11/2011 [Member] Starter | Points: 25

Up
0
Down
Hi Sachi,
What you can do try to use a calendar control in a page.
in aspx page
<asp:Calendar ID="Calendar1" runat="server"></asp:Calendar>

In .cs file
public partial class TestPage : System.Web.UI.Page

{
List<DateTime> _availabledates = new List<DateTime>();
public void Page_Load(object sender, EventArgs e)
{
Calendar1.DayRender += new DayRenderEventHandler(Calendar1_DayRender);
Calendar1.VisibleMonthChanged += new MonthChangedEventHandler(Calendar1_VisibleMonthChanged);
if (!IsPostBack)
{
//Show Current month booking details by default
//load this collection _availabledates from database for current month
}
}
void Calendar1_VisibleMonthChanged(object sender, MonthChangedEventArgs e)
{
//load this collection _availabledates from database for new month ( which you can get from e.NewDate )
}
void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
// Here check if dates are available or not if not change the back color to red.
if (!_availabledates.Contains(e.Day.Date))
{
e.Cell.BackColor = Color.Red;
e.Cell.ToolTip = "Already Booked";
}
}
}


Sachi, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response