public void OkDialog() { if (ExistingNames.Contains(textName.Text)) { var message = TextUtil.LineSeparate( string.Format(Resources.RenameResultDlg_ReplicateName_The_name__0__is_already_in_use, textName.Text), Resources.RenameResultDlg_OkDialog_Please_use_a_different_name); MessageDlg.Show(this, message); return; } DialogResult = DialogResult.OK; }
public bool ValidateForm() { // Sanity check to avoid empty string names txtName.Text = txtName.Text.Trim(); if ((string.IsNullOrEmpty(txtName.Text.Trim()))) { MessageBox.Show(string.Format("You must provide a unique name for the {0}.", Noun), GCDCore.Properties.Resources.ApplicationNameLong, MessageBoxButtons.OK, MessageBoxIcon.Information); txtName.Select(); return(false); } if (ExistingNames.Contains(txtName.Text)) { MessageBox.Show(string.Format("There is another {0} in this GCD Project that possesses this name. You must provide a unique name for the {0}.", Noun), GCDCore.Properties.Resources.ApplicationNameLong, MessageBoxButtons.OK, MessageBoxIcon.Information); txtName.Select(txtName.Text.Length, 0); return(false); } return(true); }
/// <summary> /// Validates the form field. /// </summary> private bool ValidateField() { string name = ItemName; if (name == "") { ScadaUiUtils.ShowError(AppPhrases.ItemNameEmpty); return(false); } if (!AdminUtils.NameIsValid(name)) { ScadaUiUtils.ShowError(AppPhrases.ItemNameInvalid); return(false); } if (ExistingNames != null && ExistingNames.Contains(name.ToLowerInvariant())) { ScadaUiUtils.ShowError(AppPhrases.ItemNameDuplicated); return(false); } return(true); }