private void BtnDeleteCategory(object sender, RoutedEventArgs e) { if (!txtCatId.Text.Equals("")) { Category c = new Category(); c.CategoryID = Int32.Parse(txtCatId.Text); string msg = da.DeleteCategory(c); MessageBox.Show("" + msg); if (msg.Equals("Category Discontinued Successful")) { MainWindow mw = Application.Current.Windows.OfType <MainWindow>().FirstOrDefault(); if (mw != null) { mw.MainFrame.Content = new ManageCategories(); } } } else { MessageBox.Show("Category Id can't be empty"); } }