private void SaveBTN_Click(object sender, RoutedEventArgs e) { try { ImpBL bl = ImpBL.Instance; HostingUnit hu = new HostingUnit(); hu.Owner = new Host(); hu.Owner.PrivateName = FirstNameTextBox.Text; if (hu.Owner.PrivateName == "" || hu.Owner.PrivateName == null) { throw new TzimerException("Must enter a private name!"); } hu.Owner.FamilyName = LastNameTextBox.Text; hu.Owner.HostId = HostIdTextBox.Text; if (hu.Owner.HostId == "" || hu.Owner.HostId == null) { throw new TzimerException("Must enter a Host Id!"); } hu.Owner.FamilyName = LastNameTextBox.Text; if (hu.Owner.FamilyName == null || hu.Owner.FamilyName == "") { throw new TzimerException("Must enter a family name!"); } hu.Owner.PhoneNumber = PhoneNumberTextBox.Text; if (hu.Owner.PhoneNumber == null) { throw new TzimerException("Must enter a Phone number"); } int number; bool checknumber = Int32.TryParse(hu.Owner.PhoneNumber, out number); if (!checknumber) { throw new TzimerException("Phone number must contain only numbers.", "bl"); } hu.Owner.MailAddress = EmailTextBox.Text; if (!(hu.Owner.MailAddress.Contains("@"))) { throw new TzimerException("E-mail Address format is invaled.Please enter the correct format.", "pl"); } if (string.IsNullOrEmpty(hu.Owner.MailAddress)) { throw new TzimerException("Please enter your e-mail address", "pl"); } hu.Owner.BankAccountNumber = BankAccountNumberTextBox.Text; int number2; bool checknumber2 = Int32.TryParse(hu.Owner.BankAccountNumber, out number2); if (!checknumber) { throw new TzimerException("Account number must contain only numbers.", "pl"); } hu.Owner.CollectionClearance = (bool)collectoinCleearenceCheckBox.IsChecked; if (BaranchesListComboBox.SelectedValue == null) { throw new TzimerException("Bank branch must be selected", "pl"); } string branchNumber = BaranchesListComboBox.SelectedValue.ToString().Split('-')[1].Trim(); int branchNum = int.Parse(branchNumber); hu.Owner.BankBranchDetails = branches?.FirstOrDefault(x => x.BranchNumber == branchNum); // if unit is null there is nothing to update if (m_hostingUnit != null) { bl.UpdateHostInfo(hu.Owner, m_hostingUnit.HostingUnitKey); } HostingUnitPage obj = new HostingUnitPage(hu.Owner, m_hostingUnit); this.NavigationService.Navigate(obj); } catch (Exception err) { MessageBox.Show(err.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }