Beispiel #1
0
        void addNewCard()
        {
            //check to see if the card should maybe be added to a CardList
            if (cardListPlayList.CardListIDs.Count > 0)
            {
                //If the user needs to select which cardLists to add it to
                if (_chooseCardListsDialog == null || _chooseCardListsDialog.Description != cardListPlayList.Description || !_chooseCardListsDialog.RememberSelection)
                {
                    _chooseCardListsDialog = new ChooseCardListsDialog(cardListPlayList.CardListIDs, cardListPlayList.Description);
                    _chooseCardListsDialog.ShowDialog();

                    if (_chooseCardListsDialog.DialogResult != DialogResult.OK)
                    {
                        _chooseCardListsDialog = null;
                        return;
                    }
                }
            }

            //Create the card
            LanguageData dataLayer = new LanguageData();
            dsLanguageData.CardRow newCard = new dsLanguageData.CardDataTable().MakeNewCardRow();
            int tmp = dataLayer.InsertOrUpdateCard(newCard);

            //Add the card to the selected CardLists
            if (_chooseCardListsDialog != null)
            {
                foreach (int id in _chooseCardListsDialog.SelectedCardListIDs)
                {
                    int i = dataLayer.InsertCardListDataItem(id, newCard.ID);
                }
            }

            //Load the card and refresh the lists
            cardListPlayList.RefreshCards();
            cardControl.LoadCard(newCard);

            cardListPlayList.AddCard(newCard);
        }
        /// <summary>
        /// Saves the card.
        /// </summary>
        /// <returns></returns>
        public bool SaveCard()
        {
            if (_curCard == null)
                return false;

            writeDataToCard(_curCard);

            LanguageData dataLayer = new LanguageData();
            int i = dataLayer.InsertOrUpdateCard(_curCard);

            writeSoundDataToSoundClip(_curSoundClip);

            i += dataLayer.InsertUpdateOrDeleteSoundClip(_curSoundClip);

            i += dataLayer.InsertUpdateOrDeleteImage(pictureBox.Image, _curCard.ID, _curCard.Answer);

            if(CardDataChanged != null)
                CardDataChanged(this, new CardChangedEventArgs(_curCard, _curSoundClip));

            if(i > 0)
                return true;
            return false;
        }