protected virtual void OnValidateClientData(ClientInformationEventArgs e) { if (ValidateClientData != null) { ValidateClientData(this, e); } }
void dialog_Validate(object sender, ClientInformationEventArgs e) { string error = string.Empty; InsertModifyClientDialog dialog = (InsertModifyClientDialog)sender; e.IsValid = true; // Clear existing errors dialog.ValidateAeTitle(string.Empty); dialog.ValidateAddress(string.Empty); dialog.ValidateMask(string.Empty); dialog.ValidatePort(string.Empty); dialog.ValidateSecurePort(string.Empty); // AETitle if (!Utils.IsValidApplicationEntity(e.ClientInformation.Client.AETitle, out error)) { dialog.ValidateAeTitle(error); e.IsValid = false; } else if (e.IsInsert && (ClientInformationList.ClientDictionary.ContainsKey(e.ClientInformation.Client.AETitle.Trim()))) { // insert -- verify AeTile does not already exist dialog.ValidateAeTitle("Duplicate Application Entity Title."); e.IsValid = false; } else if (!e.IsInsert && e.IsNewAeTitle && (ClientInformationList.ClientDictionary.ContainsKey(e.ClientInformation.Client.AETitle.Trim()))) { // modify and the aeTitle has changed -- verify the AeTitle does not already exist dialog.ValidateAeTitle("Duplicate Application Entity Title."); e.IsValid = false; } else if (e.ClientInformation.Client.VerifyAddress && !Utils.IsValidHostnameOrAddress(e.ClientInformation.Client.Address, out error)) { // Address dialog.ValidateAddress(error); e.IsValid = false; } else if (e.ClientInformation.Client.VerifyMask && !Utils.IsValidHostnameOrAddress(e.ClientInformation.Client.Mask, out error)) { // Mask dialog.ValidateMask(error); e.IsValid = false; } else if (e.ClientInformation.Client.Port == 0) { // port dialog.ValidatePort("Port must be non-zero"); e.IsValid = false; } else if (e.ClientInformation.Client.SecurePort == 0) { // secure port dialog.ValidateSecurePort("Port must be non-zero"); e.IsValid = false; } }
private void buttonOK_Click(object sender, EventArgs e) { ClientInformationEventArgs eventArgs = new ClientInformationEventArgs(); eventArgs.IsInsert = DialogType == InsertModifyClientControlType.Insert; eventArgs.IsValid = true; eventArgs.ClientInformation = this.ClientInformation; this.ClientInformation.Client.LastAccessDate = DateTime.Now; string newAeTitle = ClientInformation.Client.AETitle.Trim(); eventArgs.IsNewAeTitle = string.Compare(newAeTitle, _originalAeTitle, true) != 0; OnValidateClientData(eventArgs); if (eventArgs.IsValid) { DialogResult = DialogResult.OK; Close(); } }