Esempio n. 1
0
 private void promptToDelete()
 {
     if (lvFieldMappings.SelectedItems.Count > 0)
     {
         if (DialogResult.Yes == MessageBox.Show(this, getDisplayMember("promptToDelete{start_body}", "Are you sure you want to delete field(s)?"),
                                                 getDisplayMember("promptToDelete{start_title}", "Delete field(s)?"), MessageBoxButtons.YesNo, MessageBoxIcon.Question))
         {
             var total = 0;
             try {
                 foreach (ListViewItem lvi in lvFieldMappings.SelectedItems)
                 {
                     try {
                         AdminProxy.DeleteTableFieldMapping(Toolkit.ToInt32(lvi.Tag, -1), false);
                         total++;
                     } catch (Exception ex) {
                         if (ex.Message.Contains("Cannot delete field mapping"))
                         {
                             if (DialogResult.Yes == MessageBox.Show(this, getDisplayMember("delete{references_body}", "{0}\r\n\r\nDo you want to remove the reference(s) and continue deleting {1}?", ex.Message, lvi.Text),
                                                                     getDisplayMember("delete{references_title}", "Remove References and Continue Delete?"), MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                             {
                                 AdminProxy.DeleteTableFieldMapping(Toolkit.ToInt32(lvi.Tag, -1), true);
                                 total++;
                             }
                             else
                             {
                                 // nothing to do
                             }
                         }
                         else
                         {
                             throw;
                         }
                     }
                 }
                 MainFormUpdateStatus(getDisplayMember("promptToDelete{deleted}", "Deleted {0} fields.", lvFieldMappings.SelectedItems.Count.ToString("###,##0")), true);
                 RefreshData();
             } catch (Exception ex) {
                 MessageBox.Show(this, ex.Message, getDisplayMember("promptToDelete{failed_title}", "Error Deleting Field"), MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
 }