예제 #1
0
        private void buttonAddItem_Click(object sender, EventArgs e)
        {
            var addedItem = ItemForm.ShowAddItemDialog(this, categories, listViewCategories.SelectedIndex);

            if (addedItem == null)
            {
                return;
            }

            ShowItemList(categories.IndexOf(addedItem.Category));
            listViewCategories.SelectObject(addedItem.Category);
            needUpdate = true;
        }
예제 #2
0
        private void menuItemAdd_Click(object sender, EventArgs e)
        {
            Item item = ItemForm.ShowAddItemDialog(this, categories, 0);

            if (item != null)
            {
                if (item.Image != null && item.ImageId != null &&
                    !ImageList.Images.ContainsKey(item.ImageId))
                {
                    ImageList.Images.Add(item.ImageId, item.Image);
                }

                SetupUIAsync();
            }
        }
예제 #3
0
        public static Item ShowAddItemDialog(Form parent, List <Category> categories, int selectedCategoryIndex)
        {
            if (categories == null || categories.Count <= 0)
            {
                MessageBox.Show("Vous devez d'abord créer une catégorie",
                                "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(null);
            }

            ItemForm addItemForm = new ItemForm(categories, selectedCategoryIndex);

            addItemForm.categories = categories;
            addItemForm.ShowDialog(parent);

            return(addItemForm.DialogResult == DialogResult.OK
                    ? addItemForm.item : null);
        }
예제 #4
0
        private void contextMenuItemEdit_Click(object sender, EventArgs e)
        {
            var item             = listViewItems.SelectedObject as Item;
            int oldCategoryIndex = categories.IndexOf(item.Category);

            ItemForm editItemForm = new ItemForm(categories, oldCategoryIndex, item);

            editItemForm.ShowDialog(this);

            if (editItemForm.DialogResult != DialogResult.OK)
            {
                return;
            }

            listViewCategories.SelectObject(item.Category);
            ShowItemList(categories.IndexOf(item.Category));

            XmlManager.SaveCategories(categories);

            needUpdate = true;
        }