示例#1
0
        private void BtnAdd_Click(object sender, EventArgs e)
        {
            // Add Lootbox into database
            LootboxClass lb = new LootboxClass()
            {
                Theme       = txtTheme.Text,
                Name        = txtName.Text,
                Contents    = txtContents.Text,
                Description = txtDescription.Text,
                Price       = Convert.ToDouble(txtPrice.Text)
            };

            try
            {
                if (existingLootbox != null)
                {
                    lb.LootboxID = existingLootbox.LootboxID;
                    LootboxDB.Update(lb);
                    MessageBox.Show("Lootbox Updated!");
                }
                else
                {
                    LootboxDB.Add(lb);
                    MessageBox.Show("Lootbox added!");
                }
                Close();
            }
            catch (SqlException)
            {
                MessageBox.Show("Error, Try Again.");
            }
        }
示例#2
0
        private void BtnDeleteBox_Click(object sender, EventArgs e)
        {
            //List<LootboxClass> boxs = LootboxDB.GetAllLootboxes();
            LootboxClass box = lstLootBox.SelectedItem as LootboxClass;

            LootboxDB.Delete(box);
            PopulateForm();
        }
示例#3
0
        private void Populate_lstLootBox()
        {
            List <LootboxClass> boxes = LootboxDB.GetAllLootboxes();

            boxes = boxes.OrderBy(box => box.Name).ToList();
            lstLootBox.DataSource    = boxes;
            lstLootBox.DisplayMember = nameof(LootboxClass.Name);
        }
示例#4
0
        private void PopulateLootboxListbox()
        {
            List <LootboxClass> lootboxes = LootboxDB.GetAllLootboxes();

            lootboxes = lootboxes.OrderBy(lb => lb.Name).ToList();

            foreach (LootboxClass ltbx in lootboxes)
            {
                lstLootBox.Items.Add(ltbx).ToString();
            }
        }