protected void Page_Load(object sender, EventArgs e) { _AffiliateAccounts = UserDataSource.LoadUserAffiliateAccounts(AbleContext.Current.User.Id); //IF SELEF SIGNUP IS NOT ALLOWED AND AFFILIATE IS NOT REGISTERED THEN NO ACCESS TO THIS PAGE if (!AbleContext.Current.Store.Settings.AffiliateAllowSelfSignup && _AffiliateAccounts.Count == 0) { Response.Redirect("MyAccount.aspx"); } //IF NO EXISTING AFFILIATE ACCOUNT THEN ENABLE SIGNUP if (_AffiliateAccounts.Count == 0) { AffiliateForm1.Visible = true; AffiliateInfoPanel.Visible = false; } //IF HAVE REGISTED AFFILIATE ACCOUNTS THEN SHOW THEM IN DROPDOWN else { AffiliateForm1.Visible = false; AffiliateInfoPanel.Visible = true; trAffiliateReport.Visible = true; int affiliateId = 0; if (!Page.IsPostBack && _AffiliateAccounts.Count > 1) { AffiliateAccountList.DataSource = _AffiliateAccounts; AffiliateAccountList.DataBind(); trMultiAccounts.Visible = true; } else if (!Page.IsPostBack && _AffiliateAccounts.Count == 1) { _Affiliate = _AffiliateAccounts[0]; trMultiAccounts.Visible = false; } if (_AffiliateAccounts.Count > 1) { affiliateId = AlwaysConvert.ToInt(AffiliateAccountList.SelectedValue); _Affiliate = AffiliateDataSource.Load(affiliateId); } else if (_AffiliateAccounts.Count == 1) { _Affiliate = _AffiliateAccounts[0]; } if (!Page.IsPostBack && _Affiliate != null) { BindAffiliateReport(); } HiddenAffiliateId.Value = _Affiliate.Id.ToString(); } }
protected void Page_Load(object sender, EventArgs e) { // get settings that impact menu tabs User user = AbleContext.Current.User; StoreSettingsManager settings = AbleContext.Current.Store.Settings; bool isRegistered = !user.IsAnonymous; // construct links NameValueCollection menuLinks = new NameValueCollection(); if (isRegistered) { menuLinks.Add("Orders", "MyAccount.aspx"); if (SubscriptionDataSource.CountForUser(user.Id) > 0) { menuLinks.Add("Subscriptions", "MySubscriptions.aspx"); } if (OrderItemDigitalGoodDataSource.CountForUser(user.Id) > 0 || DigitalGoodDataSource.FindByUserGroupsCount(user.Id) > 0) { menuLinks.Add("Digital Goods", "MyDigitalGoods.aspx"); } } if (settings.WishlistsEnabled) { menuLinks.Add("Wishlist", "MyWishlist.aspx"); } if (isRegistered) { menuLinks.Add("Profile", "MyCredentials.aspx"); if (settings.EnablePaymentProfilesStorage && !AbleContext.Current.User.IsAnonymousOrGuest) { menuLinks.Add("Payment Types", "PaymentTypes.aspx"); } menuLinks.Add("Address Book", "MyAddressBook.aspx"); if (settings.ProductReviewEnabled != CommerceBuilder.Users.UserAuthFilter.None) { menuLinks.Add("Product Reviews", "MyProductReviews.aspx"); } } int affiliateCount = UserDataSource.LoadUserAffiliateAccounts(user.Id).Count; if (affiliateCount > 0 || settings.AffiliateAllowSelfSignup) { menuLinks.Add("Affiliate Program", "MyAffiliateAccount.aspx"); } // determine active page string activePage = Request.Url.Segments[Request.Url.Segments.Length - 1].ToLowerInvariant(); // build menu StringBuilder menu = new StringBuilder(); menu.AppendLine("<div class=\"tabstrip\">"); menu.AppendLine("<ul>"); foreach (string key in menuLinks.AllKeys) { if (IsActive(activePage, menuLinks[key].ToLowerInvariant())) { menu.Append("<li class=\"active\">"); } else { menu.Append("<li>"); } menu.AppendLine("<a href=\"" + Page.ResolveUrl("~/Members/" + menuLinks[key]) + "\">" + key + "</a></li>"); } menu.AppendLine("</ul>"); menu.AppendLine("</div>"); MenuContent.Text = menu.ToString(); }