示例#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);
        }