/// <summary> /// Get the specified item. /// </summary> /// <param name="itemID"></param> /// <returns></returns> /// <exception cref="EMMADataMissingException"></exception> public static EveDataSet.invTypesRow GetItem(int itemID) { EveDataSet.invTypesDataTable table = new EveDataSet.invTypesDataTable(); table = GetItems(itemID.ToString()); EveDataSet.invTypesRow data = table.FindBytypeID(itemID); return data; }
public EveDataSet.invTypesDataTable GetAllItems() { EveDataSet.invTypesDataTable retVal = new EveDataSet.invTypesDataTable(); foreach (EMMADataSet.TradedItemsRow item in table) { EveDataSet.invTypesRow existing = retVal.FindBytypeID((short)item.ItemID); if (existing == null) { retVal.ImportRow(Items.GetItem(item.ItemID)); } } return retVal; }
/// <summary> /// Add a new item to the items table with the specified ID and name. /// </summary> /// <param name="itemID"></param> /// <param name="itemName"></param> public static void AddItem(int itemID, string itemName) { try { // First make sure this item is not already in the database. lock (tableAdapter) { EveDataSet.invTypesDataTable items = new EveDataSet.invTypesDataTable(); items = GetItems(itemID.ToString()); EveDataSet.invTypesRow data = items.FindBytypeID(itemID); if (data == null) { EveDataSet.invTypesRow newRow = items.NewinvTypesRow(); newRow.typeID = itemID; newRow.typeName = itemName; /// Just adding a placeholder row until an offical datadump arrives. /// Can't expect the user to enter other details so just leave other rows /// to default value (i.e. null)... items.AddinvTypesRow(newRow); tableAdapter.Update(items); } else { /*throw new EMMADataException(ExceptionSeverity.Error, "Item with ID " + itemID + " already exists in database.");*/ } } } catch (Exception ex) { throw new EMMADataException(ExceptionSeverity.Error, "Problem adding item to database.", ex); } }
/// <summary> /// Get the specified item. itemName can be the whole name or just part of a name. /// </summary> /// <param name="itemName"></param> /// <returns></returns> public static EveDataSet.invTypesRow GetItem(string itemName) { EveDataSet.invTypesDataTable table = new EveDataSet.invTypesDataTable(); EveDataSet.invTypesRow retVal = null; lock (tableAdapter) { tableAdapter.FillByName(table, itemName); } if (table.Count == 1) { retVal = table[0]; } else { lock (tableAdapter) { tableAdapter.FillByName(table, "%" + itemName + "%"); } if (table.Count < 1) { throw new EMMADataException(ExceptionSeverity.Error, "No item found matching '" + itemName + "'"); } else if (table.Count > 1) { SortedList<object, string> options = new SortedList<object, string>(); foreach (EveDataSet.invTypesRow item in table) { options.Add(item.typeID, item.typeName); } OptionPicker picker = new OptionPicker("Select Item", "Choose the specific item you want from " + "those listed below.", options); if (picker.ShowDialog() != System.Windows.Forms.DialogResult.Cancel) { retVal = table.FindBytypeID((int)picker.SelectedItem); } } else { retVal = table[0]; } } return retVal; }