private void GetAllFirearms()
        {
            List <Firearms> firearms = FirearmDB.GetFirearms();

            lstFirearms.DataSource    = firearms;
            lstFirearms.DisplayMember = nameof(Firearms.Manufacturer);
        }
        private void btnUpdateFirearm_Click(object sender, EventArgs e)
        {
            Firearms gun = new Firearms();

            try
            {
                //Keep the ID of the gun the same because we are UPDATING
                gun.FirearmID = existingFirearm.FirearmID;
                FirearmDB.UpdateFirearm(gun);
                MessageBox.Show("Firearm has been updated!");
                Close();
            }
            catch (SqlException ex)
            {
                MessageBox.Show("There was an issue contacting the Database, please try agian");
                MessageBox.Show(ex.Message);
                MessageBox.Show(ex.GetType().ToString());
            }
        }
Esempio n. 3
0
        private void btnAddFirearm_Click(object sender, EventArgs e)
        {
            Firearms f = new Firearms()
            {
                SerialNumber = txtSerialNumber.Text,
                Manufacturer = txtManufacturer.Text,
                ModelName    = txtModel.Text,
                Caliber      = txtCaliper.Text,
                Price        = Convert.ToDecimal(txtPrice.Text)
            };

            try
            {
                FirearmDB.AddFirearm(f);
                MessageBox.Show("Firearm was added!");
                Close();
            }
            catch (SqlException)
            {
                MessageBox.Show("Database Error", "There was an issue when trying to add to the DB");
            }
        }