private void BtnDeleteProduct(object sender, RoutedEventArgs e) { Product p = new Product(); p.ProductID = long.Parse(txtProdId.Text); string msg = da.DeleteProduct(p); MessageBox.Show("" + msg); if (msg.Equals("Product Discontinued")) { MainWindow mw = Application.Current.Windows.OfType <MainWindow>().FirstOrDefault(); if (mw != null) { mw.MainFrame.Content = new ManageProducts(); } } }