private void ListViewItem_Menu_Selected(object sender, RoutedEventArgs e)
        {
            var mainMenuWindow = new MainMenuWindow();

            mainMenuWindow.Show();
            Close();
        }
Example #2
0
        //Button to login will open a connection to check for details in database
        private void btnClick_Click(object sender, RoutedEventArgs e)
        {
            String message = "Login failed: Invalid Credentials";

            try
            {
                con = new SqlConnection(connectionString);
                con.Open();
                cmd    = new SqlCommand("SELECT * FROM adminAccounts WHERE Username = '******'", con);
                reader = cmd.ExecuteReader();
                if (reader.Read())
                {
                    if (reader["Password"].ToString().Equals(passBox.Password.ToString(), StringComparison.InvariantCulture))
                    {
                        var mainWindow = new MainMenuWindow();
                        mainWindow.Show();
                        Close();
                    }
                    else
                    {
                        message = "Login failed: Invalid Password";
                        MessageBox.Show(message);
                    }
                }
                reader.Close();
                con.Close();
            }
            catch
            {
                MessageBox.Show(message);
            }
        }