public void OkDialog() { var helper = new MessageBoxHelper(this); string name; if (!helper.ValidateNameTextBox(textName, out name)) return; string cleavageC; if (!helper.ValidateAATextBox(textCleavage, false, out cleavageC)) return; string restrictC; if (!helper.ValidateAATextBox(textRestrict, true, out restrictC)) return; string cleavageN; string restrictN; if (comboDirection.SelectedIndex == 2) { if (!helper.ValidateAATextBox(textCleavageN, false, out cleavageN)) return; if (!helper.ValidateAATextBox(textRestrictN, true, out restrictN)) return; } else if (comboDirection.SelectedIndex == 1) { cleavageN = cleavageC; cleavageC = null; restrictN = restrictC; restrictC = null; } else { cleavageN = null; restrictN = null; } Enzyme enzyme = new Enzyme(name, cleavageC, restrictC, cleavageN, restrictN); if (_enzyme == null && _existing.Contains(enzyme)) { helper.ShowTextBoxError(textName, Resources.EditEnzymeDlg_OnClosing_The_enzyme__0__already_exists, name); return; } _enzyme = enzyme; DialogResult = DialogResult.OK; }