protected void _dgvFuncao_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Deletar") { try { int index = int.Parse(e.CommandArgument.ToString()); int fun_id = Convert.ToInt32(_dgvFuncao.DataKeys[index].Value); RHU_Funcao entity = new RHU_Funcao { fun_id = fun_id }; RHU_FuncaoBO.GetEntity(entity); if (RHU_FuncaoBO.Delete(entity)) { _dgvFuncao.PageIndex = 0; _dgvFuncao.Sort("", SortDirection.Ascending); _dgvFuncao.DataBind(); ApplicationWEB._GravaLogSistema(LOG_SistemaTipo.Delete, "fun_id: " + fun_id); _lblMessage.Text = UtilBO.GetErroMessage("Função excluída com sucesso.", UtilBO.TipoMensagem.Sucesso); } } catch (ValidationException ex) { _lblMessage.Text = UtilBO.GetErroMessage(ex.Message, UtilBO.TipoMensagem.Alerta); } catch (Exception ex) { ApplicationWEB._GravaErro(ex); _lblMessage.Text = UtilBO.GetErroMessage("Erro ao tentar excluir a função.", UtilBO.TipoMensagem.Erro); } } }
/// <summary> /// Carrega as informações da função informada. /// </summary> /// <param name="fun_id">id da função</param> private void _Carregar(int fun_id) { try { RHU_Funcao _Funcao = new RHU_Funcao { fun_id = fun_id }; RHU_FuncaoBO.GetEntity(_Funcao); if (_Funcao.ent_id != __SessionWEB.__UsuarioWEB.Usuario.ent_id) { __SessionWEB.PostMessages = UtilBO.GetErroMessage("A função não pertence à entidade na qual você está logado.", UtilBO.TipoMensagem.Alerta); Response.Redirect("Busca.aspx", false); HttpContext.Current.ApplicationInstance.CompleteRequest(); } _VS_fun_id = _Funcao.fun_id; _txtCodigo.Text = _Funcao.fun_codigo; _txtFuncao.Text = _Funcao.fun_nome; _txtDescricao.Text = _Funcao.fun_descricao; _txtCodIntegracao.Text = _Funcao.fun_codIntegracao; if (!string.IsNullOrEmpty(_Funcao.pgs_chave)) { if (UCComboParametroGrupoPerfil1.ExisteItem(_Funcao.pgs_chave)) { UCComboParametroGrupoPerfil1.Valor = _Funcao.pgs_chave; } } _ckbBloqueado.Checked = !_Funcao.fun_situacao.Equals(1); } catch (Exception ex) { ApplicationWEB._GravaErro(ex); _lblMessage.Text = UtilBO.GetErroMessage("Erro ao tentar carregar a função.", UtilBO.TipoMensagem.Erro); } }