protected void gridUsuario_SelectedIndexChanged(object sender, EventArgs e) { usuarioL = new UsuariosLN(); usuarioL.listUsuariosMenus(cbListMenus, int.Parse(gridUsuario.SelectedValue.ToString())); usuarioL.gridCargoUsuario(gridCargo, int.Parse(gridUsuario.SelectedValue.ToString())); lblUsuario.Text = gridUsuario.SelectedValue.ToString() + " - " + gridUsuario.SelectedRow.Cells[2].Text; ocultarLblSuccess(); ocultarLblError(); }
protected void Button1_Click(object sender, EventArgs e) { string idUsuario = lblUsuario.Text.Split('-')[0].Trim(); string id = ((Label)Master.FindControl("lblUsuario")).Text; try { if (validarControlesInsertar()) { if (idUsuario.Equals(string.Empty)) { throw new Exception("Seleccione un usuario!"); } usuarioL = new UsuariosLN(); DataSet dsResultado = usuarioL.IngresarCargoUsuario(int.Parse(idUsuario), int.Parse(dropUnidad.SelectedValue), int.Parse(dropDependencia.SelectedValue), int.Parse(dropTipoUsuario.SelectedValue), id); if (bool.Parse(dsResultado.Tables[0].Rows[0]["ERRORES"].ToString())) { throw new Exception(dsResultado.Tables[0].Rows[0]["MSG_ERROR"].ToString()); } usuarioL.gridCargoUsuario(gridCargo, int.Parse(idUsuario)); lblSuccess.Text = "El registro fue ingresado correctamente"; lblError.Text = string.Empty; } } catch (Exception ex) { string mensaje = "Error al ingresar el registro: " + ex.Message; if (ex.Message.Equals("Seleccione un usuario!")) { mensaje = "Seleccione un usuario!"; } lblError.Text = mensaje; lblSuccess.Text = string.Empty; } lblErrorM.Text = string.Empty; lblSuccessM.Text = string.Empty; }
protected void gridCargo_RowDeleting(object sender, GridViewDeleteEventArgs e) { try { int idcu; idcu = Convert.ToInt32(gridCargo.Rows[e.RowIndex].Cells[2].Text); usuarioL = new UsuariosLN(); if (usuarioL.desactivarCargoUsuario(idcu, ((Label)Master.FindControl("lblUsuario")).Text)) { usuarioL.gridCargoUsuario(gridCargo, int.Parse(lblUsuario.Text.Split('-')[0].Trim())); lblSuccess.Text = "El registro fue eliminado correctamente"; ocultarLblError(); } else { lblError.Text = "El usuario no tiene los permisos para realizar la accion"; } } catch (Exception ex) { lblError.Text = "Error al eliminar el registro: " + ex.Message; lblSuccess.Text = string.Empty; } }