private void displayQuestion(int id)
        {
            SqlConnect con = new SqlConnect();

            con.conOpen();
            if (con != null)
            {
                string     q   = "SELECT * FROM tblQuestions A WHERE id = '" + id + "' ";
                SqlCommand cmd = new SqlCommand(q, con.Con);

                try
                {
                    using (SqlDataReader read = cmd.ExecuteReader())
                    {
                        while (read.Read())
                        {
                            tbQuestion.Text = (read["Question"]).ToString();
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Debug at displayQuestion Function");
                    Console.WriteLine(ex.Message);
                }
                con.conclose();
            }
        }
        private void getTotalCount()
        {
            int        numX;
            string     q;
            SqlConnect con = new SqlConnect();

            con.conOpen();
            if (con != null)
            {
                if (levelCounter >= 3)
                {
                    q = "Select TOP 1 A.id, '1' as count from tblQuestions A INNER JOIN tblLevel B ON A.levelid = B.LevelId WHERE B.LevelName = '" + levelname[levelCounter].ToString().Trim() + "' ORDER BY NEWID()";
                }
                else
                {
                    q = "Select TOP 5 A.id , '5' as count from tblQuestions A INNER JOIN tblLevel B ON A.levelid = B.LevelId WHERE B.LevelName = '" + levelname[levelCounter].ToString().Trim() + "' ORDER BY NEWID()";
                }
                //string q = "Select '"+ topConcat + "' COUNT(A.id)as count from tblQuestions A INNER JOIN tblLevel B ON A.levelid = B.LevelId WHERE B.LevelName = '" + levelname[levelCounter].ToString().Trim() + "' ORDER BY NEWID()";

                SqlCommand cmd = new SqlCommand(q, con.Con);

                try
                {
                    using (SqlDataReader read = cmd.ExecuteReader())
                    {
                        while (read.Read())
                        {
                            numX = Convert.ToInt32((read["count"]).ToString());
                            randomQuestionsNum = new int[numX];
                        }
                    }
                }

                catch (Exception ex)
                {
                    Console.WriteLine("Debug at getTotalCount Function");
                    Console.WriteLine(ex.Message);
                }
                con.conclose();
            }
        }
        private void getRandomQuestions()
        {
            string     q;
            SqlConnect con = new SqlConnect();

            con.conOpen();
            if (con != null)
            {
                if (levelCounter >= 3)
                {
                    q = "SELECT TOP 1 A.id, B.LevelName, B.Amount From tblQuestions A INNER JOIN tblLevel B ON A.levelid = B.LevelId WHERE B.LevelName = '" + levelname[levelCounter].ToString().Trim() + "' ORDER BY NEWID()";
                }
                else
                {
                    q = "SELECT TOP 5 A.id, B.LevelName, B.Amount From tblQuestions A INNER JOIN tblLevel B ON A.levelid = B.LevelId WHERE B.LevelName = '" + levelname[levelCounter].ToString().Trim() + "' ORDER BY NEWID()";
                }

                SqlCommand cmd = new SqlCommand(q, con.Con);
                try
                {
                    using (SqlDataReader read = cmd.ExecuteReader())
                    {
                        while (read.Read())
                        {
                            randomQuestionsNum[i] = Convert.ToInt32((read["id"]).ToString());
                            tbRound.Text          = "Round: " + (read["LevelName"]).ToString();
                            tbAmount.Text         = (read["Amount"]).ToString();
                            i += 1;
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Debug at getRandomQuestion Function");
                    Console.WriteLine(ex.Message);
                }
                con.conclose();
            }
        }
        private void displaySwitchQuestion()
        {
            y = 1;
            //curValue += 1;
            SqlConnect con = new SqlConnect();

            con.conOpen();
            if (con != null)
            {
                string     q   = "SELECT C.Question, A.Choices, A.isCorrect, D.LevelName FROM tblSwitchAnswer A INNER JOIN (SELECT TOP 1 X.switchid FROM tblSwitchQuestions X INNER JOIN tblLevel Z ON X.levelid = Z.LevelId WHERE Z.LevelName= '" + levelname[levelCounter] + "' ORDER BY NEWID()) B ON A.questionid = B.switchid INNER JOIN tblSwitchQuestions C ON B.switchid =  C.switchid INNER JOIN tblLevel D ON C.levelid =  D.LevelId ORDER BY NEWID() ";
                SqlCommand cmd = new SqlCommand(q, con.Con);

                try
                {
                    using (SqlDataReader read = cmd.ExecuteReader())
                    {
                        while (read.Read())
                        {
                            tbQuestion.Text = (read["Question"]).ToString();
                            RadioButton radiobtn = (RadioButton)radioPanel.FindName("r" + y);
                            TextBlock   tbVal    = (TextBlock)radioPanel.FindName("tb" + y);
                            radiobtn.Content = (read["Choices"]).ToString();
                            tbVal.Text       = (read["isCorrect"]).ToString();
                            if (y <= 4)
                            {
                                y += 1;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Debug at displaySwitchQuestion Function");
                    Console.WriteLine(ex.Message);
                }
                con.conclose();
            }
        }
        private void displayAnswer(int id)
        {
            y = 1;
            SqlConnect con = new SqlConnect();

            con.conOpen();
            if (con != null)
            {
                string     q   = "SELECT * From tblAnswers Where questionid = '" + id + "' ORDER BY NEWID()";
                SqlCommand cmd = new SqlCommand(q, con.Con);

                try
                {
                    using (SqlDataReader read = cmd.ExecuteReader())
                    {
                        while (read.Read())
                        {
                            RadioButton radiobtn = (RadioButton)radioPanel.FindName("r" + y);
                            TextBlock   tbVal    = (TextBlock)radioPanel.FindName("tb" + y);
                            radiobtn.Content = (read["Choices"]).ToString();
                            tbVal.Text       = (read["isCorrect"]).ToString();
                            if (y <= 4)
                            {
                                y += 1;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Debug at displayAnswer Function");
                    Console.WriteLine(ex.Message);
                }
                con.conclose();
            }
            tik = 60;
            timer1.Start();
        }