Exemple #1
0
        public Retorno Consultar(TipoFormaPagamentoContaPagar Entity)
        {
            try
            {
                TipoFormaPagamentoContaPagar TipoFormaPagamentoContaPagar = new TipoFormaPagamentoContaPagar();
                CommandSQL = new StringBuilder();
                CommandSQL.AppendLine("SELECT ");
                CommandSQL.AppendLine("TB_TIPO_FORMA_PAGAMENTO_CONTA_PAGAR.CODIGO, ");
                CommandSQL.AppendLine("TB_TIPO_FORMA_PAGAMENTO_CONTA_PAGAR.DESCRICAO, ");
                CommandSQL.AppendLine("TB_TIPO_FORMA_PAGAMENTO_CONTA_PAGAR.CONTEM_PARCELAS ");
                CommandSQL.AppendLine("FROM TB_TIPO_FORMA_PAGAMENTO_CONTA_PAGAR ");

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

                CommandSQL.AppendLine("WHERE (TB_TIPO_FORMA_PAGAMENTO_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())
                {
                    TipoFormaPagamentoContaPagars.Add(FillEntity(Reader));
                }
                return(new Retorno(TipoFormaPagamentoContaPagars));
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally { Fechar(); }
        }
Exemple #4
0
 public Retorno Consultar(TipoFormaPagamentoContaPagar Entity)
 {
     try
     {
         return(new DataTipoFormaPagamentoContaPagar().Consultar(Entity));
     }
     catch (Exception ex)
     {
         return(Retorno.CriarRetornoExcecao(ex));
     }
 }
Exemple #5
0
 public Retorno Pesquisar(TipoFormaPagamentoContaPagar Entity, int Pagina, int QntPagina)
 {
     try
     {
         return(new DataTipoFormaPagamentoContaPagar().Pesquisar(Entity, Pagina, QntPagina));
     }
     catch (Exception ex)
     {
         return(Retorno.CriarRetornoExcecao(ex));
     }
 }
Exemple #6
0
 private Retorno VerificarExistencia(TipoFormaPagamentoContaPagar Entity)
 {
     try
     {
         return(new DataTipoFormaPagamentoContaPagar().VerificarExistencia(Entity));
     }
     catch (Exception ex)
     {
         return(Retorno.CriarRetornoExcecao(ex));
     }
 }
Exemple #7
0
        private TipoFormaPagamentoContaPagar FillEntity(IDataReader reader)
        {
            TipoFormaPagamentoContaPagar TipoFormaPagamentoContaPagar = new TipoFormaPagamentoContaPagar();

            try
            {
                TipoFormaPagamentoContaPagar.Codigo         = ConverterValorReader(reader, "CODIGO", 0);
                TipoFormaPagamentoContaPagar.Descricao      = ConverterValorReader(reader, "DESCRICAO", String.Empty);
                TipoFormaPagamentoContaPagar.ContemParcelas = ConverterValorReader(reader, "CONTEM_PARCELAS", false);
            }
            catch (Exception ex) { throw ex; }
            return(TipoFormaPagamentoContaPagar);
        }
Exemple #8
0
        public Retorno PreenchimentoObrigatorio(TipoFormaPagamentoContaPagar Entity)
        {
            if (String.IsNullOrEmpty(Entity.Descricao))
            {
                return(new Retorno(false, String.Format(Mensagens.MSG_01, "Descricao")));
            }

            if (Entity.ContemParcelas == false)
            {
                return(new Retorno(false, String.Format(Mensagens.MSG_01, "Contem Parcelas")));
            }

            return(new Retorno(true));
        }
Exemple #9
0
 public Retorno Excluir(TipoFormaPagamentoContaPagar Entity)
 {
     try
     {
         CommandSQL = new StringBuilder();
         CommandSQL.AppendLine("DELETE FROM TB_TIPO_FORMA_PAGAMENTO_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(); }
 }
Exemple #10
0
 public Retorno Alterar(TipoFormaPagamentoContaPagar Entity)
 {
     try
     {
         CommandSQL = new StringBuilder();
         CommandSQL.AppendLine("UPDATE TB_TIPO_FORMA_PAGAMENTO_CONTA_PAGAR SET ");
         CommandSQL.AppendLine("DESCRICAO = @DESCRICAO, ");
         CommandSQL.AppendLine("CONTEM_PARCELAS = @CONTEM_PARCELAS ");
         CommandSQL.AppendLine("WHERE CODIGO = @CODIGO");
         Command = CriaComandoSQL(CommandSQL.ToString());
         Command.Parameters.AddWithValue("@CODIGO", Entity.Codigo);
         Command.Parameters.AddWithValue("@DESCRICAO", Entity.Descricao);
         Command.Parameters.AddWithValue("@CONTEM_PARCELAS", Entity.ContemParcelas);
         Abrir();
         Command.ExecuteNonQuery();
         return(new Retorno(true, String.Format(Mensagens.MSG_02, "Alterado ")));
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally { Fechar(); }
 }
Exemple #11
0
 public Retorno Salvar(TipoFormaPagamentoContaPagar Entity)
 {
     try
     {
         Retorno retorno = PreenchimentoObrigatorio(Entity);
         if (retorno.IsValido)
         {
             if (Entity.Codigo == 0)
             {
                 retorno = new DataTipoFormaPagamentoContaPagar().Incluir(Entity);
             }
             else
             {
                 retorno = new DataTipoFormaPagamentoContaPagar().Alterar(Entity);
             }
         }
         return(retorno);
     }
     catch (Exception ex)
     {
         return(Retorno.CriarRetornoExcecao(ex));
     }
 }
Exemple #12
0
 public Retorno Incluir(TipoFormaPagamentoContaPagar Entity)
 {
     try
     {
         CommandSQL = new StringBuilder();
         CommandSQL.AppendLine("INSERT INTO TB_TIPO_FORMA_PAGAMENTO_CONTA_PAGAR( ");
         CommandSQL.AppendLine("DESCRICAO, ");
         CommandSQL.AppendLine("CONTEM_PARCELAS) ");
         CommandSQL.AppendLine("VALUES (");
         CommandSQL.AppendLine("@DESCRICAO, ");
         CommandSQL.AppendLine("@CONTEM_PARCELAS) ");
         Command = CriaComandoSQL(CommandSQL.ToString());
         Command.Parameters.AddWithValue("@DESCRICAO", Entity.Descricao);
         Command.Parameters.AddWithValue("@CONTEM_PARCELAS", Entity.ContemParcelas);
         Abrir();
         Command.ExecuteNonQuery();
         return(new Retorno(true, String.Format(Mensagens.MSG_02, "Salvo")));
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally { Fechar(); }
 }