public Database() { wordImageDB = new CardDataContext(CardDataContext.DBConnectionString); // Data context and observable collection are children of the main page. this.DataContext = this; }
public void init() { MyMessageBox myMessageBox = new MyMessageBox(); CardDataContext card = new CardDataContext(); Card cards; var innerJoinQuery = from Deck in card.MemberCardDeck join Hero in card.HeroCard on Deck.CardNumberID equals Hero.CardNumberID where Deck.MemberName == Player.getInstance().getID() select Hero; foreach (var item in innerJoinQuery) { cards = new Card(); cards.CardName = item.HeroCardName; cards.CardHP = item.HeroCardHealthPoint; cards.CardDam = item.HeroCardAttackPoint; cards.cardNumber = (int)item.CardNumberID; cards.HeroCardInfo = item.HeroCardInformation; playerCardDeckList.Add(cards); var innerJoinQuery2 = from Deck in card.HeroCard join Magic in card.HeroCardSkill on Deck.HeroCardName equals Magic.HeroCardName where Deck.HeroCardName == cards.CardName select Magic; int i = 0; foreach (var item2 in innerJoinQuery2) { if (i == 0) { cards.skill1 = item2.SkillName; cards.attackUpSkill = item2.SkillPoint; } else if (i == 1) { cards.skill2 = item2.SkillName; cards.healthUpSkill = item2.SkillPoint; } else if (i == 2) { cards.skill3 = item2.SkillName; cards.turnUpSkill = item2.SkillPoint; } i++; } } }
private void CardInfo() { CardDataContext card = new CardDataContext(); MyMessageBox myMessageBox = new MyMessageBox(); var innerJoinQuery = from Deck in card.HeroCard join Magic in card.HeroCardSkill on Deck.HeroCardName equals Magic.HeroCardName where Deck.HeroCardName == "동명왕" select Magic; String str = ""; foreach (var item in innerJoinQuery) { str += item.HeroCardName; str += " "; str += item.SkillName; str += item.SkillPoint; } myMessageBox.SetText = str; myMessageBox.ShowDialog(); }
private void db_Insert() { MemberDataContext memContext = new MemberDataContext(); CardDataContext card = new CardDataContext(); Member mem = new Member(); mem.MemberName = txtID.Text; mem.MemberPassword = txtPassword.Text; mem.MemberPassword2 = txtPassword2.Text; memContext.Member.InsertOnSubmit(mem); try { memContext.SubmitChanges(); card.Game_CardDeck(txtID.Text); } catch { MyMessageBox error = new MyMessageBox(); error.SetText = "같은 아이디가 있습니다."; error.ShowDialog(); } }
private void userCard_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { selectCanvas = (Canvas)sender; // 클릭한놈으로 부터 canvas 연결 int selectDeckCard = 0; try { if (UpdateCard == true) { Test myDialog = new Test(); myDialog.SetText = "선택한 카드가 " + selectCanvas.Name + " 이 맞나요?"; myDialog.ShowDialog(); if (myDialog.DialogResult == true) { // Check for (int i = 0; i < gameCardDeckList.Count; i++) { if (gameCardDeckList[i].CardName.CompareTo(selectCanvas.Name) == 0) { throw new ExceptionError(); } } // Update DataBase for (int i = 0; i < playerCardDeckList.Count; i++) { if (playerCardDeckList[i].CardName.CompareTo(selectCanvas.Name) == 0) { selectDeckCard = playerCardDeckList[i].cardNumber; playerDeckCardList_Index = i; break; } } if (selectDeckCard == selectCardNumber) { throw new ExceptionError(); } CardDataContext card = new CardDataContext(); var query = from gameDeck in card.GameDeck where gameDeck.MemberName == Player.getInstance().getID() && gameDeck.CardNumberID == selectCardNumber select gameDeck; foreach (var item in query) { item.CardNumberID = selectDeckCard; } try { card.SubmitChanges(); gameCardDeckList[gameDeckCardList_Index] = playerCardDeckList[playerDeckCardList_Index]; MyMessageBox myMessageBox = new MyMessageBox(); myMessageBox.SetText = "카드를 변경 하였어요."; myMessageBox.ShowDialog(); gameDeckRef(); } catch (Exception error) { MyMessageBox myMessageBoxError = new MyMessageBox(); myMessageBoxError.SetText = error.ToString(); myMessageBoxError.ShowDialog(); } } UpdateCard = false; selectCardNumber = 0; } } catch (ExceptionError) { MyMessageBox myMessageBoxError = new MyMessageBox(); myMessageBoxError.SetText = "선택된 카드가 중복 되었네요. 다른 카드를 선택해 주세요."; myMessageBoxError.ShowDialog(); } }
/// <summary> /// Initializes a new instance of the dabase context. /// </summary> /// <param name="cardDataContext"></param> public EligibilityCheckerController(CardDataContext cardDataContext) { _cardDataContext = cardDataContext; }