Esempio n. 1
0
 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);
     }
 }
Esempio n. 2
0
 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);
     }
 }
Esempio n. 3
0
 public ImovelController(ImovelDAO imovelDAO, TipoImovelDAO tipoImovelDAO, IWebHostEnvironment hosting)
 {
     _imovelDAO = imovelDAO;
     _hosting = hosting;
     _tipoImovelDAO = tipoImovelDAO;
 }