示例#1
0
        private void btnAdd_Click(object sender, System.EventArgs e)
        {
            RecipeForm addForm = new RecipeForm(_storage);

            addForm.ShowDialog();

            if (addForm.DialogResult == System.Windows.Forms.DialogResult.OK)
            {
                _storage.GetRecipe().Add(addForm.Recipe);
            }
        }
示例#2
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (mainListView.SelectedItems.Count == 0)
            {
                MessageBox.Show("Please select at least one item from the list", "Delete error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else
            {
                Recipe     recipe  = _storage.GetRecipe().ElementAt(mainListView.SelectedIndices[0]);
                RecipeForm addForm = new RecipeForm(_storage, recipe);
                addForm.ShowDialog();

                if (addForm.DialogResult == System.Windows.Forms.DialogResult.OK)
                {
                    _storage.GetRecipe().Remove(mainListView.SelectedIndices[0]);
                    _storage.GetRecipe().Add(addForm.Recipe);
                }
            }
        }
示例#3
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (mainListView.SelectedItems.Count == 0)
            {
                MessageBox.Show("Пожалуйста, выберите хотя бы один пункт из списка", "Ошибка удаления",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else
            {
                Recipe     recipe  = _storage.GetRecipe().ElementAt(mainListView.SelectedIndices[0]);
                RecipeForm addForm = new RecipeForm(_storage, recipe);
                addForm.ShowDialog();

                if (addForm.DialogResult == System.Windows.Forms.DialogResult.OK)
                {
                    _storage.GetRecipe().Remove(mainListView.SelectedIndices[0]);
                    _storage.GetRecipe().Add(addForm.Recipe);
                }
            }
        }