Esempio n. 1
0
        public Form1()
        {
            InitializeComponent();
            bl = new BindingList <CartItem>(selected);

            dataGridView1.AutoGenerateColumns = false;
            dataGridView1.AutoSize            = true;

            selectedGames.AutoGenerateColumns = false;

            this.CenterToScreen();

            try
            {
                UpdateList();
            }
            catch (System.Data.SQLite.SQLiteException)
            {
                using (var password = new Password())
                {
                    password.ShowDialog(this);
                }
                UpdateList();
            }

            KeysDAO.Backup();
        }
Esempio n. 2
0
 static void Main()
 {
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     if (!File.Exists("Keys.db"))
     {
         KeysDAO.Create();
     }
     Application.Run(new Form1());
 }
Esempio n. 3
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();
        }
Esempio n. 4
0
 private void button2_Click(object sender, EventArgs e)
 {
     DBConnection.Password = textBox1.Text;
     try
     {
         KeysDAO.ReadAll();
         DialogResult = DialogResult.OK;
         this.Close();
     }
     catch (System.Data.SQLite.SQLiteException)
     {
         MessageBox.Show("Wrong password", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
     }
 }
Esempio n. 5
0
        public Package(int subId, int appId, string appName, bool hasCards)
        {
            this.SubId    = subId;
            this.AppId    = appId;
            this.AppName  = appName;
            this.HasCards = hasCards;
            this.keys     = KeysDAO.Find(subId);

            foreach (Key key in this.keys)
            {
                if (!this.details.Contains(key.Details))
                {
                    this.details.Add(key.Details);
                }
            }
        }
Esempio n. 6
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();
        }
Esempio n. 7
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();
        }