/// <summary> /// When the enter key is pressed, it open the welcome form /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void txtBoxPseudo_KeyDown(object sender, KeyEventArgs e) { if (e.KeyValue == (char)Keys.Enter) { //We add the name of the player Program.playerName = txtPseudo.Text; //We do a try catch if there is a problem with de DB connection try { //Declaration and instanciation of a new DBConnection DBConnection sqliteConn = new DBConnection(); //Insertion of the new player's name sqliteConn.InsertData(Program.playerName, 10); // --------------------------------------Add at the end of the game, it's jsut a test //DB connection close sqliteConn.Close(); } catch (Exception ex) { //Message to show what was wrong with the connection MessageBox.Show(ex.Message, "Attention", MessageBoxButtons.OK, MessageBoxIcon.Error); } this.Hide(); frmWelcome form = new frmWelcome(); form.ShowDialog(); this.Close(); } }
/// <summary> /// When the button cmdBack is clicked, it open the welcome form /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cmdBack_Click(object sender, EventArgs e) { this.Hide(); frmWelcome form = new frmWelcome(); form.ShowDialog(); this.Close(); }