Mini Kabibi Habibi
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DevExpress.Web.ASPxClasses;
using System.Reflection;
using DevExpress.Web.ASPxEditors;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Init(object sender, EventArgs e) {
if(!IsPostBack)
InitEditorsValues();
}
protected void btnSubmit_Click(object sender, EventArgs e) {
if(ASPxEdit.ValidateEditorsInContainer(Page)) {
InitializeSearchQuery();
Response.Redirect("Results.aspx");
}
}
protected void cmbCity_Callback(object source, CallbackEventArgsBase e) {
string country = e.Parameter;
if(string.IsNullOrEmpty(country)) return;
cmbCity.DataSource = Data.Instance.Countries.Find(c => c.Name == country).Cities;
cmbCity.DataBind();
}
protected void deCheckIn_Validation(object sender, DevExpress.Web.ASPxEditors.ValidationEventArgs e) {
Utils.ValidateCheckInDate(e);
}
protected void deCheckOut_Validation(object sender, DevExpress.Web.ASPxEditors.ValidationEventArgs e) {
Utils.ValidateCheckOutDate((DateTime)deCheckIn.Value, e);
}
void 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();
}
void InitializeSearchQuery() {
Data.Instance.CurrentQuery = new SearchQuery() {
Country = (string)cmbCountry.Value,
City = (string)cmbCity.Value,
MaxPrice = seMaxPrice.Value != null ? (decimal)seMaxPrice.Value : 0,
FromDate = (DateTime)deCheckIn.Value,
ToDate = (DateTime)deCheckOut.Value,
RoomType = (string)cmbRoomType.Value,
Adults = Convert.ToInt32(seAdults.Value),
Children = Convert.ToInt32(seChildren.Value),
Stars = cblHotelstars.SelectedValues.Cast<int>().ToArray(),
HotelServices = cblHotelService.SelectedValues.Cast<string>().ToArray(),
RoomServices = cblRoomService.SelectedValues.Cast<string>().ToArray()
};
}
}