protected void btnGuardar_Click(object sender, EventArgs e) { try { Logica.Models.clsTBUsuarios obclsTBUsuarios = new Logica.Models.clsTBUsuarios { stNombre = txtNombre.Text, stApellido = txtApellido.Text, stUsuario = txtUsuario.Text, stContraseña = txtContraseña.Text, stCorreo = txtCorreo.Text, stTipoUs = ddlTipoUsuario.SelectedItem.Text }; Controllers.GestionUsuariosController obGestionUsuariosController = new Controllers.GestionUsuariosController(); string stMensaje = obGestionUsuariosController.addUsuarioController(obclsTBUsuarios); ClientScript.RegisterStartupScript(this.GetType(), "Mesaje", "<Script> swal('MENSAJE!', '" + stMensaje + "!', 'info')</Script>"); getUsuarios(); } catch (Exception ex) { ClientScript.RegisterStartupScript(this.GetType(), "Mesaje", "<Script> swal('ERROR!', '" + ex.Message + "!', 'error')</Script>"); } }
void getUsuarios() { try { Controllers.GestionUsuariosController obGestionUsuariosController = new Controllers.GestionUsuariosController(); List <Logica.Models.clsTBUsuarios> lstclsTBUsuarios = obGestionUsuariosController.getUsuarioController(); if (lstclsTBUsuarios.Count > 0) { gvwUsuarios.DataSource = lstclsTBUsuarios; } else { gvwUsuarios.DataSource = null; } gvwUsuarios.DataBind(); } catch (Exception ex) { ClientScript.RegisterStartupScript(this.GetType(), "Mesaje", "<Script> swal('ERROR!', '" + ex.Message + "!', 'error')</Script>"); } }