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