Example #1
0
    private int SavePhotoToDb(string guidPhoto, Tuple <int, int> imSizes)
    {
        int userId     = (int)MyUtils.GetUserField("id_user");
        int newIdPhoto = 0;

        //Insert a new photo to photos table
        try
        {
            DataSet ds       = db.CommandBuilder_LoadDataSet("select * from photos where id_user=-1"); //get the columns schema
            DataRow newPhoto = ds.Tables[0].NewRow();
            newPhoto["id_user"]      = userId;
            newPhoto["GUID"]         = guidPhoto;
            newPhoto["is_approved"]  = false;
            newPhoto["is_private"]   = false;
            newPhoto["image_height"] = imSizes.Item1;
            newPhoto["image_width"]  = imSizes.Item2;
            ds.Tables[0].Rows.Add(newPhoto);

            newIdPhoto = db.CommandBuilder_SaveDataset(); //gets back @@identity

            foreach (DataRow dr in dsImages.Tables[0].Rows)
            {
                if (dr["ImageGuid"].ToString() == guidPhoto)
                {
                    dr["ImageID"] = newIdPhoto;
                }
            }
        }
        finally
        {
            db.CommandBuilder_Disconnect();
        }
        return(newIdPhoto);
    }
Example #2
0
    protected void btnBlock_Click(object sender, EventArgs e)
    {
        // Block
        if ((sender as LinkButton).Text == "Block")
        {
            int newBlockId = 0;
            //Insert a new block to blocks table
            try
            {
                DataSet ds       = db.CommandBuilder_LoadDataSet("select * from blocks where id =-1"); //get the columns schema
                DataRow newBlock = ds.Tables[0].NewRow();
                newBlock["id_user_child"] = (int)MyUtils.GetUserField("id_user");
                newBlock["id_user"]       = currentUser;
                newBlock["time"]          = DateTime.Now;

                ds.Tables[0].Rows.Add(newBlock);

                newBlockId = db.CommandBuilder_SaveDataset();

                SetButtonBlock(true);
            }
            finally
            {
                db.CommandBuilder_Disconnect();
            }
        }
        //Unblock
        else
        {
            try
            {
                db.Execute(string.Format("delete from blocks where id_user_child={0} and id_user = {1}", (int)MyUtils.GetUserField("id_user"), currentUser));
                SetButtonBlock(false);
            }
            finally
            {
                db.CommandBuilder_Disconnect();
            }
        }
    }
Example #3
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();
        }
    }
Example #4
0
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        bool revalidate = false;

        try
        {
            string newemail = txtEmail.Text.Trim();
            int    cnt      = db.ExecuteScalarInt("select count(*) from users where email=" + MyUtils.safe(newemail) + " and id_user<>" + MyUtils.ID_USER);
            if (cnt > 0)
            {
                Session["message"] = "ERROR: this email is used by other user. You need to provide a new email.";
                return;
            }


            DataSet ds      = db.CommandBuilder_LoadDataSet(string.Format("select * from users where id_user={0}", MyUtils.ID_USER));
            DataRow userRow = ds.Tables[0].Rows[0];

            if (txtPassword.Text.Trim() != string.Empty)
            {
                userRow["password"] = txtPassword.Text.Trim();
            }


            revalidate = userRow["email"].ToString().ToUpper() != newemail.ToUpper();


            userRow["email"] = newemail;
            if (revalidate)
            {
                userRow["email_verified"] = 0;
            }

            //cbx
            userRow["email_new_matches"]      = cbxEmailNewMatches.Checked;
            userRow["email_when_new_message"] = cbxEmailWhenNewMessage.Checked;
            userRow["email_when_favorited"]   = cbxEmailWhenFavorited.Checked;
            userRow["email_when_new_offer"]   = cbxemail_when_new_offer.Checked;
            userRow["email_newsletter"]       = cbxEmailNewsletter.Checked;

            userRow["hide_from_search_results"] = cbxHideFromSearchResults.Checked;
//            userRow["hide_on_viewed_favorited_list"] = cbxHideOnViewedFavoritedList.Checked;
//          userRow["hide_last_logintime"] = cbxHideLastLogintime.Checked;

            db.CommandBuilder_SaveDataset();
        }
        finally
        {
            db.CommandBuilder_Disconnect();
        }

        MyUtils.RefreshUserRow();

        if (revalidate)
        {
            RWorker.AddToEmailQueue("EMAIL_ACTIVATE", MyUtils.ID_USER);
        }

        Session["message"] = "Settings have been saved";
        Response.Redirect("~/Account/");
    }
Example #5
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();
        }
    }