예제 #1
0
    private void mUpdateProfile(ProfileCommon userProfile)
    {
        userProfile.SetPropertyValue("DateOfBirth", DateTime.UtcNow.AddHours(3.5));

        if (!string.IsNullOrEmpty(txtFirstName.Text))
        {
            userProfile.SetPropertyValue("FirstName", txtFirstName.Text);
        }

        if (!string.IsNullOrEmpty(txtLastName.Text))
        {
            userProfile.SetPropertyValue("LastName", txtLastName.Text);
        }

        if (!string.IsNullOrEmpty(rblGender.SelectedValue))
        {
            userProfile.SetPropertyValue("Gender", Convert.ToBoolean(Convert.ToByte(rblGender.SelectedValue)));
        }

        if (!string.IsNullOrEmpty(txtTel.Text))
        {
            userProfile.SetPropertyValue("Tel", txtTel.Text);
        }

        if (!string.IsNullOrEmpty(txtMobile.Text))
        {
            userProfile.SetPropertyValue("Mobile", txtMobile.Text);
        }

        if (!string.IsNullOrEmpty(txtCity.Text))
        {
            userProfile.SetPropertyValue("City", txtCity.Text);
        }

        if (!string.IsNullOrEmpty(txtAddress.Text))
        {
            userProfile.SetPropertyValue("Address", txtAddress.Text);
        }

        if (!string.IsNullOrEmpty(txtDescription.Text))
        {
            userProfile.SetPropertyValue("Description", txtDescription.Text);
        }

        userProfile.Save();
    }
예제 #2
0
    private void mSave()
    {
        if (mValidateAddEdit())
        {
            try
            {
                if (pIDUser.HasValue)
                {
                    string email = pMembershipUser.Email;
                    if (!string.IsNullOrEmpty(txtEmail.Text) && !email.Equals(txtEmail.Text.Trim()))
                    {
                        pMembershipUser.Email = txtEmail.Text.Trim();
                    }
                    if (!string.IsNullOrEmpty(txtPassword.Text))
                    {
                        string tempPWD = pMembershipUser.ResetPassword();
                        pMembershipUser.ChangePassword(tempPWD, txtPassword.Text.Trim());
                    }
                }
                else
                {
                    Membership.CreateUser(txtUserName.Text.Trim(), txtPassword.Text.Trim(), txtEmail.Text.Trim());
                    MembershipUser membershipUser = Membership.GetUser(txtUserName.Text.Trim());
                    pIDUser = new Guid(membershipUser.ProviderUserKey.ToString());
                }

                Membership.UpdateUser(pMembershipUser);

                ProfileCommon userProfile = Profile.GetProfile(pMembershipUser.UserName);

                if (!string.IsNullOrEmpty(txtFirstName.Text))
                {
                    userProfile.SetPropertyValue("FirstName", txtFirstName.Text);
                }
                if (!string.IsNullOrEmpty(txtLastName.Text))
                {
                    userProfile.SetPropertyValue("LastName", txtLastName.Text);
                }
                if (!string.IsNullOrEmpty(txtDateOfBirth.Text))
                {
                    userProfile.SetPropertyValue("DateOfBirth", Convert.ToDateTime(string.Format("{0} {1}", Convert.ToDateTime(txtDateOfBirth.Text).ToString(Global.MethodsAndProps.DateFormat), DateTime.UtcNow.AddHours(Global.MethodsAndProps.TimeZone).ToString("HH:mm:ss"))));
                }
                if (!string.IsNullOrEmpty(rblGender.SelectedValue))
                {
                    userProfile.SetPropertyValue("Gender", Convert.ToBoolean(Convert.ToByte(rblGender.SelectedValue)));
                }
                if (!string.IsNullOrEmpty(txtTel.Text))
                {
                    userProfile.SetPropertyValue("Tel", txtTel.Text);
                }
                if (!string.IsNullOrEmpty(txtAddress.Text))
                {
                    userProfile.SetPropertyValue("Address", txtAddress.Text);
                }

                userProfile.Save();
                UpdateUserRoles();

                pMessage.Clear();
                pMessage.Add(Farschidus.Translator.AppTranslate["general.message.success"], Farschidus.Web.UI.Message.MessageTypes.Success);
                mShowMessage(pMessage);
            }
            catch (Exception ex)
            {
                pMessage.Clear();
                pMessage.Add(ex.Message, Farschidus.Web.UI.Message.MessageTypes.Error);
                mShowMessage(pMessage);
            }
        }
        else
        {
            mShowMessage(pMessage);
        }
    }