Exemple #1
0
        private void rwSubmitButton_Click(object sender, EventArgs e)
        {
            using (var ctx = new Shadowrun3Context())
            {
                RangedWeapon rw = new RangedWeapon();

                rw.RangedWeaponId = nameTB.Text;
                rw = SetVar(rw);

                Skill newSkill = ctx.Skills.FirstOrDefault(i => i.SkillId == skillString);
                rw.skill = newSkill;

                try
                {
                    ctx.RangedWeapons.Add(rw);
                    ctx.SaveChanges();

                    ResetForm();
                }
                catch
                {
                    MessageBox.Show("That weapon already exists");
                }
            }
        }
Exemple #2
0
 private RangedWeapon SetVar(RangedWeapon rw)
 {
     rw.DamageAmount = (int)damAmtNB.Value;
     rw.TypeOfDamage = damTypeCB.Text;
     rw.ModeOfFire   = modeOfFireCB.Text;
     rw.AmmoType     = ammoTypeTB.Text;
     rw.AP           = (int)apNB.Value;
     return(rw);
 }
Exemple #3
0
        private void remRangedButton_Click(object sender, EventArgs e)
        {
            string rwString = rwLB.SelectedItem.ToString();

            using (var ctx = new Shadowrun3Context())
            {
                RangedWeapon remRW     = ctx.RangedWeapons.FirstOrDefault(i => i.RangedWeaponId == rwString);
                EnemyType    updatedET = ctx.EnemyTypes.First(a => a.EnemyTypeId == nameTB.Text);
                updatedET.RangedWeapons.Remove(remRW);

                ctx.SaveChanges();

                ResetForm();
            }
        }
Exemple #4
0
        private void updateButton_Click(object sender, EventArgs e)
        {
            using (var ctx = new Shadowrun3Context())
            {
                RangedWeapon rw = ctx.RangedWeapons.First(a => a.RangedWeaponId == nameTB.Text);
                rw = SetVar(rw);

                Skill newSkill = ctx.Skills.FirstOrDefault(i => i.SkillId == skillString);
                rw.skill = newSkill;

                ctx.SaveChanges();

                ResetForm();
            }
        }