Mini Kabibi Habibi

Current Path : C:/Users/Public/Documents/DXperience 13.1 Demos/ASP.NET/VB/HotelBooking/
Upload File :
Current File : C:/Users/Public/Documents/DXperience 13.1 Demos/ASP.NET/VB/HotelBooking/Default.aspx.vb

Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports DevExpress.Web.ASPxClasses
Imports System.Reflection
Imports DevExpress.Web.ASPxEditors

Partial Public Class _Default
	Inherits System.Web.UI.Page
	Protected Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs)
		If (Not IsPostBack) Then
			InitEditorsValues()
		End If
	End Sub
	Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As EventArgs)
		If ASPxEdit.ValidateEditorsInContainer(Page) Then
			InitializeSearchQuery()
			Response.Redirect("Results.aspx")
		End If
	End Sub
	Protected Sub cmbCity_Callback(ByVal source As Object, ByVal e As CallbackEventArgsBase)
		Dim country As String = e.Parameter
		If String.IsNullOrEmpty(country) Then
			Return
		End If
		cmbCity.DataSource = Data.Instance.Countries.Find(Function(c) c.Name = country).Cities
		cmbCity.DataBind()
	End Sub
	Protected Sub deCheckIn_Validation(ByVal sender As Object, ByVal e As DevExpress.Web.ASPxEditors.ValidationEventArgs)
		Utils.ValidateCheckInDate(e)
	End Sub
	Protected Sub deCheckOut_Validation(ByVal sender As Object, ByVal e As DevExpress.Web.ASPxEditors.ValidationEventArgs)
		Utils.ValidateCheckOutDate(CDate(deCheckIn.Value), e)
	End Sub

	Private Sub InitEditorsValues()
		Utils.SetDefaultDateEditValues(deCheckIn, deCheckOut)

		ccPopularCountries.DataSource = Data.Instance.GetPopularCountries()
		ccPopularCountries.DataBind()

		rpExclusiveHotels.DataSource = Data.Instance.GetExclusiveHotels()
		rpExclusiveHotels.DataBind()

		cmbCountry.DataSource = Data.Instance.Countries
		cmbCountry.DataBind()

		cmbRoomType.DataSource = Data.Instance.RoomTypes
		cmbRoomType.DataBind()
		cmbRoomType.SelectedIndex = 0

		cmbCity.ClientEnabled = False

		cblHotelService.DataSource = Data.Instance.HotelServices
		cblHotelService.DataBind()

		cblRoomService.DataSource = Data.Instance.RoomServices
		cblRoomService.DataBind()
	End Sub
	Private Sub InitializeSearchQuery()
		If seMaxPrice.Value IsNot Nothing Then
			Data.Instance.CurrentQuery = New SearchQuery() With {.Country = CStr(cmbCountry.Value), .City = CStr(cmbCity.Value), .MaxPrice = CDec(seMaxPrice.Value), .FromDate = CDate(deCheckIn.Value), .ToDate = CDate(deCheckOut.Value), .RoomType = CStr(cmbRoomType.Value), .Adults = Convert.ToInt32(seAdults.Value), .Children = Convert.ToInt32(seChildren.Value), .Stars = cblHotelstars.SelectedValues.Cast(Of Integer)().ToArray(), .HotelServices = cblHotelService.SelectedValues.Cast(Of String)().ToArray(), .RoomServices = cblRoomService.SelectedValues.Cast(Of String)().ToArray()}
		Else
			Data.Instance.CurrentQuery = New SearchQuery() With {.Country = CStr(cmbCountry.Value), .City = CStr(cmbCity.Value), .MaxPrice = 0, .FromDate = CDate(deCheckIn.Value), .ToDate = CDate(deCheckOut.Value), .RoomType = CStr(cmbRoomType.Value), .Adults = Convert.ToInt32(seAdults.Value), .Children = Convert.ToInt32(seChildren.Value), .Stars = cblHotelstars.SelectedValues.Cast(Of Integer)().ToArray(), .HotelServices = cblHotelService.SelectedValues.Cast(Of String)().ToArray(), .RoomServices = cblRoomService.SelectedValues.Cast(Of String)().ToArray()}
		End If
	End Sub
End Class