예제 #1
0
        private void restartAccountToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var result = MessageBox.Show("Are you sure?", "Restart account", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                pm.PlayerRestartAccount();
                var frmLog = new FormLogin();
                Hide();
                frmLog.Show();
            }
        }
        private void btnChangePassChange_Click(object sender, EventArgs e)
        {
            string oldPass    = tbOldPassChange.Text.Trim();
            string newPass    = tbNewPassChange.Text.Trim();
            string repeatPass = tbRepeatPassChange.Text.Trim();

            var player = pm.GetCurrentPlayer();

            if (player.Password != oldPass)
            {
                MessageBox.Show("Your password is wrong!", "Oops!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (oldPass == newPass)
            {
                MessageBox.Show("Please, insert a new password!", "Oops!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (newPass.Length < 6)
            {
                MessageBox.Show("Password should be more than 6 characters", "Oops!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (newPass.Length >= 16)
            {
                MessageBox.Show("Password should be shorther than 16 characters", "Oops!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (newPass != repeatPass)
            {
                MessageBox.Show("Please, repeat your new password again!", "Oops!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                pm.PlayerPasswordChange(newPass);
                MessageBox.Show("Your password has been successfully changed!", "Congrats!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                FormChangePass.ActiveForm.Visible = false;
                FormLogin frmLog = new FormLogin();
                frmLog.ShowDialog();
            }
        }
예제 #3
0
        private void btnRegisterReg_Click(object sender, EventArgs e)
        {
            string  fullName = tbFullNameReg.Text.Trim();
            string  username = tbUsernameReg.Text.Trim();
            string  password = tbPasswordReg.Text.Trim();
            decimal money;
            decimal moneyMax = 922337203685477;

            string sex = "";

            if (rbMaleReg.Checked)
            {
                sex = rbMaleReg.Text;
            }
            if (rbFemaleReg.Checked)
            {
                sex = rbFemaleReg.Text;
            }

            if (fullName == "")
            {
                MessageBox.Show("Please, fill the Full Name field!", "Oops!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (fullName.Length > 50)
            {
                MessageBox.Show("Your Full Name shouldn't be longer than 50 characters!", "Oops!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (username == "")
            {
                MessageBox.Show("Please, fill the Username field!", "Oops!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (username.Length >= 16)
            {
                MessageBox.Show("Username should be shorther than 16 characters");
            }
            else if (password == "")
            {
                MessageBox.Show("Please, fill the Password field!", "Oops!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (password.Length < 6)
            {
                MessageBox.Show("Password should be at least 6 characters");
            }
            else if (password.Length >= 16)
            {
                MessageBox.Show("Password should be shorther than 16 characters");
            }
            else if (sex == "")
            {
                MessageBox.Show("Please, select your sex!", "Oops!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (decimal.TryParse(tbDepositReg.Text.Trim(), out money) == false)
            {
                MessageBox.Show("Please, input only numbers in the deposit field!");
            }
            else if (money > moneyMax)
            {
                MessageBox.Show("Sorry, you can't deposit so much money!", "Oops!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (money < 0)
            {
                MessageBox.Show("The amount of money must be a positive number!", "Oops!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (imagePath == null)
            {
                MessageBox.Show("Please, choose your profile picture!", "Oops!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                byte[] image = pm.ConvertImageToByte(imagePath);
                pm.PlayerRegister(fullName, username, password, money, sex, image);
                var frmLog = new FormLogin();
                frmLog.FormClosed += FormLogin_Closed;
                Hide();
                frmLog.Show();
            }
        }