private void GameEnd() { timer.Stop(); SqlConnectionHandler.RunNonQuery($"INSERT INTO snake (score) VALUES({score})"); panel.Location = new Point((Width / 2) - (panel.Size.Width / 2), (Height / 2) - (panel.Size.Height / 2)); panel.Visible = true; }
//DISPLAY WIN private void OnWinSingle(BattleshipPlayer winner) { ChangeView(menu, win); winnerLb.Text = winner.name + " WON!"; List <List <string> > sum = new List <List <string> >(); //INSERTING DATA TO THE TABLE try { if (SqlConnectionHandler.InitialSetup() == 0) { if (winner.name != "BOT") { SqlConnectionHandler.RunNonQuery($"INSERT INTO battleship(score) VALUES(1)"); } else { SqlConnectionHandler.RunNonQuery($"INSERT INTO battleship(score) VALUES(-1)"); } } //GETTING STATS sum = SqlConnectionHandler.Query($"SELECT sum(score) FROM battleship WHERE score = 1"); if (sum.Count > 0) { string ammount = Convert.ToString(sum[0][0]); winStatisticsLabel.Text = "Wins against bot: " + ammount; } else { winStatisticsLabel.Hide(); } } catch { winStatisticsLabel.Hide(); } }
//Reopening menu window on the close of one of the games private void WindowReopen(object sender, EventArgs e) { timeSpan = DateTime.Now - date1; SqlConnectionHandler.RunNonQuery($"INSERT INTO times (timeSpent) VALUES('{timeSpan.ToString("c")}')"); this.Visible = true; }