private void incomeCategorySelected(object sender, EventArgs e) { AddNewCategoryView addNewCategoryView = new AddNewCategoryView(); if (incomeCategoriesList.SelectedItems.Count > 0) { ListViewItem item = incomeCategoriesList.SelectedItems[0]; var id = int.Parse(item.Tag.ToString()); using (DataBase.DBContainer db = new DataBase.DBContainer()) { var Category = (from Categories in db.Categories where id == Categories.Id select Categories).FirstOrDefault(); if (Category != null) { Models.Category _category = new Models.Category(); _category.Id = Category.Id; _category.Name = Category.Name; _category.Type = Models.TransactionType.Income; addNewCategoryView.Category = _category; addNewCategoryView.isUpdating = true; addNewCategoryView.Text = "Update category"; addNewCategoryView.ShowDialog(); } } } }
private void addNewCategory(object sender, EventArgs e) { Category.AddNewCategoryView addNewCategoryView = new AddNewCategoryView(); addNewCategoryView.ShowDialog(); }