Ejemplo n.º 1
0
        private void EditJewelry(Object parameter)
        {
            try
            {
                if (SelectedJewelry == string.Empty)
                {
                    MessageBox.Show("Please choose jewelry.");
                    return;
                }

                var     editedIndex   = JewelryList.FindIndex(x => x.ToString() == SelectedJewelry);
                Jewelry editedJewelry = JewelryList.Find(x => x.ToString() == SelectedJewelry);

                if (editedJewelry == null)
                {
                    MessageBox.Show($"Choose one jewerly from dropdown menu.");
                    return;
                }

                editJewelryView.InitJewelryFields(ref editedJewelry);

                JewelryList.RemoveAt(editedIndex);
                JewelryListUI.RemoveAt(editedIndex);
                JewelryList.Add(editedJewelry);
                JewelryListUI.Add(editedJewelry);

                CurrentAppScreen = (int)ApplicationScreen.EditJewelry;
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Could not edit jewerly. Reason: {ex.Message}");
            }
        }
Ejemplo n.º 2
0
        private void DeleteJewelry(object p)
        {
            if (string.IsNullOrEmpty(SelectedJewelry))
            {
                MessageBox.Show("Please choose a jewelry from the list.");
                return;
            }

            try
            {
                var removalIndex = JewelryList.FindIndex(x => x.ToString() == SelectedJewelry);
                JewelryList.RemoveAt(removalIndex);
                JewelryListUI.RemoveAt(removalIndex);
                MessageBox.Show($"Successfully removed.");
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Could not remove jewelry. Reason: {ex.Message}");
            }
        }