示例#1
0
        private void SignInButton_Click(object sender, RoutedEventArgs e)
        {
            if (emailTextField.Text == "" || passwordTextField.Password == "")
            {
                Msgbox.Show("Please enter email, and password");
            }
            else
            {
                using (SqlConnection myConnection = new SqlConnection(Globals.SQL_DATA_CONNECTION))
                {
                    string     oString = $"SELECT (SELECT UserID FROM Users WHERE email = '{emailTextField.Text}' AND password='******')";
                    SqlCommand oCmd    = new SqlCommand(oString, myConnection);
                    myConnection.Open();
                    using (SqlDataReader oReader = oCmd.ExecuteReader())
                    {
                        while (oReader.Read())
                        {
                            try
                            {
                                Globals.uid = (string)oReader.GetValue(0);

                                //emailTextField.Text = Globals.uid;
                                emailTextField.Text        = "";
                                passwordTextField.Password = "";

                                Globals.UNIQUE_INVENTORY_ITEM_COUNT = GenerateDashboard.GetUniqueItemCount(Globals.uid);
                                Globals.SHOPPING_LIST_ITEM_COUNT    = GenerateDashboard.GetShoppingListCount(Globals.uid);
                                Globals.INVENTORY_ITEM_COUNT        = GenerateDashboard.GetInventoryListCount(Globals.uid);

                                Frame.Navigate(typeof(WelcomePage));
                            }
                            catch (InvalidCastException)
                            {
                                Msgbox.Show("Login credentials invalid. Please try again.");
                                emailTextField.Text        = string.Empty;
                                passwordTextField.Password = string.Empty;
                                //throw theException;
                            }
                        }
                    }
                }
            }
        }
示例#2
0
 private void ForgotPasswordButton_Click(object sender, RoutedEventArgs e)
 {
     Globals.uid = string.Empty;
     Msgbox.Show("Signed out, Goodbye!");
 }