예제 #1
0
 public static void UpdateCard(string englishText, string chineseText, Guid cardId)
 {
     using (CitizenEntities db = new CitizenEntities())
     {
         if (cardId == Guid.Empty)   // new card to add
         {
             Card newCard = new Card()
             {
                 CardId = Guid.NewGuid(),
                 EnglishText = englishText,
                 ChineseText = chineseText,
                 Score = 0d
             };
             db.AddToCards(newCard);
         }
         else
         {
             Card card = db.Cards.Where(c => c.CardId == cardId).First();
             card.ChineseText = chineseText;
             card.EnglishText = englishText;
         }
         db.SaveChanges();
     }
 }
예제 #2
0
        private void GoForNextCard()
        {
            if (_isSimple)
            {
                if (_goToNumber != "")
                {
                    Card goToCard = GetGoToCard(_goToNumber);
                    _goToNumber = "";
                    if (goToCard == null) return;
                    else _currentCard = goToCard;
                }
                else _currentCard = Learning.GetNextCardSimple();
            }
            else _currentCard = Learning.GetNextCard();

            // handle no more cards
            if (_currentCard == null)
            {
                if (_isSimple)
                {
                    if (MessageBox.Show("恭喜!!! 全部卡都已完成。需要重来一遍吗?", "", MessageBoxButtons.YesNo)
                        == System.Windows.Forms.DialogResult.Yes)
                    {
                        Learning.ResetAllCardsSimple();
                        GoForNextCard();
                        return;
                    }
                    else
                    {
                        this.Close();
                    }
                }
                else
                {
                    MessageBox.Show("暂时没有更多的,添加新卡或者休息一下再回来。");
                    this.Close();
                }
                return;
            }
            ResetUIControls(UIActions.NewCard);
            DoSpeak();
        }