private void DeleteButtonOnToolBarItemClick(object sender, ItemClickEventArgs e) { if (CategoryTreeListControl.SelectedItem is Category category) { if (MessageBoxService.AskForDelete(category.Title) == true) { using (var dbContext = new FarnahadManufacturingDbContext()) { var categoryInDb = dbContext.Categories.First(item => item.Id == category.Id); if (dbContext.Categories.Any(item => item.ParentCategoryId == categoryInDb.Id)) { MessageBoxService.CannotDeleteParent(categoryInDb.Title); } else { dbContext.Categories.Remove(categoryInDb); dbContext.SaveChanges(); LoadCategories(); LoadCategoriesTreeList(); } } } } else { // No Valid Item Selected } }
private void DeleteItemButtonOnClick(object sender, RoutedEventArgs e) { var activeCarrierService = CarrierServiceGridControl.SelectedItem as CarrierService; if (MessageBoxService.AskForDelete(activeCarrierService.Title) == true) { _carrierServices.Remove(activeCarrierService); } }
private void AddEditDeleteListUserControlOnClickOnDeleteItem(object sender, RoutedEventArgs e) { if (ReorderInformationGridControl.SelectedItem is PartReorderInformation partReorderInformation) { if (MessageBoxService.AskForDelete() == true) { if (ReorderInformationGridControl.ItemsSource is ObservableCollection <PartReorderInformation> partReorderInformations) { partReorderInformations.Remove(partReorderInformation); } } } }
private void ProductAssociatePriceListUserControlOnClickOnDeleteItem(object sender, RoutedEventArgs e) { if (ProductAssociatePriceGridControl.SelectedItem is ProductAssociatePrice productAssociatePrice) { if (MessageBoxService.AskForDelete() == true) { if (ProductAssociatePriceGridControl.ItemsSource is ObservableCollection <ProductAssociatePrice> productAssociatePrices) { productAssociatePrices.Remove(productAssociatePrice); } } } }
protected override void OnDeleteToolBarItem() { if (MessageBoxService.AskForDelete(_activeCity.Title) == true) { using (var dbContext = new FarnahadManufacturingDbContext()) { var city = dbContext.Cities.Find(_activeCity.Id); dbContext.Cities.Remove(city); dbContext.SaveChanges(); } LoadSearchGridControl(); _activeCity = new City(); } IsNotEditingAndAdding(); }
protected override void OnDeleteToolBarItem() { if (MessageBoxService.AskForDelete(_activePart.Title) == true) { using (var dbContext = new FarnahadManufacturingDbContext()) { var partInDb = dbContext.Parts.FirstOrDefault(item => item.Id == _activePart.Id); dbContext.Parts.Remove(partInDb); dbContext.SaveChanges(); } LoadSearchGridControl(); _activePart = new Part(); IsNotEditingAndAdding(); } }
protected override void OnDeleteToolBarItem() { if (MessageBoxService.AskForDelete(_activeUser.UserName) == true) { using (var dbContext = new FarnahadManufacturingDbContext()) { var user = dbContext.Users.Find(_activeUser.Id); dbContext.Users.Remove(user); dbContext.SaveChanges(); } LoadSearchGridControl(); _activeUser = new User(); IsNotEditingAndAdding(); } }
protected override void OnDeleteToolBarItem() { if (MessageBoxService.AskForDelete(_activeAddressType.Title) == true) { using (var dbContext = new FarnahadManufacturingDbContext()) { var addressType = dbContext.AddressTypes.Find(_activeAddressType.Id); dbContext.AddressTypes.Remove(addressType); dbContext.SaveChanges(); } LoadSearchGridControl(); _activeAddressType = new AddressType(); IsNotEditingAndAdding(); } }
protected override void OnDeleteToolBarItem() { if (MessageBoxService.AskForDelete(_activeShippingTerm.Title) == true) { using (var dbContext = new FarnahadManufacturingDbContext()) { var shippingTerm = dbContext.ShippingTerms.Find(_activeShippingTerm.Id); dbContext.ShippingTerms.Remove(shippingTerm); dbContext.SaveChanges(); } LoadSearchGridControl(); _activeShippingTerm = new ShippingTerm(); IsNotEditingAndAdding(); } }
protected override void OnDeleteToolBarItem() { if (MessageBoxService.AskForDelete(_activeLocation.Title) == true) { using (var dbContext = new FarnahadManufacturingDbContext()) { var locationInDb = dbContext.Locations.Find(_activeLocation.Id); dbContext.Locations.Remove(locationInDb); dbContext.SaveChanges(); } LoadSearchGridControl(); _activeLocation = new Location(); IsNotEditingAndAdding(); } }
protected override void OnDeleteToolBarItem() { if (MessageBoxService.AskForDelete(_activeTracking.Title) == true) { using (var dbContext = new FarnahadManufacturingDbContext()) { var tracking = dbContext.Trackings.Find(_activeTracking.Id); dbContext.Trackings.Remove(tracking); dbContext.SaveChanges(); } LoadSearchGridControl(); _activeTracking = new Tracking(); IsNotEditingAndAdding(); } }
protected override void OnDeleteToolBarItem() { if (MessageBoxService.AskForDelete(_activeCountry.Title) == true) { using (var dbContext = new FarnahadManufacturingDbContext()) { var country = dbContext.Countries.Find(_activeCountry.Id); dbContext.Countries.Remove(country); dbContext.SaveChanges(); } LoadSearchGridControl(); _activeCountry = new Country(); MainLayoutGroup.IsEnabled = false; } IsNotEditingAndAdding(); }
private void OnDeleteClickButton(object sender, RoutedEventArgs e) { if (ProductCategoriesTreeListControl.SelectedItem is ProductCategory productCategory) { if (MessageBoxService.AskForDelete(productCategory.Title) == true) { using (var dbContext = new FarnahadManufacturingDbContext()) { var productCategoryInDb = dbContext.ProductCategories.First(item => item.Id == productCategory.Id); dbContext.ProductCategories.Remove(productCategoryInDb); dbContext.SaveChanges(); } } } else { // No Valid Item Selected } }
protected override void OnDeleteToolBarItem() { if (MessageBoxService.AskForDelete(_activeVendor.Title) == true) { using (var dbContext = new FarnahadManufacturingDbContext()) { var vendor = dbContext.Vendors .Include(item => item.Addresses) .Include("Addresses.ContactInformations") .First(item => item.Id == _activeVendor.Id); foreach (var address in vendor.Addresses) { dbContext.ContactInformations.RemoveRange(address.ContactInformations); } dbContext.Addresses.RemoveRange(vendor.Addresses); dbContext.Vendors.Remove(vendor); dbContext.SaveChanges(); } LoadSearchGridControl(); _activeVendor = new Vendor(); IsNotEditingAndAdding(); } }