Ejemplo n.º 1
0
        private void ExportKeys_Load(object sender, EventArgs e)
        {
            var keys = KeysDAO.ReadAll();

            foreach (Package pack in PackagesDAO.ReadAll())
            {
                if (pack.Quantity > 0)
                {
                    this.keys.Add(pack, keys.FindAll(x => x.SubId == pack.SubId));
                }
            }

            UpdateResults();
        }
Ejemplo n.º 2
0
        public void UpdateList()
        {
            bs = new List <Package>();
            foreach (Package package in PackagesDAO.ReadAll())
            {
                if (!hide.Checked || package.Quantity > 0)
                {
                    bs.Add(package);
                }
            }
            dataGridView1.DataSource = bs;

            selected = new List <CartItem>();
            bl       = new BindingList <CartItem>(selected);
            selectedGames.DataSource = bl;

            int keys = 0;

            foreach (Package item in bs)
            {
                keys += item.Quantity;
            }
            label1.Text = "Total: " + keys + " Keys - " + bs.Count + " Games";

            foreach (DataGridViewRow row in dataGridView1.SelectedRows)
            {
                if (((Package)row.DataBoundItem).Quantity == 0)
                {
                    row.Frozen = true;
                }
            }

            foreach (DataGridViewColumn column in dataGridView1.Columns)
            {
                column.SortMode = DataGridViewColumnSortMode.Automatic;
            }
        }
Ejemplo n.º 3
0
        private void removeButton_Click(object sender, EventArgs e)
        {
            List <Key> toRemove = new List <Key>();

            foreach (CheckBox cb in checkBoxes)
            {
                if (cb.Checked)
                {
                    toRemove.Add(keys.Find(x => x.KeyCode.Equals(cb.Text.Split(':').Last <string>().TrimStart())));
                }
            }

            if (keys.Count > 0)
            {
                KeysDAO.Remove(toRemove);

                List <Package> packages         = PackagesDAO.ReadAll();
                List <Package> emptyGames       = new List <Package>();
                string         emptyGamesString = "";
                foreach (var removed in toRemove)
                {
                    Package package = packages.Find(x => removed.SubId == x.SubId);
                    if (package.Quantity < 1 && !emptyGames.Contains(package))
                    {
                        emptyGames.Add(package);
                        emptyGamesString += " - " + package.AppName + "\r\n";
                    }
                }

                if (emptyGames.Count > 0)
                {
                    MessageBox.Show("The following games are out of keys now: \r\n\r\n" + emptyGamesString, "No more keys", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }

            this.Close();
        }