//Fyller i TB's med en användare man valt att uppdatera ur Listan private void listBoxUsers_SelectionChanged(object sender, SelectionChangedEventArgs e) { tbUserID.IsEnabled = true; tbUsername.IsEnabled = true; tbBoss.IsEnabled = true; var logic = new LogicHandler(); var selected = listBoxUsers.SelectedValue.ToString(); var u = logic.getInfoOnSelectedUser(); var val = logic.checkIfDigits(selected); foreach (var user in u.Where(user => val.Equals(user.UID))) { tbFirstName.Text = user.FirstName; tbLastNamne.Text = user.LastName; tbEmail.Text = user.Email; tbPassword.Text = user.PW; tbUsername.Text = user.Username; tbSsn.Text = user.SSN; tbBoss.Text = user.BID.ToString(); tbUserID.Text = user.UID.ToString(); } }
//Fyllar listview med användare private void PopulateListViewUsers() { var logic = new LogicHandler(); var users = logic.getInfoOnSelectedUser(); foreach (var user in users) { listBoxUsers.Items.Add("Anst nr: " + user.UID + " " + user.FirstName + " " + user.LastName); } }
//Söka användare private void btnSearchUser1_Click(object sender, RoutedEventArgs e) { var search = tbSearchUser.Text.ToLower(); var logic = new LogicHandler(); var allUsers = logic.getInfoOnSelectedUser(); listBoxUsers.Items.Clear(); var u = (from m in allUsers where m.FirstName.ToLower().Contains(search) select m); foreach (var item in u) { listBoxUsers.Items.Add("Anst nr: " + item.UID + " " + item.FirstName + " " + item.LastName); } }