protected override void OnClosing(CancelEventArgs e) { if (DialogResult != DialogResult.Cancel) { try { System.Net.ServicePointManager.ServerCertificateValidationCallback = ((sender, certificate, chain, sslPolicyErrors) => true); PLMPackServiceClient client = WCFClientSingleton.ClientGuest; if (null != client.Connect()) { e.Cancel = true; } string userName = client.EmailToUserName(Email); string email = client.UserNameToEmail(UserName); if (!string.IsNullOrEmpty(userName)) { MessageBox.Show(string.Format(Properties.Resources.ID_EMAILALREADYUSED, Email)); e.Cancel = true; } else if (!string.IsNullOrEmpty(email)) { MessageBox.Show(string.Format(Properties.Resources.ID_USERNAMEALREADYUSED, UserName)); e.Cancel = true; } else if (client.CreateUser(UserName, UserPassword, FirstName, LastName, Email, Country, City, PhoneNumber, Company, WebSiteURL)) { MessageBox.Show(string.Format(Properties.Resources.ID_USERSUCCESSFULLYCREATED, UserName)); e.Cancel = false; } } catch (Exception ex) { _log.Error(ex.Message); } } base.OnClosing(e); }