Esempio n. 1
0
        private void checkForWinner()
        {
            foreach (Control control in GamePanel.Controls)
            {
                Label iconLabel = control as Label;
                if (iconLabel != null)
                {
                    if (iconLabel.ForeColor == iconLabel.BackColor)
                    {
                        return;
                    }
                }
            }
            timeElpased.Stop();
            finalScore = newScore * timer;
            MessageBox.Show("Your final score is : " + finalScore + "!", "Winner!");
            SqlConnection con = new SqlConnection("Data Source=(localdb)\\Projects;Initial Catalog=memoryGame;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;");

            con.Open();
            string     query     = "insert into highScores (scores) values (@scores)";
            SqlCommand myCommand = new SqlCommand(query, con);

            myCommand.Parameters.AddWithValue("@scores", finalScore);
            myCommand.ExecuteNonQuery();
            con.Close();
            PlayAgain pa = new PlayAgain();

            pa.Show();
            Close();
        }
Esempio n. 2
0
 public void timeElpased_Tick_1(object sender, EventArgs e)
 {
     if (timer > 0)
     {
         timer          = timer - 1;
         lbl_timer.Text = timer + " seconds";
     }
     else
     {
         timeElpased.Stop();
         finalScore     = newScore;
         lbl_timer.Text = "Time's up!";
         MessageBox.Show("You didn't finish in time. \n      Your Score: " + finalScore, "Sorry");
         this.Hide();
         PlayAgain pa = new PlayAgain();
         pa.Show();
     }
 }