private void scoreListButton_Click(object sender, EventArgs e) { ScoreListForm scoreListForm = new ScoreListForm(); scoreListForm.onlineUserNo = onlineUserNo; scoreListForm.ShowDialog(); }
private void savePointButton_Click(object sender, EventArgs e) { SqlCommand sqlCommand; try { connnectDb.Open(); } catch { MessageBox.Show("Check your connection!", "Error"); } try { string sqlString = "INSERT INTO Points (userNo,topicNo,point) VALUES(@userNo,@topicNo,@point)"; sqlCommand = new SqlCommand(sqlString, connnectDb); sqlCommand.Parameters.AddWithValue("@userNo", onlineUserNo); sqlCommand.Parameters.AddWithValue("@topicNo", gameType); sqlCommand.Parameters.AddWithValue("@point", point); sqlCommand.ExecuteNonQuery(); connnectDb.Close(); MessageBox.Show("Your score has been added to score list successfully!", "Congratulation"); savePointButton.Enabled = false; } catch { MessageBox.Show("You saved score for this game type before!", "Error"); } finally { connnectDb.Close(); this.Close(); ScoreListForm scoreListForm = new ScoreListForm(); scoreListForm.ShowDialog(); } }