Example #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();
        }
Example #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;
            }
        }
Example #3
0
        private void addBtn_Click(object sender, EventArgs e)
        {
            int subID;
            int appID;

            try
            {
                subID = Int32.Parse(this.subID.Text);
                appID = Int32.Parse(this.appID.Text);
            }
            catch (System.FormatException)
            {
                return;
            }
            string name  = this.name.Text;
            bool   cards = this.hasCards.Checked;

            if (string.IsNullOrWhiteSpace(name))
            {
                return;
            }
            Package pack = new Package(subID, appID, name, cards);

            PackagesDAO.Add(pack);

            List <Key> keys = new List <Key>();

            foreach (string key in this.keys.Lines)
            {
                if (!string.IsNullOrWhiteSpace(key))
                {
                    keys.Add(new Key(key.Trim(), subID, DateTime.Now, detailsBox.Text));
                }
            }
            KeysDAO.Add(keys);
            this.Close();
        }
Example #4
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();
        }