Exemplo n.º 1
0
        public Error GetFatosOrigem(string _connString, ref List <fatos> _fatos)
        {
            Error error = new Error();

            error.SetErro(Error.tipoRetorno.indefinido, "", "");

            if (_fatos == null)
            {
                _fatos = new List <fatos>();
            }

            try
            {
                connection.ConnectionString = _connString;

                command.Connection  = connection;
                command.CommandText = "SELECT descricao, financas, persona, scritta FROM contabilizacao.vw_fatos_origem ORDER BY descricao;";

                connection.OpenAsync();

                reader = command.ExecuteReader();
                while (reader.Read())
                {
                    if (reader["descricao"].ToString() != "")
                    {
                        fatos fato = new fatos();
                        fato.descricao = reader["descricao"].ToString().ToUpper();
                        fato.financas  = Convert.ToBoolean(reader["financas"].ToString());
                        fato.persona   = Convert.ToBoolean(reader["persona"].ToString());
                        fato.scritta   = Convert.ToBoolean(reader["scritta"].ToString());

                        _fatos.Add(fato);
                    }
                }
            } catch (NpgsqlException ex)
            {
                error.SetErro(Error.tipoRetorno.erro, ex.ErrorCode.ToString(), ex.Message);
                return(error);
            } catch (Exception ex)
            {
                error.SetErro(Error.tipoRetorno.erro, "", ex.Message);
                return(error);
            } finally
            {
                connection.CloseAsync();
            }

            error.SetErro(Error.tipoRetorno.sucesso, "", "");
            return(error);
        }
Exemplo n.º 2
0
        public Error GetFatos(string _connString, ref List <fatos> _fatos)
        {
            Error error = new Error();

            error.SetErro(Error.tipoRetorno.indefinido, "", "");

            if (_fatos == null)
            {
                _fatos = new List <fatos>();
            }

            try
            {
                connection.ConnectionString = _connString;

                command.Connection  = connection;
                command.CommandText = "SELECT objeto, descricao FROM contabilizacao.objetos ORDER BY descricao;";

                connection.OpenAsync();

                reader = command.ExecuteReader();
                while (reader.Read())
                {
                    if (reader["objeto"].ToString() != "")
                    {
                        fatos fato = new fatos();
                        fato.objeto    = "'" + reader["objeto"].ToString() + "'";
                        fato.descricao = reader["descricao"].ToString().ToUpper();

                        _fatos.Add(fato);
                    }
                }
            } catch (NpgsqlException ex)
            {
                error.SetErro(Error.tipoRetorno.erro, ex.ErrorCode.ToString(), ex.Message.ToString());
                return(error);
            } catch (Exception ex)
            {
                error.SetErro(Error.tipoRetorno.erro, "", ex.Message.ToString());
                return(error);
            } finally
            {
                connection.CloseAsync();
            }

            error.SetErro(Error.tipoRetorno.sucesso, "", "");
            return(error);
        }