private void statisticsButton_Click(object sender, EventArgs e) { if (SqlConnectionHandler.InitialSetup() == 0) { this.Visible = false; Statistics statisticsWindow = new Statistics(); statisticsWindow.Show(); statisticsWindow.FormClosed += new FormClosedEventHandler(this.WindowReopen); } }
//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(); } }
public LogicGames() { int returnValue = SqlConnectionHandler.InitialSetup(); InitializeComponent(); }