//changes user details if something is changed on this page.
        protected void btnSaveChanges_Click(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
            conn.Open();
            SqlCommand getPrevious = new SqlCommand("Select Location, Interests, Gender from  User where UserEmail = @UserEmail", conn);
            getPrevious.Parameters.AddWithValue("@UserEmail", UserEmail);
            previousLocation = "Location";
            previousInterest = "Interests";
            previousGender = "Gender";

            User aUser = new User();

            if (txtShopName.Text != "")
            {
                UserAccess.changeShopName(txtShopName.Text, UserID);//Method in User.cs
            }

            if (txtDescription.Text != "")
            {
                UserAccess.changeBio(txtDescription.Text, UserID);//Method in User.cs
            }

            if (txtFirstName.Text != "")
            {
                UserAccess.changeFirstname(txtFirstName.Text, UserID);//Method in User.cs
            }

            if (txtSurname.Text != "")
            {
                UserAccess.changeSurname(txtSurname.Text, UserID);//Method in User.cs
            }

            if (txtUsername.Text != "")
            {
                UserAccess.changeUsername(txtUsername.Text, UserID);//Method in User.cs
            }

            if (txtNewPassword.Text != "" && txtNewPassword.Text == txtReEnterPassword.Text)
            {
                UserAccess.changePassword(txtNewPassword.Text, UserID);//Method in User.cs
            }

            if (ddlLocation.SelectedValue != previousLocation)
            {
                UserAccess.changeLocation(Convert.ToInt32(ddlLocation.SelectedValue), UserID);//Method in User.cs
            }

            if (txtDOB.Text != "")
            {
                DateTime DOB = Convert.ToDateTime(txtDOB.Text);
                UserAccess.changeDOB(DOB, UserID);//Method in User.cs
            }

            if (ddlInterests.SelectedValue != previousInterest)
            {
                UserAccess.changeInterests(Convert.ToInt32(ddlInterests.SelectedValue), UserID);//Method in User.cs
            }

            if (ddlGender.SelectedValue != previousGender)
            {
                UserAccess.changeGender(ddlGender.SelectedValue, UserID);//Method in User.cs
            }

            if (txtAddress.Text != "")
            {
                UserAccess.changeAddress(txtAddress.Text, UserID);//Method in User.cs
            }

            string saveDir = @"images\";
            string appPath = Request.PhysicalApplicationPath;
            string savePath, dbPath;

            if (fuProfilePhoto.HasFile)
            {
                if (checkFileType(fuProfilePhoto.FileName) == true)
                {
                    savePath = appPath + saveDir + fuProfilePhoto.FileName;
                    dbPath = "\\images\\" + fuProfilePhoto.FileName;
                    fuProfilePhoto.SaveAs(savePath);

                    UserAccess.changeProfilePicture(dbPath, UserID);//Method in User.cs

                }
                else
                    lblUploadStatus.Text = "Upload status: No File Selected.";
            }

            lblFailure.Text = "Settings changed!";
            lblFailure.ForeColor = System.Drawing.Color.Green;
            txtDescription.Text = "";
            txtShopName.Text = "";
            txtFirstName.Text = "";
            txtSurname.Text = "";
            txtUsername.Text = "";
            txtNewPassword.Text = "";
            txtReEnterPassword.Text = "";
            txtDOB.Text = "";
            txtAddress.Text = "";
            conn.Close();
        }
示例#2
0
 public static void changeSettings(User aUser)
 {
     string UserFirstname = aUser.UserFirstname;
     string UserSurname = aUser.UserSurname;
     string Username = aUser.Username;
     string password = aUser.UserPassword;
     int location = aUser.Location;
     DateTime DOB = aUser.DateOfBirth;
     int interests = aUser.Interests;
     string gender = aUser.Gender;
     string address = aUser.Address;
 }