//EXCLUIR public static void Excluir(MTipoDado item) { if (item == null) { throw new ExcecaoPadrao(Erros.TipoDadoNull); } MCampo pesquisa = new MCampo(); pesquisa.Nome = ""; pesquisa.TipoDado = item.ID; if (CCampo.Pesquisar(pesquisa) != null) { throw new ExcecaoPadrao(Erros.TipoDadoChaveEstrangeira); } try { DTipoDado.Excluir(item); } catch { throw; } }
//OBTER public static MTipoDado Obter(MTipoDado item) { MTipoDado retorno = null; if (item != null) { retorno = DTipoDado.Obter(item); } return(retorno); }
//PESQUISAR public static List <MTipoDado> Pesquisar(MTipoDado item) { List <MTipoDado> retorno = null; if (item.Nome != null && item.Nome.Length <= 100) { retorno = DTipoDado.Pesquisar(item); } return(retorno); }
//EDITAR public static void Editar(MTipoDado item) { if (item == null) { throw new ExcecaoPadrao(Erros.TipoDadoNull); } if (item.Nome.Trim() == "" || item.Nome.Length > 100) { throw new ExcecaoPadrao(Erros.TipoDadoNome); } if (item.Descricao.Length > 100) { throw new ExcecaoPadrao(Erros.TipoDadoDescricao); } List <MTipoDado> lista = Pesquisar(item); 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.TipoDadoNomeDuplicado); } } } try { DTipoDado.Editar(item); } catch { throw; } }