Exemple #1
0
        public PlayerMenu(string playerAccountName, string playerEmail, bool isItSignUp, bool useUserNameToLogin)
        {
            InitializeComponent();

            if (isItSignUp)
            {
                Player.PlayerMenu_SignUp playerMenu_SignUp = new Player.PlayerMenu_SignUp
                {
                    Owner = this
                };
                playerMenu_SignUp.ShowDialog();
                lblPlayerName.Text = PlayerDataBaseControl.playerName;
                PlayerDataBaseControl.Load();
                return;
            }

            // use User Name to Login
            if (useUserNameToLogin)
            {
                PlayerDataBaseControl.playerID = PlayerDataBaseControl.GetData_ByColumn("PlayerAccountName", playerAccountName, "PlayerID");
            }
            else
            {
                PlayerDataBaseControl.playerID = PlayerDataBaseControl.GetData_ByColumn("PlayerEmail", playerEmail, "PlayerID");
            }

            PlayerDataBaseControl.Load();

            lblPlayerName.Text = PlayerDataBaseControl.playerName;
        }
        private void SignUp()
        {
            if (txtUserAccountName.Text == "")
            {
                MessageBox.Show("User Account Name should not be empty.");
                return;
            }

            if (txtPassword.Text == "")
            {
                MessageBox.Show("User Account Name should not be empty.");
                return;
            }

            bool anyError = false;

            if (!FormatChecking.UserName(txtUserAccountName.Text))
            {
                anyError = true;
            }
            if (!FormatChecking.Password(txtPassword.Text))
            {
                anyError = true;
            }

            if (anyError)
            {
                CleanUpTextBox();
                return;
            }

            if (DataBaseControl.MatchingAccountName_OfAllTable(txtUserAccountName.Text))
            {
                MessageBox.Show("Sorry, the User Account Name has been used.");
                return;
            }

            if (txtEmail.Text != "" && PlayerDataBaseControl.MatchingEmail(txtEmail.Text))
            {
                MessageBox.Show("Sorry, the Email has been used.");
                return;
            }



            PlayerDataBaseControl.Insert(txtUserAccountName.Text,
                                         txtPassword.Text,
                                         txtEmail.Text);


            userAccountName = txtUserAccountName.Text;
            userEmail       = txtEmail.Text;

            PlayerDataBaseControl.playerAccountName = userAccountName;
            PlayerDataBaseControl.Load_PlayerID_By_PlayerAccountName();

            user = User.Player;
            Close();
        }
        private User LoginByEmailAndPassword(string email, string password)
        {
            if (PlayerDataBaseControl.MatchingEmailPassword(email, password))
            {
                return(User.Player);
            }
            if (DataBaseControl.MatchingEmailPassword_InStaffTable(email, password))
            {
                return(User.Staff);
            }
            if (DataBaseControl.MatchingEmailPassword_InCSMTable(email, password))
            {
                return(User.CustomerServiceManager);
            }

            return(User.Quit);
        }
        private User LoginByAccountNameAndPassword(string accountName, string password)
        {
            if (PlayerDataBaseControl.MatchingAccountPassword(accountName, password))
            {
                return(User.Player);
            }
            if (DataBaseControl.MatchingAccountPassword_InStaffTable(accountName, password))
            {
                return(User.Staff);
            }
            if (DataBaseControl.MatchingAccountPassword_InCSMTable(accountName, password))
            {
                return(User.CustomerServiceManager);
            }

            return(User.Quit);
        }
        // Matching Account Name in All three Table
        public static bool MatchingAccountName_OfAllTable(string target)
        {
            if (PlayerDataBaseControl.MatchingPlayerAccountName(target))
            {
                return(true);
            }
            if (StaffDataBaseControl.MatchingAccountName(target))
            {
                return(true);
            }
            if (CSMDataBaseControl.MatchingAccountName(target))
            {
                return(true);
            }

            // Do not Exist in All Data Table
            return(false);
        }