예제 #1
0
        private void BtnSalvar_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.Locado               = false;
                Imovel.UF                   = txtUF.Text;
                Imovel.ValorAluguel         = Convert.ToDouble(txtValorAluguel.Text);
                Imovel.TipoImovel.Comissao  = Imovel.TipoImovel.Comissao;
                Imovel.TipoImovel.Descricao = Imovel.TipoImovel.Descricao;

                if (ImovelDAO.Atualizar(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);
            }
        }
예제 #2
0
 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();
     }
 }
예제 #3
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);
     }
 }
예제 #4
0
        // 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();
            }
        }