public void AgregarUsuarios() { UsuarioDAL oUsuario = new UsuarioDAL(); UsuarioBLL oUsuarioBll = new UsuarioBLL(); User oUser = new User(); oUser.UserName = txtNombreUsuario.Text; oUser.Password = txtContrasena.Text; //if (oUser.Password == txtConfirmarContasena.Text) //{ // oUser.Password = txtContrasena.Text; //} //else //{ // Page.ClientScript.RegisterStartupScript(this.GetType(), "Error", "alert('Las Contaseñas no coinciden');", true); //} oUser.Name = txtNombreCompleto.Text; oUser.Email = txtEmail.Text; oUser.Type = "Usuario"; try { oUsuarioBll.AgregarUsuario(oUser); } catch (Exception ex) { Page.ClientScript.RegisterStartupScript(this.GetType(), "Error", "alert('" + ex.Message + "');", true); } }
private void btnAceptarAgregarUsuario_Click(object sender, EventArgs e) { //FALTAN VALIDAR LOS TXT BorrarError(); if (ValidarCampos()) { if (txtConfirmarcontrasena.Text != txtContraseña.Text) { MessageBox.Show("Las contraseñas no coinciden"); } else { Usuario usuarios = new Usuario { Nombre = txtNombreUsuario.Text, Apellido = txtApellidoUsuario.Text, Correo = txtCorreo.Text, password = txtContraseña.Text, IdRol = int.Parse(cmbRol.SelectedValue.ToString()) }; Usuario u = UsuarioBLL.verificarSiExiste(txtCorreo.Text); if (u != null) { MessageBox.Show("Usuario ya existe"); } else { UsuarioBLL.AgregarUsuario(usuarios); MessageBox.Show("Usuario creado correctamente"); control.refrescarTablaUsuarios(); this.Visible = false; } } LimpiarCajasTexto(); } else { MessageBox.Show("Error al ingresar datos"); } }