private void PopulateIdentifyingAreasLeaderboard()
        {
            LearningGames lg = new LearningGames();
            RegisterLogin rl = new RegisterLogin();

            mlb = lg.GetAllLeadBoardRecords(connectionString).OrderByDescending(a => a.IDENTIFYING_AREAS_PERSONAL_BEST).ToList();

            int i = 1;

            foreach (var item in mlb)
            {
                user = rl.GetUser(item.USER_LIBRARY_CARD_ID, connectionString);

                DataGridBind dgb = new DataGridBind
                {
                    POSITION = i.ToString(),
                    NAME     = user[0].USER_FNAME + " " + user[0].USER_LNAME,
                    SCORE    = item.IDENTIFYING_AREAS_PERSONAL_BEST.ToString()
                };


                dgIdentifyingAreas.Items.Add(dgb);
                i++;
            }
        }
        private void PopulateReplacingBooksLeaderboard()
        {
            LearningGames lg = new LearningGames();
            RegisterLogin rl = new RegisterLogin();

            mlb = lg.GetAllLeadBoardRecords(connectionString).OrderBy(a => a.REPLACING_BOOKS_PERSONAL_BEST).ToList();

            int i = 1;

            foreach (var item in mlb)
            {
                user = rl.GetUser(item.USER_LIBRARY_CARD_ID, connectionString);

                DataGridBind dgb = new DataGridBind
                {
                    POSITION = i.ToString(),
                    NAME     = user[0].USER_FNAME + " " + user[0].USER_LNAME,
                    SCORE    = item.REPLACING_BOOKS_PERSONAL_BEST
                };


                dgReplacingBooks.Items.Add(dgb);
                i++;
            }
        }
        private void UpdateLeaderBoardPersonalBest()
        {
            try
            {
                LearningGames lg = new LearningGames();
                RegisterLogin rl = new RegisterLogin();

                ModelLeaderBoard mlb = new ModelLeaderBoard
                {
                    USER_LIBRARY_CARD_ID = currentUser
                };

                List <ModelLeaderBoard> getPersonalBest = lg.GetPersonalBestIdentifyingAreas(mlb, connectionString);


                tbPBSCore.Text = getPersonalBest[0].IDENTIFYING_AREAS_PERSONAL_BEST.ToString();



                if (getPersonalBest.Count == 1)
                {
                    tbPBSCore.Text = getPersonalBest[0].IDENTIFYING_AREAS_PERSONAL_BEST.ToString();
                }



                getAllRecords = lg.GetIdentifyingAreasChampion(connectionString);

                if (getAllRecords[0].IDENTIFYING_AREAS_PERSONAL_BEST == 0)
                {
                    tbChampionName.Text = "No Champion Yet !";
                }
                else
                {
                    tbChampScore.Text = getAllRecords[0].IDENTIFYING_AREAS_PERSONAL_BEST.ToString();

                    List <ModelLeaderBoard> getBestUserId = lg.GetChampionNameIdentifyingAreas(getAllRecords[0].IDENTIFYING_AREAS_PERSONAL_BEST.ToString(), connectionString);

                    int id = getBestUserId[0].USER_LIBRARY_CARD_ID;

                    if (id == currentUser)
                    {
                        isChamp = true;
                    }

                    List <ModelRegisterLogin> getBestUser = rl.GetUser(id, connectionString);
                    tbChampionName.Text = getBestUser[0].USER_FNAME + " " + getBestUser[0].USER_LNAME;
                }
            }
            catch (Exception)
            {
                tbChampionName.Text = "No Champion Yet !";
            }
        }
Esempio n. 4
0
        //This method inputs new user data into the database
        public void RegisterNewUser()
        {
            LearningGames lg = new LearningGames();

            try
            {
                var login    = Int32.Parse(tbUsername.Text);
                var password = tbPassword.Password;
                var fName    = tbFName.Text;
                var lName    = tbLName.Text;

                var c = new ModelRegisterLogin
                {
                    USER_LIBRARY_CARD_ID = login,
                    USER_PASSWORD        = password,
                    USER_FNAME           = fName,
                    USER_LNAME           = lName
                };

                cl.InsertUserRegData(c, connectionString);

                var ml = new ModelLeaderBoard
                {
                    USER_LIBRARY_CARD_ID               = login,
                    REPLACING_BOOKS_PERSONAL_BEST      = "Not Set",
                    IDENTIFYING_AREAS_PERSONAL_BEST    = 0,
                    FINDING_CALL_NUMBERS_PERSONAL_BEST = 0
                };

                lg.InsertNewBlankLeaderboardRecord(ml, connectionString);



                MessageBox.Show($"Registration Successful!" +
                                "\nYou may now Login,  " + tbFName.Text + " !");
                tabLoginRegister.SelectedIndex = 1;
            }
            catch (System.Exception)
            {
                MessageBox.Show("User already exists or the input for LIBRARY CARD ID is not a number\nPlease try again", "Error");
                tbUsername.Text     = "";
                tbPassword.Password = "";
            }
        }
        private void InsertUpdateRecords()
        {
            LearningGames    lg  = new LearningGames();
            ModelLeaderBoard mlb = new ModelLeaderBoard
            {
                USER_LIBRARY_CARD_ID            = currentUser,
                IDENTIFYING_AREAS_PERSONAL_BEST = userCurrentScore
            };


            List <ModelLeaderBoard> rec = lg.GetPersonalBestIdentifyingAreas(mlb, connectionString);

            if (rec.Count == 0)
            {
                lg.InsertNewPersonalBestIdentifyingAreas(mlb, connectionString);
            }
            else
            {
                lg.UpdateNewPersonalBestIdentifyingAreas(mlb, connectionString);
            }
        }
Esempio n. 6
0
        private void InsertUpdateRecords()
        {
            LearningGames    lg  = new LearningGames();
            ModelLeaderBoard mlb = new ModelLeaderBoard
            {
                USER_LIBRARY_CARD_ID = currentUser,
                FINDING_CALL_NUMBERS_PERSONAL_BEST = currentGameScore
            };


            List <ModelLeaderBoard> rec = lg.GetPersonalBestFindingCallNumbers(mlb, connectionString);

            if (rec.Count == 0)
            {
                lg.InsertNewPersonalBestFindingCallNumbers(mlb, connectionString);
            }
            else
            {
                lg.UpdateNewPersonalBestFindingCallNumbers(mlb, connectionString);
            }
        }
Esempio n. 7
0
        //Updates labels related to personal best score and champion
        private void UpdateLeaderBoardPersonalBest()
        {
            try
            {
                LearningGames lg = new LearningGames();
                RegisterLogin rl = new RegisterLogin();

                ModelLeaderBoard mlb = new ModelLeaderBoard
                {
                    USER_LIBRARY_CARD_ID = currentUser
                };

                List <ModelLeaderBoard> getPersonalBest = lg.GetPersonalBestReplacingBooks(mlb, connectionString);

                if (getPersonalBest.Count == 1)
                {
                    lbPersonalBest.Text = getPersonalBest[0].REPLACING_BOOKS_PERSONAL_BEST.ToString();
                    pb = getPersonalBest[0].REPLACING_BOOKS_PERSONAL_BEST.ToString();
                }

                getAllRecords = lg.GetAllLeadBoardRecords(connectionString);

                SelectionSortBestTime();

                lbChampTime.Text = getAllRecords[0].REPLACING_BOOKS_PERSONAL_BEST;

                List <ModelLeaderBoard> getBestUserId = lg.GetChampionNameReplacingBooks(getAllRecords[0].REPLACING_BOOKS_PERSONAL_BEST.ToString(), connectionString);

                int id = getBestUserId[0].USER_LIBRARY_CARD_ID;

                List <ModelRegisterLogin> getBestUser = rl.GetUser(id, connectionString);
                tbChampionName.Text = getBestUser[0].USER_FNAME + " " + getBestUser[0].USER_LNAME;
                ChampTime           = getAllRecords[0].REPLACING_BOOKS_PERSONAL_BEST;
            }
            catch (Exception)
            {
                tbChampionName.Text = "No Champion Yet !";
            }
        }
Esempio n. 8
0
        private void btStartStop_Click(object sender, RoutedEventArgs e)
        {
            if (btStartStop.Content.Equals("START") || btStartStop.Content.Equals("TRY AGAIN?"))
            {
                stopwatch.Reset();
                tbTimeDisplay.Text = startTimeDisplay;

                btStartStop.Content = "STOP";
                btDown.IsEnabled    = true;
                btUp.IsEnabled      = true;
                unsortedListString.Clear();
                usersList.Clear();
                userOrderLinkedList.Clear();
                sortedList.Clear();

                for (int i = 0; i < 10; i++)
                {
                    randomNumber = GenerateRandomNumber();
                    author       = GenerateRandomAuthor();
                    callNumber   = randomNumber + " " + author;

                    DataGridBind dgb = new DataGridBind
                    {
                        CALL_NUMBER = callNumber
                    };
                    unsortedListString.Insert(i, dgb);
                    usersList.Insert(i, dgb);
                }

                dgCallNumbers.Items.Clear();

                foreach (var callNumber in unsortedListString)
                {
                    DataGridBind dgb = new DataGridBind
                    {
                        CALL_NUMBER = callNumber.CALL_NUMBER
                    };


                    dgCallNumbers.Items.Add(dgb);
                }

                stopwatch.Start();
                timer.Start();
            }
            else if (btStartStop.Content.Equals("STOP"))
            {
                LearningGames lg = new LearningGames();

                string timeScore = tbTimeDisplay.Text;
                stopwatch.Stop();
                timer.Stop();


                for (int i = 0; i < 10; i++)
                {
                    DataGridBind dgb = new DataGridBind
                    {
                        CALL_NUMBER = usersList[i].CALL_NUMBER
                    };

                    userOrderLinkedList.AddLast(usersList[i].CALL_NUMBER.ToString());
                }

                SelectionSortUserBooks();

                foreach (var item in unsortedListString)
                {
                    sortedList.Add(item.CALL_NUMBER);
                }

                bool equal = userOrderLinkedList.SequenceEqual(sortedList);



                if (equal)
                {
                    ModelLeaderBoard ml = new ModelLeaderBoard
                    {
                        USER_LIBRARY_CARD_ID          = currentUser,
                        REPLACING_BOOKS_PERSONAL_BEST = timeScore
                    };

                    List <ModelLeaderBoard> getPersonalBest = lg.GetPersonalBestReplacingBooks(ml, connectionString);

                    if (pb.Equals("Not Set"))
                    {
                        List <ModelLeaderBoard> getLeaderBoardRecords = lg.GetAllLeadBoardRecords(connectionString);

                        if (getLeaderBoardRecords.Count == 0)
                        {
                            lg.UpdateNewPersonalBestReplacingBooks(ml, connectionString);
                            MessageBox.Show("Congratulations ! You won, set your first PERSONAL BEST and are the first CHAMPION for this game mode ! It took you " + timeScore + " to complete the game! Try again to beat your PERSONAL BEST !");
                        }
                        else if (TimeSpan.Compare(TimeSpan.Parse(timeScore), TimeSpan.Parse(ChampTime.ToString())) == -1)
                        {
                            lg.UpdateNewPersonalBestReplacingBooks(ml, connectionString);
                            MessageBox.Show("Congratulations ! You won, set your first PERSONAL BEST and are the new CHAMPION for this game mode ! It took you " + timeScore + " to complete the game! Try again to beat your PERSONAL BEST !");
                        }
                        else
                        {
                            lg.UpdateNewPersonalBestReplacingBooks(ml, connectionString);
                            MessageBox.Show("Congratulations ! You won and set your first PERSONAL BEST ! It took you " + timeScore + " to complete the game! Try again to beat your PERSONAL BEST !");
                        }

                        UpdateLeaderBoardPersonalBest();
                    }
                    else if (TimeSpan.Compare(TimeSpan.Parse(timeScore), TimeSpan.Parse(ChampTime.ToString())) == -1)
                    {
                        if (TimeSpan.Compare(TimeSpan.Parse(timeScore), TimeSpan.Parse(getPersonalBest[0].REPLACING_BOOKS_PERSONAL_BEST.ToString())) == -1)
                        {
                            lg.UpdateNewPersonalBestReplacingBooks(ml, connectionString);
                            MessageBox.Show("Congratulations ! You WON, beat your PERSONAL BEST time and are the new CHAMPION ! It took you " + timeScore + " to complete the game! Try again to beat your PERSONAL BEST for this game mode!");
                            UpdateLeaderBoardPersonalBest();
                        }
                        else
                        {
                            lg.UpdateNewPersonalBestReplacingBooks(ml, connectionString);
                            MessageBox.Show("Congratulations ! You WON and are the new CHAMPION ! It took you " + timeScore + " to complete the game! Try again to beat your PERSONAL BEST for this game mode!");
                            UpdateLeaderBoardPersonalBest();
                        }
                    }
                    else if (TimeSpan.Compare(TimeSpan.Parse(timeScore), TimeSpan.Parse(getPersonalBest[0].REPLACING_BOOKS_PERSONAL_BEST.ToString())) == -1)
                    {
                        lg.UpdateNewPersonalBestReplacingBooks(ml, connectionString);
                        MessageBox.Show("Congratulations ! You WON and beat your PERSONAL BEST time ! It took you " + timeScore + " to complete the game! Try again to beat your PERSONAL BEST or to become library CHAMPION for this game mode!");
                        UpdateLeaderBoardPersonalBest();
                    }
                    else
                    {
                        MessageBox.Show("Congratulations ! You WON ! It took you " + timeScore + " to complete the game! Try again to beat your PERSONAL BEST or to become library CHAMPION for this game mode!");
                    }
                }
                else
                {
                    MessageBox.Show("SORRY You LOSE ! Unfortunately the CALL NUMBER order was INCORRECT! TRY AGAIN to have another chance at WINNING this game mode !");
                }

                btStartStop.Content = "TRY AGAIN?";
            }
        }