public static Boolean deleteProduct(int pc) { if (ServiceOrders.isProductOrederd(pc)) { return(false); } else { String cmd = "alter table orderedProducts nocheck constraint all;alter table activeDiscounts nocheck constraint all;delete from products where Code = ('" + pc + "');alter table activeDiscounts check constraint all;alter table orderedProducts check constraint all"; // String cmd = "DELETE FROM products WHERE code = ('" + pc + "')"; if (dbConnection.insertQuery(cmd) == 1) { return(true); } } return(false); }
private void BtnDeleteProduct_Click(object sender, RoutedEventArgs e) { if (ServiceOrders.isProductOrederd(productCode)) { MessageBox.Show("can not delete an ordered product", "info", MessageBoxButton.OK, MessageBoxImage.Information); } else { if (productCode != -1 && ServiceProducts.deleteProduct(productCode)) { loadProductsToDataGrid(); clearInputs(); } else { MessageBox.Show("something went wrong deleting a product", "info", MessageBoxButton.OK, MessageBoxImage.Information); } } }