Esempio n. 1
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     if (dataGridView.SelectedRows.Count == 1)
     {
         if (MessageBox.Show("Удалить запись", "Вопрос", MessageBoxButtons.YesNo,
                             MessageBoxIcon.Question) == DialogResult.Yes)
         {
             int id =
                 Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
             try
             {
                 service.DelElement(id);
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
                                 MessageBoxIcon.Error);
             }
             LoadData();
         }
     }
 }
 public ActionResult Delete(int id)
 {
     service.DelElement(id);
     return(RedirectToAction("Index"));
 }