Beispiel #1
0
        private void cancelButton_Click(object sender, RoutedEventArgs e)
        {
            MainWindowLoggedIn main = new MainWindowLoggedIn();

            main.Show();
            this.Close();
        }
Beispiel #2
0
        private void logIn_Click(object sender, RoutedEventArgs e)
        {
            string query = "SELECT pass FROM Accounts WHERE email = " + emailTextBox.Text;

            //if ()
            //{
            errorTextblock.Text = "Invalid combination. Please try again.";
            //}
            //else
            //{
            App.Current.Properties["email"] = emailTextBox.Text;
            MainWindowLoggedIn main = new MainWindowLoggedIn();

            main.Show();
            this.Close();
            //}
        }
        private void signUpButton_Click(object sender, RoutedEventArgs e)
        {
            if (passwordConfirmBox.Password.Equals(passwordBox.Password) &&
                emailConfirmTextbox.Text.Equals(emailTextbox.Text) &&
                passwordBox.Password.Any(char.IsDigit) &&
                passwordBox.Password.Length >= 6 &&
                emailTextbox.Text.Contains("@") &&
                emailTextbox.Text.Substring(emailTextbox.Text.Length - 4, 4)[0] == '.')
            {
                //put data into DB
                try
                {
                    SqlConnection conn = new SqlConnection();
                    conn.ConnectionString = "Server=DESKTOP-GRD8P4F;Database=GLOBALDOMINATION;Trusted_Connection=true;";
                    conn.Open();
                    string insert = "INSERT INTO Accounts VALUES (" +
                                    (char)34 +
                                    emailTextbox.Text +
                                    (char)34 +
                                    ", " +
                                    (char)34 +
                                    passwordBox.Password +
                                    (char)34 +
                                    ", null, null, null, 0, 0, " +
                                    DateTime.Today + ");";
                    SqlCommand cmd = conn.CreateCommand();
                    cmd.CommandText = insert;
                }
                catch
                {
                    MessageBox.Show("DB error");
                }

                App.Current.Properties["email"] = emailTextbox.Text;
                MainWindowLoggedIn main = new MainWindowLoggedIn();
                main.Show();
                this.Close();
            }
            else
            {
                errorBlock.Text = "Error occured with signup. Please match the instructions at the top of the screen.";
            }
        }