Beispiel #1
0
 private void changepwdBTN_Click(object sender, EventArgs e)
 {
     try
     {
         if (cmbUser1.SelectedValue.Equals(txtOldPassword1.Text))
         {
             Player p = (Player)cmbUser1.SelectedItem;
             if (txtNewPassword2.Text.Equals("") ||
                 txtCNewPassword3.Text.Equals(""))
             {
                 throw new EmptyFormFieldException("Don't leave blank spaces, fill out the form!");
             }
             else
             {
                 if (txtNewPassword2.Text != txtCNewPassword3.Text)
                 {
                     throw new NonMatchingPasswordValidationException("Error en su nueva contraseña. " +
                                                                      "Escriba la misma contraseña en " +
                                                                      "ambos campos");
                 }
                 else
                 {
                     PlayerDAO.changePassword(p, txtNewPassword2.Text);
                 }
             }
         }
         else
         {
             MessageBox.Show("Contraseña incorrecta!", "Error", MessageBoxButtons.OK,
                             MessageBoxIcon.Exclamation);
         }
     }
     catch (EmptyFormFieldException exception)
     {
         MessageBox.Show(exception.Message);
     }
     catch (NonMatchingPasswordValidationException exception)
     {
         MessageBox.Show(exception.Message);
     }
 }