public void AtualizarGrid() { dgvTransf.AutoGenerateColumns = false; using (var bo = new TranferenciaBO()) { bsTransferencias.DataSource = bo.List(); } }
private void dgvTransf_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { try { using (var bo = new TranferenciaBO()) { var id = dgvTransf.Rows[e.RowIndex].Cells["Id"].Value.ToString().ToInt(); var transferencia = bo.Get(id); var form = new TransferenciaForm(this, transferencia); form.Show(); } } catch (Exception) { throw; } }
private void menuSalvar_Click(object sender, EventArgs e) { try { using (var bo = new TranferenciaBO()) { bo.Save(_transferencia); } MessageBox.Show("Salvo com sucesso!", "Sucesso", MessageBoxButtons.OK, MessageBoxIcon.Information); _lista.AtualizarGrid(); Hide(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void menuRemover_Click(object sender, EventArgs e) { try { var id = idTextBox.Text.ToInt(); var result = MessageBox.Show($"Tem certeza que deseja remover a transferência nº{idTextBox.Text}?", "Atenção", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { using (var bo = new TranferenciaBO()) { bo.Remove(id); } _lista.AtualizarGrid(); Hide(); } } catch (Exception) { throw; } }