private void BtnAddcategory(object sender, RoutedEventArgs e) { if (!(txtCId.Text.Equals("") || txtCName.Text.Equals("") || txtDescr.Text.Equals(""))) { Category c = new Category(); c.CategoryID = Int32.Parse(txtCId.Text); c.CategoryName = txtCName.Text; c.Description = txtDescr.Text; string msg = da.AddCategory(c); MessageBox.Show("" + msg); if (msg.Equals("Category Added")) { MainWindow mw = Application.Current.Windows.OfType <MainWindow>().FirstOrDefault(); if (mw != null) { mw.MainFrame.Content = new ManageCategories(); } } } else { MessageBox.Show("Make sure all textbox are full"); } }