public MainWindow() { try { InitializeComponent(); GuestRequest_UserControl guestRequest_UserControl = new GuestRequest_UserControl(); UserControlGrid.Children.Add(guestRequest_UserControl); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void SerchButton_Click(object sender, RoutedEventArgs e) { if (DateTime.Compare(ArrivalDate.SelectedDate.Value, LeavingDate.SelectedDate.Value) < 0) { Area_ComboBox.GetBindingExpression(ComboBox.SelectedIndexProperty).UpdateSource(); Type_ComboBox.GetBindingExpression(ComboBox.SelectedIndexProperty).UpdateSource(); Adult_Textbox.GetBindingExpression(TextBox.TextProperty).UpdateSource(); Children_Textbox.GetBindingExpression(TextBox.TextProperty).UpdateSource(); ArrivalDate.GetBindingExpression(DatePicker.SelectedDateProperty).UpdateSource(); LeavingDate.GetBindingExpression(DatePicker.SelectedDateProperty).UpdateSource(); guestRequest.Pool = ThreeStateToChoice(SwimmingPool_CheckBox); guestRequest.Jacuzzi = ThreeStateToChoice(Jacuzzi_CheckBox); guestRequest.Garden = ThreeStateToChoice(Garden_CheckBox); guestRequest.ChildrensAttractions = ThreeStateToChoice(ChildrensAttractions_CheckBox); List <HostingUnit> HostingUnitList = bl.MachUnitToRequest(guestRequest); if (HostingUnitList.Count() == 0) { MessageBox.Show("Sorry, their is no hosting unit maching to your request!!"); GuestRequest_UserControl guestRequest_UserControl = new GuestRequest_UserControl(); (this.Parent as StackPanel).Children.Add(guestRequest_UserControl); (this.Parent as StackPanel).Children.Remove(this); } else { foreach (var hu in HostingUnitList) { HostingUnit_UserControl hostingUnit_UserControl = new HostingUnit_UserControl(hu, guestRequest); (this.Parent as StackPanel).Children.Add(hostingUnit_UserControl); } (this.Parent as StackPanel).Children.Remove(this); } } else { MessageBox.Show("Leaving day cannot be before arrival day!"); } }