예제 #1
0
        }// --------------------------------------------------------------------------------------------

        public Entidades.ImovelColletion CarregaSubCategorias()
        {
            try
            {
                Entidades.Imovel          Ent    = new Entidades.Imovel();
                Entidades.ImovelColletion EntCol = new Entidades.ImovelColletion();

                string banco = "server=mysql.brnow.com.br;database=brnow;uid=brnow;pwd=e7p5a7";
                conexao = new MySqlConnection(banco);
                conexao.Open();

                string          comando = "SELECT * FROM tb_SubCategoria WHERE Ativo = 1";
                MySqlCommand    cmd     = new MySqlCommand(comando, conexao);
                MySqlDataReader reader  = cmd.ExecuteReader();

                while (reader.Read())
                {
                    Ent = new Entidades.Imovel();

                    Ent.Id_SubCategoria = reader.GetInt32(0);
                    Ent.Nome            = reader.GetString(1);

                    EntCol.Add(Ent);
                }

                conexao.Close();
                return(EntCol);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #2
0
        // --------------------------------------------------------------------------------------------
        public Entidades.ImovelColletion CarregaImovel()
        {
            try
            {
                Entidades.Imovel          Ent    = new Entidades.Imovel();
                Entidades.ImovelColletion EntCol = new Entidades.ImovelColletion();
                string banco = "server=mysql.brnow.com.br;database=brnow;uid=brnow;pwd=e7p5a7";
                conexao = new MySqlConnection(banco);
                //string banco = "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=buffalobr.mysql.uhserver.com; DATABASE=buffalobr; UID=buffalobr;PASSWORD=gab97081@@--; OPTION=3";
                //OdbcConnection conexao = new OdbcConnection(banco);
                conexao.Open();
                string          comando = @"SELECT
	                                TBP.ID_Imovel,
	                                TBP.Nome_Imovel,
	                                TBP.Numero,
	                                TBP.Preco,
	                                TBP.Categoria,
	                                TBP.SubCategoria,
	                                TBC.tipoImovel
                                FROM
	                                `TB_Imovel` TBP INNER JOIN tb_Categoria TBC ON TBP.Categoria = TBC.idTipoImovel
                                WHERE
	                                TBP.Ativo = 1 ORDER BY ID_Imovel DESC;"    ;
                MySqlCommand    cmd     = new MySqlCommand(comando, conexao);
                MySqlDataReader reader  = cmd.ExecuteReader();

                while (reader.Read())
                {
                    Ent              = new Entidades.Imovel();
                    Ent.ID_Imovel    = reader.GetInt32(0);
                    Ent.Nome_Imovel  = reader.GetString(1);
                    Ent.Numero       = reader.GetInt32(2);
                    Ent.Preco        = reader.GetDouble(3);
                    Ent.Categoria    = reader.GetInt32(4);
                    Ent.SubCategoria = reader.GetInt32(5);
                    Ent.TipoImovel   = reader.GetString(6);
                    //Ent.Imagem = reader.GetString(7);
                    //Ent.IdProduto = Convert.ToInt32(reader.GetString("idProduto"));
                    //Ent.CodProduto = reader.GetString("Codigo");
                    //Ent.NomeProduto = reader.GetString("NomeProduto");
                    //Ent.Descricao = reader.GetString("Descricao");
                    //Ent.Especificacoes = reader.GetString("Especificacoes");
                    //Ent.IdCategoria = Convert.ToInt32(reader.GetString("Categoria"));
                    //Ent.NomeCategoria = reader.GetString("NomeCategoria");
                    //Ent.Imagem = reader.GetString("Imagem");
                    EntCol.Add(Ent);
                }
                conexao.Close();
                return(EntCol);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }// --------------------------------------------------------------------------------------------