Пример #1
0
        private void addToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var form = new PlayerForm();

            if (form.ShowDialog() == DialogResult.OK)
            {
                db.Players.Add(form.Player);
                db.SaveChanges();
            }
        }
Пример #2
0
        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();
                    }
                }
            }
        }