Ejemplo n.º 1
0
    protected void btnsend_Click(object sender, EventArgs e)
    {
        DB_Helper DB = new DB_Helper();

        if (txtEmail.Text.Length > 0)
        {
            int userId = DB.ExecuteScalarInt("select id_user from users where email='" + txtEmail.Text.Replace("'", "''") + "'", 0); // db.getActiveUserIdByEmail(txtEmail.Text);
            if (userId != 0)
            {
                EmailWrapper mw = new EmailWrapper();
                mw.SendTemplate("EMAIL_LOSTPASSWORD", userId);
                Session["SUCCESS"] = "Password has been sent to provided e-mail";
                Response.Redirect("/Forgot");
            }
            else
            {
                MyUtils.DisplayCustomMessageInValidationSummary("Provided e-mail is not registered as a valid user e-mail.", ValidationSummary1);
            }
        }
        //else
        //{
        //    MyUtils.DisplayCustomMessageInValidationSummary("E-mail is required.", ValidationSummary1);
        //}
    }
Ejemplo n.º 2
0
    private void SaveUserInDB()
    {
        try
        {
            DataSet ds      = db.CommandBuilder_LoadDataSet(string.Format("select * from users where id_user={0}", ID_USER));
            DataRow userRow = ds.Tables[0].Rows[0];


            userRow["zip"]       = zip;
            userRow["latitude"]  = otherZipData.lat;
            userRow["longitude"] = otherZipData.lon;
            userRow["place"]     = otherZipData.place;

            string old_description = Convert.ToString(userRow["title"]) + Convert.ToString(userRow["description"]) + Convert.ToString(userRow["firstdate"]);

            userRow["title"]       = title;
            userRow["description"] = desc;
            userRow["firstdate"]   = date;

            string new_description = Convert.ToString(userRow["title"]) + Convert.ToString(userRow["description"]) + Convert.ToString(userRow["firstdate"]);

            if (old_description.ToUpper() != new_description.ToUpper())
            {
                userRow["status"] = 0;
            }


            //ddl
            Utils.SetDdlField(ddlEthnicity, userRow, "id_ethnicity");
            Utils.SetDdlField(ddlReligion, userRow, "id_religion");
            Utils.SetDdlField(ddlChildren, userRow, "id_children");
            Utils.SetDdlField(ddlDrinking, userRow, "id_drinking");
            Utils.SetDdlField(ddlSmoking, userRow, "id_smoking");
            Utils.SetDdlField(ddlHeight, userRow, "id_height");
            Utils.SetDdlField(ddlBodyType, userRow, "id_bodytype");
            Utils.SetDdlField(ddlEyeColor, userRow, "id_eyecolor");
            Utils.SetDdlField(ddlHairColor, userRow, "id_haircolor");
            Utils.SetDdlField(ddlRelationship, userRow, "id_relationship");
            Utils.SetDdlField(ddlEducation, userRow, "id_education");
            Utils.SetDdlField(ddlIncome, userRow, "id_income");
            Utils.SetDdlField(ddlWorth, userRow, "id_networth");

            string   error = "";
            DateTime dt    = birthday.GetBirthday(out error);
            if (error != "")
            {
                MyUtils.DisplayCustomMessageInValidationSummary(error, RegisterUserValidationSummary);
                return;
            }
            userRow["birthdate"]  = dt;
            userRow["occupation"] = MyUtils.StripHTML(ocupation.Text.Trim());

            //cbx
            userRow["lookingforshortterm"]    = cbxShortDating.Checked;
            userRow["lookingforfriendship"]   = cbxFriendship.Checked;
            userRow["lookingforlongterm"]     = cbxLongTerm.Checked;
            userRow["lookingforarrangement"]  = cbxMutually.Checked;
            userRow["lookingforaffair"]       = cbxDiscreet.Checked;
            userRow["lookingforcasualdating"] = cbxCasual.Checked;

            db.CommandBuilder_SaveDataset();
        }
        finally
        {
            db.CommandBuilder_Disconnect();
        }
    }
Ejemplo n.º 3
0
    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));
        }
    }
Ejemplo n.º 4
0
    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();
        }
    }