예제 #1
0
        private void btnBuscarLocatario_Click(object sender, EventArgs e)
        {
            var cpf = txtBuscarCpfLocatario.Text;

            _locatarioEncontrado = _locatarioDao.BuscarLocatarioPeloCpf(cpf);

            _imovelEncontrado = _imovelDao.BuscarImovelPorId(idSelecionado);
            string editarImovelBairro       = _imovelEncontrado.bairro;
            string editarImovelRua          = _imovelEncontrado.rua;
            string editarImovelNum          = _imovelEncontrado.numero.ToString();
            string editarImovelRef          = _imovelEncontrado.pontoReferencia;
            string editarImovelObs          = _imovelEncontrado.observacoes;
            string editarImovelProprietario = _imovelEncontrado.nomeProprietario.ToString();
            bool   editarImovelTipo         = _imovelEncontrado.tipo;
            string editarImovelValor        = _imovelEncontrado.valor.ToString();

            Imovel imovel = new Imovel()
            {
                id              = idSelecionado,
                bairro          = editarImovelBairro,
                rua             = editarImovelRua,
                numero          = int.Parse(editarImovelNum),
                pontoReferencia = editarImovelRef,
                observacoes     = editarImovelObs,
                id_proprietario = _imovelEncontrado.id_proprietario,
                valor           = float.Parse(editarImovelValor),
                situacao        = '1',
                id_locatario    = _locatarioEncontrado.id,
                tipo            = editarImovelTipo,
            };

            _imovelDao.Editar(imovel);
            MessageBox.Show("Imóvel Locado com sucesso!");
            this.Close();
        }
예제 #2
0
        public void Teste_Deve_Editar_Qualquer_Campo_do_Imovel()
        {
            //CENÁRIO
            int    idImovelEditado = 1;
            string bairroEditado   = "Teste EDITADO";
            Imovel imovelEditado   = _imovelDao.BuscarImovelPorId(idImovelEditado);

            //AÇÃO
            imovelEditado.bairro = bairroEditado;
            _imovelDao.Editar(imovelEditado);

            Imovel imovelBuscado = _imovelDao.BuscarImovelPorId(idImovelEditado);

            Assert.AreEqual(bairroEditado, imovelBuscado.bairro);
        }
예제 #3
0
        private void editarImovelAlterar_Click(object sender, EventArgs e)
        {
            if (editarImovelSituacao.Text == "Locar")
            {
                situacaoAux = '0';
            }
            else if (editarImovelSituacao.Text == "Locado")
            {
                situacaoAux = '1';
            }
            else if (editarImovelSituacao.Text == "Vender")
            {
                situacaoAux = '2';
            }
            else if (editarImovelSituacao.Text == "Vendido")
            {
                situacaoAux = '3';
            }

            // -------------------------------------------------

            if (string.IsNullOrEmpty(editarImovelBairro.Text))
            {
                MessageBox.Show("Bairro precisa ser preenchido!");
            }
            else
            {
                if (string.IsNullOrEmpty(editarImovelRua.Text))
                {
                    MessageBox.Show("Rua precisa ser preenchida!");
                }
                else
                {
                    if (string.IsNullOrEmpty(editarImovelNum.Text))
                    {
                        MessageBox.Show("Numero precisa ser preenchido!");
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(editarImovelTipo.Text))
                        {
                            MessageBox.Show("Tipo precisa ser selecionado!");
                        }
                        else
                        {
                            if (string.IsNullOrEmpty(editarImovelValor.Text))
                            {
                                MessageBox.Show("Valor precisa ser preenchido!");
                            }
                            else
                            {
                                if (string.IsNullOrEmpty(editarImovelSituacao.Text))
                                {
                                    MessageBox.Show("Situação precisa ser selecionado!");
                                }
                                else
                                {
                                    Imovel imovel = new Imovel()
                                    {
                                        id              = idSelecionado,
                                        bairro          = editarImovelBairro.Text,
                                        rua             = editarImovelRua.Text,
                                        numero          = int.Parse(editarImovelNum.Text),
                                        pontoReferencia = editarImovelRef.Text,
                                        observacoes     = editarImovelObs.Text,
                                        id_proprietario = _imovelEncontrado.id_proprietario,
                                        valor           = float.Parse(editarImovelValor.Text),
                                        situacao        = situacaoAux,
                                        id_locatario    = 1,
                                        tipo            = editarImovelTipo.Text == "Locação" ? false : true
                                    };
                                    _imovelDao.Editar(imovel);
                                    MessageBox.Show("Imóvel alterado com sucesso!");
                                    this.Close();
                                }
                            }
                        }
                    }
                }
            }
        }