/// <summary> /// Altera ordem dos níveis. /// </summary> private bool AlteraOrdem(int nvl_idDescer, int nvl_ordemDescer, int nvl_idSubir, int nvl_ordemSubir) { ORC_Nivel entityDescer = new ORC_Nivel { nvl_id = nvl_idDescer }; ORC_NivelBO.GetEntity(entityDescer); entityDescer.nvl_ordem = nvl_ordemDescer; entityDescer.nvl_dataAlteracao = DateTime.Now; ORC_Nivel entitySubir = new ORC_Nivel { nvl_id = nvl_idSubir }; ORC_NivelBO.GetEntity(entitySubir); entitySubir.nvl_ordem = nvl_ordemSubir; entitySubir.nvl_dataAlteracao = DateTime.Now; return(ORC_NivelBO.SaveOrdem(entityDescer, entitySubir)); }
protected void grvNiveis_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Deletar") { try { int index = int.Parse(e.CommandArgument.ToString()); int nvl_id = Convert.ToInt32(grvNiveis.DataKeys[index].Value); ORC_Nivel entity = new ORC_Nivel { nvl_id = nvl_id }; ORC_NivelBO.GetEntity(entity); entity.nvl_situacao = 3; ORC_NivelBO.Save(entity); ApplicationWEB._GravaLogSistema(LOG_SistemaTipo.Update, "nvl_id: " + entity.nvl_id); lblMensagem.Text = UtilBO.GetErroMessage("Nível da orientação curricular excluído com sucesso.", UtilBO.TipoMensagem.Sucesso); CarregaNiveis(true); } catch (Exception ex) { ApplicationWEB._GravaErro(ex); lblMensagem.Text = UtilBO.GetErroMessage("Erro ao excluir o nível da orientação curricular.", UtilBO.TipoMensagem.Erro); } } else if (e.CommandName == "Subir") { try { int index = int.Parse(e.CommandArgument.ToString()); int nvl_idDescer = Convert.ToInt32(grvNiveis.DataKeys[index - 1]["nvl_id"]); int nvl_ordemDescer = Convert.ToInt32(grvNiveis.DataKeys[index]["nvl_ordem"]); int nvl_idSubir = Convert.ToInt32(grvNiveis.DataKeys[index]["nvl_id"]); int nvl_ordemSubir = Convert.ToInt32(grvNiveis.DataKeys[index - 1]["nvl_ordem"]); if (AlteraOrdem(nvl_idDescer, nvl_ordemDescer, nvl_idSubir, nvl_ordemSubir)) { CarregaNiveis(true); } ApplicationWEB._GravaLogSistema(LOG_SistemaTipo.Update, "nvl_id: " + nvl_idDescer); ApplicationWEB._GravaLogSistema(LOG_SistemaTipo.Update, "nvl_id: " + nvl_idSubir); } catch (Exception ex) { ApplicationWEB._GravaErro(ex); lblMensagem.Text = UtilBO.GetErroMessage(ex.Message, UtilBO.TipoMensagem.Erro); } } else if (e.CommandName == "Descer") { try { int index = int.Parse(e.CommandArgument.ToString()); int nvl_idDescer = Convert.ToInt32(grvNiveis.DataKeys[index]["nvl_id"]); int nvl_ordemDescer = Convert.ToInt32(grvNiveis.DataKeys[index + 1]["nvl_ordem"]); int nvl_idSubir = Convert.ToInt32(grvNiveis.DataKeys[index + 1]["nvl_id"]); int nvl_ordemSubir = Convert.ToInt32(grvNiveis.DataKeys[index]["nvl_ordem"]); if (AlteraOrdem(nvl_idDescer, nvl_ordemDescer, nvl_idSubir, nvl_ordemSubir)) { CarregaNiveis(true); } ApplicationWEB._GravaLogSistema(LOG_SistemaTipo.Update, "nvl_id: " + nvl_idDescer); ApplicationWEB._GravaLogSistema(LOG_SistemaTipo.Update, "nvl_id: " + nvl_idSubir); } catch (Exception ex) { ApplicationWEB._GravaErro(ex); lblMensagem.Text = UtilBO.GetErroMessage(ex.Message, UtilBO.TipoMensagem.Erro); } } }