Example #1
0
    protected void _grvColaborador_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Deletar")
        {
            try
            {
                int  index  = int.Parse(e.CommandArgument.ToString());
                long col_id = Convert.ToInt32(_grvColaborador.DataKeys[index].Value);

                RHU_Colaborador entity = new RHU_Colaborador {
                    col_id = col_id
                };
                RHU_ColaboradorBO.GetEntity(entity);

                if (RHU_ColaboradorBO.Delete(entity, null, __SessionWEB.__UsuarioWEB.Usuario.ent_id))
                {
                    _grvColaborador.PageIndex = 0;
                    _grvColaborador.DataBind();
                    ApplicationWEB._GravaLogSistema(LOG_SistemaTipo.Delete, "col_id: " + col_id);
                    _lblMessage.Text = UtilBO.GetErroMessage("Colaborador excluído 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 o colaborador.", UtilBO.TipoMensagem.Erro);
            }
        }

        if (e.CommandName == "CriaDocente")
        {
            try
            {
                int  index  = int.Parse(e.CommandArgument.ToString());
                long col_id = Convert.ToInt32(_grvColaborador.DataKeys[index].Value);

                Session["col_id"] = col_id;
                RedirecionarPagina("~/Academico/RecursosHumanos/Docente/Cadastro.aspx");
            }
            catch (Exception ex)
            {
                ApplicationWEB._GravaErro(ex);
                _lblMessage.Text = UtilBO.GetErroMessage("Erro ao tentar carregar os dados.", UtilBO.TipoMensagem.Erro);
            }
        }
    }
Example #2
0
        public new static bool Delete
        (
            ACA_Docente entity
        )
        {
            ACA_DocenteDAO dao = new ACA_DocenteDAO();

            dao._Banco.Open(IsolationLevel.ReadCommitted);

            try
            {
                //Verifica se o docente pode ser deletado
                if (GestaoEscolarUtilBO.VerificarIntegridade("doc_id", entity.doc_id.ToString(), "ACA_Docente,REL_SituacaoPlanejamentoAulasNotas", dao._Banco))
                {
                    throw new ValidationException("Não é possível excluir o docente pois possui outros registros ligados a ele.");
                }

                //Deleta logicamente o docente
                dao.Delete(entity);

                RHU_Colaborador col = new RHU_Colaborador {
                    col_id = entity.col_id
                };
                RHU_ColaboradorBO.GetEntity(col);

                RHU_ColaboradorBO.Delete(col, dao._Banco);

                //Limpa o cache do docente
                CacheManager.Factory.Remove(string.Format(ModelCache.DOCENTE_POR_ENTIDADE_PESSOA_MODEL_KEY, col.ent_id, col.pes_id));

                return(true);
            }
            catch (Exception err)
            {
                dao._Banco.Close(err);
                throw;
            }
            finally
            {
                dao._Banco.Close();
            }
        }