protected void b_Click(object sender, EventArgs e) { AppUser appUserObj = new AppUser(); appUserObj.username = usernameTb.Text; appUserObj.pwd = passwordTb.Text; String pwdConfirm = ConfirmPwdTb.Text; appUserObj.fullName = fullNameTb.Text; appUserObj.email = emailTb.Text; appUserObj.module = moduleTypeDdl.SelectedValue; appUserObj.userType = userTypeDdl.SelectedValue; appUserObj.course = courseDdl.SelectedValue; Boolean isError = false; if (!appUserObj.pwd.Equals(pwdConfirm)) { confirmPwdError.Text = "Confirm Password did not match."; isError = true; } DBUtils dbUtils1 = new DBUtils(); SqlDataReader attributeTypeReader1 = dbUtils1.readOperation("SELECT Username FROM Users"); while (attributeTypeReader1.Read()) { if (attributeTypeReader1[0].ToString().Equals(appUserObj.username)) { usernameError.Text = "Username already exists"; isError = true; break; } } dbUtils1.closeDBConnection(); if (isError) { return; } AppDao appDaoObj = new AppDao(); appUserObj.instructorId = appDaoObj.insertInstructor(appUserObj); appDaoObj.insertUser(appUserObj); GeneralUtils guObj = new GeneralUtils(); AppEmailData emailDataObj = new AppEmailData(); emailDataObj.toAddress = appUserObj.email; emailDataObj.ccAddress = (new AppDao()).getEmailConfiguration().fromAddress; emailDataObj.subject = "Expert System - Account Created"; emailDataObj.bodyHtml = "Dear " + appUserObj.fullName + "," + "<br/><br/>Your account has been successfully created on" + " <a href='http://esabet.azurewebsites.net'>Expert System for AEBT</a>" + " for the course of " + courseDdl.SelectedItem.Text + " with the following credentials:" + "<br/><b>Username: </b>" + appUserObj.username + "<br/><b>Password: </b>" + appUserObj.pwd + "<br/><br/>Please change your password after first login." + " If you are not the intended person kindly ignore this email." + "<br/><br/>Regards," + "<br/>Admin of Expert System for ABET"; guObj.sendEmail(emailDataObj); Response.Redirect("UserManagement.aspx"); }