public static void saveUserProfile(UserProfileBO saveMe)
        {
            SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["oitSqlServer"].ConnectionString);
            SqlCommand    saveUPobj  = new SqlCommand();

            saveUPobj.CommandText = "UserProfile_InsertUpdate";
            saveUPobj.CommandType = CommandType.StoredProcedure;
            saveUPobj.Parameters.AddWithValue("@UserId", saveMe.UserID);
            saveUPobj.Parameters.AddWithValue("@FirstName", saveMe.FirstName);
            saveUPobj.Parameters.AddWithValue("@LastName", saveMe.LastName);
            saveUPobj.Parameters.AddWithValue("@Age", saveMe.Age);
            saveUPobj.Parameters.AddWithValue("@PhoneNumber", saveMe.PhoneNumber);
            saveUPobj.Parameters.AddWithValue("@EmailAddress", saveMe.Email);
            saveUPobj.Parameters.AddWithValue("@StreetAddress", saveMe.StreetAddress);
            saveUPobj.Parameters.AddWithValue("@City", saveMe.City);
            saveUPobj.Parameters.AddWithValue("@State", saveMe.State);
            saveUPobj.Parameters.AddWithValue("@ZipCode", saveMe.Zipcode);
            saveUPobj.Parameters.AddWithValue("@ProfileImage", saveMe.Image2);
            saveUPobj.Connection = connection;

            try
            {
                connection.Open();
                saveUPobj.ExecuteNonQuery();
            }
            catch
            {
                throw;
            }
            finally
            {
                connection.Close();
            }
        }
        public static UserProfileBO getUserProfile(Guid userGuid)
        {
            UserProfileBO returnMe   = new UserProfileBO();
            SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["oitSqlServer"].ConnectionString);

            SqlCommand getUPobj = new SqlCommand();

            getUPobj.CommandText = "UserProfile_Get";
            getUPobj.CommandType = CommandType.StoredProcedure;
            getUPobj.Parameters.AddWithValue("@UserId", userGuid);
            getUPobj.Connection = connection;

            try
            {
                connection.Open();
                SqlDataReader reader = getUPobj.ExecuteReader();

                if (reader.Read())
                {
                    returnMe.UserID        = (Guid)reader["UserID"];
                    returnMe.FirstName     = reader["FirstName"].ToString();
                    returnMe.LastName      = reader["LastName"].ToString();
                    returnMe.Age           = (int)reader["Age"];
                    returnMe.PhoneNumber   = reader["PhoneNumber"].ToString();
                    returnMe.Email         = reader["EmailAddress"].ToString();
                    returnMe.EmailConfirm  = returnMe.Email;
                    returnMe.StreetAddress = reader["StreetAddress"].ToString();
                    returnMe.City          = reader["City"].ToString();
                    returnMe.State         = reader["State"].ToString();
                    returnMe.Zipcode       = reader["Zipcode"].ToString();
                    if (reader["ProfileImage"].GetType().ToString() != "System.DBNull")
                    {
                        returnMe.Image2 = (byte[])reader["ProfileImage"];
                    }
                }

                reader.Close();
            }
            catch
            {
                throw;
            }
            finally
            {
                connection.Close();
            }

            return(returnMe);
        }
        public static UserProfileBO getUserProfile(Guid userGuid)
        {
            UserProfileBO returnMe = new UserProfileBO();
            SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["oitSqlServer"].ConnectionString);

            SqlCommand getUPobj = new SqlCommand();
            getUPobj.CommandText = "UserProfile_Get";
            getUPobj.CommandType = CommandType.StoredProcedure;
            getUPobj.Parameters.AddWithValue("@UserId", userGuid);
            getUPobj.Connection = connection;

            try
            {
                connection.Open();
                SqlDataReader reader = getUPobj.ExecuteReader();

                if (reader.Read())
                {
                    returnMe.UserID = (Guid)reader["UserID"];
                    returnMe.FirstName = reader["FirstName"].ToString();
                    returnMe.LastName = reader["LastName"].ToString();
                    returnMe.Age = (int)reader["Age"];
                    returnMe.PhoneNumber = reader["PhoneNumber"].ToString();
                    returnMe.Email = reader["EmailAddress"].ToString();
                    returnMe.EmailConfirm = returnMe.Email;
                    returnMe.StreetAddress = reader["StreetAddress"].ToString();
                    returnMe.City = reader["City"].ToString();
                    returnMe.State = reader["State"].ToString();
                    returnMe.Zipcode = reader["Zipcode"].ToString();
                    if (reader["ProfileImage"].GetType().ToString() != "System.DBNull")
                        returnMe.Image2 = (byte[])reader["ProfileImage"];
                }

                reader.Close();
            }
            catch
            {
                throw;
            }
            finally
            {
                connection.Close();
            }

            return returnMe;
        }
Example #4
0
        protected void uxSubmitButton_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                MembershipUser user   = Membership.GetUser();
                Guid           userID = (Guid)user.ProviderUserKey;

                UserProfileBO passMe = new UserProfileBO();
                passMe.UserID        = userID;
                passMe.FirstName     = uxFirstName.Text;
                passMe.LastName      = uxLastName.Text;
                passMe.Age           = Int32.Parse(uxAge.Text);
                passMe.PhoneNumber   = uxPhoneNumber.Text;
                passMe.Email         = uxEmail.Text;
                passMe.EmailConfirm  = uxEmailConfirm.Text;
                passMe.StreetAddress = uxStreetAddress.Text;
                passMe.City          = uxCity.Text;
                passMe.State         = uxState.Text;
                passMe.Zipcode       = uxZipcode.Text;

                if (uxImageUpload.HasFile)
                {
                    byte[] buffer = new byte[uxImageUpload.PostedFile.ContentLength];
                    uxImageUpload.PostedFile.InputStream.Read(buffer, 0, uxImageUpload.PostedFile.ContentLength);
                    passMe.Image2 = buffer;
                }
                else if (uxDeletePicCB.Checked)
                {
                    //This results in a "broken image" box. Don't have to to figure out better. Due at midnight.
                    passMe.Image2 = new byte[1];
                }
                else
                {
                    passMe.Image2 = null;
                }

                multiView1.ActiveViewIndex = 1;
                UserProfileRepo.saveUserProfile(passMe);
                Response.Redirect("~/Customers/UserProfile.aspx");
            }
        }
Example #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            MembershipUser user   = Membership.GetUser();
            Guid           userID = (Guid)user.ProviderUserKey;

            UserProfileBO sessionRestoreFromRepository = new UserProfileBO();

            sessionRestoreFromRepository = UserProfileRepo.getUserProfile(userID);

            multiView1.ActiveViewIndex = 1;

            //if (sessionRestoreFromRepository.Email != null)
            //{
            uxFirstNameResult.Text   = sessionRestoreFromRepository.FirstName;
            uxLastNameResult.Text    = sessionRestoreFromRepository.LastName;
            uxAgeResult.Text         = sessionRestoreFromRepository.Age.ToString();
            uxPhoneNumberResult.Text = sessionRestoreFromRepository.PhoneNumber;
            uxEamilResult.Text       = sessionRestoreFromRepository.Email;
            uxStreetResult.Text      = sessionRestoreFromRepository.StreetAddress;
            uxCityResult.Text        = sessionRestoreFromRepository.City;
            uxStateResult.Text       = sessionRestoreFromRepository.State;
            uxZipResult.Text         = sessionRestoreFromRepository.Zipcode;

            //uxImage.ImageUrl = sessionRestoreFromRepository.Image2;
            string base64String = null;

            if (sessionRestoreFromRepository.Image2 != null)
            {
                using (MemoryStream m = new MemoryStream(sessionRestoreFromRepository.Image2))
                {
                    byte[] imageBytes = m.ToArray();
                    base64String = Convert.ToBase64String(imageBytes);
                }
                if (!string.IsNullOrEmpty(base64String))
                {
                    uxImage.ImageUrl = "data:image/jpeg;base64," + base64String;
                }
            }
            //}
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            MembershipUser user = Membership.GetUser();
            Guid userID = (Guid)user.ProviderUserKey;

            UserProfileBO sessionRestoreFromRepository = new UserProfileBO();
            sessionRestoreFromRepository = UserProfileRepo.getUserProfile(userID);

            multiView1.ActiveViewIndex = 1;

            //if (sessionRestoreFromRepository.Email != null)
            //{
                uxFirstNameResult.Text = sessionRestoreFromRepository.FirstName;
                uxLastNameResult.Text = sessionRestoreFromRepository.LastName;
                uxAgeResult.Text = sessionRestoreFromRepository.Age.ToString();
                uxPhoneNumberResult.Text = sessionRestoreFromRepository.PhoneNumber;
                uxEamilResult.Text = sessionRestoreFromRepository.Email;
                uxStreetResult.Text = sessionRestoreFromRepository.StreetAddress;
                uxCityResult.Text = sessionRestoreFromRepository.City;
                uxStateResult.Text = sessionRestoreFromRepository.State;
                uxZipResult.Text = sessionRestoreFromRepository.Zipcode;

                //uxImage.ImageUrl = sessionRestoreFromRepository.Image2;
                string base64String = null;

                if (sessionRestoreFromRepository.Image2 != null)
                {
                    using (MemoryStream m = new MemoryStream(sessionRestoreFromRepository.Image2))
                    {
                        byte[] imageBytes = m.ToArray();
                        base64String = Convert.ToBase64String(imageBytes);
                    }
                    if (!string.IsNullOrEmpty(base64String))
                    {
                        uxImage.ImageUrl = "data:image/jpeg;base64," + base64String;
                    }
                }
            //}
        }
        public static void saveUserProfile(UserProfileBO saveMe)
        {
            SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["oitSqlServer"].ConnectionString);
            SqlCommand saveUPobj = new SqlCommand();
            saveUPobj.CommandText = "UserProfile_InsertUpdate";
            saveUPobj.CommandType = CommandType.StoredProcedure;
            saveUPobj.Parameters.AddWithValue("@UserId", saveMe.UserID);
            saveUPobj.Parameters.AddWithValue("@FirstName", saveMe.FirstName);
            saveUPobj.Parameters.AddWithValue("@LastName", saveMe.LastName);
            saveUPobj.Parameters.AddWithValue("@Age", saveMe.Age);
            saveUPobj.Parameters.AddWithValue("@PhoneNumber", saveMe.PhoneNumber);
            saveUPobj.Parameters.AddWithValue("@EmailAddress", saveMe.Email);
            saveUPobj.Parameters.AddWithValue("@StreetAddress", saveMe.StreetAddress);
            saveUPobj.Parameters.AddWithValue("@City", saveMe.City);
            saveUPobj.Parameters.AddWithValue("@State", saveMe.State);
            saveUPobj.Parameters.AddWithValue("@ZipCode", saveMe.Zipcode);
            saveUPobj.Parameters.AddWithValue("@ProfileImage", saveMe.Image2);
            saveUPobj.Connection = connection;

            try
            {
                connection.Open();
                saveUPobj.ExecuteNonQuery();
            }
            catch
            {
                throw;
            }
            finally
            {
                connection.Close();
            }
        }
        protected void uxSubmitButton_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                MembershipUser user = Membership.GetUser();
                Guid userID = (Guid)user.ProviderUserKey;

                UserProfileBO passMe = new UserProfileBO();
                passMe.UserID = userID;
                passMe.FirstName = uxFirstName.Text;
                passMe.LastName = uxLastName.Text;
                passMe.Age = Int32.Parse(uxAge.Text);
                passMe.PhoneNumber = uxPhoneNumber.Text;
                passMe.Email = uxEmail.Text;
                passMe.EmailConfirm = uxEmailConfirm.Text;
                passMe.StreetAddress = uxStreetAddress.Text;
                passMe.City = uxCity.Text;
                passMe.State = uxState.Text;
                passMe.Zipcode = uxZipcode.Text;

                if (uxImageUpload.HasFile)
                {
                    byte[] buffer = new byte[uxImageUpload.PostedFile.ContentLength];
                    uxImageUpload.PostedFile.InputStream.Read(buffer, 0, uxImageUpload.PostedFile.ContentLength);
                    passMe.Image2 = buffer;
                }
                else if (uxDeletePicCB.Checked)
                {
                    //This results in a "broken image" box. Don't have to to figure out better. Due at midnight.
                    passMe.Image2 = new byte[1];
                }
                else
                {
                    passMe.Image2 = null;
                }

                multiView1.ActiveViewIndex = 1;
                UserProfileRepo.saveUserProfile(passMe);
                Response.Redirect("~/Customers/UserProfile.aspx");
            }
        }