private void timer1_Tick(object sender, EventArgs e) { //MessageBox.Show("qwe"); bool ok = s.step(); if (!ok) { timer1.Stop(); MessageBox.Show("You have lost"); int highScore = s.body.Count; string playerName = tbPlayerName.Text; SqlConnection myConnection = new SqlConnection("Server=tcp:c-sharp-course.database.windows.net,1433;Initial Catalog=C_Sharp_Course_Sample_Database;Persist Security Info=False;User ID=nsk;Password=QWEqwe123;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"); myConnection.Open(); SqlCommand qc = new SqlCommand("INSERT INTO SampleTable VALUES ('" + playerName + "'," + highScore + ")", myConnection); qc.ExecuteNonQuery(); myConnection.Close(); updateHighScore(); } else { timer1.Interval = s.delay; drawBoard(); } }
private void timer1_Tick(object sender, EventArgs e) { //MessageBox.Show("qwe"); bool ok = s.step(); if (!ok) { timer1.Stop(); MessageBox.Show("You have lost"); } else { timer1.Interval = s.delay; drawBoard(); } }