/// <summary> /// Handles the Click event of the btnOK control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void btnOK_Click(object sender, EventArgs e) { // Validate the sender email is not empty if (!FormHelper.ValidateNotEmpty(txtSenderEmail, Resources.MsgSenderEmailRequired)) { return; } // Validate the email subject is not empty if (!FormHelper.ValidateNotEmpty(txtMailSubject, Resources.MsgEmailSubjectRequired)) { return; } // Validate SMTP server is not empty if (!FormHelper.ValidateNotEmpty(txtSMTPServer, Resources.MsgSmtpServerRequired)) { return; } // If checked then user name and password must be entered if (chkRequireAuthentication.Checked) { if (!FormHelper.ValidateNotEmpty(txtUserName, Resources.MsgSmtpInformationRequired)) { return; } if (!FormHelper.ValidateNotEmpty(txtPassword, Resources.MsgSmtpInformationRequired)) { return; } } try { // Delete all records EmailConfig.Delete(config => true); // Save current record EmailConfig emailConfig = new EmailConfig(); emailConfig.SenderEmail = txtSenderEmail.Text.Trim(); emailConfig.MailSubject = txtMailSubject.Text.Trim(); emailConfig.SmtpServer = txtSMTPServer.Text.Trim(); emailConfig.Authentication = chkRequireAuthentication.Checked; emailConfig.UserName = txtUserName.Text.Trim(); emailConfig.UserPassword = txtPassword.Text; emailConfig.Save(); FormHelper.ShowInfo(Resources.MsgEmailConfigSaved); this.Close(); } catch (Exception ex) { FormHelper.ShowError(ex.Message); } }