public new static bool Delete(Autenticador.Entities.SYS_TipoDocumentacao entity) { SYS_TipoDocumentacaoDAO dal = new SYS_TipoDocumentacaoDAO(); dal._Banco.Open(IsolationLevel.ReadCommitted); try { if (dal.Select_Integridade(entity.tdo_id) > 0) { throw new CoreLibrary.Validation.Exceptions.ValidationException("Não é possível excluir o tipo de documentação pois possui outros registros ligados a ele."); } else { //Deleta logicamente o tipo de documento dal.Delete(entity); } return(true); } catch (Exception err) { dal._Banco.Close(err); throw; } finally { dal._Banco.Close(); } }
public static bool GetSelectNome(Autenticador.Entities.SYS_TipoDocumentacao entity) { try { SYS_TipoDocumentacaoDAO dal = new SYS_TipoDocumentacaoDAO(); return(dal.SelectBy_Nome(entity.tdo_nome, entity.tdo_id)); } catch { throw; } }
public new static bool Save(Autenticador.Entities.SYS_TipoDocumentacao entity) { SYS_TipoDocumentacaoDAO dal = new SYS_TipoDocumentacaoDAO(); dal._Banco.Open(IsolationLevel.ReadCommitted); try { if (entity.Validate()) { if (VerificaDuplicidadeDeClassificacao(entity) && entity.tdo_classificacao != Convert.ToByte(eClassificacao.Outros)) { throw new DuplicateNameException("Já existe um tipo de documentação cadastrado com esta classificação."); } else if (GetSelectNome(entity)) { throw new DuplicateNameException("Já existe um tipo de documentação cadastrado com este nome."); } else { dal.Salvar(entity); } } else { throw new CoreLibrary.Validation.Exceptions.ValidationException(entity.PropertiesErrorList[0].Message); } return(true); } catch (Exception err) { dal._Banco.Close(err); throw; } finally { dal._Banco.Close(); } }
/// <summary> /// Verifica se parametro que validade duplicidade de documento por classificação esta habilitado /// </summary> /// <returns>bool</returns> //public static bool VerificaParametroDuplicidadeCategoria() //{ // //VERIFICA SE PARAMETRO QUE VALIDA POR DUPLICIDADE DE DOCUMENTO POR CLASSIFICAÇÃO ESTA HABILITADO // var verificaParametro = SYS_ParametroBO.ParametroValor(SYS_ParametroBO.eChave.HABILITAR_VALIDACAO_DUPLICIDADE_TIPO_DOCUMENTO_POR_CLASSIFICACAO); // bool saida; // if(Boolean.TryParse(verificaParametro, out saida)) // { // if (!Convert.ToBoolean(verificaParametro)) // { // return false; // } // } // return true; //} /// <summary> /// Verifica se parametro que validade duplicidade de documento por classificação esta habilitado /// e (caso esteja) se existe documento com mesma classificação /// </summary> /// <returns>bool</returns> public static bool VerificaDuplicidadeDeClassificacao(Autenticador.Entities.SYS_TipoDocumentacao entity) { //VERIFICA SE PARAMETRO QUE VALIDA POR DUPLICIDADE DE DOCUMENTO POR CLASSIFICAÇÃO ESTA HABILITADO var verificaParametro = SYS_ParametroBO.ParametroValorBooleano(SYS_ParametroBO.eChave.HABILITAR_VALIDACAO_DUPLICIDADE_TIPO_DOCUMENTO_POR_CLASSIFICACAO); if (!Convert.ToBoolean(verificaParametro)) { return(false); } else { try { SYS_TipoDocumentacaoDAO dal = new SYS_TipoDocumentacaoDAO(); return(dal.SelectBy_Classificacao(entity.tdo_classificacao, entity.tdo_id)); } catch { throw; } } }