コード例 #1
0
        protected override void LoadForm()
        {
            try
            {
                BindcblRoles();
                //BindrblDeliveryTypes();
                BindddlCoupons();

                //form fields
                if (CurrentAspNetId != null)
                {
                    divPassword.Visible = true;

                    MembershipUser user = Membership.GetUser(CurrentAspNetId);

                    chkIsLockedOut.Checked = user.IsLockedOut;
                    chkIsActive.Checked    = user.IsApproved;

                    if ((Guid)user.ProviderUserKey == (Guid)Helpers.LoggedUser.ProviderUserKey)
                    {
                        chkIsLockedOut.Enabled = false;
                    }

                    txtEmail.Text = user.Email;

                    string[] userRoles = Roles.GetRolesForUser(user.UserName);

                    foreach (string role in userRoles)
                    {
                        ListItem roleItem = cblRoles.Items.FindByValue(role);

                        if (roleItem != null)
                        {
                            roleItem.Selected = true;
                        }
                    }

                    if (userRoles.ToList().Count(a => a == "Customer") > 0)
                    {
                        DisplayProfileTabs(true);
                    }
                    else
                    {
                        DisplayProfileTabs(false);
                    }

                    PasswordReset1.CurrentAspNetId = CurrentAspNetId;

                    CurrentUserProfile = hccUserProfile.GetParentProfileBy((Guid)user.ProviderUserKey);

                    if (CurrentUserProfile == null)
                    {
                        hccUserProfile newProfile = new hccUserProfile
                        {
                            MembershipID   = (Guid)user.ProviderUserKey,
                            CreatedBy      = (Guid)Helpers.LoggedUser.ProviderUserKey,
                            CreatedDate    = DateTime.Now,
                            ProfileName    = string.Empty,
                            AccountBalance = 0.00m,
                            IsActive       = true
                        };

                        newProfile.Save();
                        CurrentUserID.Value  = newProfile.MembershipID.ToString();
                        CurrentUserProfile   = newProfile;
                        this.PrimaryKeyIndex = newProfile.UserProfileID;
                    }


                    if (CurrentUserProfile != null)
                    {
                        txtProfileName.Text = CurrentUserProfile.ProfileName;
                        txtFirstName.Text   = CurrentUserProfile.FirstName;
                        txtLastName.Text    = CurrentUserProfile.LastName;

                        // Canyon Ranch
                        if (CurrentUserProfile.CanyonRanchCustomer != null)
                        {
                            cbCanyonRanchCustomer.Checked = CurrentUserProfile.CanyonRanchCustomer.Value;
                        }

                        if (CurrentUserProfile.DefaultCouponId.HasValue)
                        {
                            ddlCoupons.SelectedIndex = ddlCoupons.Items.IndexOf(
                                ddlCoupons.Items.FindByValue(CurrentUserProfile.DefaultCouponId.ToString()));
                        }

                        //billing info
                        BillingInfoEdit1.PrimaryKeyIndex = CurrentUserProfile.UserProfileID;
                        BillingInfoEdit1.Bind();

                        //shipping address
                        if (CurrentUserProfile.ShippingAddressID.HasValue)
                        {
                            AddressEdit_Shipping1.PrimaryKeyIndex = CurrentUserProfile.ShippingAddressID.Value;
                            AddressEdit_Shipping1.Bind();
                        }

                        //preferences
                        ProfilePrefsEdit1.PrimaryKeyIndex = CurrentUserProfile.UserProfileID;
                        ProfilePrefsEdit1.Bind();

                        //allergens
                        ProfileAllgsEdit1.PrimaryKeyIndex = CurrentUserProfile.UserProfileID;
                        ProfileAllgsEdit1.Bind();

                        //subprofiles
                        BindgvwSubProfiles();
                        SubProfileEdit1.CurrentParentAspNetId  = CurrentAspNetId;
                        SubProfileEdit1.CurrentParentProfileId = CurrentUserProfile.UserProfileID;

                        //order history
                        BindHistory(); //0);

                        // recurring
                        BindRecurring();

                        //ledger
                        BindLedger();

                        //notes
                        ProfileNotesEdit_Billing.CurrentUserProfileId = CurrentUserProfile.UserProfileID;
                        ProfileNotesEdit_Billing.Bind();
                        ProfileNotesEdit_General.CurrentUserProfileId = CurrentUserProfile.UserProfileID;
                        ProfileNotesEdit_General.Bind();
                        ProfileNotesEdit_Shipping.CurrentUserProfileId = CurrentUserProfile.UserProfileID;
                        ProfileNotesEdit_Shipping.Bind();

                        //current cart
                        ProfileCartEdit1.PrimaryKeyIndex = CurrentUserProfile.UserProfileID;
                        ProfileCartEdit1.Bind();
                    }
                }
                else
                {
                    cblRoles.Items.FindByText("Customer").Selected = true;
                    DisplayProfileTabs(true);

                    liBilling.Visible      = false;
                    liShipping.Visible     = false;
                    liPrefs.Visible        = false;
                    liAllergens.Visible    = false;
                    liSubProfiles.Visible  = false;
                    liNotes.Visible        = false;
                    liTransactions.Visible = false;
                    liPurchases.Visible    = false;
                    liCart.Visible         = false;

                    tabs2.Visible  = false;
                    tabs3.Visible  = false;
                    tabs4.Visible  = false;
                    tabs5.Visible  = false;
                    tabs6.Visible  = false;
                    tabs8.Visible  = false;
                    tabs10.Visible = false;
                    tabs7.Visible  = false;
                    tabs9.Visible  = false;
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #2
0
        protected override void LoadForm()
        {
            try
            {
                MembershipUser user = Helpers.LoggedUser;

                //form fields
                if (user != null)
                {
                    CurrentUserProfile = hccUserProfile.GetParentProfileBy((Guid)user.ProviderUserKey);

                    if (Roles.IsUserInRole("Customer"))
                    {
                        if (CurrentUserProfile == null)
                        {
                            CurrentUserProfile = new hccUserProfile
                            {
                                AccountBalance = 0.0m,
                                CreatedBy      = (Guid)user.ProviderUserKey,
                                CreatedDate    = DateTime.Now,
                                IsActive       = true,
                                MembershipID   = (Guid)user.ProviderUserKey,
                                ModifiedBy     = (Guid)user.ProviderUserKey,
                                ModifiedDate   = DateTime.Now
                            };

                            CurrentUserProfile.Save();
                        }

                        if (CurrentUserProfile != null)
                        {
                            this.PrimaryKeyIndex = CurrentUserProfile.UserProfileID;

                            //Basic Info
                            BasicEdit1.PrimaryKeyIndex = this.PrimaryKeyIndex;
                            BasicEdit1.Bind();

                            //shipping address
                            if (CurrentUserProfile.ShippingAddressID.HasValue)
                            {
                                AddressEdit_Shipping1.PrimaryKeyIndex = CurrentUserProfile.ShippingAddressID.Value;
                                AddressEdit_Shipping1.Bind();
                            }

                            ProfileNotesEdit_Shipping.CurrentUserProfileId = CurrentUserProfile.UserProfileID;
                            ProfileNotesEdit_Shipping.Bind();

                            //billing address
                            BillingInfoEdit1.PrimaryKeyIndex         = CurrentUserProfile.UserProfileID;
                            BillingInfoEdit1.CurrentBillingAddressID = CurrentUserProfile.BillingAddressID;
                            BillingInfoEdit1.Bind();

                            ProfileNotesEdit_Billing.CurrentUserProfileId = CurrentUserProfile.UserProfileID;
                            ProfileNotesEdit_Billing.Bind();

                            ProfilePrefsEdit1.PrimaryKeyIndex = CurrentUserProfile.UserProfileID;
                            ProfilePrefsEdit1.Bind();

                            ProfileAllgsEdit1.PrimaryKeyIndex = CurrentUserProfile.UserProfileID;
                            ProfileAllgsEdit1.Bind();

                            //subprofiles
                            BindgvwSubProfiles();
                            SubProfileEdit1.CurrentParentAspNetId  = (Guid)user.ProviderUserKey;
                            SubProfileEdit1.CurrentParentProfileId = CurrentUserProfile.UserProfileID;

                            //order history
                            PurchaseHistory1.CurrentAspNetId = (Guid)user.ProviderUserKey;
                            PurchaseHistory1.Bind();

                            //Recurring Orders
                            UserProfileRecurringOrders.CurrentAspNetId = (Guid)user.ProviderUserKey;
                            UserProfileRecurringOrders.Bind();
                        }
                    }
                    else
                    {
                        //This Account exists but doesn't have the Customer Role
                        //pnl_js_noncustomer.Visible = true;
                        li_link_01.Visible = false;
                        panel1.Visible     = false;
                        li_link_02.Visible = false;
                        panel2.Visible     = false;
                        li_link_03.Visible = false;
                        panel3.Visible     = false;
                        li_link_04.Visible = false;
                        panel4.Visible     = false;
                        li_link_05.Visible = false;
                        panel5.Visible     = false;
                        li_link_06.Visible = false;
                        panel6.Visible     = false;
                        li_link_07.Visible = false;
                        panel7.Visible     = false;
                        li_link_09.Visible = false;
                        panel9.Visible     = false;

                        if (CurrentUserProfile != null)
                        {
                            CurrentUserProfile.Activation(false);
                        }
                    }
                }
                else
                {
                    FormsAuthentication.RedirectToLoginPage();
                }
            }
            catch (Exception)
            {
                throw;
            }
        }