private void BtnSalvar_Click(object sender, RoutedEventArgs e) { if (cboCorretor.SelectedValue != null || cboImovel.SelectedValue != null || cboLocatario.SelectedValue != null || txtDataVencimento.SelectedDate != null) { var Corretor = CorretorDAO.BuscarPorId((int)cboCorretor.SelectedValue); var Imovel = ImovelDAO.BuscarPorId((int)cboImovel.SelectedValue); var TipoImovel = TipoImovelDAO.BuscarPorId((int)cboImovel.SelectedValue); var Locatario = LocatarioDAO.BuscarPorId((int)cboLocatario.SelectedValue); Contrato = new Contrato() { ComissaoCorretor = (TipoImovel.Comissao * 0.01) * Imovel.ValorAluguel, DataVencimento = txtDataVencimento.SelectedDate.Value, CorretorId = Corretor.Id, ImovelId = Imovel.Id, LocatarioId = Locatario.Id, ValorAluguel = Imovel.ValorAluguel }; if (Imovel.Locado != true) { if (Imovel.ValorAluguel <= Locatario.RendaDisponivel) { if (Imovel.Cidade == Locatario.Cidade && Imovel.UF == Locatario.UF) { if (ContratoDAO.Cadastrar(Contrato)) { Imovel.Locado = true; ImovelDAO.Atualizar(Imovel); MessageBox.Show("Contrato salvo com sucesso!", "Imob", MessageBoxButton.OK, MessageBoxImage.Information); } else { MessageBox.Show("Erro interno: contate um ADM!", "Imob", MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBox.Show("Locatario não pertence a este Estado nem Cidade!", "Imob", MessageBoxButton.OK, MessageBoxImage.Information); } } else { MessageBox.Show("Valor do aluguel excede a renda disponivel!", "Imob", MessageBoxButton.OK, MessageBoxImage.Information); } } else { MessageBox.Show("Imovel já está locado!", "Imob", MessageBoxButton.OK, MessageBoxImage.Information); } } else { MessageBox.Show("Todos os campos são obrigatórios!", "Imob", MessageBoxButton.OK, MessageBoxImage.Error); } }
// GET: Imoveis public ActionResult Index() { ImovelDAO imovelDAO = new ImovelDAO(); ViewBag.imoveis = imovelDAO.ListarFullPropriety(); return(View()); }
private void btnBuscarI_Click(object sender, EventArgs e) { try { ImovelDAO iDAO = new ImovelDAO(); ProprietarioDao pDAO = new ProprietarioDao(); Imovel i = iDAO.BuscaPorId(int.Parse(textBoxIDI.Text)); // Busca o proprietario do imovel pelo idProprietario do objeto imovel i.P = pDAO.BuscarPorId(i.IdProprietario); GetDtoP(i.P); GetDtoI(i); // Passa o imovel para a venda v.I = i; v.IdImovel = v.I.Id; // Passa o proprietario do imovel para a venda v.P = i.P; v.IdProprietario = i.P.Id; } catch { MessageBox.Show("Imóvel não disponível ou não encontrado.", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } finally { textBoxIDI.Clear(); } }
private void btnSalvar_Click(object sender, EventArgs e) { try { VendaDAO vDAO = new VendaDAO(); ImovelDAO iDAO = new ImovelDAO(); if (comboBox1.Text == "Venda") { // Se vender, não pode alugar v.I.Vendido = 1; v.I.Alugado = 1; } else { // Se alugar, pode vender v.I.Alugado = 1; } // Mando atualizar o imovel no banco iDAO.Atualizar(v.I); v.Tipo = comboBox1.Text; v.DataVenda = dateTimePickerDATA.Value.ToString("ddMMyyyy"); vDAO.Salvar(v); MessageBox.Show("Venda realizada.", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch { MessageBox.Show("Erro para realizar venda. Certifique-se de preencher todos os dados.", "", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { Dispose(); } }
private void BtnExluir_Click(object sender, RoutedEventArgs e) { if (!string.IsNullOrWhiteSpace(txtArea.Text) || !string.IsNullOrWhiteSpace(txtId.Text) || !string.IsNullOrWhiteSpace(txtCidade.Text) || !string.IsNullOrWhiteSpace(txtComissao.Text) || !string.IsNullOrWhiteSpace(txtDescricao.Text) || !string.IsNullOrWhiteSpace(txtRua.Text) || !string.IsNullOrWhiteSpace(txtUF.Text) || !string.IsNullOrWhiteSpace(txtValorAluguel.Text)) { Imovel.Area = Convert.ToDouble(txtArea.Text); Imovel.Cidade = txtCidade.Text; Imovel.Endereco = txtRua.Text; Imovel.UF = txtUF.Text; Imovel.ValorAluguel = Convert.ToDouble(txtValorAluguel.Text); Imovel.TipoImovel.Comissao = Convert.ToInt32(txtComissao.Text); Imovel.TipoImovel.Descricao = txtDescricao.Text; if (ImovelDAO.Remover(Imovel)) { MessageBox.Show("Imóvel excluído com sucesso!", "Imob", MessageBoxButton.OK, MessageBoxImage.Information); LimparFormulario(); } else { MessageBox.Show("Erro interno: tente novamente ou contate um ADM!", "Imob", MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBox.Show("Todos os campos são obrigatórios", "Imob", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void BtnBuscaNome_Click(object sender, RoutedEventArgs e) { Imovel = ImovelDAO.BuscarPorId(Convert.ToInt32(txtId.Text)); if (txtId.Text != null) { if (ImovelDAO.BuscarPorId(Convert.ToInt32(txtId.Text)) != null) { Imovel = ImovelDAO.BuscarPorId(Convert.ToInt32(txtId.Text)); var tipoImovel = TipoImovelDAO.BuscarPorId(Convert.ToInt32(txtId.Text)); txtArea.Text = Imovel.Area.ToString(); txtCidade.Text = Imovel.Cidade; txtRua.Text = Imovel.Endereco; txtUF.Text = Imovel.UF; txtValorAluguel.Text = Imovel.ValorAluguel.ToString(); txtId.IsEnabled = false; txtDescricao.Text = tipoImovel.Descricao; txtComissao.Text = tipoImovel.Comissao.ToString(); } else { MessageBox.Show("ID Inválido não existe", "Imob", MessageBoxButton.OK, MessageBoxImage.Warning); } } else { MessageBox.Show("Id está Vazio", "Imob", MessageBoxButton.OK, MessageBoxImage.Warning); } }
public ContratoController(ContratoDAO contratoDAO, ImovelDAO imovelDAO, LocatarioDAO locatarioDAO, CorretorDAO corretorDAO, IWebHostEnvironment hosting) { _contratoDAO = contratoDAO; _imovelDAO = imovelDAO; _locatarioDAO = locatarioDAO; _corretorDAO = corretorDAO; _geradorDePDF = new GeradorDePDFUtils(hosting); }
public void Fill(string s) { ImovelDAO iDAO = new ImovelDAO(); List <Imovel> lista = iDAO.Buscar(s); dgvImovel.Rows.Clear(); foreach (Imovel i in lista) { dgvImovel.Rows.Add(i.Id, i.Bairro, i.Metragem, i.Valor); } }
private void GetDTO(Venda v) { ClienteDAO cDAO = new ClienteDAO(); ProprietarioDao pDAO = new ProprietarioDao(); ImovelDAO iDAO = new ImovelDAO(); FuncionarioDAO fDAO = new FuncionarioDAO(); // Venda textBoxIDVenda.Text = v.Id.ToString(); txtBoxTipo.Text = v.Tipo; mtbData.Text = v.DataVenda; // Proprietario Proprietario p = pDAO.BuscarPorId(v.IdProprietario); textBoxIDP.Text = p.Id.ToString(); textBoxNomeP.Text = p.Nome; maskedTextBoxCpfP.Text = p.Cpf; textBoxRgP.Text = p.Rg; textBoxEmailP.Text = p.Email; textBoxRuaP.Text = p.Rua; textBoxBairroP.Text = p.Bairro; textBoxCidadeP.Text = p.Cidade; textBoxNumeroP.Text = p.Numero.ToString(); maskedTextBoxTelefoneP.Text = p.Telefone; // Cliente Cliente c = cDAO.BuscarPorId(v.IdCliente); textBoxIDC.Text = c.Id.ToString(); textBoxNomeC.Text = c.Nome; maskedTextBoxTelefoneC.Text = c.Telefone; maskedTextBoxCpfC.Text = c.Cpf; textBoxEmailC.Text = c.Email; textBoxRgC.Text = c.Rg; // Imóvel Imovel i = iDAO.BuscaTodosPorId(v.IdImovel); textBoxIDI.Text = i.Id.ToString(); maskedTextBoxCpfPImovel.Text = p.Cpf; textBoxCategoria.Text = i.Categoria; textBoxTipo.Text = i.Tipo; textBoxValorI.Text = i.Valor.ToString(); textBoxRuaI.Text = i.Rua; textBoxNumeroI.Text = i.Numero.ToString(); textBoxBairroI.Text = i.Bairro; textBoxMetragemI.Text = i.Metragem.ToString(); textBoxFrente.Text = i.Frente.ToString(); textBoxFundo.Text = i.Fundo.ToString(); // Funcionario Funcionario f = fDAO.BuscarPorId(v.IdFuncionario); textBoxID.Text = f.Id.ToString(); textBoxNomeF.Text = f.Nome; textBoxCreci.Text = f.Creci; }
// FALTA FAZER OS CAMPOS OBRIGATORIOS private void btnAlterar_Click(object sender, EventArgs e) { ImovelDAO iDAO = new ImovelDAO(); iDAO.Atualizar(SetDTO()); if (MessageBox.Show("Cadastro atualizado!", "", MessageBoxButtons.OK, MessageBoxIcon.Information) == DialogResult.OK) { this.Dispose(); } }
public void InsertImovel(ImoveisVO vo) { try { ImovelDAO dataAcess = new ImovelDAO(); dataAcess.InsertImovel(vo); } catch (Exception ex) { throw new Exception(ex.Message); } }
// FALTA VALIDAR OS CAMPOS OBRIGATORIOS // METROS DE FUNDO E FRENTE NÃO SÃO OBRIGATORIOS private void btnSalvar_Click(object sender, EventArgs e) { try { Imovel i = new Imovel(); ImovelDAO iDAO = new ImovelDAO(); ProprietarioDao pDAO = new ProprietarioDao(); List <Proprietario> lista = new List <Proprietario>(); // buscando proprietario lista = pDAO.Buscar(maskedTextBoxCpf.Text); foreach (Proprietario p in lista) { i.P = p; } // criando DTO i.Tipo = comboBoxTipo.Text; i.Categoria = comboBoxCategoria.Text; i.Metragem = float.Parse(textBoxMetragem.Text); i.Frente = float.Parse(textBoxFrente.Text); // Se estiverem vazios, salva com o valor 0 i.Frente = 0; if (textBoxFrente.Text != "") { i.Frente = float.Parse(textBoxFrente.Text); } i.Fundo = 0; if (textBoxFundo.Text != "") { i.Fundo = float.Parse(textBoxFundo.Text); } i.Valor = float.Parse(textBoxValor.Text); i.Bairro = textBoxBairro.Text; i.Cidade = textBoxCidade.Text; i.Rua = textBoxRua.Text; i.Numero = int.Parse(textBoxNumero.Text); i.Vendido = 0; i.Alugado = 0; i.IdProprietario = i.P.Id; // Salvando iDAO.Salvar(i); } catch { MessageBox.Show("Erro ao cadastrar imóvel.", "", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { LimpaCampos(); } }
private void btnDeletar_Click(object sender, EventArgs e) { if (MessageBox.Show("Deseja realmente EXCLUIR o imovel? ", "", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK) { ImovelDAO iDAO = new ImovelDAO(); iDAO.Excluir(int.Parse(textBoxID.Text)); this.Dispose(); } else { this.Dispose(); } }
public ActionResult Form(int id) { var imovel = new ImovelDAO().BuscarPorId(id); ViewBag.imovel = new ImovelDAO().GetFullPropriety(imovel); ViewBag.valor = new ValorVendaDAO().BuscarPorId(imovel.ValorID); ViewBag.tipoNegocio = new ImovelDAO().ListaTipoNegocio(); ViewBag.tipoDeImovel = new ImovelDAO().ListaTipoImovel(); ViewBag.finalidade = new ImovelDAO().ListaFinalidadeNegocio(); ViewBag.enderecos = new EnderecoDAO().ListarFullProperties(); ViewBag.Pessoa = new PessoaDAO().ListaPorFuncao(ETipoPessoa.Cliente); return(View()); }
private void Window_Loaded(object sender, RoutedEventArgs e) { //Carregar os dados de Locatario cboLocatario.ItemsSource = LocatarioDAO.Listar(); cboLocatario.DisplayMemberPath = "Nome"; cboLocatario.SelectedValuePath = "Id"; //Carregar os dados de vendedores cboCorretor.ItemsSource = CorretorDAO.Listar(); cboCorretor.DisplayMemberPath = "Nome"; cboCorretor.SelectedValuePath = "Id"; //Carregar os dados de produtos cboImovel.ItemsSource = ImovelDAO.Listar(); cboImovel.DisplayMemberPath = "Endereco"; cboImovel.SelectedValuePath = "Id"; }
private List <PizzaFuncionarioInfo> ListaRendimentoFuncionarios() { var atendimentos = new AtendimentoDAO().ListaPorData(1); var imoveis = new ImovelDAO().ListarImoveisDeAtendimento(); var funcionarios = new PessoaDAO().ListaPorFuncao(ETipoPessoa.Funcionario); var lista = new List <PizzaFuncionarioInfo>(); double valorTotal = 0; foreach (var imovel in imoveis) { if (imovel.TipoNegocio == ETipoNegocio.Locação) { valorTotal += imovel.Valor.Comissao * 12.0; } else { valorTotal += imovel.Valor.Comissao; } } foreach (var funcionario in funcionarios) { double valorFuncionario = 0; foreach (var imovel in imoveis) { if (imovel.Atendimento.FuncionarioID == funcionario.ID) { if (imovel.TipoNegocio == ETipoNegocio.Locação) { valorFuncionario += imovel.Valor.Comissao * 12.0; } else { valorFuncionario += imovel.Valor.Comissao; } } } var percentual = (valorFuncionario * 100) / valorTotal; lista.Add(new PizzaFuncionarioInfo(funcionario.Nome, percentual)); } return(lista); }
private void PopularDataGridInicial() { var listaImoveis = ImovelDAO.Listar(); foreach (var imovel in listaImoveis) { itens.Add(new Imovel() { Id = imovel.Id, Area = imovel.Area, Cidade = imovel.Cidade, Endereco = imovel.Endereco, ValorAluguel = imovel.ValorAluguel, Locado = imovel.Locado, TipoImovel = imovel.TipoImovel, UF = imovel.UF }); } }
private void btnAlterarDeletar_Click(object sender, EventArgs e) { if (dgvImovel.CurrentRow != null) { int key = int.Parse(dgvImovel.CurrentRow.Cells[0].Value.ToString()); ImovelDAO iDAO = new ImovelDAO(); ProprietarioDao pDAO = new ProprietarioDao(); Proprietario p = new Proprietario(); Imovel i = iDAO.BuscaPorId(key); i.P = pDAO.BuscarPorId(i.IdProprietario); VisualizarImovelV v = new VisualizarImovelV(i); v.ShowDialog(); } else { MessageBox.Show("Selecione uma linha para vizualizar.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } Fill(""); }
private void BtnSalvar_Click(object sender, RoutedEventArgs e) { if (!string.IsNullOrWhiteSpace(txtArea.Text) || !string.IsNullOrWhiteSpace(txtCEP.Text) || !string.IsNullOrWhiteSpace(txtCidade.Text) || !string.IsNullOrWhiteSpace(txtComissao.Text) || !string.IsNullOrWhiteSpace(txtDescricao.Text) || !string.IsNullOrWhiteSpace(txtRua.Text) || !string.IsNullOrWhiteSpace(txtUF.Text) || !string.IsNullOrWhiteSpace(txtValorAluguel.Text)) { Imovel = new Imovel() { Area = Convert.ToDouble(txtArea.Text), Cidade = txtCidade.Text, Endereco = txtRua.Text, Locado = false, UF = txtUF.Text, ValorAluguel = Convert.ToDouble(txtValorAluguel.Text), TipoImovel = new TipoImovel() { Comissao = Convert.ToInt32(txtComissao.Text), Descricao = txtDescricao.Text } }; if (ImovelDAO.Cadastrar(Imovel)) { MessageBox.Show("Imóvel salvo com sucesso!", "Imob", MessageBoxButton.OK, MessageBoxImage.Information); LimparFormulario(); } else { MessageBox.Show("Erro interno: contate um ADM!", "Imob", MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBox.Show("Todos os campos são obrigatórios", "Imob", MessageBoxButton.OK, MessageBoxImage.Error); } }
public void BuscarComFiltro() { if (Convert.ToBoolean(filtroDisponivel.IsChecked)) { itens.Clear(); itens = ImovelDAO.ListarPorFiltro("disponivel"); dtaImovel.ItemsSource = itens; dtaImovel.Items.Refresh(); } else if (Convert.ToBoolean(filtroAlugado.IsChecked)) { itens.Clear(); itens = ImovelDAO.ListarPorFiltro("alugado"); dtaImovel.ItemsSource = itens; dtaImovel.Items.Refresh(); } else { itens.Clear(); PopularDataGridInicial(); dtaImovel.Items.Refresh(); } }
public ImovelController(ImovelDAO imovelDAO, TipoImovelDAO tipoImovelDAO, IWebHostEnvironment hosting) { _imovelDAO = imovelDAO; _hosting = hosting; _tipoImovelDAO = tipoImovelDAO; }
public bool ExistImovel(long codImovel) { ImovelDAO dao = new ImovelDAO(); return(dao.ExistImovel(codImovel)); }
public ImovelBLL() { _dao = new ImovelDAO(); }