private void button_Click(object sender, RoutedEventArgs e) { Admin_Menu adminMenu = new Admin_Menu(); adminMenu.Show(); this.Close(); }
public void nextPageCheck() { SqlConnection con = new SqlConnection(AccessString); //startConnection(); try { //startConnection(); con.Open(); SqlDataAdapter sda = new SqlDataAdapter("SELECT * FROM Users WHERE Username = '******' AND Password = '******' AND AdminAccess = 'Yes'", con); con.Close(); con.Open(); SqlDataAdapter sda2 = new SqlDataAdapter("SELECT * FROM Users WHERE Username = '******' AND Password = '******' AND AdminAccess = 'No'", con); con.Close(); DataTable dt = new DataTable(); DataTable dt2 = new DataTable(); sda.Fill(dt); sda2.Fill(dt2); if (dt.Rows.Count == 1) //Checks if the user exists in the table and is a normal user or not { Admin_Menu admin = new Admin_Menu(); admin.Show(); this.Close(); //HomePage homePage = new HomePage(); //homePage.Show(); } else if (dt2.Rows.Count == 1) //Checks if the user is in the table and is an admin or not { NormalUserMenu normal = new NormalUserMenu(); normal.Show(); this.Close(); } else { MessageBox.Show("You entered a wrong username and password", "Error"); //Tells the user if they ahgve entered a wrong username or password } } catch (Exception f) { MessageBox.Show("exception occured while accessing the database:" + f.Message + "\t" + f.GetType()); //Tells the user what error has occured } }