private void AddPersonButton_Click(object sender, RoutedEventArgs e) { foreach (var item in AddPerson.Children) { if (item is TextBox || item is PasswordBox) { if ((item as Control).Background == Brushes.Red || (item as Control).Background == Brushes.WhiteSmoke) { MessageBox.Show("לא כל השדות מלאו כנדרש"); return; } } } BO.Person person = new BO.Person(); person.FirstName = this.FirstNameTextBox.Text; person.LastName = this.LastNameTextBox.Text; person.Id = int.Parse(this.IdTextBox.Text); person.MailAddress = this.MailAddressTextBox.Text; person.Password = this.PasswordTextBox.Password; person.PhoneNumber = int.Parse(this.PhoneNumberTextBox.Text); person.Status = BO.Status.ACTIVE; person.IdType = (BO.ID)MyDictionary.TranslatStringeToEnum(IdTypeComboBox.SelectedItem.ToString()); try { bl.AddPerson(person); } catch (DuplicateWaitObjectException exp) { MessageBox.Show(exp.Message, "שגיאה", MessageBoxButton.OK, MessageBoxImage.Error); return; } NavigationService.Navigate((new MainWindowPage(bl, person))); }