private void quitar(object sender, EventArgs e)
 {
     try
     {
         pagamentos_tabela quitar = new pagamentos_tabela()
         {
             id_apartamento = telaPrincipal.selecionado.id,
             tipo           = "Outro",
             valor          = Convert.ToDecimal(Convert.ToDouble(algumApartamento.saldo_devedor_cub) * telaPrincipal.valorCub),
             data           = Convert.ToDateTime(txtDataPagamento.Text),
             valor_cub      = Convert.ToDecimal(telaPrincipal.valorCub)
         };
         bd.pagamentos_tabela.Add(quitar);
         apartamentos_tabela m = bd.apartamentos_tabela.Single(a => a.id.Equals(telaPrincipal.selecionado.id));
         m.valor_pago_reais += quitar.valor;
         m.valor_pago_cub   += Convert.ToDecimal(Convert.ToDouble(quitar.valor) / telaPrincipal.valorCub);
         m.saldo_devedor_cub = 0;
         bd.SaveChanges();
         MessageBox.Show($"O aparamento foi quitado");
         carregaTabela();
         sumirTudo();
         carregaLabels(telaPrincipal.valorCub);
     }
     catch
     {
         MessageBox.Show("Erro ao tentar quitar");
         sumirTudo();
     }
 }
 private void pagarOutroValor(object sender, EventArgs e)
 {
     try
     {
         pagamentos_tabela pagaOutroValor = new pagamentos_tabela()
         {
             id_apartamento = telaPrincipal.selecionado.id,
             tipo           = "Outro",
             valor          = Convert.ToDecimal(txtValorPagamento.Text),
             data           = Convert.ToDateTime(txtDataPagamento.Text),
             valor_cub      = Convert.ToDecimal(telaPrincipal.valorCub)
         };
         bd.pagamentos_tabela.Add(pagaOutroValor);
         apartamentos_tabela m = bd.apartamentos_tabela.Single(a => a.id.Equals(telaPrincipal.selecionado.id));
         m.valor_pago_reais  += pagaOutroValor.valor;
         m.valor_pago_cub    += Convert.ToDecimal(Convert.ToDouble(pagaOutroValor.valor) / telaPrincipal.valorCub);
         m.saldo_devedor_cub -= Convert.ToDecimal(Convert.ToDouble(pagaOutroValor.valor) / telaPrincipal.valorCub);
         bd.SaveChanges();
         MessageBox.Show($"O Pagamento no valor de R${txtValorPagamento.Text} foi efetuado");
         carregaTabela();
         sumirTudo();
         carregaLabels(telaPrincipal.valorCub);
     }
     catch
     {
         MessageBox.Show("Erro ao tentar pagar");
         sumirTudo();
     }
 }
 private void pagarReforco(object sender, EventArgs e)
 {
     try
     {
         pagamentos_tabela pagaReforco = new pagamentos_tabela()
         {
             id_apartamento = telaPrincipal.selecionado.id,
             tipo           = "Reforço",
             valor          = Convert.ToDecimal(Convert.ToDouble(telaPrincipal.selecionado.valor_reforco_cub) * telaPrincipal.valorCub),
             data           = Convert.ToDateTime(txtDataPagamento.Text),
             valor_cub      = Convert.ToDecimal(telaPrincipal.valorCub)
         };
         bd.pagamentos_tabela.Add(pagaReforco);
         apartamentos_tabela m = bd.apartamentos_tabela.Single(a => a.id.Equals(telaPrincipal.selecionado.id));
         m.saldo_devedor_cub -= Convert.ToDecimal(telaPrincipal.selecionado.valor_reforco_cub);
         m.valor_pago_reais  += pagaReforco.valor;
         m.valor_pago_cub    += Convert.ToDecimal(m.valor_reforco_cub);
         bd.SaveChanges();
         MessageBox.Show("O Pagamento do reforço foi efetuado");
         carregaTabela();
         carregaLabels(telaPrincipal.valorCub);
         sumirTudo();
     }
     catch
     {
         MessageBox.Show("Erro ao pagar o reforço");
         sumirTudo();
     }
 }
 private void definirAlgumApartamento()
 {
     bd.apartamentos_tabela.ToList().ForEach(z =>
     {
         if (z.id == telaPrincipal.selecionado.id)
         {
             algumApartamento = z;
         }
     });
 }
Example #5
0
 private void salvarAluguel(object sender, EventArgs e)
 {
     try
     {
         apartamentos_tabela novo = new apartamentos_tabela()
         {
             descricao           = txtDescricao.Text,
             data_compra         = Convert.ToDateTime(txtDataCompra.Text),
             valor_em_reais      = Convert.ToDecimal(txtValorTotal.Text),
             cub_quando_comprado = Convert.ToDecimal(txtValorCubCompra.Text),
             valor_em_cub        = Convert.ToDecimal(Convert.ToDecimal(txtValorTotal.Text) / Convert.ToDecimal(txtValorCubCompra.Text)),
             valor_pago_reais    = Convert.ToDecimal(txtValorEntrada.Text),
             valor_pago_cub      = Convert.ToDecimal(Convert.ToDecimal(txtValorEntrada.Text) / Convert.ToDecimal(txtValorCubCompra.Text)),
             saldo_devedor_cub   = Convert.ToDecimal((Convert.ToDecimal(txtValorTotal.Text) - Convert.ToDecimal(txtValorEntrada.Text)) / Convert.ToDecimal(txtValorCubCompra.Text)),
             valor_parcela_cub   = Convert.ToDecimal(Convert.ToDecimal(txtValorParcelas.Text) / Convert.ToDecimal(txtValorCubCompra.Text)),
             valor_reforco_cub   = Convert.ToDecimal(Convert.ToDecimal(txtValorReforcos.Text) / Convert.ToDecimal(txtValorCubCompra.Text)),
         };
         bd.apartamentos_tabela.Add(novo);
         bd.SaveChanges();
         int idEntrada = 0;
         bd.apartamentos_tabela.ToList().ForEach(m =>
         {
             if (m.descricao.Equals(txtDescricao.Text))
             {
                 idEntrada = m.id;
             }
         });
         pagamentos_tabela pagaEntrada = new pagamentos_tabela()
         {
             id_apartamento = idEntrada,
             tipo           = "Entrada",
             valor          = Convert.ToDecimal(txtValorEntrada.Text),
             data           = Convert.ToDateTime(txtDataCompra.Text),
             valor_cub      = Convert.ToDecimal(txtValorCubCompra.Text)
         };
         bd.pagamentos_tabela.Add(pagaEntrada);
         bd.SaveChanges();
         MessageBox.Show("Aluguel salvo com sucesso");
         this.Close();
     }
     catch
     {
         MessageBox.Show("Preencha todos os campos");
     }
 }
Example #6
0
 private void informcoes(object sender, EventArgs e)
 {
     try
     {
         int idSelecionado = Convert.ToInt32(tblAlugueisTelaPrincipal.SelectedRows[0].Cells[0].Value);
         selecionado = bd.apartamentos_tabela.Where(u => u.id.Equals(idSelecionado)).FirstOrDefault();
         if (selecionado != null)
         {
             new telaInformacoes().Show();
         }
         else
         {
             MessageBox.Show("Selecione um apartamento");
         }
     }
     catch
     {
         MessageBox.Show("Selecione uma linha antes");
     }
 }
Example #7
0
 private void excluir(object sender, EventArgs e)
 {
     try
     {
         int idSelecionado = Convert.ToInt32(tblAlugueisTelaPrincipal.SelectedRows[0].Cells[0].Value);
         selecionado = bd.apartamentos_tabela.Where(u => u.id.Equals(idSelecionado)).FirstOrDefault();
         apartamentos_tabela excluirI = new apartamentos_tabela();
         bd.apartamentos_tabela.ToList().ForEach(f =>
         {
             if (f.id.Equals(idSelecionado))
             {
                 excluirI = f;
             }
         });
         bd.apartamentos_tabela.Remove(excluirI);
         pagamentos_tabela ExclirPg = new pagamentos_tabela();
         bd.pagamentos_tabela.ToList().ForEach(z =>
         {
             if (z.id_apartamento.Equals(idSelecionado))
             {
                 ExclirPg = z;
                 bd.pagamentos_tabela.Remove(ExclirPg);
             }
         });
         bd.SaveChanges();
         MessageBox.Show("Apartamento excluído");
         lblExcluir.Visible  = false;
         pbxExcluir.Visible  = false;
         btnDeletar.Visible  = false;
         btnCancelar.Visible = false;
         montarTabelaApartamentos();
     }
     catch
     {
         MessageBox.Show("Selecione uma linha antes de deletar");
         lblExcluir.Visible  = false;
         pbxExcluir.Visible  = false;
         btnDeletar.Visible  = false;
         btnCancelar.Visible = false;
     }
 }