Exemple #1
0
        private void btnApagar_Click(object sender, EventArgs e)
        {
            int id = Convert.ToInt32(dataGridView1.CurrentRow.Cells[0].Value);

            RemedioRepositorio repositorio = new RemedioRepositorio();

            repositorio.Apagar(id);
            dataGridView1.Rows.RemoveAt(dataGridView1.CurrentCell.RowIndex);
        }
Exemple #2
0
        public void btnApagar_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count == 0)
            {
                MessageBox.Show("Selecione uma linha para apagar");
                return;
            }
            int id = Convert.ToInt32(dataGridView1.CurrentRow.Cells[0].Value);

            RemedioRepositorio repositorio = new RemedioRepositorio();

            repositorio.Apagar(id);

            dataGridView1.Rows.RemoveAt(dataGridView1.CurrentCell.RowIndex);
        }
        private void btnApagar_Click(object sender, EventArgs e)
        {
            if (dataGridView1.Rows.Count == 0)
            {
                MessageBox.Show("Não há registros para apagar.");
            }
            else
            {
                DialogResult dialogResult = MessageBox.Show("AVISO!", "DESEJA APAGAR?", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    int id = Convert.ToInt32(dataGridView1.CurrentRow.Cells[0].Value);

                    RemedioRepositorio repositorio = new RemedioRepositorio();
                    repositorio.Apagar(id);
                    dataGridView1.Rows.RemoveAt(dataGridView1.CurrentCell.RowIndex);

                    MessageBox.Show("Registro apagado com sucesso.");
                    AtualizarTabela();
                }
            }
        }