//Boton crear usuario private void BttnAddPlayer_Click(object sender, EventArgs e) { try { //Verificar formato correcto del nickname switch (txtNickname.Text) { case string aux when aux.Length > 15: throw new ExceededMaxCharactersException("No se puede introducir un nick de mas de 15 car"); case string aux when aux.Trim().Length == 0: throw new EmptyNicknameException("Necesita ingresar un Nickname"); case string aux when aux.Trim().Length < 3: throw new InvalidNicknameFormatException("Nickname de 3 letras o más"); default: PlayerDAO.CreatePlayer(txtNickname.Text); MessageBox.Show("Usuario creado con éxito", "Arkanoid", MessageBoxButtons.OK); break; } } //Capturar excepciones catch (InvalidNicknameFormatException ex) { MessageBox.Show(ex.Message, "Arkanoid", MessageBoxButtons.OK); } catch (ExceededMaxCharactersException ex) { MessageBox.Show(ex.Message, "Arkanoid", MessageBoxButtons.OK); } catch (EmptyNicknameException ex) { MessageBox.Show(ex.Message, "Arkanoid", MessageBoxButtons.OK); } catch (Exception ex) { MessageBox.Show("El nickname ya se encuentra registrado " + ex.Message, "Arkanoid", MessageBoxButtons.OK); } }
public bool CreateRole(int userid, string name, EPlayerJob job, ECharacter character) { return(playerDAO.CreatePlayer(userid, name, job, character)); }