private void button_Click(object sender, RoutedEventArgs e) { try { if (textBox.Text == "" || textBox_Copy.Text == "" || textBox_Copy1.Text == "" || textBox_Copy2.Text == "" || bankAccountText.Text == "" || textBox_Copy4.Text == "" || passwordBox.Password == "") { throw new ArgumentNullException("You need to fill all fields"); } if (bankNameCombo.SelectedIndex == -1 || branchNameCombo.SelectedIndex == -1) { throw new ArgumentNullException("You need to fill all fields"); } bl.AddHost(host); HostGrid.Children.RemoveAt(0); HostGrid.Children.Add(new HostHostingUnits(host, HostGrid)); RulerGrid.Children.RemoveAt(0); RulerGrid.Children.Add(new HostRuler(host, HostGrid, RulerGrid)); } catch (Exception ex) { MessageBox.Show(ex.Message); } }