Example #1
0
 //Изучение колоды
 private void bLearnCardList_Click(object sender, EventArgs e)
 {
     try
     {
         if (CardListComboBox.SelectedItem == null)
         {
             throw new Exception();
         }
         this.Deck = new CardList(CardListComboBox.SelectedItem.ToString());
         Deck.SetCurrent(0);
         db = new DataBase();
         int size = Convert.ToInt32(db.GetCountCardList(Deck));
         if (size < 3)
         {
             MessageBox.Show("Для того, чтобы учить колоду, в ней должно быть не менее трёх карт.", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else
         {
             ReviewForm reviewform = new ReviewForm(Deck);
             reviewform.StyleManager = this.StyleManager;
             reviewform.ShowDialog();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Выберите колоду, с которой вы будете работать.", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Example #2
0
        public void LoadCardList(CardList D)        // Перенос имнофрмации из бд в объект CardList D
        {
            D.SetCurrent(1);
            DB = new SQLiteConnection("Data Source=DB.db; Version=3");
            DB.Open();
            SQLiteCommand CMD = DB.CreateCommand();

            CMD.CommandText = "SELECT Count(*) From " + '\u0022' + D.GetName() + '\u0022';      // Количество строк в таблице бд
            string s = CMD.ExecuteScalar().ToString();

            int size = Convert.ToInt32(s);

            SQLiteCommand    CMD1 = DB.CreateCommand();
            SQLiteDataReader SQL;

            for (int i = 1; i < size + 1; i++)
            {
                CMD1.CommandText = "SELECT * FROM " + '\u0022' + D.GetName() + '\u0022' + " WHERE id like '%' || @Numb || '%' ";      // Выбрать строку таблицы бд в номером i
                CMD1.Parameters.Add("@Numb", DbType.Int16).Value = i;                                                                 //
                SQL = CMD1.ExecuteReader();                                                                                           //
                SQL.Read();                                                                                                           //
                DateTime T = DateTime.Parse(SQL["time"].ToString());                                                                  //
                Card     C = new Card(SQL["question"].ToString(), SQL["answer"].ToString(), T, Int32.Parse(SQL["level"].ToString())); // и перенести информацию из этой строки в объект Card C
                D.Add(C);
                SQL.Close();
            }
        }
Example #3
0
        private void ReviewForm_Load(object sender, EventArgs e)
        {
            LevelLabel.StyleManager = this.StyleManager;
            LevelUp.StyleManager    = this.StyleManager;
            LevelDown.StyleManager  = this.StyleManager;
            bShowQA.StyleManager    = this.StyleManager;
            tQA.StyleManager        = this.StyleManager;
            bNext.StyleManager      = this.StyleManager;
            db = new DataBase();
            db.LoadCardList(Deck);
            this.Deck.Sorting();
            Deck.SetCurrent(0);
            DateTime now      = DateTime.Now;
            DateTime card_now = Deck.GetList(Deck.GetCurrent()).GetTime();
            int      comp     = DateTime.Compare(now, card_now);

            if (comp > 0)
            {
                tQA.Text        = Deck.GetList(Deck.GetCurrent()).GetQuestion();
                First           = Deck.GetList(Deck.GetCurrent());
                LevelLabel.Text = "Уровень карточки: " + Deck.GetList(Deck.GetCurrent()).GetLevel().ToString();
                StreamWriter writer = new StreamWriter("NameOfLastDeck.txt");
                writer.Write(this.Deck.GetName());
                writer.Close();
            }
            else
            {
                tQA.Text        = "Пока карт для изучения нет, зайдите позже.";
                LevelLabel.Text = "";
                bNext.Enabled   = false;
                bShowQA.Visible = false;
            }
        }