private void addButton_Click(object sender, EventArgs e) { CategoryForm categoryForm = new CategoryForm(); categoryForm.setFlag("add"); if (categoryForm.ShowDialog() == DialogResult.OK) { initListView(); } }
private void updateButton_Click(object sender, EventArgs e) { ListViewItem item = this.categoryListView.FocusedItem; if (null != item) { CategoryForm categoryForm = new CategoryForm(); Category category = new Category(item.SubItems[1].Text,float.Parse(item.SubItems[2].Text),int.Parse(item.SubItems[4].Text)); category.Id = Int32.Parse(item.SubItems[0].Text); categoryForm.setCategory(category); categoryForm.init(); categoryForm.setFlag("update"); if (categoryForm.ShowDialog() == DialogResult.OK) { initListView(); } } else { MessageBox.Show("请先选择类别!"); } }