Exemplo n.º 1
0
        // Button used to retrieve a password only if the email matched the one provided in the database
        private void Button_ResetPassword_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                // Trim white spaces
                string email = Textbox_Email.Text.Trim();
                // Trim white spaces


                var query = from p in db.PlayerInformations
                            where (p.Email.Equals(email))
                            select p;

                if (query.Any())
                {
                    // Look up user account associated with email address
                    PlayerInformation player = db.PlayerInformations.Single(p => p.Email.Equals(email));


                    MailMessage mail = new MailMessage();
                    mail.From = new MailAddress("*****@*****.**", "Tfour Team");
                    mail.To.Add(player.Email);
                    mail.IsBodyHtml = true;
                    mail.Subject    = "Password Reset Request";
                    mail.Body       = "<html><body><h2>Password Reset Request</h2><p>Hi " + player.Name + "!<br>Your new system generated password is: " + player.Password + "<br>You can change this password using the edit profile menu within the application.<h3>Thank you for playing!<br>The Tfour Team</h3></body></html>";
                    mail.Priority   = MailPriority.High;
                    // Send email
                    SmtpClient smtp = new SmtpClient("smtp.live.com", 587);
                    smtp.EnableSsl   = true;
                    smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "uhdcsse3420");
                    smtp.Send(mail);
                    MessageBox.Show("Password reset sucessful!");



                    MessageBox.Show("Password reset sucessful!");

                    // Navigate back to the previous window
                    this.Visibility       = Visibility.Hidden;
                    prevWindow.Visibility = Visibility.Visible;
                }

                else
                {
                    MessageBox.Show("Your email is not registered in the system.");
                    Textbox_Email.Text = "";
                    Textbox_Email.Focus();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error occurred please try again.");
                Console.WriteLine(ex.InnerException.Message);
                Console.WriteLine(ex.InnerException);
                Textbox_Email.Text = "";
                Textbox_Email.Focus();
            }
        }
Exemplo n.º 2
0
        // Button to create the profile in database
            // All textbox designated are checked for input
            // The username is checked in the database for any similar usernames ( No double usernames allowed )
        private void Button_Register_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(TextBox_Name.Text)
                || string.IsNullOrWhiteSpace(TextBox_userID.Text)
                || string.IsNullOrWhiteSpace(PasswordBox_password.Password)
                || string.IsNullOrWhiteSpace(TextBox_email.Text))
            {
                MessageBox.Show("Required fields missing, please complete the registration form.");
            }
            else
            {
                try
                {
                    var query = from p in db.PlayerInformations
                                where (p.UserID.Equals(TextBox_userID.Text))
                                select p;

                    if (query.Any())
                    {
                        MessageBox.Show("Username is already taken. Please choose a different username.");
                        TextBox_userID.Text = "";
                        TextBox_userID.Focus();
                    }
                    else if (!PasswordBox_ReenterPassword.Password.Equals(PasswordBox_password.Password))
                    {
                        MessageBox.Show("Passwords do not match. Please reenter you password.");
                        PasswordBox_password.Password = "";
                        PasswordBox_ReenterPassword.Password = "";
                        PasswordBox_password.Focus();
                    }
                    else
                    {
                        // Create new player information object
                        PlayerInformation newplayer = new PlayerInformation();
                        newplayer.Name = TextBox_Name.Text;
                        newplayer.UserID = TextBox_userID.Text;
                        newplayer.Password = PasswordBox_password.Password;
                        newplayer.Email = TextBox_email.Text.Trim();

                        db.PlayerInformations.InsertOnSubmit(newplayer);
                        db.SubmitChanges();


                        prevWindow.Show();
                        this.Close();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("There was an error processing your registration, please try again.");
                    Console.WriteLine(ex.Message);
                }
            }
        }
Exemplo n.º 3
0
        // Button to create the profile in database
        // All textbox designated are checked for input
        // The username is checked in the database for any similar usernames ( No double usernames allowed )
        private void Button_Register_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(TextBox_Name.Text) ||
                string.IsNullOrWhiteSpace(TextBox_userID.Text) ||
                string.IsNullOrWhiteSpace(PasswordBox_password.Password) ||
                string.IsNullOrWhiteSpace(TextBox_email.Text))
            {
                MessageBox.Show("Required fields missing, please complete the registration form.");
            }
            else
            {
                try
                {
                    var query = from p in db.PlayerInformations
                                where (p.UserID.Equals(TextBox_userID.Text))
                                select p;

                    if (query.Any())
                    {
                        MessageBox.Show("Username is already taken. Please choose a different username.");
                        TextBox_userID.Text = "";
                        TextBox_userID.Focus();
                    }
                    else if (!PasswordBox_ReenterPassword.Password.Equals(PasswordBox_password.Password))
                    {
                        MessageBox.Show("Passwords do not match. Please reenter you password.");
                        PasswordBox_password.Password        = "";
                        PasswordBox_ReenterPassword.Password = "";
                        PasswordBox_password.Focus();
                    }
                    else
                    {
                        // Create new player information object
                        PlayerInformation newplayer = new PlayerInformation();
                        newplayer.Name     = TextBox_Name.Text;
                        newplayer.UserID   = TextBox_userID.Text;
                        newplayer.Password = PasswordBox_password.Password;
                        newplayer.Email    = TextBox_email.Text.Trim();

                        db.PlayerInformations.InsertOnSubmit(newplayer);
                        db.SubmitChanges();


                        prevWindow.Show();
                        this.Close();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("There was an error processing your registration, please try again.");
                    Console.WriteLine(ex.Message);
                }
            }
        }
Exemplo n.º 4
0
        // Button used to retrieve a users username only if email provided matches the email in the database
        private void Button_RetriveUserName_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                // Trim white spaces
                string email = Textbox_Email.Text.Trim();

                var query = from p in db.PlayerInformations
                            where (p.Email.Equals(email))
                            select p;

                if (query.Any())
                {
                    PlayerInformation player = db.PlayerInformations.Single(p => p.Email.Equals(email));



                    MessageBox.Show("Your username is : " + player.UserID);
                    // Navigate back to the previous window
                    this.Visibility       = Visibility.Hidden;
                    prevWindow.Visibility = Visibility.Visible;
                }
                else
                {
                    MessageBox.Show("Your email is not registered in the system.");
                    Textbox_Email.Text = "";
                    Textbox_Email.Focus();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error occurred please try again.");
                Console.WriteLine(ex.InnerException.Message);
                Console.WriteLine(ex.InnerException);
                Textbox_Email.Text = "";
                Textbox_Email.Focus();
            }
        }
Exemplo n.º 5
0
 partial void DeletePlayerInformation(PlayerInformation instance);
Exemplo n.º 6
0
 partial void UpdatePlayerInformation(PlayerInformation instance);
Exemplo n.º 7
0
 partial void InsertPlayerInformation(PlayerInformation instance);
Exemplo n.º 8
0
 partial void DeletePlayerInformation(PlayerInformation instance);
Exemplo n.º 9
0
 partial void UpdatePlayerInformation(PlayerInformation instance);
Exemplo n.º 10
0
 partial void InsertPlayerInformation(PlayerInformation instance);