Ejemplo n.º 1
0
 private void DeleteActivity_Button_Click(object sender, EventArgs e)
 {
     if (Activities_DataGridView.CurrentRow == null)
     {
         Alert.DisplayError("No item selected!");
         return;
     }
     try
     {
         Activity activity = new Activity();
         activity.id_activity = (int)Activities_DataGridView.CurrentRow.Cells[0].Value;
         activity             = ManagerService.GetActivities(activity).SingleOrDefault();
         ManagerService.DeleteActivity(activity);
         int             index           = Activities_DataGridView.CurrentRow.Index;
         CurrencyManager currencyManager = (CurrencyManager)BindingContext[Activities_DataGridView.DataSource];
         currencyManager.SuspendBinding();
         Activities_DataGridView.Rows[index].Visible = false;
         currencyManager.ResumeBinding();
     }
     catch (ServiceException exc)
     {
         Alert.DisplayError(exc.Message);
     }
 }