private void btnAddEntry_Click(object sender, RoutedEventArgs e) { try { // sets headache type to headacheObj headacheObj.AcheType = comboAcheType.Text; // sets pain intensity to headacheObj Int32.TryParse(PainLevel.Text.ToString(), out int painLvl); headacheObj.PainLevel = painLvl; bool result = DatabaseAccess.AddToSQLite(headacheObj); if (result == false) { MessageBox.Show("Could not add entry", "Adding error", MessageBoxButton.OK); } // closes this window this.Close(); } catch (InvalidOperationException ex) // Näyttää virheviestin { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK); } }