private void Button_Click_AddCustomer(object sender, RoutedEventArgs e) { if (!string.IsNullOrWhiteSpace(txtNaamCustomerAdd.Text) && !string.IsNullOrWhiteSpace(txtAdresCustomerAdd.Text)) { using (var ctx = new OrderManagerContext()) { ctx.Customers.Add(new Customer() { Name = txtNaamCustomerAdd.Text, Address = txtAdresCustomerAdd.Text }); ctx.SaveChanges(); dgCustomersAdd.ItemsSource = null; dgCustomersAdd.ItemsSource = ctx.Customers.ToList(); dgCustomersEdit.ItemsSource = null; dgCustomersEdit.ItemsSource = ctx.Customers.ToList(); cbCustomersEdit.ItemsSource = ctx.Customers.ToList(); dgCustomersDelete.ItemsSource = null; dgCustomersDelete.ItemsSource = ctx.Customers.ToList(); cbCustomersDelete.ItemsSource = ctx.Customers.ToList(); } MessageBox.Show("Klant werd toegevoegd.", "", MessageBoxButton.OK, MessageBoxImage.Information); txtNaamCustomerAdd.Clear(); txtAdresCustomerAdd.Clear(); } else { MessageBox.Show("Klant toevoegen mislukt!\nNiet alle velden werden ingevuld.", "", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void Button_Click_EditCustomer(object sender, RoutedEventArgs e) { if (cbCustomersEdit.SelectedItem != null) { Customer selected = cbCustomersEdit.SelectedItem as Customer; using (var ctx = new OrderManagerContext()) { ctx.Customers.FirstOrDefault(c => c.CustomerId == selected.CustomerId).Name = txtNaamCustomerEdit.Text; ctx.Customers.FirstOrDefault(c => c.CustomerId == selected.CustomerId).Address = txtAdresCustomerEdit.Text; ctx.SaveChanges(); dgCustomersAdd.ItemsSource = null; dgCustomersAdd.ItemsSource = ctx.Customers.ToList(); dgCustomersEdit.ItemsSource = null; dgCustomersEdit.ItemsSource = ctx.Customers.ToList(); cbCustomersEdit.ItemsSource = ctx.Customers.ToList(); dgCustomersDelete.ItemsSource = null; dgCustomersDelete.ItemsSource = ctx.Customers.ToList(); cbCustomersDelete.ItemsSource = ctx.Customers.ToList(); } MessageBox.Show("De wijzigingen werden opgeslagen.", "", MessageBoxButton.OK, MessageBoxImage.Information); txtNaamCustomerEdit.Clear(); txtAdresCustomerEdit.Clear(); } else { MessageBox.Show("Gelieve eerst een klant te selecteren.", "", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void Button_Click_EditSupplier(object sender, RoutedEventArgs e) { if (cbSuppliersSupplierEdit.SelectedItem != null) { Supplier selected = cbSuppliersSupplierEdit.SelectedItem as Supplier; using (var ctx = new OrderManagerContext()) { ctx.Suppliers.FirstOrDefault(s => s.SupplierId == selected.SupplierId).Name = txtNaamSupplierEdit.Text; ctx.Suppliers.FirstOrDefault(s => s.SupplierId == selected.SupplierId).Address = txtAdresSupplierEdit.Text; ctx.SaveChanges(); dgSuppliersAdd.ItemsSource = null; dgSuppliersAdd.ItemsSource = ctx.Suppliers.ToList(); cbSuppliersAdd.ItemsSource = ctx.Suppliers.ToList(); dgSuppliersEdit.ItemsSource = null; dgSuppliersEdit.ItemsSource = ctx.Suppliers.ToList(); cbSuppliersSupplierEdit.ItemsSource = ctx.Suppliers.ToList(); dgSuppliersDelete.ItemsSource = null; dgSuppliersDelete.ItemsSource = ctx.Suppliers.ToList(); cbSuppliersDelete.ItemsSource = ctx.Suppliers.ToList(); dgProductsAdd.ItemsSource = null; dgProductsAdd.ItemsSource = ctx.Products.GroupJoin(ctx.Suppliers, p => p.Supplier.SupplierId, s => s.SupplierId, (p, s) => new { Name = p.Name, UnitPrice = p.UnitPrice, Stock = p.Stock, Supplier = p.Supplier.Name }).ToList(); dgProductsEdit.ItemsSource = null; dgProductsEdit.ItemsSource = ctx.Products.GroupJoin(ctx.Suppliers, p => p.Supplier.SupplierId, s => s.SupplierId, (p, s) => new { Name = p.Name, UnitPrice = p.UnitPrice, Stock = p.Stock, Supplier = p.Supplier.Name }).ToList(); cbSuppliersProductEdit.ItemsSource = ctx.Suppliers.ToList(); dgProductsDelete.ItemsSource = null; dgProductsDelete.ItemsSource = ctx.Products.GroupJoin(ctx.Suppliers, p => p.Supplier.SupplierId, s => s.SupplierId, (p, s) => new { Name = p.Name, UnitPrice = p.UnitPrice, Stock = p.Stock, Supplier = p.Supplier.Name }).ToList(); } MessageBox.Show("De wijzigingen werden opgeslagen.", "", MessageBoxButton.OK, MessageBoxImage.Information); txtNaamSupplierEdit.Clear(); txtAdresSupplierEdit.Clear(); } else { MessageBox.Show("Gelieve eerst een leverancier te selecteren.", "", MessageBoxButton.OK, MessageBoxImage.Error); } }
public void CreateDB() { using (var ctx = new OrderManagerContext()) { ctx.Roles.Add(new Role() { Name = "Administrator" }); ctx.Roles.Add(new Role() { Name = "Magazijnier" }); ctx.Roles.Add(new Role() { Name = "Verkoper" }); ctx.SaveChanges(); ctx.Users.Add(new User("Nick", "Zubrzycki", "nickz", "nz1983", ctx.Roles.FirstOrDefault(r => r.RoleId == 1))); ctx.SaveChanges(); } }
private void Button_Click_Finish(object sender, RoutedEventArgs e) { if (cbCustomersAdd.SelectedItem != null && dpOrderAdd.SelectedDate != null && lbProductsAdd.Items != null) { Customer selected = cbCustomersAdd.SelectedItem as Customer; using (var ctx = new OrderManagerContext()) { Order order = new Order { Customer = ctx.Customers.FirstOrDefault(c => c.CustomerId == selected.CustomerId), OrderDate = (DateTime)dpOrderAdd.SelectedDate, OrderDetails = new List <OrderDetail>() }; foreach (Tuple <Product, int> item in lbProductsAdd.Items) { OrderDetail detail = new OrderDetail { Product = ctx.Products.FirstOrDefault(p => p.ProductId == item.Item1.ProductId), Quantity = item.Item2 }; order.OrderDetails.Add(detail); ctx.Products.FirstOrDefault(p => p.ProductId == detail.Product.ProductId).Stock = detail.Product.Stock - detail.Quantity; } ctx.Orders.Add(order); ctx.SaveChanges(); dgOrders.ItemsSource = null; var collection = ctx.OrderDetails.Join(ctx.Products, od => od.Product.ProductId, p => p.ProductId, (sc, p) => new { sc, p }) .GroupBy(c => c.sc.Order.OrderId); dgOrders.ItemsSource = ctx.Orders.Join(collection, o => o.OrderId, c => c.Key, (o, c) => new { OrderId = o.OrderId, Name = o.Customer.Name, OrderDate = o.OrderDate, TotalQ = c.Sum(s => s.sc.Quantity), TotalP = c.Sum(s => s.sc.Product.UnitPrice * s.sc.Quantity) }) .ToList(); cbOrders.ItemsSource = ctx.Orders.ToList(); } MessageBox.Show("Bestelling werd aangemaakt.", "", MessageBoxButton.OK, MessageBoxImage.Information); cbCustomersAdd.SelectedItem = null; dpOrderAdd.SelectedDate = null; lbProductsAdd.Items.Clear(); } else { MessageBox.Show("Bestelling aanmaken mislukt!\nNiet alle velden werden ingevuld.", "", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void Button_Click_EditUser(object sender, RoutedEventArgs e) { if (cbUsersEdit.SelectedItem != null) { User selectedUser = cbUsersEdit.SelectedItem as User; Role selectedRole = cbRolesEdit.SelectedItem as Role; using (var ctx = new OrderManagerContext()) { ctx.Users.FirstOrDefault(u => u.UserId == selectedUser.UserId).FirstName = txtVoornaamEdit.Text; ctx.Users.FirstOrDefault(u => u.UserId == selectedUser.UserId).LastName = txtAchternaamEdit.Text; ctx.Users.FirstOrDefault(u => u.UserId == selectedUser.UserId).Username = txtUsernameEdit.Text; ctx.Users.FirstOrDefault(u => u.UserId == selectedUser.UserId).Password = Encryption(txtPasswordEdit.Text); ctx.Users.FirstOrDefault(u => u.UserId == selectedUser.UserId).Role = ctx.Roles.FirstOrDefault(r => r.RoleId == selectedRole.RoleId); ctx.SaveChanges(); dgUsersAdd.ItemsSource = null; dgUsersAdd.ItemsSource = ctx.Users.Join(ctx.Roles, u => u.Role.RoleId, r => r.RoleId, (u, r) => new { FirstName = u.FirstName, LastName = u.LastName, Username = u.Username, Password = u.Password, Role = r.Name }).ToList(); dgUsersEdit.ItemsSource = null; dgUsersEdit.ItemsSource = ctx.Users.Join(ctx.Roles, u => u.Role.RoleId, r => r.RoleId, (u, r) => new { FirstName = u.FirstName, LastName = u.LastName, Username = u.Username, Password = u.Password, Role = r.Name }).ToList(); cbUsersEdit.ItemsSource = ctx.Users.ToList(); dgUsersDelete.ItemsSource = null; dgUsersDelete.ItemsSource = ctx.Users.Join(ctx.Roles, u => u.Role.RoleId, r => r.RoleId, (u, r) => new { FirstName = u.FirstName, LastName = u.LastName, Username = u.Username, Password = u.Password, Role = r.Name }).ToList(); cbUsersDelete.ItemsSource = ctx.Users.ToList(); } MessageBox.Show("De wijzigingen werden opgeslagen.", "", MessageBoxButton.OK, MessageBoxImage.Information); txtVoornaamEdit.Clear(); txtAchternaamEdit.Clear(); txtUsernameEdit.Clear(); txtPasswordEdit.Clear(); cbRolesEdit.SelectedItem = null; } else { MessageBox.Show("Gelieve eerst een user te selecteren.", "", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void Button_Click_EditProduct(object sender, RoutedEventArgs e) { if (cbProductsEdit.SelectedItem != null) { Product selectedProduct = cbProductsEdit.SelectedItem as Product; Supplier selectedSupplier = cbSuppliersProductEdit.SelectedItem as Supplier; using (var ctx = new OrderManagerContext()) { ctx.Products.FirstOrDefault(p => p.ProductId == selectedProduct.ProductId).Name = txtNaamProductEdit.Text; ctx.Products.FirstOrDefault(p => p.ProductId == selectedProduct.ProductId).UnitPrice = Convert.ToDouble(txtPrijsEdit.Text); ctx.Products.FirstOrDefault(p => p.ProductId == selectedProduct.ProductId).Stock = Convert.ToInt32(txtAantalEdit.Text); ctx.Products.FirstOrDefault(p => p.ProductId == selectedProduct.ProductId).Supplier = ctx.Suppliers.FirstOrDefault(s => s.SupplierId == selectedSupplier.SupplierId); ctx.SaveChanges(); dgProductsAdd.ItemsSource = null; dgProductsAdd.ItemsSource = ctx.Products.GroupJoin(ctx.Suppliers, p => p.Supplier.SupplierId, s => s.SupplierId, (p, s) => new { Name = p.Name, UnitPrice = p.UnitPrice, Stock = p.Stock, Supplier = p.Supplier.Name }).ToList(); dgProductsEdit.ItemsSource = null; dgProductsEdit.ItemsSource = ctx.Products.GroupJoin(ctx.Suppliers, p => p.Supplier.SupplierId, s => s.SupplierId, (p, s) => new { Name = p.Name, UnitPrice = p.UnitPrice, Stock = p.Stock, Supplier = p.Supplier.Name }).ToList(); cbProductsEdit.ItemsSource = ctx.Products.ToList(); dgProductsDelete.ItemsSource = null; dgProductsDelete.ItemsSource = ctx.Products.GroupJoin(ctx.Suppliers, p => p.Supplier.SupplierId, s => s.SupplierId, (p, s) => new { Name = p.Name, UnitPrice = p.UnitPrice, Stock = p.Stock, Supplier = p.Supplier.Name }).ToList(); cbProductsDelete.ItemsSource = ctx.Products.ToList(); } MessageBox.Show("De wijzigingen werden opgeslagen.", "", MessageBoxButton.OK, MessageBoxImage.Information); txtNaamProductEdit.Clear(); txtPrijsEdit.Clear(); txtAantalEdit.Clear(); cbSuppliersProductEdit.SelectedItem = null; } else { MessageBox.Show("Gelieve eerst een product te selecteren.", "", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void Button_Click_AddProduct(object sender, RoutedEventArgs e) { if (txtNaamProductAdd.Text != null && txtPrijsAdd.Text != null && txtAantalAdd.Text != null && cbSuppliersAdd.SelectedItem != null) { Supplier selected = cbSuppliersAdd.SelectedItem as Supplier; using (var ctx = new OrderManagerContext()) { ctx.Products.Add(new Product() { Name = txtNaamProductAdd.Text, UnitPrice = Convert.ToDouble(txtPrijsAdd.Text), Stock = Convert.ToInt32(txtAantalAdd.Text), Supplier = ctx.Suppliers.FirstOrDefault(s => s.SupplierId == selected.SupplierId) }); ctx.SaveChanges(); dgProductsAdd.ItemsSource = null; dgProductsAdd.ItemsSource = ctx.Products.GroupJoin(ctx.Suppliers, p => p.Supplier.SupplierId, s => s.SupplierId, (p, s) => new { Name = p.Name, UnitPrice = p.UnitPrice, Stock = p.Stock, Supplier = p.Supplier.Name }).ToList(); dgProductsEdit.ItemsSource = null; dgProductsEdit.ItemsSource = ctx.Products.GroupJoin(ctx.Suppliers, p => p.Supplier.SupplierId, s => s.SupplierId, (p, s) => new { Name = p.Name, UnitPrice = p.UnitPrice, Stock = p.Stock, Supplier = p.Supplier.Name }).ToList(); cbProductsEdit.ItemsSource = ctx.Products.ToList(); dgProductsDelete.ItemsSource = null; dgProductsDelete.ItemsSource = ctx.Products.GroupJoin(ctx.Suppliers, p => p.Supplier.SupplierId, s => s.SupplierId, (p, s) => new { Name = p.Name, UnitPrice = p.UnitPrice, Stock = p.Stock, Supplier = p.Supplier.Name }).ToList(); cbProductsDelete.ItemsSource = ctx.Products.ToList(); } MessageBox.Show("Product werd toegevoegd.", "", MessageBoxButton.OK, MessageBoxImage.Information); txtNaamProductAdd.Clear(); txtPrijsAdd.Clear(); txtAantalAdd.Clear(); cbSuppliersAdd.SelectedItem = null; } else { MessageBox.Show("Product toevoegen mislukt!\nNiet alle velden werden ingevuld.", "", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void Button_Click_AddUser(object sender, RoutedEventArgs e) { if (txtVoornaamAdd.Text != null && txtAchternaamAdd.Text != null && txtUsernameAdd.Text != null && txtPasswordAdd.Text != null && cbRolesAdd.SelectedItem != null) { Role selected = cbRolesAdd.SelectedItem as Role; using (var ctx = new OrderManagerContext()) { ctx.Users.Add(new User(txtVoornaamAdd.Text, txtAchternaamAdd.Text, txtUsernameAdd.Text, txtPasswordAdd.Text, ctx.Roles.FirstOrDefault(r => r.RoleId == selected.RoleId))); ctx.SaveChanges(); dgUsersAdd.ItemsSource = null; dgUsersAdd.ItemsSource = ctx.Users.Join(ctx.Roles, u => u.Role.RoleId, r => r.RoleId, (u, r) => new { FirstName = u.FirstName, LastName = u.LastName, Username = u.Username, Password = u.Password, Role = r.Name }).ToList(); dgUsersEdit.ItemsSource = null; dgUsersEdit.ItemsSource = ctx.Users.Join(ctx.Roles, u => u.Role.RoleId, r => r.RoleId, (u, r) => new { FirstName = u.FirstName, LastName = u.LastName, Username = u.Username, Password = u.Password, Role = r.Name }).ToList(); cbUsersEdit.ItemsSource = ctx.Users.ToList(); dgUsersDelete.ItemsSource = null; dgUsersDelete.ItemsSource = ctx.Users.Join(ctx.Roles, u => u.Role.RoleId, r => r.RoleId, (u, r) => new { FirstName = u.FirstName, LastName = u.LastName, Username = u.Username, Password = u.Password, Role = r.Name }).ToList(); cbUsersDelete.ItemsSource = ctx.Users.ToList(); } MessageBox.Show("User werd toegevoegd.", "", MessageBoxButton.OK, MessageBoxImage.Information); txtVoornaamAdd.Clear(); txtAchternaamAdd.Clear(); txtUsernameAdd.Clear(); txtPasswordAdd.Clear(); cbRolesAdd.SelectedItem = null; } else { MessageBox.Show("User toevoegen mislukt!\nNiet alle velden werden ingevuld.", "", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void Button_Click_DeleteCustomer(object sender, RoutedEventArgs e) { if (cbCustomersDelete.SelectedItem != null) { Customer selected = cbCustomersDelete.SelectedItem as Customer; using (var ctx = new OrderManagerContext()) { ctx.OrderDetails.RemoveRange(ctx.OrderDetails.Where(od => od.Order.Customer.CustomerId == selected.CustomerId)); ctx.Orders.RemoveRange(ctx.Orders.Where(o => o.Customer.CustomerId == selected.CustomerId)); ctx.Customers.Remove(ctx.Customers.FirstOrDefault(c => c.CustomerId == selected.CustomerId)); var collection = ctx.OrderDetails.Join(ctx.Products, od => od.Product.ProductId, p => p.ProductId, (od, p) => new { od, p }) .Join(ctx.Customers, sc => sc.od.Order.Customer.CustomerId, cu => cu.CustomerId, (sc, cu) => new { sc, cu }) .Where(c => c.cu.CustomerId == selected.CustomerId).ToList(); foreach (var item in collection) { ctx.Products.FirstOrDefault(p => p.ProductId == item.sc.p.ProductId).Stock = item.sc.p.Stock + item.sc.od.Quantity; } ctx.SaveChanges(); dgCustomersAdd.ItemsSource = null; dgCustomersAdd.ItemsSource = ctx.Customers.ToList(); dgCustomersEdit.ItemsSource = null; dgCustomersEdit.ItemsSource = ctx.Customers.ToList(); cbCustomersEdit.ItemsSource = ctx.Customers.ToList(); dgCustomersDelete.ItemsSource = null; dgCustomersDelete.ItemsSource = ctx.Customers.ToList(); cbCustomersDelete.ItemsSource = ctx.Customers.ToList(); } MessageBox.Show("De klant werd verwijderd.", "", MessageBoxButton.OK, MessageBoxImage.Information); } else { MessageBox.Show("Gelieve eerst een klant te selecteren.", "", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void Button_Click_DeleteProduct(object sender, RoutedEventArgs e) { if (cbProductsDelete.SelectedItem != null) { Product selected = cbProductsDelete.SelectedItem as Product; using (var ctx = new OrderManagerContext()) { ctx.OrderDetails.RemoveRange(ctx.OrderDetails.Where(od => od.Product.ProductId == selected.ProductId)); ctx.Products.Remove(ctx.Products.FirstOrDefault(p => p.ProductId == selected.ProductId)); ctx.SaveChanges(); dgProductsAdd.ItemsSource = null; dgProductsAdd.ItemsSource = ctx.Products.GroupJoin(ctx.Suppliers, p => p.Supplier.SupplierId, s => s.SupplierId, (p, s) => new { Name = p.Name, UnitPrice = p.UnitPrice, Stock = p.Stock, Supplier = p.Supplier.Name }).ToList(); dgProductsEdit.ItemsSource = null; dgProductsEdit.ItemsSource = ctx.Products.GroupJoin(ctx.Suppliers, p => p.Supplier.SupplierId, s => s.SupplierId, (p, s) => new { Name = p.Name, UnitPrice = p.UnitPrice, Stock = p.Stock, Supplier = p.Supplier.Name }).ToList(); cbProductsEdit.ItemsSource = ctx.Products.ToList(); dgProductsDelete.ItemsSource = null; dgProductsDelete.ItemsSource = ctx.Products.GroupJoin(ctx.Suppliers, p => p.Supplier.SupplierId, s => s.SupplierId, (p, s) => new { Name = p.Name, UnitPrice = p.UnitPrice, Stock = p.Stock, Supplier = p.Supplier.Name }).ToList(); cbProductsDelete.ItemsSource = ctx.Products.ToList(); } MessageBox.Show("Het product werd verwijderd.", "", MessageBoxButton.OK, MessageBoxImage.Information); } else { MessageBox.Show("Gelieve eerst een product te selecteren.", "", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void Button_Click_Delete(object sender, RoutedEventArgs e) { if (cbOrders.SelectedItem != null) { Order selected = cbOrders.SelectedItem as Order; using (var ctx = new OrderManagerContext()) { ctx.Orders.Remove(ctx.Orders.FirstOrDefault(o => o.OrderId == selected.OrderId)); ctx.OrderDetails.RemoveRange(ctx.OrderDetails.Where(od => od.Order.OrderId == selected.OrderId)); foreach (OrderDetail item in selected.OrderDetails) { ctx.Products.FirstOrDefault(p => p.ProductId == item.Product.ProductId).Stock = item.Product.Stock + item.Quantity; } ctx.SaveChanges(); var collection = ctx.OrderDetails.Join(ctx.Products, od => od.Product.ProductId, p => p.ProductId, (sc, p) => new { sc, p }) .GroupBy(c => c.sc.Order.OrderId); dgOrders.ItemsSource = ctx.Orders.Join(collection, o => o.OrderId, c => c.Key, (o, c) => new { OrderId = o.OrderId, Name = o.Customer.Name, OrderDate = o.OrderDate, TotalQ = c.Sum(s => s.sc.Quantity), TotalP = c.Sum(s => s.sc.Product.UnitPrice * s.sc.Quantity) }) .ToList(); cbOrders.ItemsSource = ctx.Orders.ToList(); } MessageBox.Show("De bestelling werd verwijderd.", "", MessageBoxButton.OK, MessageBoxImage.Information); } else { MessageBox.Show("Gelieve eerst een bestelling te selecteren.", "", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void Button_Click_DeleteUser(object sender, RoutedEventArgs e) { if (cbUsersDelete.SelectedItem != null) { User selected = cbUsersDelete.SelectedItem as User; using (var ctx = new OrderManagerContext()) { ctx.Users.Remove(ctx.Users.FirstOrDefault(u => u.UserId == selected.UserId)); ctx.SaveChanges(); dgUsersAdd.ItemsSource = null; dgUsersAdd.ItemsSource = ctx.Users.Join(ctx.Roles, u => u.Role.RoleId, r => r.RoleId, (u, r) => new { FirstName = u.FirstName, LastName = u.LastName, Username = u.Username, Password = u.Password, Role = r.Name }).ToList(); dgUsersEdit.ItemsSource = null; dgUsersEdit.ItemsSource = ctx.Users.Join(ctx.Roles, u => u.Role.RoleId, r => r.RoleId, (u, r) => new { FirstName = u.FirstName, LastName = u.LastName, Username = u.Username, Password = u.Password, Role = r.Name }).ToList(); cbUsersEdit.ItemsSource = ctx.Users.ToList(); dgUsersDelete.ItemsSource = null; dgUsersDelete.ItemsSource = ctx.Users.Join(ctx.Roles, u => u.Role.RoleId, r => r.RoleId, (u, r) => new { FirstName = u.FirstName, LastName = u.LastName, Username = u.Username, Password = u.Password, Role = r.Name }).ToList(); cbUsersDelete.ItemsSource = ctx.Users.ToList(); } MessageBox.Show("De user werd verwijderd.", "", MessageBoxButton.OK, MessageBoxImage.Information); } else { MessageBox.Show("Gelieve eerst een user te selecteren.", "", MessageBoxButton.OK, MessageBoxImage.Error); } }