protected void btnCompleteProfile_Click(object sender, EventArgs e) { if (!cbxCasual.Checked && !cbxDiscreet.Checked && !cbxFriendship.Checked && !cbxLongTerm.Checked && !cbxMutually.Checked && !cbxShortDating.Checked) { MyUtils.DisplayCustomMessageInValidationSummary("You should select 'What Are You Loking For?'", RegisterUserValidationSummary, "RegisterUserValidationGroup"); return; } title = MyUtils.StripHTML(profileHeadline.Text.Trim()); desc = MyUtils.StripHTML(describe.Text.Trim()); date = MyUtils.StripHTML(ideal.Text.Trim()); nGram g = new nGram(); string s = title + ". " + desc + ". " + date; double q; q = g.CalculateQuality(s); if (q < 0.11) { MyUtils.DisplayCustomMessageInValidationSummary("Your description is below our quality standards. Please use correct grammar and write in complete sentences.", RegisterUserValidationSummary, "RegisterUserValidationGroup"); return; } if (g.WordCount < 5) { MyUtils.DisplayCustomMessageInValidationSummary("Your description doesn't have enough details. Please describe yourself in detail using correct grammar and complete sentences.", RegisterUserValidationSummary, "RegisterUserValidationGroup"); return; } string xx; xx = Profanity.TestAndMessage(desc); if (xx != null) { MyUtils.DisplayCustomMessageInValidationSummary("Your description " + xx, RegisterUserValidationSummary, "RegisterUserValidationGroup"); return; } xx = Profanity.TestAndMessage(title); if (xx != null) { MyUtils.DisplayCustomMessageInValidationSummary("Your title " + xx, RegisterUserValidationSummary, "RegisterUserValidationGroup"); return; } xx = Profanity.TestAndMessage(date); if (xx != null) { MyUtils.DisplayCustomMessageInValidationSummary("Your ideal date description " + xx, RegisterUserValidationSummary, "RegisterUserValidationGroup"); return; } desc = ReplaceEmail(desc); title = ReplaceEmail(title); date = ReplaceEmail(date); zip = MyUtils.StripHTML(zipCode.Text); otherZipData = MyUtils.GetZipCoordinates(zip.ToString()); if (otherZipData == null) { MyUtils.DisplayCustomMessageInValidationSummary("ZIP code does not exist. Please enter valid zip code.", RegisterUserValidationSummary, "RegisterUserValidationGroup"); return; } SaveUserInDB(); MyUtils.RefreshUserRow(); if (IsRegistration) { Session["message"] = "Your profile has been saved. Please upload photos."; Response.Redirect("~/Account/UploadPhotos?hidemenu=1"); } else { Session["message"] = "Your profile has been updated"; Response.Redirect(Utils.GetProfileLink(ID_USER)); } }
protected void btnSignUp_Click(object sender, EventArgs e) { int id_user; try { txtName.Text = txtName.Text.Trim(); txtPassword.Text = txtPassword.Text.Trim(); txtEmail.Text = txtEmail.Text.Trim(); if (db.ExecuteScalarInt(string.Format("select count(*) from users where username = {0}", MyUtils.safe(txtName.Text))) > 0) { MyUtils.DisplayCustomMessageInValidationSummary("User with this Username already exists.", ValidationSummary1); return; } if (db.ExecuteScalarInt(string.Format("select count(*) from users where email = {0}", MyUtils.safe(txtEmail.Text))) > 0) { MyUtils.DisplayCustomMessageInValidationSummary("User with this Email Address already exists.", ValidationSummary1); return; } string xx = Profanity.TestAndMessage(txtName.Text); if (xx != null) { MyUtils.DisplayCustomMessageInValidationSummary("User name " + xx, ValidationSummary1); return; } DataSet d = db.CommandBuilder_LoadDataSet("select * from users where id_user=-1"); //get the columns schema DataRow n = d.Tables[0].NewRow(); n["username"] = MyUtils.StripHTML(txtName.Text); n["password"] = txtPassword.Text; n["email"] = txtEmail.Text; n["sex"] = MyUtils.StripHTML(ddlGender.SelectedValue); string error = ""; DateTime dt = birthday.GetBirthday(out error); if (error != "") { MyUtils.DisplayCustomMessageInValidationSummary(error, ValidationSummary1); return; } n["birthdate"] = dt; n["country"] = 28; // United States d.Tables[0].Rows.Add(n); id_user = db.CommandBuilder_SaveDataset(); //gets back @@identity EmailWrapper mw = new EmailWrapper(); mw.SendTemplate("EMAIL_ACTIVATE", id_user); string membership = ""; MyUtils.authenticate(txtName.Text, txtPassword.Text, out membership); FormsAuthentication.SetAuthCookie(txtName.Text, false); Response.Redirect("~/Account/Registration"); } finally { db.CommandBuilder_Disconnect(); } }