private void btnConfirm_Click(object sender, RoutedEventArgs e) { try { // check if the PIN matches the room if (txtPIN.Password.Length == 0) { throw new ApplicationException("Please enter the PIN"); } else { if (_gm.VerifyPIN(_guest, txtPIN.Password)) { this.DialogResult = true; } else { txtPIN.Clear(); txtPIN.Focus(); throw new ApplicationException("Incorrect PIN. Please try again"); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }