protected void btn_guardar_Click(object sender, EventArgs e) { try { Negocio.usuariosNegocio dc = new Negocio.usuariosNegocio(); Entidad.Insertar_Usuario_Result resp = null; string nombre = tb_nombre.Text; int idrol ; Entidad.Validar_Login_Result login = (Entidad.Validar_Login_Result)Session["S_Login"]; if (login == null) { idrol = 3; // ESTE ES EL IDROL EL CUAL INDICA EN LA TABLA CAT_ROL QUE SE REFIERE AL USUARIO PACIENTE, CON MENOS PRIVILEGIOS EN EL SISTEMA } else { idrol = int.Parse(ddl_rol.SelectedValue); } string user = tb_usuario.Text; string pass = tb_contraseniaverificacion.Text; string activo = "1"; bool existe = false; existe = dc.VerificarUsuario(user); if (existe != true) { resp = dc.InsertarUsuario(nombre, idrol, user, pass, activo); if (resp != null) { //lb_mensajes.ForeColor = System.Drawing.Color.Green; //lb_mensajes.Text = "Datos almacenados satisfactoriamente!!!"; string mensaje = "MostrarMensaje('SUCCESS','Datos almacenados satisfactoriamente!!!')"; ScriptManager.RegisterStartupScript(this, GetType(), "mensaje", mensaje, true); CleanControls(this.Controls); } else { //lb_mensajes.ForeColor = System.Drawing.Color.Red; //lb_mensajes.Text = "Error al almacenar el usuario!!!"; string mensaje = "MostrarMensaje('ERROR','Error al almacenar los datos del usuario!!!')"; ScriptManager.RegisterStartupScript(this, GetType(), "mensaje", mensaje, true); } } else { //lb_mensajes.ForeColor = System.Drawing.Color.Red; //lb_mensajes.Text = "El usuario ya existe, por favor seleccionar otro!!!"; string mensaje = "MostrarMensaje('WARNING','El usuario seleccionado ya existe, por favor seleccione otro!!!')"; ScriptManager.RegisterStartupScript(this, GetType(), "mensaje", mensaje, true); } } catch (Exception err) { cv_datos.IsValid = false; cv_datos.ErrorMessage ="Error al insertar al usuario " + err.Message; } }