protected void gvItensArea_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "DeletarItem") { try { int index = int.Parse(e.CommandArgument.ToString()); GridView gvItens = (GridView)sender; int mbf_id = Convert.ToInt32(gvItens.DataKeys[index].Values["mbf_id"].ToString()); int mbf_idPai = Convert.ToInt32(gvItens.DataKeys[index].Values["mbf_idPai"].ToString()); ACA_MotivoBaixaFrequencia entity = new ACA_MotivoBaixaFrequencia { mbf_id = mbf_id }; ACA_MotivoBaixaFrequenciaBO.GetEntity(entity); if (ACA_MotivoBaixaFrequenciaBO.Delete(entity)) // executa a exclusao { ApplicationWEB._GravaLogSistema(LOG_SistemaTipo.Delete, "mbf_id: " + mbf_id); lblMessage.Text = UtilBO.GetErroMessage("Item excluído com sucesso.", UtilBO.TipoMensagem.Sucesso); // carrega itens da área gvItens.DataSource = ACA_MotivoBaixaFrequenciaBO.Seleciona_Entidades_ItensMotivoInfrequencia(mbf_idPai); gvItens.DataBind(); } } catch (Exception ex) { ApplicationWEB._GravaErro(ex); lblMessage.Text = UtilBO.GetErroMessage("Erro ao tentar excluir o item.", UtilBO.TipoMensagem.Erro); } } }
protected void rptAreasInfrequencia_ItemCommand(object source, RepeaterCommandEventArgs e) { Button btnExcluir = rptAreasInfrequencia.Items[e.Item.ItemIndex].FindControl("btnExcluirArea") as Button; if (e.CommandName == "Deletar") { try { HiddenField hdnMbf_id = rptAreasInfrequencia.Items[e.Item.ItemIndex].FindControl("hdnMbf_id") as HiddenField; int mbf_id = Convert.ToInt32(hdnMbf_id.Value); ACA_MotivoBaixaFrequencia entity = new ACA_MotivoBaixaFrequencia { mbf_id = mbf_id }; ACA_MotivoBaixaFrequenciaBO.GetEntity(entity); if (ACA_MotivoBaixaFrequenciaBO.Delete(entity)) { ApplicationWEB._GravaLogSistema(LOG_SistemaTipo.Delete, "mbf_id: " + mbf_id); lblMessage.Text = UtilBO.GetErroMessage("Área excluído com sucesso.", UtilBO.TipoMensagem.Sucesso); // movo -1 para iniciar com todos os accords fechados hdnAreaSelecionada.Value = "-1"; // atualiza accordion carregaAreas(); } } catch (Exception ex) { ApplicationWEB._GravaErro(ex); lblMessage.Text = UtilBO.GetErroMessage("Erro ao tentar excluir a área.", UtilBO.TipoMensagem.Erro); } } }