Example #1
0
        private void GetWeaponTypes()
        {
            ProjectStrawberryEntities ctx = new ProjectStrawberryEntities();

            weaponTypes = ctx.WeaponTypes.ToList();

            comboBoxWeaponTypes.DataSource    = weaponTypes;
            comboBoxWeaponTypes.DisplayMember = "Name";
            comboBoxWeaponTypes.ValueMember   = "Id";
        }
Example #2
0
        private void GetWeapons(int id)
        {
            var ctx = new ProjectStrawberryEntities();

            weapons = ctx.Weapons.Select(w => new WeaponModel
            {
                Id               = w.Id,
                Name             = w.Name,
                MinimumDamage    = w.MinimumDamage,
                MaximumDamage    = w.MaximumDamage,
                ReqWeaponMastery = w.ReqWeaponMastery,
                Weight           = w.Weight,
                WeaponTypeId     = w.WeaponTypeId,
                WeaponType       = w.WeaponType,
                Price            = w.Price
            }).Where(w => w.WeaponTypeId == id)
                      .OrderBy(w => w.Price).ToList();

            listBoxWeapons.DataSource = weapons;
        }
Example #3
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            if (checkBoxTournamentItem.Checked)
            {
                _tournamentItem = true;
            }
            else
            {
                _tournamentItem = false;
            }

            var weapon = new Weapon
            {
                Name             = textBoxName.Text,
                WeaponTypeId     = (int)comboBoxWeaponTypes.SelectedValue,
                MinimumDamage    = _minDmg,
                MaximumDamage    = _maxDmg,
                ReqWeaponMastery = _reqWp,
                Weight           = _weight,
                TournamentReward = _tournamentItem,
                Price            = _price,
            };

            if (!string.IsNullOrWhiteSpace(textBoxName.Text))
            {
                var ctx = new ProjectStrawberryEntities();
                ctx.Weapons.Add(weapon);
                ctx.SaveChanges();
            }

            ResetForm();

            WeaponType wt = (WeaponType)comboBoxWeaponTypes.SelectedItem;

            GetWeapons(wt.Id);
        }