public void RegisteredOrVerified(object sender, GenericEventArgs <SQLReference.LoginRegisterData> e)
 {
     SQLReference.userLoginCompletedEventArgs eventArgs = new SQLReference.userLoginCompletedEventArgs(new object[] { e.Value }, null, false, null);
     client_LoginResult(sender, eventArgs);
 }
        private void client_LoginResult(object sender, SQLReference.userLoginCompletedEventArgs e)
        {
            client.userLoginCompleted -= client_LoginResult;

            txtUsername.IsEnabled = true;
            txtPassword.IsEnabled = true;
            cmdRegister.IsEnabled = true;
            MyMainPage.enableNavigation();



            if (e.Error != null)
            {
                MessageBox.Show("The service is temporarily unavailable.");
                cmdLogin.IsEnabled = true;
                M.username         = "";
                return;
            }



            if (!e.Result.Verified && !string.IsNullOrEmpty(e.Result.FailMessage))
            {
                cmdLogin.IsEnabled = true;
                if (e.Result.FailMessage.Contains("Authentication"))
                {
                    lblSuccess.Text = "Error: MySQL Authentication Failed";
                }
                else
                {
                    lblSuccess.Text = e.Result.FailMessage;
                }
                lblSuccess.Visibility = System.Windows.Visibility.Visible;

                M.username = "";
            }
            else if (!e.Result.Verified) //Not verified
            {
                M.username = "";
                DuelPortalCS.Views.NotVerified nv = new Views.NotVerified(e.Result);
                nv.OnVerificationAccepted += RegisteredOrVerified;
                nv.Show();

                return;
            }
            else //Success
            {
                M.username     = e.Result.Username;
                M.mySet        = e.Result.Pool;
                M.myUsernameId = e.Result.Id;

                switch (M.mySet)
                {
                case "Default":

                    client.populateSQLCompleted += sqlFile_Get;

                    client.populateSQLAsync(M.username, false);
                    loadingMenu = new DuelPortalCS.Views.cldLoading("Loading " + M.mySet + " cards and images...");
                    loadingMenu.Show();
                    break;

                default:     //CCG
                    client.InetConnectionCompleted += setfile_Get;
                    client.InetConnectionAsync("http://192.227.234.101/admin/" + M.mySet + ".txt");
                    loadingMenu = new DuelPortalCS.Views.cldLoading("Loading " + M.mySet + " cards and images...");
                    loadingMenu.Show();
                    break;
                }
                client.getListOfMyDecksCompleted += (s, e2) =>
                {
                    if (e2.Error == null)
                    {
                        M.listOfMyDecks = e2.Result.ToList();
                    }
                };
                client.getListOfMyDecksAsync(M.username);
            }
        }