private void addToolStripMenuItem2_Click(object sender, EventArgs e) { var form = new ItemForm(); if (form.ShowDialog() == DialogResult.OK) { db.Items.Add(form.Item); db.SaveChanges(); } }
private void button2_Click(object sender, EventArgs e) { var id = dataGridView1.SelectedRows[0].Cells[0].Value; if (typeof(T) == typeof(Item)) { var item = set.Find(id) as Item; if (item != null) { var form = new ItemForm(item); if (form.ShowDialog() == DialogResult.OK) { item = form.Item; db.SaveChanges(); dataGridView1.Update(); } } } else if (typeof(T) == typeof(Player)) { var player = set.Find(id) as Player; if (player != null) { var form = new PlayerForm(player); if (form.ShowDialog() == DialogResult.OK) { player = form.Player; db.SaveChanges(); dataGridView1.Update(); } } } else if (typeof(T) == typeof(Character)) { var character = set.Find(id) as Character; if (character != null) { var form = new CharacterForm(character); if (form.ShowDialog() == DialogResult.OK) { character = form.Character; db.SaveChanges(); dataGridView1.Update(); } } } }