Esempio n. 1
0
        private void DeleteSetBtn_Click(object sender, EventArgs e)
        {
            ChooseSet.Text = "";
            ChooseSet.Items.Remove(currentSet.SetName);

            Text1.Clear();
            Text2.Clear();
            Title1.Clear();
            Title2.Clear();
            PointerInput.Clear();
            PointerVal.Text = "";

            Querey querey = new Querey();

            using (querey.connection = querey.NewConn)
            {
                string[][] tables = { new string[] { "Sets", "Id" }, new string[] { "Flashcards", "SetId" }, new string[] { "Permissions", "SetId" }, new string[] { "SetProgress", "SetId" } };

                foreach (string[] table in tables)
                {
                    using (querey.command = querey.NewComm)
                    {
                        querey.command.CommandText = "DELETE FROM " + table[0] + " WHERE " + table[1] + "= @setid;";
                        querey.AddParameter("@setid", currentCard.setId);
                        querey.command.ExecuteNonQuery();
                    }
                }
            }

            currentSet = null;

            ChangeEdit(false);
            SaveChanges();
            new MessageForm("deleted").Show();
        }
Esempio n. 2
0
        private void JumpBtn_Click(object sender, EventArgs e)
        {
            if (PointerInput.Text == "")
            {
                MessageForm errorForm = new MessageForm("Please enter which card you want to go to");
                errorForm.Show();
            }
            else if (int.Parse(PointerInput.Text) < 0 || int.Parse(PointerInput.Text) > queue.GetQueue.Length)
            {
                MessageForm errorForm = new MessageForm("Please enter a value within the range of your flashcards");
                errorForm.Show();
            }
            else if (queue.GetQueue[int.Parse(PointerInput.Text) - 1] == null)
            {
                MessageForm errorForm = new MessageForm("Your set does not have that many flashcards");
                errorForm.Show();
            }
            else
            {
                int  difference = int.Parse(PointerVal.Text) - int.Parse(PointerInput.Text);
                bool back       = false;
                if (difference < 0)
                {
                    difference = -difference;
                    back       = true;
                }

                for (int i = 0; i < difference; i++)
                {
                    PointerVal.Text = (back ? queue.Forwards() : queue.Backwards()).ToString();
                }

                currentCard = queue.Load();
            }
            PointerInput.Clear();
        }