Beispiel #1
0
        private void deleteRecipeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (lsvSearch.SelectedIndices.Count > 0)
            {
                DialogResult confirm = MessageBox.Show("Do you really want to do this?  Deletion is irreversible!", "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (confirm == DialogResult.Yes)
                {
                    //delete it!  DELETE IT AALLLLL!!!  MUAHAAHAHHAHA
                    //is filteredlist loaded with anything?
                    if (fsFilteredlist.Count > 0 && fsFilteredlist != null)
                    {
                        //something's in it, look at selectedindex of listview and delete that index's ID number
                        DataConnection.DeleteFoodstuff((fsFilteredlist[lsvSearch.SelectedIndices[0]]).ID);
                    }
                    else
                    {
                        //filteredlist is empty or null, which means master is being displayed
                        DataConnection.DeleteFoodstuff((fsMasterlist[lsvSearch.SelectedIndices[0]]).ID);
                    }
                    //then reload the foodstuffs to reflect the new listing

                    btnClear_Click(sender, e);
                }
            }
        }