Пример #1
0
        /// <summary>
        /// The form load event handler.
        /// </summary>
        /// <param name="isPostback">Gets a value that indicates whether the form is being rendered for the first time or is being loaded in response to a postback.</param>
        /// <param name="args">The Render Form arguments.</param>
        public void Load(bool isPostback, RenderFormArgs args)
        {
            HtmlFormModifier form = new HtmlFormModifier(args);

              if (!MainUtil.IsLoggedIn())
              {
            form.ChangeFormIntroduction(string.Empty);
              }
              else
              {
            ICustomerManager<CustomerInfo> customerManager = Context.Entity.Resolve<ICustomerManager<CustomerInfo>>();
            string name = customerManager.CurrentUser.BillingAddress.Name;
            form.ChangeFormTitle(string.Format("{0} {1}.", Translate.Text(Examples.Texts.Welcome), name));
            form.HideSectionByField("Returning customer", "UserName");
            //Note: hiding of submit form button :)
            form.HideElement("div", "class", "scfSubmitButtonBorder");
              }
        }
Пример #2
0
        /// <summary>
        /// The form load event handler.
        /// </summary>
        /// <param name="isPostback">Gets a value that indicates whether the form is being rendered for the first time or is being loaded in response to a postback.</param>
        /// <param name="args">The Render Form arguments.</param>
        public void Load(bool isPostback, RenderFormArgs args)
        {
            HtmlFormModifier form = new HtmlFormModifier(args);

            if (!MainUtil.IsLoggedIn())
            {
                form.ChangeFormIntroduction(string.Empty);
            }
            else
            {
                ICustomerManager <CustomerInfo> customerManager = Context.Entity.Resolve <ICustomerManager <CustomerInfo> >();
                string name = customerManager.CurrentUser.BillingAddress.Name;
                form.ChangeFormTitle(string.Format("{0} {1}.", Translate.Text(Examples.Texts.Welcome), name));
                form.HideSectionByField("Returning customer", "UserName");
                //Note: hiding of submit form button :)
                form.HideElement("div", "class", "scfSubmitButtonBorder");
            }
        }
Пример #3
0
        /// <summary>
        /// Gets the most recent set options from the ShoppingCart and customerInfo instance
        /// and displays the options in the web form.
        /// If there are no items in the ShoppingCart, the user will be redirected to the
        /// home page.
        /// </summary>
        /// <param name="isPostback">Gets a value that indicates whether the form is being rendered for the first time or is being loaded in response to a postback.</param>
        /// <param name="args">The render form arguments.</param>
        public void Load(bool isPostback, RenderFormArgs args)
        {
            // Checks if the user has appropiate access.
              ICheckOut checkOut = Context.Entity.GetInstance<ICheckOut>();
              if (checkOut != null && checkOut is CheckOut)
              {
            if (!((CheckOut)checkOut).BeginCheckOut || !((CheckOut)checkOut).DeliveryDone)
            {
              HttpContext.Current.Response.Redirect("/");
            }
              }

              HtmlFormModifier form = new HtmlFormModifier(args);

              form.DisableInputField("UserName");

              /*
              Item navigationLinkItem = Utils.ItemUtil.GetNavigationLinkItem("Previous");
              if (navigationLinkItem != null)
              {
            form.AddButtonFromNavigationLink(navigationLinkItem, true);
              }
              */

              // If the user is logged in we hide the Create User boks.
              if (MainUtil.IsLoggedIn())
              {
            form.HideSectionByField("Create Username", "HideCreateUserSection");
              }

              ICustomerManager<CustomerInfo> customerManager = Context.Entity.Resolve<ICustomerManager<CustomerInfo>>();
              form.SetInputValue("UserName", customerManager.CurrentUser.Email);

              if (isPostback)
              {
            return;
              }

              ShoppingCart shoppingCart = Context.Entity.GetInstance<ShoppingCart>();
              shoppingCart.CustomerInfo = customerManager.CurrentUser;

              Context.Entity.SetInstance(shoppingCart);

              // Checks the Use other shipping address checkbox.
              // form.SetCheckboxSelected("HideThisSection", true);

              form.SetInputValue("Name", customerManager.CurrentUser.BillingAddress.Name);
              form.SetInputValue("Address", customerManager.CurrentUser.BillingAddress.Address);
              form.SetInputValue("Zip", customerManager.CurrentUser.BillingAddress.Zip);
              form.SetInputValue("City", customerManager.CurrentUser.BillingAddress.City);
              form.SetInputValue("Email", customerManager.CurrentUser.Email);

              if (customerManager.CurrentUser.BillingAddress.Country.Code != "US")
              {
            form.HideField("State");
              }
              else
              {
            form.SetSelectedDropListValue("State", customerManager.CurrentUser.BillingAddress.State);
              }

              if (customerManager.CurrentUser.ShippingAddress.Country.Code != "US")
              {
            form.HideField("ShippingState");
              }
              else
              {
            form.SetSelectedDropListValue("ShippingState", customerManager.CurrentUser.ShippingAddress.State);
              }

              form.SetSelectedDropListValue("Country", customerManager.CurrentUser.BillingAddress.Country.Name);

              /*
              // Only field out shipping address if it was checked before.
              if (checkOut is CheckOut)
              {
            if (!((CheckOut)checkOut).HasOtherShippingAddressBeenChecked)
            {
              return;
            }
              }
              */
              form.SetInputValue("ShippingName", customerManager.CurrentUser.ShippingAddress.Name);
              form.SetInputValue("ShippingAddress", customerManager.CurrentUser.ShippingAddress.Address);
              form.SetInputValue("ShippingZip", customerManager.CurrentUser.ShippingAddress.Zip);
              form.SetInputValue("ShippingCity", customerManager.CurrentUser.ShippingAddress.City);

              form.SetSelectedDropListValue("ShippingCountry", customerManager.CurrentUser.ShippingAddress.Country.Title);

              foreach (string key in customerManager.CurrentUser.CustomProperties.AllKeys)
              {
            form.SetInputValue(key, customerManager.CurrentUser.CustomProperties[key]);
              }
        }
Пример #4
0
        /// <summary>
        /// Gets the most recent set options from the ShoppingCart and customerInfo instance
        /// and displays the options in the web form.
        /// If there are no items in the ShoppingCart, the user will be redirected to the
        /// home page.
        /// </summary>
        /// <param name="isPostback">Gets a value that indicates whether the form is being rendered for the first time or is being loaded in response to a postback.</param>
        /// <param name="args">The render form arguments.</param>
        public void Load(bool isPostback, RenderFormArgs args)
        {
            // Checks if the user has appropiate access.
            ICheckOut checkOut = Context.Entity.GetInstance <ICheckOut>();

            if (checkOut != null && checkOut is CheckOut)
            {
                if (!((CheckOut)checkOut).BeginCheckOut || !((CheckOut)checkOut).DeliveryDone)
                {
                    HttpContext.Current.Response.Redirect("/");
                }
            }

            HtmlFormModifier form = new HtmlFormModifier(args);

            form.DisableInputField("UserName");

            /*
             * Item navigationLinkItem = Utils.ItemUtil.GetNavigationLinkItem("Previous");
             * if (navigationLinkItem != null)
             * {
             * form.AddButtonFromNavigationLink(navigationLinkItem, true);
             * }
             */

            // If the user is logged in we hide the Create User boks.
            if (MainUtil.IsLoggedIn())
            {
                form.HideSectionByField("Create Username", "HideCreateUserSection");
            }

            ICustomerManager <CustomerInfo> customerManager = Context.Entity.Resolve <ICustomerManager <CustomerInfo> >();

            form.SetInputValue("UserName", customerManager.CurrentUser.Email);

            if (isPostback)
            {
                return;
            }

            ShoppingCart shoppingCart = Context.Entity.GetInstance <ShoppingCart>();

            shoppingCart.CustomerInfo = customerManager.CurrentUser;

            Context.Entity.SetInstance(shoppingCart);

            // Checks the Use other shipping address checkbox.
            // form.SetCheckboxSelected("HideThisSection", true);

            form.SetInputValue("Name", customerManager.CurrentUser.BillingAddress.Name);
            form.SetInputValue("Address", customerManager.CurrentUser.BillingAddress.Address);
            form.SetInputValue("Zip", customerManager.CurrentUser.BillingAddress.Zip);
            form.SetInputValue("City", customerManager.CurrentUser.BillingAddress.City);
            form.SetInputValue("Email", customerManager.CurrentUser.Email);

            if (customerManager.CurrentUser.BillingAddress.Country.Code != "US")
            {
                form.HideField("State");
            }
            else
            {
                form.SetSelectedDropListValue("State", customerManager.CurrentUser.BillingAddress.State);
            }

            if (customerManager.CurrentUser.ShippingAddress.Country.Code != "US")
            {
                form.HideField("ShippingState");
            }
            else
            {
                form.SetSelectedDropListValue("ShippingState", customerManager.CurrentUser.ShippingAddress.State);
            }

            form.SetSelectedDropListValue("Country", customerManager.CurrentUser.BillingAddress.Country.Name);

            /*
             * // Only field out shipping address if it was checked before.
             * if (checkOut is CheckOut)
             * {
             * if (!((CheckOut)checkOut).HasOtherShippingAddressBeenChecked)
             * {
             *  return;
             * }
             * }
             */
            form.SetInputValue("ShippingName", customerManager.CurrentUser.ShippingAddress.Name);
            form.SetInputValue("ShippingAddress", customerManager.CurrentUser.ShippingAddress.Address);
            form.SetInputValue("ShippingZip", customerManager.CurrentUser.ShippingAddress.Zip);
            form.SetInputValue("ShippingCity", customerManager.CurrentUser.ShippingAddress.City);

            form.SetSelectedDropListValue("ShippingCountry", customerManager.CurrentUser.ShippingAddress.Country.Title);

            foreach (string key in customerManager.CurrentUser.CustomProperties.AllKeys)
            {
                form.SetInputValue(key, customerManager.CurrentUser.CustomProperties[key]);
            }
        }