public void LoginUser(string username, string password) { home_admin admin = new home_admin(); home gebruiker = new home(); home_gemeente gemeente = new home_gemeente(); using (MySqlConnection conn = new MySqlConnection(MyConnectionString)) { conn.Open(); string query = "(SELECT * FROM user WHERE user_name = @user_name AND user_pass = @user_pass) "; MySqlCommand command = new MySqlCommand(query, conn); command.Parameters.Add(new MySqlParameter("@user_name", username)); command.Parameters.Add(new MySqlParameter("@user_pass", password)); MySqlDataReader login = command.ExecuteReader(); while (login.Read()) { usernaam = login.GetString("user_name"); wachtwoord = login.GetString("user_pass"); userid = login.GetInt32("user_id"); roleid = login.GetInt32("role_id"); Infoid = login.GetInt32("info_id"); Person.userid = userid; Person.infoid = Infoid; } if (usernaam == username) { Console.WriteLine(" de username klopt"); if (wachtwoord == password) { Console.WriteLine(" het wachtwoord klopt"); } } else { MessageBox.Show("De ingevoerde gegevens kloppen niet"); } if (roleid == 1) { admin.Show(); Console.WriteLine("admin"); verificatie = true; } if (roleid == 2) { gemeente.Show(); Console.WriteLine("gemeente"); verificatie = true; } if (roleid == 3) { Console.WriteLine("woonstichting"); verificatie = true; } if (roleid == 4) { gebruiker.Show(); Console.WriteLine("huurder"); verificatie = true; } } }
private void CancelBtn_Click(object sender, RoutedEventArgs e) { home.Show(); this.Close(); }