Exemple #1
0
        public void mostrarDetalhe(VerImoveis verImoveis, DetalheImovel detalheImovel)
        {
            CrudLocador crudLocador = new CrudLocador(inicio);

            DataGridViewRow selectedRow = verImoveis.dgvImovel.Rows[verImoveis.linha];

            int id_Imovel = Convert.ToInt16(selectedRow.Cells[0].Value);



            detalheImovel.btnSalvar.Visible = false;

            detalheImovel.pbImovel.ImageLocation = getImovelByPathName(verImoveis.dgvImovel, verImoveis.linha);
            detalheImovel.rtxtDescricao.Text     = selectedRow.Cells[2].Value.ToString();
            detalheImovel.txtRuaAvenida.Text     = selectedRow.Cells[3].Value.ToString();
            detalheImovel.txtComplemento.Text    = selectedRow.Cells[4].Value.ToString();


            detalheImovel.cboUf.SelectedItem     = selectedRow.Cells[5].Value.ToString();
            detalheImovel.txtNumero.Text         = selectedRow.Cells[6].Value.ToString();
            detalheImovel.txtBairro.Text         = selectedRow.Cells[7].Value.ToString();
            detalheImovel.txtCidade.Text         = selectedRow.Cells[8].Value.ToString();
            detalheImovel.txtValorAluguel.Text   = selectedRow.Cells[9].Value.ToString();
            detalheImovel.cboStatus.SelectedItem = selectedRow.Cells[10].Value.ToString();

            detalheImovel.txtLocador.Text = crudLocador.getNameById(Convert.ToInt16(selectedRow.Cells[1].Value));

            detalheImovel.Visible = true;
        }
Exemple #2
0
        public void setValuesLocacao(VerImoveis verImoveis, Locacao locacao)
        {
            ds = new DataSet();
            DataSet ds1 = new DataSet();

            DataGridViewRow selectedRow = verImoveis.dgvImovel.Rows[verImoveis.linha];

            int id_Locador = Convert.ToInt16(selectedRow.Cells[1].Value);

            locacao.txtValorLocacao.Text = selectedRow.Cells[9].Value.ToString();

            int id_Imovel = Convert.ToInt16(selectedRow.Cells[0].Value);

            locacao.id_Imovel = id_Imovel;

            try
            {
                stringConexao.conn.Open();
            }
            catch (SqlException ex)
            {
                MessageBox.Show("Não foi possível se conectar ao sistema! Contate o administrador",
                                "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

            try
            {
                dataAdapter = new SqlDataAdapter("select nome from Locador where id = '" + id_Locador + "'", stringConexao.conn);
                dataAdapter.Fill(ds);
            }
            catch (SqlException ex)
            {
                MessageBox.Show("Não foi possível buscar o nome do locador da base de dados",
                                "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            try
            {
                dataAdapter = new SqlDataAdapter("select fileNameImg from Imovel where id = '" + id_Imovel + "'", stringConexao.conn);
                dataAdapter.Fill(ds1);
            }
            catch (SqlException ex)
            {
                MessageBox.Show("Não foi possível buscar a imagem do imóvel da base de dados", "Mensagem",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            stringConexao.conn.Close();

            locacao.txtLocador.Text = ds.Tables[0].Rows[0][0].ToString();

            locacao.id_Locador = id_Locador;

            locacao.path = ds1.Tables[0].Rows[0][0].ToString();

            locacao.pbLocacao.ImageLocation = locacao.path;

            locacao.Visible = true;
        }
Exemple #3
0
 public CrudImovel(VerImoveis verImoveis, home inicio)
 {
     this.verImoveis = verImoveis;
     this.inicio     = inicio;
 }
Exemple #4
0
        public void mostrar(VerImoveis imoveis)
        {
            mostrarImoveis = true;

            ds = new DataSet();


            try
            {
                stringConexao.conn.Open();
            }
            catch (SqlException ex)
            {
                MessageBox.Show("Não foi possível conectar com a base de dados", "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            if (ordImoveis == false)
            {
                if (imoveis.rbDisponiveis.Checked)
                {
                    dataAdapter = new SqlDataAdapter("select id, id_Locador, descricao, rua_avenida, " +
                                                     "complemento, uf, numero, bairro, cidade, valor_Aluguel, status_Imovel from Imovel where " +
                                                     "status_Imovel = 'Disponível'",
                                                     stringConexao.conn);
                }
                else if (imoveis.rbAlugados.Checked)
                {
                    dataAdapter = new SqlDataAdapter("select id, id_Locador, descricao, rua_avenida, " +
                                                     "complemento, uf, numero, bairro, cidade, valor_Aluguel, status_Imovel from Imovel where " +
                                                     "status_Imovel = 'Alugado'",
                                                     stringConexao.conn);
                }
            }
            else
            {
                if (imoveis.rbCidade.Checked && imoveis.rbDisponiveis.Checked)
                {
                    dataAdapter = new SqlDataAdapter("select id, id_Locador, descricao, rua_avenida, complemento, uf, numero, bairro, cidade, valor_Aluguel, status_Imovel from Imovel where " +
                                                     "id = (select id from Imovel where status_Imovel = 'Disponível') " +
                                                     "order by cidade", stringConexao.conn);
                }
                else if (imoveis.rbCidade.Checked && imoveis.rbAlugados.Checked)
                {
                    dataAdapter = new SqlDataAdapter("select id, id_Locador, descricao, rua_avenida, complemento, uf, numero, bairro, cidade, valor_Aluguel, status_Imovel from Imovel where id = " +
                                                     "(select id from Imovel where status_Imovel = 'Indisponível') " +
                                                     "order by cidade",
                                                     stringConexao.conn);
                }
                else if (imoveis.rbEstado.Checked && imoveis.rbDisponiveis.Checked)
                {
                    dataAdapter = new SqlDataAdapter("select id, id_Locador, descricao, rua_avenida, complemento, uf, numero, bairro, cidade, valor_Aluguel, status_Imovel from Imovel where " +
                                                     "id = (select id from Imovel where status_Imovel = 'Disponível') " +
                                                     "order by uf",
                                                     stringConexao.conn);
                }
                else if (imoveis.rbEstado.Checked && imoveis.rbAlugados.Checked)
                {
                    dataAdapter = new SqlDataAdapter("select id, id_Locador, descricao, rua_avenida, complemento, uf, numero, bairro, cidade, valor_Aluguel, status_Imovel from Imovel where " +
                                                     "id = (select id from Imovel where status_Imovel = 'Indisponível') " +
                                                     "order by uf",
                                                     stringConexao.conn);
                }
            }

            try
            {
                dataAdapter.Fill(ds);
                imoveis.dgvImovel.DataSource = ds.Tables[0];
            }
            catch (SqlException ex)
            {
                MessageBox.Show("Falha em ordenar imóveis", "Error", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }

            stringConexao.conn.Close();



            ordImoveis = false;
        }