protected void retry_Click(object sender, EventArgs e) { String email = (String)Request.Params["email"]; Service1Client client = new Service1Client(); if (!String.IsNullOrEmpty(email)) { SMTPMailer smtpemail = new SMTPMailer(); Boolean result = false; smtpemail.addEmail(email); smtpemail.addSubject("Welcome!"); String link = $"https://localhost:44376/Customer/VerifyEmail?email={email}"; smtpemail.addBody($"<a href='{link}'> Click here to verify your account</a>"); smtpemail.SetHTML(true); result = smtpemail.sendEmail(); if (result != true) { ErrorMessage.Visible = true; ErrorMessageLB.Text = "Email was not provided"; } } else { successAlert.Visible = false; dangerAlert.Visible = true; } }
protected void Submit_Click(object sender, EventArgs e) { String role = (String)Submit_Role_Value.Text.Trim(); if (role == "0") { String FirstName = (String)tbFirstName.Text.Trim(); String LastName = (String)tbLastName.Text.Trim(); String Email = (String)tbEmail.Text.Trim().ToLower(); tbEmail_TextChanged(Email); String Password = (String)tbPassword.Text.Trim(); String cfmPassword = (String)tbPasswordCfm.Text.Trim(); String PhoneNumber = (String)tbPhoneNumber.Text.Trim(); String tmpBirthDate = (String)tbBirthDate.Text.Trim(); Boolean TermsAndConditions = cbTermsAndConditions.Checked; Boolean One = validate(FirstName, LastName, Email, PhoneNumber, tmpBirthDate, TermsAndConditions); Boolean Two = PasswordValidation(Password, cfmPassword, true); if (One && Two) { Service1Client client = new Service1Client(); DateTime BirthDate = DateTime.Parse(tmpBirthDate); Int16 result = 0; try { SMTPMailer smtpemail = new SMTPMailer(); smtpemail.addEmail(Email); smtpemail.addSubject("Welcome!"); String link = $"https://localhost:{Request.Url.Port}/ CustomerVerifyEmail?email={Email}&purpose=Customer"; smtpemail.addBody($"<a href='{link}'> Click here to verify your account</a>"); smtpemail.SetHTML(true); result = client.InsertCustomer(FirstName, LastName, Email, Password, PhoneNumber, BirthDate); if (result >= 0) { Boolean resultTmp = smtpemail.sendEmail(); lbErrorMsg.Text = "Email failed to register!"; } } catch (SqlException) { errorDiv.Visible = true; lbErrorMsg.Text = "Are you trying to perform an illegal operation?"; } catch (TimeoutException) { errorDiv.Visible = true; lbErrorMsg.Text = "Something went wrong, please try again"; } if (result == 1) { Response.Redirect("~/CustomerLogin?Feedback=1"); } else { errorDiv.Visible = true; lbErrorMsg.Text = "Something went wrong, please try again"; } } } else if (role == "1") { String FullName = (String)tbFullname.Text.Trim(); String Email = (String)tbEmailTwo.Text.Trim().ToLower(); tbEmail_TextChanged(Email); String Password = (String)tbPasswordTwo.Text.Trim(); String cfmPassword = (String)tbPasswordCfmTwo.Text.Trim(); String PhoneNumber = (String)tbPhoneNumberTwo.Text.Trim(); Boolean One = validateExtra(FullName, Email, PhoneNumber); Boolean Two = PasswordValidation(Password, cfmPassword, false); if (One && Two) { Service1Client client = new Service1Client(); Boolean result = false; try { SMTPMailer smtpemail = new SMTPMailer(); smtpemail.addEmail(Email); smtpemail.addSubject("Welcome!"); String link = $"https://localhost:{Request.Url.Port}/ CustomerVerifyEmail?email={Email}&purpose=Business"; smtpemail.addBody($"<a href='{link}'> Click here to verify your account</a>"); smtpemail.SetHTML(true); result = client.CreateBusinessUser(FullName, Email, Password, PhoneNumber); if (result == true) { Boolean resultTmp = smtpemail.sendEmail(); if (resultTmp != true) { lbErrorMsg.Text = "Email failed to register!"; } } } catch (SqlException) { errorDiv.Visible = true; lbErrorMsg.Text = "Are you trying to perform an illegal operation?"; } catch (TimeoutException) { errorDiv.Visible = true; lbErrorMsg.Text = "Something went wrong, please try again"; } if (result == true) { Response.Redirect("~/CustomerLogin?Feedback=1"); } else { errorDiv.Visible = true; lbErrorMsg.Text = "Something went wrong, please try again"; } } } }