} // end of gameLobby_FormClosing /********************************** Create Button *********************************** * Tells the server a client has created a game and adds the game to the game list * allowing other users to join the game and play. */ private void CreateButton_Click(object sender, EventArgs e) { listBox1.Items.Clear(); gameWindow = new game(this, clientNo, true, ""); gameWindow.Show(); this.Hide(); } // end of CreatButton
} // end of ListGamesButton /************************************ Join Button ***************************** * Allows users to joing an game that isn't full and checks to make sure the game * isn't full before connecting. Once connected it starts a game for the user and * connects to the creators game. */ private void JoinButton_Click(object sender, EventArgs e) { //Protect against null listbox selection try { opponentName = listBox1.SelectedItem.ToString(); //Check to see if game has been removed from list ListGamesButton_Click(null, null); //wait for server to complete update of game list Thread.Sleep(300); // Lists all items in the game list if (listBox1.Items.Contains(opponentName)) { if (opponentName.Length > 4) { listBox1.Items.Clear(); //initialize game window gameWindow = new game(this, clientNo, false, opponentName); gameWindow.Show(); listBox1.Items.Clear(); this.Hide(); } } } catch (Exception j) { _ = j.StackTrace; } } // end of JoingButton
private void button2_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\login1.mdf;Integrated Security=True;Connect Timeout=30"); con.Open(); SqlCommand sda = new SqlCommand("select * from user2 where username='******' and password ='******'", con); SqlDataReader dr; dr = sda.ExecuteReader(); int ok = 0; while (dr.Read()) { if (this.CompareStrings(dr["username"].ToString(), textBox1.Text) && this.CompareStrings(dr["password"].ToString(), textBox2.Text)) { username = dr["username"].ToString(); hs = Convert.ToInt32(dr["highscore"]); game ss = new game(); ss.Show(); ok = 1; } } if (ok == 0) { MessageBox.Show("incorect"); } textBox1.Clear(); textBox2.Clear(); }