/// <summary> /// send email /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnFind_Click(object sender, EventArgs e) { CancelEventArgs cea = new CancelEventArgs(); txtUsername_Validating(sender, cea); txtEmail_Validating(sender, cea); if (cea.Cancel == false) { UserService.UserServiceClient client = new UserService.UserServiceClient(); bool result = client.ValidateUserAndEmail(this.txtUsername.Text.Trim(), this.txtEmail.Text.Trim()); //If has sent email, refuse send again in one minute. if (FormPassValue.isSendEmail) { TipForm tipForm = new TipForm(); tipForm.SetMessage(ResourceCulture.GetString(HAS_SEND_MAIL)); tipForm.SetIsShowCancel(false); tipForm.ShowDialog(); this.DialogResult = DialogResult.OK; this.Owner.Show(); return; } //validate user pass if (result == true) { Guid guid = Guid.NewGuid(); string verificationCode = guid.ToString().Substring(0, 8); bool isSuccess = SendEmail.SendingEmail(SEND_EMAIL_ADDRESS, SENDER_PASSWORD, this.txtEmail.Text.Trim(), ResourceCulture.GetString(TITLE), ResourceCulture.GetString(CONTENT_ONE) + verificationCode, HOST); if (isSuccess) { FormPassValue.isSendEmail = true; TipForm tipForm = new TipForm(); tipForm.SetMessage(ResourceCulture.GetString(EMAIL_HAS_SEND)); tipForm.SetIsShowCancel(false); tipForm.IsOpenTimer(true); DialogResult tipResult = tipForm.ShowDialog(); if (tipResult == DialogResult.OK || tipResult == DialogResult.Cancel) { tipForm.GetCustomTimer().GetTimer().Enabled = false; ResetPassword form = new ResetPassword(); form.SetVerificationCode(verificationCode); form.SetUserName(this.txtUsername.Text.Trim()); form.SetEMail(this.txtEmail.Text.Trim()); form.SetCount(tipForm.GetCustomTimer().GetCount()); form.OpenTimer(); form.ShowDialog(this.Owner); this.DialogResult = DialogResult.OK; } // time out else if (tipResult == DialogResult.Ignore) { this.btnFind.Text = ResourceCulture.GetString(RESEND); } } else { TipForm tipForm = new TipForm(); tipForm.SetMessage(ResourceCulture.GetString(EMAIL_SEND_FAIL)); tipForm.SetIsShowCancel(false); tipForm.ShowDialog(); this.DialogResult = DialogResult.OK; } } else { this.lblErrorMessage.Text = ResourceCulture.GetString(USER_AND_EMAIL_NOT_MATCH); this.lblErrorMessage.Show(); } } }