//Add data. private void btnOK_Click(object sender, RoutedEventArgs e) { if (!_proxy.CheckExistence(txtName.Text, dataType)) { if (_proxy.AddData(txtName.Text, dataType) == null) { MessageBox.Show("Something went wrong. This type was not addded.", "Wrong", MessageBoxButton.OK, MessageBoxImage.Error); return; } } switch (dataType) { case ServerData.Example: FormData.ExampleID = _proxy.GetItemsId(txtName.Text, ServerData.Example); break; case ServerData.Translation: FormData.TranslationID = _proxy.GetItemsId(txtName.Text, ServerData.Translation); break; case ServerData.Definition: FormData.DefinitionID = _proxy.GetItemsId(txtName.Text, ServerData.Definition); break; case ServerData.Group: FormData.GroupID = _proxy.GetItemsId(txtName.Text, ServerData.Group); break; case ServerData.GrammarExample: FormData.GrExampleID = _proxy.GetItemsId(txtName.Text, ServerData.GrammarExample); break; case ServerData.GrammarException: FormData.ExceptionID = _proxy.GetItemsId(txtName.Text, ServerData.GrammarException); break; case ServerData.Rule: FormData.RuleID = _proxy.GetItemsId(txtName.Text, ServerData.Rule); break; } Close(); return; }
//Add an author. private void btnOK_Click(object sender, RoutedEventArgs e) { if (!_proxy.CheckExistence(txtName.Text, dataType)) { if (id == null) { if (_proxy.AddData(txtName.Text, dataType) == null) { MessageBox.Show("Something went wrong. This category was not addded.", "Wrong", MessageBoxButton.OK, MessageBoxImage.Error); return; } } else { _proxy.EditData(Convert.ToInt32(id), txtName.Text, dataType, PropertyData.Name); } Close(); } else { MessageBox.Show("This category already exists!", "Wrong.", MessageBoxButton.OK, MessageBoxImage.Error); } }