Esempio n. 1
0
        public Retorno Consultar(TipoStatusContaPagar Entity)
        {
            try
            {
                TipoStatusContaPagar TipoStatusContaPagar = new TipoStatusContaPagar();
                CommandSQL = new StringBuilder();
                CommandSQL.AppendLine("SELECT ");
                CommandSQL.AppendLine("TB_TIPO_STATUS_CONTA_PAGAR.CODIGO, ");
                CommandSQL.AppendLine("TB_TIPO_STATUS_CONTA_PAGAR.DESCRICAO ");
                CommandSQL.AppendLine("FROM TB_TIPO_STATUS_CONTA_PAGAR ");

                CommandSQL.AppendLine("WHERE TB_TIPO_STATUS_CONTA_PAGAR.CODIGO = @CODIGO ");
                Command = CriaComandoSQL(CommandSQL.ToString());
                Abrir();
                Command.Parameters.AddWithValue("@CODIGO", Entity.Codigo);
                Reader = Command.ExecuteReader();
                while (Reader.Read())
                {
                    TipoStatusContaPagar = FillEntity(Reader);
                }
                return(new Retorno(TipoStatusContaPagar));
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally { Fechar(); }
        }
Esempio n. 2
0
 public Retorno VerificarExistencia(TipoStatusContaPagar Entity)
 {
     try
     {
         CommandSQL = new StringBuilder();
         CommandSQL.AppendLine("SELECT 1 FROM TB_TIPO_STATUS_CONTA_PAGAR ");
         CommandSQL.AppendLine("WHERE TB_TIPO_STATUS_CONTA_PAGAR.DESCRICAO = @DESCRICAO ");
         CommandSQL.AppendLine("AND TB_TIPO_STATUS_CONTA_PAGAR.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, "TipoStatusContaPagar", "Descricao")));
         }
         return(new Retorno(true));
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally { Fechar(); }
 }
Esempio n. 3
0
        public Retorno Pesquisar(TipoStatusContaPagar Entity, int Pagina, int QntPagina)
        {
            try
            {
                List <TipoStatusContaPagar> TipoStatusContaPagars = new List <TipoStatusContaPagar>();
                int Limite = (Pagina - 1) * QntPagina;
                CommandSQL = new StringBuilder();
                CommandSQL.AppendLine("SELECT ");
                CommandSQL.AppendLine("TB_TIPO_STATUS_CONTA_PAGAR.CODIGO, ");
                CommandSQL.AppendLine("TB_TIPO_STATUS_CONTA_PAGAR.DESCRICAO ");
                CommandSQL.AppendLine("FROM TB_TIPO_STATUS_CONTA_PAGAR ");

                CommandSQL.AppendLine("WHERE (TB_TIPO_STATUS_CONTA_PAGAR.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())
                {
                    TipoStatusContaPagars.Add(FillEntity(Reader));
                }
                return(new Retorno(TipoStatusContaPagars));
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally { Fechar(); }
        }
Esempio n. 4
0
        public Retorno PreenchimentoObrigatorio(TipoStatusContaPagar Entity)
        {
            if (String.IsNullOrEmpty(Entity.Descricao))
            {
                return(new Retorno(false, String.Format(Mensagens.MSG_01, "Descricao")));
            }

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

            try
            {
                TipoStatusContaPagar.Codigo    = ConverterValorReader(reader, "CODIGO", 0);
                TipoStatusContaPagar.Descricao = ConverterValorReader(reader, "DESCRICAO", String.Empty);
            }
            catch (Exception ex) { throw ex; }
            return(TipoStatusContaPagar);
        }
Esempio n. 9
0
 public Retorno Alterar(TipoStatusContaPagar Entity)
 {
     try
     {
         CommandSQL = new StringBuilder();
         CommandSQL.AppendLine("UPDATE TB_TIPO_STATUS_CONTA_PAGAR 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(); }
 }
Esempio n. 10
0
 public Retorno Incluir(TipoStatusContaPagar Entity)
 {
     try
     {
         CommandSQL = new StringBuilder();
         CommandSQL.AppendLine("INSERT INTO TB_TIPO_STATUS_CONTA_PAGAR( ");
         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(); }
 }
Esempio n. 11
0
 public Retorno Excluir(TipoStatusContaPagar Entity)
 {
     try
     {
         CommandSQL = new StringBuilder();
         CommandSQL.AppendLine("DELETE FROM TB_TIPO_STATUS_CONTA_PAGAR 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(); }
 }
Esempio n. 12
0
 public Retorno Salvar(TipoStatusContaPagar Entity)
 {
     try
     {
         Retorno retorno = PreenchimentoObrigatorio(Entity);
         if (retorno.IsValido)
         {
             if (Entity.Codigo == 0)
             {
                 retorno = new DataTipoStatusContaPagar().Incluir(Entity);
             }
             else
             {
                 retorno = new DataTipoStatusContaPagar().Alterar(Entity);
             }
         }
         return(retorno);
     }
     catch (Exception ex)
     {
         return(Retorno.CriarRetornoExcecao(ex));
     }
 }