private void SaveBtn_Click(object sender, RoutedEventArgs e) { ImpBL bl = ImpBL.Instance; HostingUnit hu = m_hostingUnit == null ? new HostingUnit() : m_hostingUnit; try { hu.HostingUnitName = HostinUnitNameTextBox.Text; if (hu.HostingUnitName == "") { throw new TzimerException("Must enter a name for the unit!"); } hu.Area = (BE.Areas)AreaComboBox.SelectedIndex; hu.Type = (BE.UnitType)AreaComboBox.SelectedIndex; hu.SubArea = SubAreaTextBox.Text; hu.AirConditoiner = (bool)AirConditionerCheckBox.IsChecked; hu.FreeParking = (bool)FreeParkingCheckBox.IsChecked; hu.breakfastIncluded = (bool)BreakFastIncludedcheckBox.IsChecked; hu.RoomService = (bool)RoomServiceCheckBox.IsChecked; if (hu.SubArea == "") { throw new TzimerException("Must enter a sub area for your unit!"); } switch (AreaComboBox.SelectedIndex) { case 0: hu.Area = Areas.Jerusalem; break; case 1: hu.Area = Areas.Center; break; case 2: hu.Area = Areas.North; break; case 3: hu.Area = Areas.South; break; default: break; } switch (UnitTypeComboBox.SelectedIndex) { case 0: hu.Type = UnitType.Tzimer; break; case 1: hu.Type = UnitType.HostingUnit; break; case 2: hu.Type = UnitType.HotelRoom; break; case 3: hu.Type = UnitType.Tent; break; default: break; } hu.Pool = (bool)HasPoolCheckBox.IsChecked; hu.Jacuzz = (bool)HasJacuzzCheckBox.IsChecked; hu.Garden = (bool)HasGardanCheckBox.IsChecked; hu.ChildrensAttractions = (bool)HasChildrenAttractionsCheckBox.IsChecked; hu.Owner = m_Owner; if (m_isEdit) { int hostingUnitKey = int.Parse(HostingUnitKeyLable.Content.ToString().Substring(1)); hu.HostingUnitKey = hostingUnitKey; bl.UpdateHostingUnit(hu); HostinUnitListPage obj = new HostinUnitListPage(hu.Owner, this.NavigationService); this.NavigationService.Navigate(obj); } else { bl.AddHostingUnit(hu); HostinUnitListPage obj = new HostinUnitListPage(hu.Owner, this.NavigationService); this.NavigationService.Navigate(obj); } } catch (Exception err) { MessageBox.Show(err.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }