Example #1
0
        //EXCLUIR
        public static void Excluir(MTipoAtividade item)
        {
            if (item == null)
            {
                throw new ExcecaoPadrao(Erros.TipoDadoNull);
            }

            MTipoAtividadeCampo pesquisa = new MTipoAtividadeCampo();

            pesquisa.CampoID         = 0;
            pesquisa.TipoAtividadeID = item.ID;
            pesquisa.ValorInicial    = "";
            pesquisa.ValorFinal      = "";
            if (CTipoAtividadeCampo.Pesquisar(pesquisa) != null)
            {
                throw new ExcecaoPadrao(Erros.AtividadeChaveEstrangeira);
            }

            try
            {
                DTipoAtividade.Excluir(item);
            }
            catch
            {
                throw;
            }
        }
Example #2
0
        //OBTER
        public static MTipoAtividade Obter(MTipoAtividade item)
        {
            MTipoAtividade retorno = null;

            if (item != null)
            {
                retorno = DTipoAtividade.Obter(item);
            }

            return(retorno);
        }
Example #3
0
        //PESQUISAR INSERIR
        public static List <MTipoAtividade> PesquisarInserir(MTipoAtividade item)
        {
            List <MTipoAtividade> retorno = null;

            if (item.Nome != null && item.Nome.Length <= 100)
            {
                retorno = DTipoAtividade.PesquisarInserir(item);
            }

            return(retorno);
        }
Example #4
0
        //EDITAR
        public static void Editar(MTipoAtividade item)
        {
            if (item == null)
            {
                throw new ExcecaoPadrao(Erros.TipoDadoNull);
            }

            if (item.Nome.Trim() == "" || item.Nome.Length > 100)
            {
                throw new ExcecaoPadrao(Erros.TipoDadoNome);
            }

            MTipoAtividade pesquisa = new MTipoAtividade();

            pesquisa.Nome = item.Nome;

            List <MTipoAtividade> lista = Pesquisar(pesquisa);

            if (lista != null && lista.Count != 0)
            {
                for (int i = 0; i < lista.Count; i++)
                {
                    if (lista[i].Nome == item.Nome && lista[i].ID != item.ID)
                    {
                        throw new ExcecaoPadrao(Erros.AtividadeNomeDuplicado);
                    }
                }
            }

            try
            {
                DTipoAtividade.Editar(item);
            }
            catch
            {
                throw;
            }
        }