示例#1
0
        private void NewGameButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            MySQLFullDB test = new MySQLFullDB();

            if (test.Database.Exists())
            {
                if (MessageBox.Show("Voulez-vous écraser la partie précédente ?", "Attention", MessageBoxButton.YesNo) == MessageBoxResult.No)
                {
                    MessageBox.Show("Cliquez sur \"Reprendre la partie\"");
                }
                else
                {
                    test.DeleteDatabase();
                    popUp = new UsernameRegister();
                    popUp.CancelButton.Click += CancelButton_Click;
                    popUp.OkButton.Click     += OkButton_Click;
                    popUp.Visibility          = Visibility.Visible;
                }
            }
            else
            {
                popUp = new UsernameRegister();
                popUp.CancelButton.Click += CancelButton_Click;
                popUp.OkButton.Click     += OkButton_Click;
                popUp.Visibility          = Visibility.Visible;
            }
        }
示例#2
0
        private void RegisterNowbutt_Click(object sender, EventArgs e)
        {
            if (UsernameRegister.Text.Equals("Username") || UsernameRegister.Text.Equals(""))
            {
                MessageBox.Show(" Your Username is incorrect \n(Usernames must be no longer than 20 characters. Usernames must contain letters (a-z)", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //Turn the line under the Username text boxe to Red
                UsernameRegister.LineIdleColor = Color.Red;
                UsernameRegister.Focus();
                UsernameRegister.LineFocusedColor = Color.Red;
            }
            else if (Password2Register.Text != PasswordRegister.Text)
            {
                MessageBox.Show(" The first Password dosn't match the second one", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //Turn the line under the second password text boxe to Red and empty it
                Password2Register.Text          = "";
                Password2Register.LineIdleColor = Color.Red;
                Password2Register.Focus();
                Password2Register.LineFocusedColor = Color.Red;
            }
            else if (PasswordRegister.Text.Equals("Password") || Password2Register.Text.Equals("Confirme Password"))
            {
                MessageBox.Show(" Your Password is incorrect \n (At least 8 characters—the more characters the better, A mixture of both uppercase and lowercase letters, A mixture of letters and numbers.)", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //Turn the line under the passwords text boxes to Red
                Password2Register.LineIdleColor = Color.Red;
                PasswordRegister.LineIdleColor  = Color.Red;
                Password2Register.Focus();
                Password2Register.LineFocusedColor = Color.Red;
            }
            else
            {
                con.Open();
                string Register = "INSERT INTO ID_Users VALUES ('" + UsernameRegister.Text + "', '" + PasswordRegister.Text + "')";
                com = new OleDbCommand(Register, con);
                com.ExecuteNonQuery();
                con.Close();

                //Empty all the text boxes
                UsernameRegister.Text  = "";
                PasswordRegister.Text  = "";
                Password2Register.Text = "";

                //Turn the line down the text box to green if the register is succefuly
                UsernameRegister.LineIdleColor  = Color.Green;
                Password2Register.LineIdleColor = Color.Green;
                PasswordRegister.LineIdleColor  = Color.Green;
                MessageBox.Show(" Your account has been created Successfully, Try to Login ", "Welcome with us!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }