예제 #1
0
        //EXCLUIR
        public static void Excluir(MCampo item)
        {
            if (item == null)
            {
                throw new ExcecaoPadrao(Erros.CampoNull);
            }

            MTipoAtividadeCampo pesquisa = new MTipoAtividadeCampo();

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

            try
            {
                DCampo.Excluir(item);
            }
            catch
            {
                throw;
            }
        }
예제 #2
0
        //PESQUISAR PARA INSERIR
        public static List <MCampo> PesquisarInserir(MCampo item)
        {
            List <MCampo> retorno = null;

            if (item.Nome != null && item.Nome.Length <= 100)
            {
                retorno = DCampo.PesquisarInserir(item);
            }
            return(retorno);
        }
예제 #3
0
        //OBTER
        public static MCampo Obter(MCampo item)
        {
            MCampo retorno = null;

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

            return(retorno);
        }
예제 #4
0
        //INSERIR
        public static void Inserir(MCampo item)
        {
            if (item == null)
            {
                throw new ExcecaoPadrao(Erros.CampoNull);
            }

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

            if (item.TipoDado == 0)
            {
                throw new ExcecaoPadrao(Erros.CampoTipoDado);
            }

            MCampo pesquisa = new MCampo();

            pesquisa.Nome     = item.Nome;
            pesquisa.TipoDado = 0;

            //Pega o pesquisar especifico para inserir
            List <MCampo> lista = PesquisarInserir(pesquisa);

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

            try
            {
                DCampo.Inserir(item);
            }
            catch
            {
                throw;
            }
        }