コード例 #1
0
ファイル: MainForm.cs プロジェクト: Borowik1/Dot_net_lessons
 private void DeleteAward()
 {
     if (listOfAwards != null && listOfAwards.GetList().Count() > 0)
     {
         int   id           = (int)ctrGridAward.Rows[ctrGridAward.SelectedCells[0].RowIndex].Cells[2].Value;
         Award deletedAward = new Award();
         foreach (Award aw in listOfAwards.GetList())
         {
             if (aw.AwardId == id)
             {
                 deletedAward = aw;
             }
         }
         var form = new ConfirmForm(deletedAward);
         if (form.ShowDialog() == DialogResult.OK)
         {
             foreach (User user in listOfUsers.GetList())
             {
                 user.Awards.Remove(deletedAward);
             }
             listOfAwards.Remove(deletedAward);
             DisplayAwards();
             DisplayUsers();
         }
     }
 }
コード例 #2
0
 public ActionResult Delete(int id, FormCollection collection)
 {
     try
     {
         listOfAwards.Remove(id);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
コード例 #3
0
ファイル: MainForm.cs プロジェクト: Borowik1/Dot_net_lessons
 private void DeleteAward()
 {
     if (listOfAwards != null & listOfAwards.GetList().Count() > 0)
     {
         var form = new ConfirmForm((Award)ctrGridAward.SelectedCells[0].OwningRow.DataBoundItem);
         if (form.ShowDialog() == DialogResult.OK)
         {
             var deletedAward = (Award)ctrGridAward.SelectedCells[0].OwningRow.DataBoundItem;
             foreach (User user in listOfUsers.GetList())
             {
                 user.Awards.Remove(deletedAward);
             }
             listOfAwards.Remove(deletedAward);
             DisplayAwards();
             DisplayUsers();
         }
     }
 }