protected void btnExcluirConteudo_Click(object sender, EventArgs e) { try { // Pegar os ID's dos itens que serão excluídos. ImageButton btn = (ImageButton)sender; string obj_id = btn.CommandArgument.Split(';')[0]; string ctd_id = btn.CommandArgument.Split(';')[1]; ORC_Conteudo entity = new ORC_Conteudo { obj_id = Convert.ToInt32(string.IsNullOrEmpty(obj_id) ? "0" : obj_id) , ctd_id = Convert.ToInt32(string.IsNullOrEmpty(ctd_id) ? "0" : ctd_id) }; if (entity.obj_id > 0 && entity.ctd_id > 0) { ORC_ConteudoBO.Delete(entity); ApplicationWEB._GravaLogSistema(LOG_SistemaTipo.Delete, "obj_id: " + entity.obj_id + "; ctd_id: " + entity.ctd_id); VS_EditItem = -1; // Recarregar repeater. CarregarObjetivosConteudos(); lblMensagem.Text = UtilBO.GetErroMessage("Conteúdo do ojetivo da orientação curricular excluído com sucesso.", UtilBO.TipoMensagem.Sucesso); } else { lblMensagem.Text = UtilBO.GetErroMessage("Não foi possível excluir o conteúdo do objetivo da orientação curricular.", UtilBO.TipoMensagem.Alerta); } } catch (ValidationException ex) { lblMensagem.Text = UtilBO.GetErroMessage(ex.Message, UtilBO.TipoMensagem.Alerta); } catch (Exception ex) { ApplicationWEB._GravaErro(ex); lblMensagem.Text = UtilBO.GetErroMessage("Erro ao tentar excluir o conteúdo do objetivo da orientação curricular.", UtilBO.TipoMensagem.Erro); } }
protected void rptObjetivos_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Header) { // Carregar header com nomes tipos de período calendário. Repeater rptTiposPeriodo = (Repeater)e.Item.FindControl("rptTiposPeriodo"); rptTiposPeriodo.DataSource = ORC_ConteudoTipoPeriodoCalendarioBO.SelecionaPor_Conteudo(-1, -1); rptTiposPeriodo.DataBind(); } else if ((e.Item.ItemType == ListItemType.AlternatingItem) || (e.Item.ItemType == ListItemType.Item)) { // Seta flag que indica se o item do Objetivo é o que está sendo editado. editandoItemObjetivo = VS_EditItem == e.Item.ItemIndex; int obj_id = Convert.ToInt32(DataBinder.Eval(e.Item.DataItem, "obj_id")); // Carregar conteúdos do objetivo. DataTable dt = ORC_ConteudoBO.SelecionaPor_Objetivo(obj_id); HtmlTableCell tdObj = (HtmlTableCell)e.Item.FindControl("tdObj"); tdObj.RowSpan = dt.Rows.Count; Repeater rptConteudos = (Repeater)e.Item.FindControl("rptConteudos"); rptConteudos.DataSource = dt; AtualizaRepeaterConteudos(rptConteudos, e.Item); LinkButton Objetivo = (LinkButton)e.Item.FindControl("Objetivo"); if (Objetivo != null) { Objetivo.Enabled = __SessionWEB.__UsuarioWEB.GrupoPermissao.grp_alterar; } // Altera a visibilidade do botão de excluir conteúdo. ImageButton btnExcluirObjetivo = (ImageButton)e.Item.FindControl("btnExcluirObjetivo"); if (btnExcluirObjetivo != null) { btnExcluirObjetivo.Visible = !editandoItemObjetivo && __SessionWEB.__UsuarioWEB.GrupoPermissao.grp_excluir; btnExcluirObjetivo.CommandArgument = obj_id.ToString(); } } }