public static void Delete(int corpID) { EMMADataSet.PublicCorpsDataTable table = new EMMADataSet.PublicCorpsDataTable(); lock (tableAdapter) { tableAdapter.FillByID(table, corpID); } table.FindByCorpID(corpID).Delete(); tableAdapter.Update(table); }
public static PublicCorp GetCorp(string corpName) { PublicCorp retVal = null; EMMADataSet.PublicCorpsDataTable table = new EMMADataSet.PublicCorpsDataTable(); EMMADataSet.PublicCorpsRow rowData = null; lock (tableAdapter) { tableAdapter.FillByName(table, corpName); } if (table.Count == 1) { rowData = table[0]; } else { lock (tableAdapter) { tableAdapter.FillByName(table, "%" + corpName + "%"); } if (table.Count < 1) { throw new EMMADataMissingException(ExceptionSeverity.Error, "No public corp found " + "matching '" + corpName + "'", "PublicCorps", corpName); } else if (table.Count > 1) { SortedList<object, string> options = new SortedList<object, string>(); foreach (EMMADataSet.PublicCorpsRow corp in table) { options.Add(corp.CorpID, corp.CorpName); } OptionPicker picker = new OptionPicker("Select Corp (" + corpName + ")", "Choose the specific corp you want from those listed below.", options); if (picker.ShowDialog() != System.Windows.Forms.DialogResult.Cancel) { rowData = table.FindByCorpID((int)picker.SelectedItem); } } else { rowData = table[0]; } } if (rowData != null) { retVal = new PublicCorp(rowData); } return retVal; }