private void salvarbutton1_Click(object sender, EventArgs e) { if (nometxt.Text == "" || nometxt.Text == null) { MessageBox.Show("Informe o nome do Usuário "); nometxt.Focus(); return; } if (senhatxt.Text == "" || senhatxt.Text == null) { MessageBox.Show("Informe a senha "); senhatxt.Focus(); return; } if (confsenhatxt.Text == "" || confsenhatxt.Text == null) { MessageBox.Show("Confirme a senha !"); confsenhatxt.Focus(); return; } if (senhatxt.Text != confsenhatxt.Text) { MessageBox.Show("As senhas informadas não estão iguais, digite e confirme a senha novamente !"); senhatxt.Focus(); return; } if (nivel1checkBox1.Checked == false && nivel2checkBox2.Checked == false) { MessageBox.Show("Escolha pelo menos um nível de usuário !"); nivel1checkBox1.Focus(); return; } Usuario u = new Usuario(); u.Login = nometxt.Text.ToString().ToLower(); u.Senha = senhatxt.Text.ToString(); if (nivel1checkBox1.Checked == true) { u.NivelAcesso = 1; } else { u.NivelAcesso = 2; } UsuarioController usucon = new UsuarioController(); if (usucon.Cadastrar(u) == true) { MessageBox.Show("Usuário Cadastrado com sucesso !"); popularGrid(); } else { MessageBox.Show("Usuário já Cadastrado !"); nometxt.Focus(); } }
private void BtnSalvar_Click(object sender, EventArgs e) { bool sucesso = false; UsuarioController usuario = new UsuarioController(); sucesso = usuario.Cadastrar(TxtNome.Text, TxtSenha.Text, TxtConfSenha.Text); if (sucesso == true) { this.Hide(); } }
public void Create_ShouldReturn_TotalResult() { var usuario = new UsuarioDTO { Id = 1, Nome = "Nome Mock 1", Email = "*****@*****.**", Senha = "SenhaSegura", DataNascimento = new DateTime(1990, 01, 01), NuDocumento = "111111111111", Telefone = "71999887744", TipoDocumento = "CPF", EscolaridadeId = new Guid("1916d92a-5d17-a345-bb86-7dded4ddc27d") }; var result = controller.Cadastrar(usuario); Assert.Multiple(() => { service.Verify(s => s.Cadastrar(It.IsAny <Usuario>()), Times.Once); Assert.NotNull(result); Assert.IsInstanceOf(typeof(OkObjectResult), result.Result); }); }
private void buttonCadastrar_Click(object sender, RoutedEventArgs e) { try { Usuario usuarioView = new Usuario(); usuarioView.NomeUsuario = nomeUsuario.Text; usuarioView.cpfUsuario = cpfUsuario.Text; usuarioView.dataNascimentoUsuario = datanascUsuario.SelectedDate.Value; usuarioView.telefoneUsuario = telefone.Text; usuarioView.emailUsuario = emailUsuario.Text; usuarioView.senhaUsuario = senhaUsuario.Password; if (validacoes(usuarioView)) { UsuarioController usuContr = new UsuarioController(); int resp = usuContr.Cadastrar(usuarioView); if (resp == 1) { MessageBox.Show("Cadastrado com Sucesso!"); } else if (resp == 0) { MessageBox.Show("Houston, temos um problema!"); } this.Close(); /* MainWindow mainWindow = new MainWindow(); * mainWindow.Show();*/ } } catch (InvalidOperationException) { MessageBox.Show("Não pode ter campos nulos"); } catch (Exception ex) { MessageBox.Show("Ligue para o suporte: " + ex); } }
public async void Cadastrar() { IndicadorDeAtividade(); try { Usuario usuario = new Usuario { Id = 0, Nome = txtNome.Text, Sobrenome = txtSobrenome.Text, DataNascimento = dtNascimento.Date, Cpf = txtCpf.Text, Email = txtEmail.Text, CidadeNatal = txtCidade.Text, Senha = txtSenha.Text }; if (await controller.Cadastrar(usuario)) { await DisplayAlert("Confirmação", "Cadastro realizado com sucesso.", "OK"); await Navigation.PopAsync(true); } else { throw new ApplicationException("Não foi possível realizar o cadastro.\nPor favor, tente novamente mais tarde."); } } catch (Exception ex) { await DisplayAlert("Atenção", ex.Message, "Ok"); } IndicadorDeAtividade(); }
private void btnCadastrar_Click(object sender, EventArgs e) { if (txtlogin.Text == "Login") { lbLogin.Visible = true; } if (txtSenha.Text == "Senha") { lbpass.Visible = true; } if (txtConfSenha.Text == "Confirme a senha") { lbConf.Visible = true; } if (txtnomeUsu.Text == "Nome de Usuário") { lbNome.Visible = true; } if (!(lbNome.Visible || lbConf.Visible || lbpass.Visible || lbLogin.Visible)) { if (txtConfSenha.Text == txtSenha.Text) { Usuario novoUsuario = new Usuario { Login = txtlogin.Text, Senha = txtSenha.Text, Nome = txtnomeUsu.Text }; if (checkRole.Checked) { novoUsuario.Role = "admin"; } else { novoUsuario.Role = "jogador"; } UsuarioController usuarioController = new UsuarioController(); try { usuarioController.Cadastrar(novoUsuario); tabela.DataSource = usuarioController.Listar(); } catch (MySqlException exce) { util.MensagemDeTeste("Erro ao cadastrar, falha na conexão ao banco de dados", "Erro!"); throw exce; } catch (Exception ex) { util.MensagemDeTeste("Erro inesperado no load dos cadastros: " + ex.Message, "Erro!"); throw ex; } finally { txtlogin.Text = "Login"; txtSenha.Text = "Senha"; txtnomeUsu.Text = "Nome de Usuário"; txtConfSenha.Text = "Confirme a senha"; txtConfSenha.UseSystemPasswordChar = false; txtSenha.UseSystemPasswordChar = false; checkRole.Checked = false; } } else { lbpass.Visible = true; lbConf.Visible = true; } } }