private void AddClassificationButton_Click(object sender, RoutedEventArgs e) { try { string conceptName; int conceptId; if (ConceptsRootComboBox.SelectedValue != null) { conceptName = ConceptsRootComboBox.SelectedValue.ToString(); conceptId = _concepts.First(c => c.Value == conceptName).Key; } else if (ConceptsRootComboBox.Text.Length != 0) { conceptName = ConceptsRootComboBox.Text; conceptId = _SQLClient.InsertConceptIdentity(conceptName); } else { throw new ArgumentException("Поле с понятием должно быть заполнено."); } _SQLClient.InsertClassification( ClassificationTypeComboBox.Text, conceptId, ClassificationBaseTextBox.Text ); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error"); } Frames.Classifications.Instance.SelectClassifications(); Frames.Concepts.Instance.SelectClassifications(); Graphs.TreeVisualizationPage.Instance.SelectClassifications(); }
private void AddClassificationToPropertyButton_Click(object sender, RoutedEventArgs e) { try { if (_SelectedClassificationId < 0) { return; } int selectedConceptId; int selectedParentId; if (ConceptsComboBox.SelectedValue != null) { selectedConceptId = _conceptsOutsideClassification .First(c => c.Value == ConceptsComboBox.SelectedValue.ToString()) .Key; } else { if (ConceptsComboBox.Text.Length == 0) { throw new Exception("Поле с понятием не должно быть пустым"); } if (_conceptsInClassification.Values.Contains(ConceptsComboBox.Text)) { throw new Exception("Понятие уже находится в классификации"); } selectedConceptId = _SQLClient.InsertConceptIdentity(ConceptsComboBox.Text); } if (ParentConceptComboBox.SelectedValue != null) { selectedParentId = _conceptsInClassification .First(c => c.Value == ParentConceptComboBox.SelectedValue.ToString()) .Key; } else { if (ParentConceptComboBox.Text.Length == 0) { throw new Exception("Поле с понятием не должно быть пустым"); } if (!_conceptsInClassification.Values.Contains(ConceptsComboBox.Text)) { throw new Exception("Родительское понятие должно находиться в классификации"); } selectedParentId = _conceptsInClassification .First(c => c.Value == ParentConceptComboBox.Text) .Key; } _SQLClient.InsertConceptToClassification( _SelectedClassificationId, selectedConceptId, selectedParentId, SpeciesDifferenceTextBox.Text ); SelectConceptsOutsideClassification(); SelectConceptsFromClassification(); if (Sender is TreeVisualizationPage) { TreeVisualizationPage.Instance.GenerateGraph(); } else if (Sender is Frames.Classifications) { Frames.Classifications.Instance.SelectClassificationConcepts(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка"); } }