private void Submit_Click(object sender, RoutedEventArgs e) { Brush fill = (SolidColorBrush) new BrushConverter().ConvertFromString("#FF622F96"); nationalCodeTextBox.BorderBrush = fill; ReadWriteJson file = new ReadWriteJson(); try { int nationalCode = Int32.Parse(nationalCodeTextBox.Text); string password = PasswordTextBox.Text; string description = descriptionTextBox.Text; User editedUser = new User(admin.Name, nationalCode, admin.ImageAddress, admin.Role, password, admin.IsAdmin, description); file.EditUser(editedUser); admin = editedUser; resultTextBox.Content = "Edited!"; } catch (FormatException) { resultTextBox.Content = "Wrong format,please check national code!"; nationalCodeTextBox.BorderBrush = Brushes.Red; //throw new userControl/ArgumentFormatException(); } catch (NullReferenceException) { resultTextBox.Content = "Fill the blank boxes!"; nationalCodeTextBox.BorderBrush = Brushes.Red; typeDetectorBox.BorderBrush = Brushes.Red; //throw new userControl/ArgumentNullException(); } catch (Exception excp) { MessageBox.Show(excp.Message); ErrorLogger.LogError(excp); //pop error in center //UserControls.ErrorBox Error = new UserControls.ErrorBox(); } }