Example #1
0
        public Retorno Consultar(TipoFuncao Entity)
        {
            try
            {
                TipoFuncao TipoFuncao = new TipoFuncao();
                CommandSQL = new StringBuilder();
                CommandSQL.AppendLine("SELECT ");
                CommandSQL.AppendLine("TB_TIPO_FUNCAO.CODIGO, ");
                CommandSQL.AppendLine("TB_TIPO_FUNCAO.DESCRICAO ");
                CommandSQL.AppendLine("FROM TB_TIPO_FUNCAO ");

                CommandSQL.AppendLine("WHERE TB_TIPO_FUNCAO.CODIGO = @CODIGO ");
                Command = CriaComandoSQL(CommandSQL.ToString());
                Abrir();
                Command.Parameters.AddWithValue("@CODIGO", Entity.Codigo);
                Reader = Command.ExecuteReader();
                while (Reader.Read())
                {
                    TipoFuncao = FillEntity(Reader);
                }
                return(new Retorno(TipoFuncao));
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally { Fechar(); }
        }
Example #2
0
 public Retorno VerificarExistencia(TipoFuncao Entity)
 {
     try
     {
         CommandSQL = new StringBuilder();
         CommandSQL.AppendLine("SELECT 1 FROM TB_TIPO_FUNCAO ");
         CommandSQL.AppendLine("WHERE TB_TIPO_FUNCAO.DESCRICAO = @DESCRICAO ");
         CommandSQL.AppendLine("AND TB_TIPO_FUNCAO.CODIGO <> @CODIGO ");
         Command = CriaComandoSQL(CommandSQL.ToString());
         Abrir();
         Command.Parameters.AddWithValue("@DESCRICAO", Entity.Descricao);
         Command.Parameters.AddWithValue("@CODIGO", Entity.Codigo);
         Reader = Command.ExecuteReader();
         while (Reader.Read())
         {
             return(new Retorno(false, String.Format(Mensagens.MSG_04, "TipoFuncao", "Descricao")));
         }
         return(new Retorno(true));
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally { Fechar(); }
 }
Example #3
0
        public Retorno Pesquisar(TipoFuncao Entity, int Pagina, int QntPagina)
        {
            try
            {
                List <TipoFuncao> TipoFuncaos = new List <TipoFuncao>();
                int Limite = (Pagina - 1) * QntPagina;
                CommandSQL = new StringBuilder();
                CommandSQL.AppendLine("SELECT ");
                CommandSQL.AppendLine("TB_TIPO_FUNCAO.CODIGO, ");
                CommandSQL.AppendLine("TB_TIPO_FUNCAO.DESCRICAO ");
                CommandSQL.AppendLine("FROM TB_TIPO_FUNCAO ");

                CommandSQL.AppendLine("WHERE (TB_TIPO_FUNCAO.DESCRICAO LIKE '%" + Entity.Descricao + "%' )");
                CommandSQL.AppendLine("LIMIT @QNT_PAGINA OFFSET @LIMITE");
                Command = CriaComandoSQL(CommandSQL.ToString());
                Abrir();
                Command.Parameters.AddWithValue("@QNT_PAGINA", QntPagina);
                Command.Parameters.AddWithValue("@LIMITE", Limite);
                Reader = Command.ExecuteReader();
                while (Reader.Read())
                {
                    TipoFuncaos.Add(FillEntity(Reader));
                }
                return(new Retorno(TipoFuncaos));
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally { Fechar(); }
        }
Example #4
0
        public Retorno PreenchimentoObrigatorio(TipoFuncao Entity)
        {
            if (String.IsNullOrEmpty(Entity.Descricao))
            {
                return(new Retorno(false, String.Format(Mensagens.MSG_01, "Descricao")));
            }

            return(new Retorno(true));
        }
Example #5
0
 public Retorno Consultar(TipoFuncao Entity)
 {
     try
     {
         return(new DataTipoFuncao().Consultar(Entity));
     }
     catch (Exception ex)
     {
         return(Retorno.CriarRetornoExcecao(ex));
     }
 }
Example #6
0
 public Retorno Pesquisar(TipoFuncao Entity, int Pagina, int QntPagina)
 {
     try
     {
         return(new DataTipoFuncao().Pesquisar(Entity, Pagina, QntPagina));
     }
     catch (Exception ex)
     {
         return(Retorno.CriarRetornoExcecao(ex));
     }
 }
Example #7
0
 private Retorno VerificarExistencia(TipoFuncao Entity)
 {
     try
     {
         return(new DataTipoFuncao().VerificarExistencia(Entity));
     }
     catch (Exception ex)
     {
         return(Retorno.CriarRetornoExcecao(ex));
     }
 }
Example #8
0
        private TipoFuncao FillEntity(IDataReader reader)
        {
            TipoFuncao TipoFuncao = new TipoFuncao();

            try
            {
                TipoFuncao.Codigo    = ConverterValorReader(reader, "CODIGO", 0);
                TipoFuncao.Descricao = ConverterValorReader(reader, "DESCRICAO", String.Empty);
            }
            catch (Exception ex) { throw ex; }
            return(TipoFuncao);
        }
Example #9
0
 public Retorno Alterar(TipoFuncao Entity)
 {
     try
     {
         CommandSQL = new StringBuilder();
         CommandSQL.AppendLine("UPDATE TB_TIPO_FUNCAO SET ");
         CommandSQL.AppendLine("DESCRICAO = @DESCRICAO ");
         CommandSQL.AppendLine("WHERE CODIGO = @CODIGO");
         Command = CriaComandoSQL(CommandSQL.ToString());
         Command.Parameters.AddWithValue("@CODIGO", Entity.Codigo);
         Command.Parameters.AddWithValue("@DESCRICAO", Entity.Descricao);
         Abrir();
         Command.ExecuteNonQuery();
         return(new Retorno(true, String.Format(Mensagens.MSG_02, "Alterado ")));
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally { Fechar(); }
 }
Example #10
0
 public Retorno Incluir(TipoFuncao Entity)
 {
     try
     {
         CommandSQL = new StringBuilder();
         CommandSQL.AppendLine("INSERT INTO TB_TIPO_FUNCAO( ");
         CommandSQL.AppendLine("DESCRICAO) ");
         CommandSQL.AppendLine("VALUES (");
         CommandSQL.AppendLine("@DESCRICAO) ");
         Command = CriaComandoSQL(CommandSQL.ToString());
         Command.Parameters.AddWithValue("@DESCRICAO", Entity.Descricao);
         Abrir();
         Command.ExecuteNonQuery();
         return(new Retorno(true, String.Format(Mensagens.MSG_02, "Salvo")));
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally { Fechar(); }
 }
Example #11
0
 public Retorno Excluir(TipoFuncao Entity)
 {
     try
     {
         CommandSQL = new StringBuilder();
         CommandSQL.AppendLine("DELETE FROM TB_TIPO_FUNCAO WHERE CODIGO = @CODIGO");
         Command = CriaComandoSQL(CommandSQL.ToString());
         Command.Parameters.AddWithValue("@CODIGO", Entity.Codigo);
         Abrir();
         Command.ExecuteNonQuery();
         return(new Retorno(true, String.Format(Mensagens.MSG_02, "Excluido ")));
     }
     catch (Exception ex)
     {
         if (((MySqlException)ex).Number == 1451)
         {
             return(new Retorno(false, Mensagens.MSG_16));
         }
         throw ex;
     }
     finally { Fechar(); }
 }
Example #12
0
 public Retorno Salvar(TipoFuncao Entity)
 {
     try
     {
         Retorno retorno = PreenchimentoObrigatorio(Entity);
         if (retorno.IsValido)
         {
             if (Entity.Codigo == 0)
             {
                 retorno = new DataTipoFuncao().Incluir(Entity);
             }
             else
             {
                 retorno = new DataTipoFuncao().Alterar(Entity);
             }
         }
         return(retorno);
     }
     catch (Exception ex)
     {
         return(Retorno.CriarRetornoExcecao(ex));
     }
 }