/// <summary> /// Add new additive item /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void newAdditiveToolStripMenuItem_Click(object sender, EventArgs e) { try { frmNewItem frmKey = new frmNewItem(); if (frmKey.ShowDialog(this) == DialogResult.OK) { string key = frmKey.getKeyName.Trim(); if (MainProc.getInstance().isItemExists(key)) throw new Exception("Item '" + key + "' already exists !"); txtName.Clear(); txtStatus.Clear(); txtFunction.Clear(); txtFoundIn.Clear(); txtSideFx.Clear(); txtDetails.Clear(); MainProc.getInstance().saveItemProps(key, txtName, txtStatus, txtFunction, txtVegetarians, txtFoundIn, txtSideFx, txtDetails); MainProc.getInstance().updateListBox(lstItems); foreach (Object item in lstItems.Items) { if ((string)item == key) { lstItems.SelectedItem = item; break; } } } } catch (Exception ex) { showError("Error adding item ! (Details: " + ex.Message + " )"); } }
/// <summary> /// Add new string/text /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void newTextToolStripMenuItem_Click(object sender, EventArgs e) { try { frmNewItem frmKey = new frmNewItem(); if (frmKey.ShowDialog(this) == DialogResult.OK) { string key = frmKey.getKeyName.Trim(); if ( MainProc.getInstance().isStringExists(key) ) throw new Exception("String '" + key + "' already exists !"); txtText.Clear(); MainProc.getInstance().saveStringProps(key, txtText); MainProc.getInstance().updateListBox(lstItems); foreach (Object item in lstItems.Items) { if ((string)item == key) { lstItems.SelectedItem = item; break; } } } } catch (Exception ex) { showError("Error adding item ! (Details:" + ex.Message + ")"); } }