private void OnFormClose(object sender, FormClosedEventArgs e) { _instance = null; global.SaveFormSettings(this); if (_updateParent) { _parentForm.RefreshLists(); } }
private void OnButtonClick(object sender, EventArgs e) { switch (((Button)sender).Name) { case "btnOk": var success = false; if (cboLocalName.Text.Length > 0 && cboLanguage.Text.Length > 0 && cboSpeciesName.Text.Length > 0) { switch (_idType) { case Identification.LocalName: success = Names.SaveNewLocalSpeciesNameLanguage( ((KeyValuePair <string, string>)cboSpeciesName.SelectedItem).Key, ((KeyValuePair <string, string>)cboLanguage.SelectedItem).Key, _selectedNameGuid ); break; case Identification.Scientific: success = Names.SaveNewLocalSpeciesNameLanguage( _selectedNameGuid, ((KeyValuePair <string, string>)cboLanguage.SelectedItem).Key, ((KeyValuePair <string, string>)cboLocalName.SelectedItem).Key ); break; } if (success) { _parentForm.RefreshLists(); switch (_idType) { case Identification.LocalName: cboSpeciesName.Text = ""; break; case Identification.Scientific: cboLocalName.Text = ""; cboLocalName.Focus(); break; } } else { MessageBox.Show("The species name-local name-language combination is already in the database", "Validation error", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("All fields must be filled up", "Validation error", MessageBoxButtons.OK, MessageBoxIcon.Information); } break; case "btnCancel": Close(); break; } }