Example #1
0
        public ManageItems(User user)
        {
            cms = new ContextMenuStrip();
            cms.Items.Add("Edit");
            cms.Items.Add("Delete");
            cms.Items[0].Click += delegate (object sender, EventArgs e)
            {
                ListViewItem lvItem = mainData.SelectedItems[0];
                if (lvItem == null)
                    return;
                Item SelectedItem = null;
                foreach (Item it in SearchResults)
                    if (it.ID.ToString() == lvItem.SubItems[0].Text)
                        SelectedItem = it;

                if (SelectedItem == null)
                    return;

                ItemAdd ia = new ItemAdd(SelectedItem);
                ia.Show();
                ia.FormClosed += delegate (object subSender, FormClosedEventArgs ea)
                {
                    this.txtSearch_KeyDown_1(null, new KeyEventArgs(Keys.Enter));
                };
            };
            cms.Items[1].Click += delegate (object sender, EventArgs e)
            {
                ListViewItem lvItem = mainData.SelectedItems[0];
                if (lvItem == null)
                    return;
                Item SelectedItem = null;
                foreach (Item it in SearchResults)
                    if (it.ID.ToString() == lvItem.SubItems[0].Text)
                        SelectedItem = it;

                if (SelectedItem == null)
                    return;

                var result = Item.RemoveItem(SelectedItem);
                if (result == Item.ItemDatabaseError.ERR_SUCCESS)
                {
                    MessageBox.Show("Item deleted successfully!", "Notice");
                    try
                    {
                        mainData.Items.Remove(lvItem);
                        SearchResults.Remove(SelectedItem);
                    }
                    catch
                    {
                    }
                }

            };
            InitializeComponent();
        }
Example #2
0
 private void addNewF1ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     ItemAdd itemAddForm = new ItemAdd();
     itemAddForm.Show();
 }