コード例 #1
0
        //Busca pelo id selecionado quando der um double click na tabela
        private void BuscaId()
        {
            ContaPagarRepository repository = new ContaPagarRepository();
            int id = Convert.ToInt32(dataGridView1.CurrentRow.Cells[0].Value);

            ContaPagar conta = repository.ObterConta(id);

            if (conta.Id != 0)
            {
                idAlterar             = conta.Id;
                txtNome.Text          = conta.Nome;
                mtxtValorConta.Text   = conta.Valor.ToString();
                dateTimePicker1.Value = conta.Data_Vencimento;
                txtTipo.Text          = conta.Tipo;
                checkPaga.Checked     = conta.Fechada;

                btnAdicionar.Enabled  = false;
                btnExcluir.Enabled    = false;
                btnAlterar.Enabled    = true;
                dataGridView1.Enabled = false;
            }
            else
            {
                MessageBox.Show("Não foi possivel buscar o registro", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }