Ejemplo n.º 1
0
    /// <summary>
    /// Saves the data.
    /// </summary>
    protected override void SaveStepData(object sender, StepEventArgs e)
    {
        base.SaveStepData(sender, e);

        if (PaymentGatewayProvider != null)
        {
            // Process inserted custom payment data from the payment form
            PaymentGatewayProvider.ProcessCustomData();
        }
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Saves the wizard step data.
    /// </summary>
    protected override void SaveStepData(object sender, StepEventArgs e)
    {
        base.SaveStepData(sender, e);

        // Clear shipping option if cart does not need shipping
        if (!ShoppingCart.IsShippingNeeded)
        {
            ShoppingCart.ShoppingCartShippingOptionID = 0;
        }
    }
    protected override void SaveStepData(object sender, StepEventArgs e)
    {
        if (useWebpartSettings)
        {
            ShoppingCart.RegisterAfterCheckout = chkRegister.Checked;
            ShoppingCart.RegisterAfterCheckoutTemplate = GetStringValue("EmailTemplate", "");
        }

        base.SaveStepData(sender, e);
    }
    /// <summary>
    /// Changes the current step
    /// </summary>
    /// <param name="offset">Offset by which the step should move</param>
    /// <param name="eventName">Event name to fire prior to step change</param>
    protected void ChangeStep(int offset)
    {
        if (offset == 0)
        {
            return;
        }

        int steps    = Steps;
        int original = CurrentStepIndex;

        // Fire the event to validate current step
        var args = new StepEventArgs(steps, original);

        if (stepLoaded)
        {
            ComponentEvents.RequestEvents.RaiseEvent(this, args, ComponentEvents.VALIDATE_STEP);

            if (args.Cancel)
            {
                // Cancel if not validated
                return;
            }

            // Fire the event to finish current step
            ComponentEvents.RequestEvents.RaiseEvent(this, args, ((offset > 0) ? ComponentEvents.FINISH_STEP : ComponentEvents.CANCEL_STEP));

            if (args.Cancel)
            {
                // Cancel if not finished
                return;
            }
        }

        // Reevaluate the current item index
        int current = original + offset;

        if (current < 1)
        {
            current = 1;
        }
        if (current > Steps)
        {
            current = Steps;
        }

        // Move the step by the given index
        CurrentStepIndex = current;

        // Change the step
        if (original != current)
        {
            // Load the step
            LoadStep(args, current);
        }
    }
Ejemplo n.º 5
0
    protected override void StepFinished(object sender, StepEventArgs e)
    {
        base.StepFinished(sender, e);
        // We are on last step and checkout process has not been finalized yet by any web part
        if (e.IsLastStep && (e.GetValue(CHOP_FINALIZED_KEY) == null))
        {
            string validationMessage;
            // Validate cart; in case of failure user is able to go through checkout process and fix errors
            if (!ValidateShoppingCart(ShoppingCart, out validationMessage))
            {
                e.CancelEvent = true;
                ShowError(validationMessage);
                e.SetValue(CHOP_FINALIZED_KEY, true);
                return;
            }

            if (FinalizeCheckout())
            {
                int    orderId   = ShoppingCart.OrderId;
                string orderHash = ShoppingCart.GetHashCode().ToString();
                WindowHelper.Add(orderHash, orderId);
                // Create URL for payment page with order id hidden in hash
                e.FinalStepUrl = URLHelper.AddParameterToUrl(e.FinalStepUrl, "o", orderHash);
            }
            else
            {
                // Log events created in transaction
                foreach (Tuple <string, string> error in loggedErrors)
                {
                    EventLogProvider.LogEvent(EventType.ERROR, EVENT_SOURCE, error.Item2, error.Item1);
                }

                foreach (Exception ex in loggedExceptions)
                {
                    EventLogProvider.LogException(EVENT_SOURCE, EVENT_CODE_EXCEPTION, ex);
                }

                e.CancelEvent = true;
                // Get error text
                string errorMessage = HTMLHelper.HTMLEncode(ResHelper.GetString("ecommerce.orderpreview.errorordersave"));

                if (!string.IsNullOrEmpty(registrationBanned))
                {
                    errorMessage += HTMLHelper.HTMLEncode(Environment.NewLine + registrationBanned);
                }

                ShowError(errorMessage);
            }

            CleanUpShoppingCart();
            DocumentWizardManager.ResetWizard();

            e.SetValue(CHOP_FINALIZED_KEY, true);
        }
    }
    protected override void SaveStepData(object sender, StepEventArgs e)
    {
        base.SaveStepData(sender, e);

        // Just set current filed values into EditableObject, saving was canceled in OnBeforeSave
        customerForm.SaveData(null, false);

        var customer = customerForm.EditedObject as CustomerInfo;

        if (customer == null)
        {
            throw new InvalidOperationException("Customer cannot be null while saving step data.");
        }

        var typeSelector = TypeSelector;

        // Clear company fields for non-company type
        if ((typeSelector != null) && !typeSelector.Value.Equals(COMPANY_TYPE))
        {
            customer.CustomerCompany           = "";
            customer.CustomerOrganizationID    = "";
            customer.CustomerTaxRegistrationID = "";
        }

        if (customer.CustomerID < 1 && ShoppingCart.ShoppingCartUserID > 0)
        {
            // Connect newly created customer with registered user -> if user returns to the site, customer`s data will be filled
            customer.CustomerUserID = ShoppingCart.ShoppingCartUserID;
        }
        customer.CustomerSiteID = ShoppingCart.ShoppingCartSiteID;

        var shoppingService = Service.Resolve <IShoppingService>();

        shoppingService.SetCustomer(customer);

        // Address cannot be inserted before customer is saved (otherwise it would be an orphan address)
        // In case of address update - AddressName and AddressPersonalName should be re-generated according current customer info (if not present on the address form)
        if (((shoppingService.GetBillingAddress() == null) ||
             (shoppingService.GetShippingAddress() == null) ||
             (ShoppingCart.ShoppingCartCompanyAddress != null)) &&
            (customer.CustomerID > 0))
        {
            SaveCustomerAddresses(ShoppingCart);
        }

        ShoppingCartInfoProvider.SetShoppingCartInfo(ShoppingCart);

        // Update contact with customer details
        var dci     = DataClassInfoProvider.GetDataClassInfo(customer.TypeInfo.ObjectClassName);
        var mapper  = new ContactDataMapper(dci.ClassName, dci.ClassContactOverwriteEnabled);
        var checker = new CustomerContactDataPropagationChecker();

        Service.Resolve <IContactDataInjector>().Inject(customer, ContactID, mapper, checker);
    }
Ejemplo n.º 7
0
    protected override void StepFinished(object sender, StepEventArgs e)
    {
        base.StepFinished(sender, e);
        // We are on last step and we don't have order yet
        if (e.IsLastStep && (e.GetValue(ORDER_CREATED_KEY) == null))
        {
            if (FinalizeCheckout())
            {
                int    orderId   = ShoppingCart.OrderId;
                string orderHash = ShoppingCart.GetHashCode().ToString();
                WindowHelper.Add(orderHash, orderId);
                // Create URL for payment page with order id hidden in hash
                e.FinalStepUrl = URLHelper.AddParameterToUrl(e.FinalStepUrl, "o", orderHash);
            }
            else
            {
                // Log events created in transaction
                foreach (Tuple <string, string> error in loggedErrors)
                {
                    EventLogProvider.LogEvent(EventType.ERROR, EVENT_SOURCE, error.Item2, error.Item1);
                }

                foreach (Exception ex in loggedExceptions)
                {
                    EventLogProvider.LogException(EVENT_SOURCE, EVENT_CODE_EXCEPTION, ex);
                }

                e.CancelEvent = true;
                // Get error text
                string errorMessage = HTMLHelper.HTMLEncode(ResHelper.GetString("ecommerce.orderpreview.errorordersave"));

                if (!string.IsNullOrEmpty(registrationBanned))
                {
                    errorMessage += HTMLHelper.HTMLEncode(Environment.NewLine + registrationBanned);
                }

                // Try to show message through Message Panel web part
                CMSEventArgs <string> args = new CMSEventArgs <string>();
                args.Parameter = errorMessage;
                ComponentEvents.RequestEvents.RaiseEvent(this, args, MESSAGE_RAISED);

                // If Message Panel web part is not present (Parameter is cleared by web part after successful handling), show message through alert script
                if (!string.IsNullOrEmpty(args.Parameter))
                {
                    ScriptHelper.Alert(Page, errorMessage);
                }
            }

            CleanUpShoppingCart();
            DocumentWizardManager.ResetWizard();

            e.SetValue(ORDER_CREATED_KEY, true);
        }
    }
Ejemplo n.º 8
0
    /// <summary>
    /// Next step
    /// </summary>
    private void ProcessNextStep(object sender, EventArgs e)
    {
        StepEventArgs sea = e as StepEventArgs;

        if (sea == null)
        {
            sea = StepEventArgs;
        }

        ProcessNextStep(sender, sea, true);
    }
Ejemplo n.º 9
0
    /// <summary>
    /// Validates data.
    /// </summary>
    protected override void ValidateStepData(object sender, StepEventArgs e)
    {
        base.ValidateStepData(sender, e);

        if (!StopProcessing && (PaymentGatewayProvider != null))
        {
            if (PaymentGatewayProvider.ValidateCustomData() != "")
            {
                e.CancelEvent = true;
            }
        }
    }
Ejemplo n.º 10
0
 /// <summary>
 /// Validates the data.
 /// </summary>
 protected override void ValidateStepData(object sender, StepEventArgs e)
 {
     base.ValidateStepData(sender, e);
     lblError.Visible = false;
     // If shipping selector is visible (needed) check if something is selected
     if (pnlShipping.Visible && (drpShipping.SelectedID == 0))
     {
         e.CancelEvent    = true;
         lblError.Text    = ResHelper.GetString("com.checkoutprocess.shippingneeded");
         lblError.Visible = true;
     }
 }
    /// <summary>
    /// Loads the given step
    /// </summary>
    /// <param name="args">Step arguments</param>
    /// <param name="current">Step index</param>
    private void LoadStep(StepEventArgs args, int current)
    {
        // Ensure the event arguments
        if (args == null)
        {
            args = new StepEventArgs(this.Steps, current);
        }

        args.FinalStepUrl = FinishRedirectUrl;
        args.CurrentStep  = current;

        // Fire the event to finish current step
        ComponentEvents.RequestEvents.RaiseEvent(this, args, ComponentEvents.LOAD_STEP);

        // Skip the current step if requested
        if (args.Skip)
        {
            ChangeStep(1);
        }
        else
        {
            // Use the custom step header if set
            string header = GetHeader(current);
            if (!String.IsNullOrEmpty(header))
            {
                args["StepHeader"] = header;
            }

            // Use the custom step icon if set
            string icon = GetIcon(current);
            if (!String.IsNullOrEmpty(icon))
            {
                args["StepIcon"] = icon;
            }

            // Use the custom step description if set
            string description = GetDescription(current);
            if (!String.IsNullOrEmpty(description))
            {
                args["StepInfo"] = description;
            }

            // Handle the next button display
            string finishUrl = String.IsNullOrEmpty(args.FinalStepUrl) ? FinishRedirectUrl : args.FinalStepUrl;
            if ((args.Steps == current) && String.IsNullOrEmpty(finishUrl))
            {
                args.HideNextButton = true;
            }

            // Fire the event to notify that the step was loaded
            ComponentEvents.RequestEvents.RaiseEvent(this, args, ComponentEvents.STEP_LOADED);
        }
    }
    protected override void ValidateStepData(object sender, StepEventArgs e)
    {
        base.ValidateStepData(sender, e);

        if (!customerForm.ValidateData() || !ValidateCustomerEmailIsUnique())
        {
            if (e != null)
            {
                e.CancelEvent = true;
            }
        }
    }
Ejemplo n.º 13
0
        ///--------------------------------------------------------------------------------
        /// <summary>This method applies step deletes.</summary>
        ///--------------------------------------------------------------------------------
        public void ProcessDeleteStepPerformed(StepEventArgs data)
        {
            try
            {
                bool isItemMatch = false;
                if (data != null && data.Step != null)
                {
                    foreach (StepViewModel item in Steps.ToList <StepViewModel>())
                    {
                        if (item.Step.StepID == data.Step.StepID)
                        {
                            // remove item from tabs, if present
                            WorkspaceEventArgs message = new WorkspaceEventArgs();
                            message.ItemID = item.Step.StepID;
                            Mediator.NotifyColleagues <WorkspaceEventArgs>(MediatorMessages.Command_CloseItemRequested, message);

                            // delete children
                            for (int i = item.Items.Count - 1; i >= 0; i--)
                            {
                                if (item.Items[i] is StepTransitionViewModel)
                                {
                                    StepTransitionViewModel child        = item.Items[i] as StepTransitionViewModel;
                                    StepTransitionEventArgs childMessage = new StepTransitionEventArgs();
                                    childMessage.StepTransition = child.StepTransition;
                                    childMessage.ToStepID       = item.Step.StepID;
                                    childMessage.Solution       = Solution;
                                    childMessage.WorkspaceID    = child.WorkspaceID;
                                    item.ProcessDeleteStepTransitionPerformed(childMessage);
                                }
                            }

                            // delete item
                            isItemMatch = true;
                            Steps.Remove(item);
                            Stage.StepList.Remove(item.Step);
                            Items.Remove(item);
                            Stage.ResetModified(true);
                            OnUpdated(this, null);
                            break;
                        }
                    }
                    if (isItemMatch == false)
                    {
                        ShowIssue(DisplayValues.Issue_DeleteItemNotFound);
                    }
                }
            }
            catch (Exception ex)
            {
                ShowIssue(ex.Message + ex.StackTrace);
            }
        }
    /// <summary>
    /// Reloads the texts of the control
    /// </summary>
    /// <param name="e">Step event arguments</param>
    /// <param name="forceLoad">If true, the load is forced</param>
    protected void ReloadTexts(StepEventArgs e, bool forceLoad)
    {
        if (loaded && !forceLoad)
        {
            return;
        }
        loaded = true;

        string header = null;
        string info   = null;
        string icon   = null;

        int current = 1;
        int steps   = 1;

        if (e != null)
        {
            // Use custom header/info/icon
            header = e["StepHeader"] as string;
            info   = e["StepInfo"] as string;
            icon   = e["StepIcon"] as string;

            current = e.CurrentStep;
            steps   = e.Steps;
        }

        // Setup the default texts
        if (header == null)
        {
            header = HeaderText;
        }

        if (icon == null)
        {
            icon = Icon;
        }

        if (info == null)
        {
            info = InfoText;
        }

        // Format the header {0} = current step index, {1} = total number of steps
        header = String.Format(header, current, steps);
        info   = String.Format(info, current, steps);
        icon   = String.Format(icon, current, steps);

        this.ltlHeader.Text   = header;
        this.ltlInfo.Text     = info;
        this.imgIcon.ImageUrl = icon;
    }
Ejemplo n.º 15
0
 private void Checker_StepChanged(object sender, StepEventArgs e)
 {
     if (e.Step >= _buttonsCount)
     {
         SetColor(_buttonsCount, _black, _white);
         MainScreens.Learning.Instance.ActivateNextStep();
         ShowEndMessage();
     }
     else
     {
         _currentStep = e.Step;
         SetColor(_currentStep, _black, _white);
     }
 }
Ejemplo n.º 16
0
        private static void Game_OnStepExecuted(object sender, StepEventArgs e)
        {
            Game game = sender as Game;

            if (game == null)
            {
                return;
            }

            if (game.State.Cells.Contains(e.Cell, new CellComparater()))
            {
                throw new CellFilledExcention("Cell is busy");
            }
        }
    /// <summary>
    /// Reloads the texts of the control
    /// </summary>
    /// <param name="e">Step event arguments</param>
    /// <param name="forceLoad">If true, the load is forced</param>
    protected void ReloadTexts(StepEventArgs e, bool forceLoad)
    {
        if (loaded && !forceLoad)
        {
            return;
        }
        loaded = true;

        // Setup the default texts
        string header = this.HeaderText;
        string info   = this.InfoText;
        string icon   = this.Icon;

        int current = 1;
        int steps   = 1;

        if (e != null)
        {
            // Use custom header
            if (e.StepHeader != null)
            {
                header = e.StepHeader;
            }

            // Use custom info
            if (e.StepInfo != null)
            {
                info = e.StepInfo;
            }

            // Use custom icon
            if (e.StepIcon != null)
            {
                icon = e.StepIcon;
            }

            current = e.CurrentStep;
            steps   = e.Steps;
        }

        // Format the header {0} = current step index, {1} = total number of steps
        header = String.Format(header, current, steps);
        info   = String.Format(info, current, steps);
        icon   = String.Format(icon, current, steps);

        this.ltlHeader.Text   = header;
        this.ltlInfo.Text     = info;
        this.imgIcon.ImageUrl = icon;
    }
Ejemplo n.º 18
0
    /// <summary>
    /// Validates data
    /// </summary>
    protected override void ValidateStepData(object sender, StepEventArgs e)
    {
        base.ValidateStepData(sender, e);

        if (!StopProcessing)
        {
            if (!addressForm.ValidateData())
            {
                e.CancelEvent = true;
                return;
            }
            // Just set current filed values into EditableObject, saving was canceled in OnBeforeSave
            addressForm.SaveData(null, false);

            AddressInfo address = addressForm.EditedObject as AddressInfo;
            if (address != null)
            {
                // Validate state
                if (!DataHelper.DataSourceIsEmpty(StateInfoProvider.GetCountryStates(address.AddressCountryID)))
                {
                    if (address.AddressStateID < 1)
                    {
                        e.CancelEvent = true;
                        addressForm.DisplayErrorLabel("AddressCountryID", ResHelper.GetString("com.address.nostate"));
                        return;
                    }
                }


                // Clear AddressName and AddressPersonalName to force their update (only if not present on the address form)
                if (!addressForm.FieldControls.Contains("AddressName"))
                {
                    address.AddressName = null;
                }
                if (!addressForm.FieldControls.Contains("AddressPersonalName"))
                {
                    address.AddressPersonalName = null;
                }

                // Assign validated new address to the current shopping cart
                // Address will be saved by customer detail web part (existing customer object is needed for the address)
                CurrentCartAddress = address;
            }
        }

        // Clear shipping address (StopProcessing is true when chkShowAddress is cleared)
        ClearShippingAddress();
    }
    protected override void ValidateStepData(object sender, StepEventArgs e)
    {
        base.ValidateStepData(sender, e);

        bool valid = ApplyDiscountCoupon();

        if (!valid)
        {
            pnlError.Visible = true;
            e.CancelEvent    = true;
        }
        else
        {
            pnlError.Visible = false;
        }
    }
    protected override void StepLoaded(object sender, StepEventArgs e)
    {
        base.StepLoaded(sender, e);

        // The default value is Personal, but if customer has some company fields filled, the Company account type should be selected
        if (!RequestHelper.IsPostBack())
        {
            SetCompanyAccountType();
        }

        // Propagate changes on postback if there is customer with company type and some tax registration id
        if (PropagateChangesOnPostback && (ShoppingCart.Customer != null))
        {
            ChangeTaxRegistrationIdBasedOnAccountType();
        }
    }
Ejemplo n.º 21
0
        ///--------------------------------------------------------------------------------
        /// <summary>This method processes the new step command.</summary>
        ///--------------------------------------------------------------------------------
        public void ProcessNewStepCommand()
        {
            StepEventArgs message = new StepEventArgs();

            message.Step          = new Step();
            message.Step.StepID   = Guid.NewGuid();
            message.Step.StageID  = Stage.StageID;
            message.Step.Stage    = Stage;
            message.StageID       = Stage.StageID;
            message.Step.Solution = Solution;
            message.Solution      = Solution;
            if (message.Step.Stage != null)
            {
                message.Step.Order = message.Step.Stage.StepList.Count + 1;
            }
            message.WorkspaceID = WorkspaceID;
            Mediator.NotifyColleagues <StepEventArgs>(MediatorMessages.Command_EditStepRequested, message);
        }
Ejemplo n.º 22
0
    protected override void SaveStepData(object sender, StepEventArgs e)
    {
        base.SaveStepData(sender, e);

        // Just set current filed values into EditableObject, saving was canceled in OnBeforeSave
        customerForm.SaveData(null, false);

        var customer     = customerForm.EditedObject as CustomerInfo;
        var typeSelector = TypeSelector;

        // Clear company fields for non-company type
        if ((customer != null) && (typeSelector != null) && !typeSelector.Value.Equals(COMPANY_TYPE))
        {
            customer.CustomerCompany           = "";
            customer.CustomerOrganizationID    = "";
            customer.CustomerTaxRegistrationID = "";
        }

        var cart = ShoppingCart;

        // Assign save customer to the shopping cart -> will be needed for addresses
        cart.Customer = SaveCustomer(customer, cart.ShoppingCartUserID, cart.ShoppingCartSiteID);

        // Address cannot be inserted before customer is saved (otherwise it would be an orphan address)
        // In case of address update - AddressName and AddressPersonalName should be re-generated according current customer info (if not present on the address form)
        if (((cart.ShoppingCartBillingAddress != null) ||
             (cart.ShoppingCartShippingAddress != null) ||
             (cart.ShoppingCartCompanyAddress != null)) &&
            (customer != null) && (customer.CustomerID > 0))
        {
            SaveCustomerAddresses(cart);
        }

        ShoppingCartInfoProvider.SetShoppingCartInfo(cart);

        // Update contact with customer details
        if (customer != null)
        {
            var dci     = DataClassInfoProvider.GetDataClassInfo(customer.TypeInfo.ObjectClassName);
            var mapper  = new ContactDataMapper(dci.ClassName, dci.ClassContactOverwriteEnabled);
            var checker = new CustomerContactDataPropagationChecker();
            Service.Resolve <IContactDataInjector>().Inject(customer, ContactID, mapper, checker);
        }
    }
Ejemplo n.º 23
0
    protected override void ValidateStepData(object sender, StepEventArgs e)
    {
        base.ValidateStepData(sender, e);

        var valid = ApplyDiscountCoupon();

        pnlError.Visible = !valid;

        // Make sure that in-memory changes persist (unsaved address, etc.)
        Service.Resolve <ICurrentShoppingCartService>().SetCurrentShoppingCart(ShoppingCart);

        // Applying discount coupon changes AppliedCouponCodes property which invalidates and recalculates shopping cart -> other web parts must be informed
        ComponentEvents.RequestEvents.RaiseEvent(this, e, SHOPPING_CART_CHANGED);

        if (!string.IsNullOrEmpty(CouponCode) && !valid)
        {
            e.CancelEvent = true;
        }
    }
Ejemplo n.º 24
0
    protected override void ValidateStepData(object sender, StepEventArgs e)
    {
        base.ValidateStepData(sender, e);

        bool valid = ApplyDiscountCoupon();

        // Applying discount coupon changes ShoppingCartCouponCode property which invalidates and recalculates shopping cart -> other web parts must be informed
        ComponentEvents.RequestEvents.RaiseEvent(sender, e, SHOPPING_CART_CHANGED);

        if (!valid)
        {
            pnlError.Visible = true;
            e.CancelEvent    = true;
        }
        else
        {
            pnlError.Visible = false;
        }
    }
    protected override void ValidateStepData(object sender, StepEventArgs e)
    {
        base.ValidateStepData(sender, e);

        bool valid = chkAccept.Checked;

        if (!valid)
        {
            pnlError.Visible = true;
            e.CancelEvent = true;

            // Get the custom error text if filled out
            lblError.Text = ValidationHelper.GetString(GetValue("ErrorMessage"), "");
        }
        else
        {
            pnlError.Visible = false;
        }
    }
    protected override void ValidateStepData(object sender, StepEventArgs e)
    {
        base.ValidateStepData(sender, e);

        bool valid = chkAccept.Checked;

        if (!valid)
        {
            pnlError.Visible = true;
            e.CancelEvent    = true;

            // Get the custom error text if filled out
            lblError.Text = ValidationHelper.GetString(GetValue("ErrorMessage"), "");
        }
        else
        {
            pnlError.Visible = false;
        }
    }
    protected override void SaveStepData(object sender, StepEventArgs e)
    {
        base.SaveStepData(sender, e);

        // Just set current filed values into EditableObject, saving was canceled in OnBeforeSave
        customerForm.SaveData(null, false);

        CustomerInfo          customer     = customerForm.EditedObject as CustomerInfo;
        FormEngineUserControl typeSelector = TypeSelector;

        // Clear company fields for non-company type
        if ((typeSelector != null) && (!typeSelector.Value.Equals(COMPANY_TYPE)))
        {
            customer.CustomerCompany           = "";
            customer.CustomerOrganizationID    = "";
            customer.CustomerTaxRegistrationID = "";
        }

        ShoppingCart.Customer = customer;
    }
Ejemplo n.º 28
0
    /// <summary>
    /// Saves data
    /// </summary>
    protected override void SaveStepData(object sender, StepEventArgs e)
    {
        base.SaveStepData(sender, e);

        if (!StopProcessing)
        {
            // Set current address
            AddressInfo ai = addressForm.EditedObject as AddressInfo;
            if (ai != null)
            {
                CurrentCartAddress = ai;
                var customer = ShoppingCart.Customer;

                if (string.IsNullOrEmpty(ai.AddressPersonalName) && (customer != null))
                {
                    ai.AddressPersonalName = TextHelper.LimitLength(string.Format("{0} {1}", customer.CustomerFirstName, customer.CustomerLastName), 200);
                }

                if (ai.AddressID != 0)
                {
                    // Save potential customer changes before address is updated
                    if ((customer != null) && (customer.CustomerID != 0))
                    {
                        customer.Update();
                    }

                    ai.Update();
                }
            }
        }

        // Clear shipping address if shipping checkbox is unchecked
        if ((AddressType == SHIPPING) && (!chkShowAddress.Checked))
        {
            ShoppingCart.ShoppingCartShippingAddress = null;
        }

        // Set shopping cart with current address change
        ShoppingCartInfoProvider.SetShoppingCartInfo(ShoppingCart);
        ShoppingCart.InvalidateCalculations();
    }
Ejemplo n.º 29
0
    /// <summary>
    /// Fired when the step is loaded.
    /// </summary>
    protected void StepLoaded(object sender, EventArgs e)
    {
        StepEventArgs args             = (StepEventArgs)e;
        int           currentStepIndex = args.CurrentStep;

        // Display/hide place holders and buttons
        plcSelectTemplate.Visible = (currentStepIndex == 1);
        plcContent.Visible        = plcContent.EnableViewState = pnlActions.Visible = ucVariantDialog.Visible = (currentStepIndex == 2);
        if (currentStepIndex != 2)
        {
            pnlSlider.Visible = false;
        }
        plcSend.Visible = (currentStepIndex == 3);
        bool isIssueVariant = false;

        if (currentStepIndex == 3)
        {
            var issue = IssueInfoProvider.GetIssueInfo(IssueId);
            isIssueVariant      = (issue != null) && issue.IssueIsABTest;
            sendElem.Visible    = !isIssueVariant;
            sendVariant.Visible = !sendElem.Visible;
        }

        if (currentStep == 2)
        {
            btnNext.OnClientClick = "if (GetContent != null) {return GetContent();}";
        }

        btnBack.Visible      = !args.HideBackButton && (currentStep == Steps);
        btnNext.Visible      = !args.HideNextButton;
        btnFinish.Visible    = (currentStepIndex == Steps) && !isIssueVariant;
        btnSendClose.Visible = (currentStepIndex == Steps) && isIssueVariant;

        btnClose.Visible = (currentStepIndex != 3);

        btnSave.Visible = (currentStepIndex == 3) && isIssueVariant;

        // Raise flag
        stepLoaded = true;
    }
    /// <summary>
    /// Loads the given step.
    /// </summary>
    /// <param name="args">Step arguments</param>
    /// <param name="current">Step index</param>
    private void LoadStep(StepEventArgs args, int current)
    {
        // Ensure the event arguments
        if (args == null)
        {
            args = new StepEventArgs(this.Steps, current);
        }

        args.CurrentStep = current;

        // Fire the event to finish current step
        ComponentEvents.RequestEvents.RaiseEvent(this, args, ComponentEvents.LOAD_STEP);

        // Skip the current step if requested
        if (args.Skip)
        {
            ChangeStep(1);
        }
        else
        {
            // Use the custom step header if set
            string header = GetHeader(current);
            if (!String.IsNullOrEmpty(header))
            {
                args.StepHeader      = header;
                ucHeader.Description = header;
            }
            ucHeader.Title  = String.Format(GetString("newsletterissue_new.step"), current - (SelectionSkipped ? 1 : 0));
            ucHeader.Header = GetString("newsletterissue_new.newissue");

            // Handle the next button display
            if (args.Steps == current)
            {
                args.HideNextButton = true;
            }

            // Fire the event to notify that the step was loaded
            ComponentEvents.RequestEvents.RaiseEvent(this, args, ComponentEvents.STEP_LOADED);
        }
    }
    protected override void StepLoaded(object sender, StepEventArgs e)
    {
        base.StepLoaded(sender, e);

        if (ShoppingCart.Customer != null)
        {
            customerForm.EditedObject = ShoppingCart.Customer;
        }

        if (!RequestHelper.IsPostBack())
        {
            customerForm.ReloadData();
        }

        // Set first time user customer for postback tax recalculation
        if (PropagateChangesOnPostback && (ShoppingCart.Customer == null))
        {
            ShoppingCart.Customer = customerForm.EditedObject as CustomerInfo;
        }

        // Propagate changes on postback if there is customer with company type and some tax registration id
        if (PropagateChangesOnPostback && (ShoppingCart.Customer != null))
        {
            FormEngineUserControl typeSelector = TypeSelector;
            bool isPersonalType            = (typeSelector != null) && (!typeSelector.Value.Equals(COMPANY_TYPE));
            var  customerTaxRegistrationID = customerForm.GetFieldValue("CustomerTaxRegistrationID");

            if ((customerTaxRegistrationID == null) || isPersonalType)
            {
                ShoppingCart.Customer.CustomerTaxRegistrationID = string.Empty;
            }
            else
            {
                ShoppingCart.Customer.CustomerTaxRegistrationID = customerTaxRegistrationID.ToString();
            }

            ShoppingCart.InvalidateCalculations();
            ComponentEvents.RequestEvents.RaiseEvent(null, e, SHOPPING_CART_CHANGED);
        }
    }
    /// <summary>
    /// Actions handler.
    /// </summary>
    protected void HeaderActions_ActionPerformed(object sender, CommandEventArgs e)
    {
        switch (e.CommandName.ToLowerInvariant())
        {
        // Validate and save the content
        case "save":
            // Fire the event to validate current step
            var args = new StepEventArgs(Steps, CurrentStepIndex);

            ComponentEvents.RequestEvents.RaiseEvent(this, args, ComponentEvents.VALIDATE_STEP);

            if (args.Cancel)
            {
                // Cancel if not validated
                return;
            }

            ComponentEvents.RequestEvents.RaiseEvent(this, args, ComponentEvents.FINISH_STEP);

            if (args.Cancel)
            {
                // Cancel if not successfully saved
                return;
            }

            // Reload edit control
            editElem.ReloadData(true);

            // Initialize action menu
            InitHeaderActions();

            // Show save message
            ShowChangesSaved();

            ComponentEvents.RequestEvents.RaiseEvent(this, args, ComponentEvents.STEP_LOADED);
            break;
        }
    }
    /// <summary>
    /// Step loaded event
    /// </summary>
    protected override void StepLoaded(object sender, StepEventArgs e)
    {
        base.StepLoaded(sender, e);

        if (!StopProcessing)
        {
            // Check whether condition is defined
            if (!String.IsNullOrEmpty(ActionCondition))
            {
                // Check condition value
                var res = ContextResolver.ResolveMacroExpression(ActionCondition, true);
                if ((res != null) && ValidationHelper.GetBoolean(res.Result, false))
                {
                    // Ensure action
                    switch (ActionType.ToLowerCSafe())
                    {
                        // Skip
                        case "skip":
                            e["RaiseEvents"] = ValidationHelper.GetBoolean(GetValue("ValidateSkip"), false);
                            e.Skip = true;
                            break;

                        //Next
                        case "next":
                            ComponentEvents.RequestEvents.RaiseComponentEvent(this, e, "PageWizardManager", ComponentEvents.NEXT);
                            break;

                        // Previous
                        case "previous":
                            ComponentEvents.RequestEvents.RaiseComponentEvent(this, e, "PageWizardManager", ComponentEvents.PREVIOUS);
                            break;
                    }
                }
            }
        }
    }
Ejemplo n.º 34
0
    /// <summary>
    /// Step loaded
    /// </summary>
    protected override void StepLoaded(object sender, StepEventArgs e)
    {
        base.StepLoaded(sender, e);

        if (WizardManager.Steps.Count != 0)
        {
            Visible = true;
            StopProcessing = false;
        }
    }
    /// <summary>
    /// Validates data
    /// </summary>
    protected override void ValidateStepData(object sender, StepEventArgs e)
    {
        base.ValidateStepData(sender, e);

        if (!StopProcessing)
        {
            if (!addressForm.ValidateData())
            {
                e.CancelEvent = true;
                return;
            }
            // Just set current filed values into EditableObject, saving was canceled in OnBeforeSave
            addressForm.SaveData(null, false);

            AddressInfo ai = addressForm.EditedObject as AddressInfo;
            if (ai != null)
            {
                // Validate state
                if (!DataHelper.DataSourceIsEmpty(StateInfoProvider.GetCountryStates(ai.AddressCountryID)))
                {
                    if (ai.AddressStateID < 1)
                    {
                        e.CancelEvent = true;
                        addressForm.DisplayErrorLabel("AddressCountryID", ResHelper.GetString("com.address.nostate"));
                    }
                }
            }
        }
    }
    protected override void LoadStep(object sender, StepEventArgs e)
    {
        base.LoadStep(sender, e);

        // Ensure log off check only once
        if (e.GetValue(LOG_OFF_VALIDATION) == null)
        {
            e.SetValue(LOG_OFF_VALIDATION, true);
            // Get current shopping cart user id, 0 for null (public user)
            int currentUserId = ShoppingCart.User == null ? 0 : ShoppingCart.User.UserID;
            // Get last known user saved in previous load of WP. In case there is no record in session current user id is retrieved.
            object userIdSessionObject = SessionHelper.GetValue("CheckoutUserID");
            int lastKnownUserID = ValidationHelper.GetInteger(userIdSessionObject, currentUserId);

            // Reset checkout process in case of different users. Possible log-off or login as another user
            if (lastKnownUserID != currentUserId)
            {
                DocumentWizardManager.ResetWizard();

                SessionHelper.Remove("CheckoutUserID");
                // Refresh page for wizard to jump at first step
                URLHelper.Redirect(RequestContext.CurrentURL);
            }

            // Set user id to session for non public users. Change from public user to authorized does not reset checkout process.
            if (currentUserId != 0)
            {
                SessionHelper.SetValue("CheckoutUserID", currentUserId);
            }
            // Clean session entry (if there was one) for public user in case of log-off action to remove previous user id.
            else if (userIdSessionObject != null)
            {
                SessionHelper.Remove("CheckoutUserID");
            }
        }
    }
    /// <summary>
    /// Validates the data.
    /// </summary>
    protected override void ValidateStepData(object sender, StepEventArgs e)
    {
        base.ValidateStepData(sender, e);

        if (!CheckShoppingCart())
        {
            e.CancelEvent = true;
        }
    }
    /// <summary>
    /// Actions handler.
    /// </summary>
    protected void HeaderActions_ActionPerformed(object sender, CommandEventArgs e)
    {
        switch (e.CommandName.ToLowerInvariant())
        {
            // Validate and save the content
            case "save":
                // Fire the event to validate current step
                var args = new StepEventArgs(Steps, CurrentStepIndex);

                ComponentEvents.RequestEvents.RaiseEvent(this, args, ComponentEvents.VALIDATE_STEP);

                if (args.Cancel)
                {
                    // Cancel if not validated
                    return;
                }

                ComponentEvents.RequestEvents.RaiseEvent(this, args, ComponentEvents.FINISH_STEP);

                if (args.Cancel)
                {
                    // Cancel if not successfully saved
                    return;
                }

                // Reload edit control
                editElem.ReloadData(true);

                // Initialize action menu
                InitHeaderActions();

                // Show save message
                ShowChangesSaved();

                ComponentEvents.RequestEvents.RaiseEvent(this, args, ComponentEvents.STEP_LOADED);
                break;
        }
    }
    /// <summary>
    /// Loads the given step.
    /// </summary>
    /// <param name="args">Step arguments</param>
    /// <param name="current">Step index</param>
    private void LoadStep(StepEventArgs args, int current)
    {
        // Ensure the event arguments
        if (args == null)
        {
            args = new StepEventArgs(this.Steps, current);
        }

        args.CurrentStep = current;

        // Fire the event to finish current step
        ComponentEvents.RequestEvents.RaiseEvent(this, args, ComponentEvents.LOAD_STEP);

        // Skip the current step if requested
        if (args.Skip)
        {
            ChangeStep(1);
        }
        else
        {
            // Use the custom step header if set
            string header = GetHeader(current);
            if (!String.IsNullOrEmpty(header))
            {
                args.StepHeader = header;
                ucHeader.Description = header;
            }
            ucHeader.Title = String.Format(GetString("newsletterissue_new.step"), current - (SelectionSkipped ? 1 : 0));
            ucHeader.Header = GetString("newsletterissue_new.newissue");

            // Handle the next button display
            if (args.Steps == current)
            {
                args.HideNextButton = true;
            }

            // Fire the event to notify that the step was loaded
            ComponentEvents.RequestEvents.RaiseEvent(this, args, ComponentEvents.STEP_LOADED);
        }
    }
    /// <summary>
    /// Step loaded
    /// </summary>
    protected override void StepLoaded(object sender, StepEventArgs e)
    {
        base.StepLoaded(sender, e);

        if (WizardManager.Steps.Count != 0)
        {
            // Allow button
            Visible = true;
            StopProcessing = false;

            // Set current control
            if (ButtonType == "button")
            {
                btn.ShowAsButton = true;
            }
            else
            {
                btn.ShowAsButton = false;
            }

            // Button settings
            btn.LinkText = Text;
            btn.Click += btn_Click;

            btn.Visible = true;
        }
    }
    protected override void StepLoaded(object sender, StepEventArgs e)
    {
        base.StepLoaded(sender, e);

        if (ShoppingCart.Customer != null)
        {
            customerForm.EditedObject = ShoppingCart.Customer;
        }

        if (!RequestHelper.IsPostBack())
        {
            customerForm.ReloadData();
        }

        // Set first time user customer for postback tax recalculation
        if (PropagateChangesOnPostback && (ShoppingCart.Customer == null))
        {
            ShoppingCart.Customer = customerForm.EditedObject as CustomerInfo;
        }

        // Propagate changes on postback if there is customer with company type and some tax registration id
        if (PropagateChangesOnPostback && (ShoppingCart.Customer != null))
        {
            FormEngineUserControl typeSelector = TypeSelector;
            bool isPersonalType = (typeSelector != null) && (!typeSelector.Value.Equals(COMPANY_TYPE));
            var customerTaxRegistrationID = customerForm.GetFieldValue("CustomerTaxRegistrationID");

            if ((customerTaxRegistrationID == null) || isPersonalType)
            {
                ShoppingCart.Customer.CustomerTaxRegistrationID = string.Empty;
            }
            else
            {
                ShoppingCart.Customer.CustomerTaxRegistrationID = customerTaxRegistrationID.ToString();
            }

            ShoppingCart.InvalidateCalculations();
            ComponentEvents.RequestEvents.RaiseEvent(null, e, SHOPPING_CART_CHANGED);
        }
    }
Ejemplo n.º 42
0
    /// <summary>
    /// Saves the data.
    /// </summary>
    /// <param name="e">The StepEventArgs instance containing the event data.</param>
    protected override void SaveStepData(object sender, StepEventArgs e)
    {
        base.SaveStepData(sender, e);

        ShoppingCart.ShoppingCartNote = txtOrderNode.Text;
    }
    protected override void ValidateStepData(object sender, StepEventArgs e)
    {
        base.ValidateStepData(sender, e);

        if (!customerForm.ValidateData())
        {
            if (e != null)
            {
                e.CancelEvent = true;
            }
        }
    }
    /// <summary>
    /// Finishes the wizard
    /// </summary>
    protected void Finish(object sender, EventArgs e)
    {
        // Fire the event to validate current step
        var args = new StepEventArgs(Steps, CurrentStepIndex);

        ComponentEvents.RequestEvents.RaiseEvent(this, args, ComponentEvents.VALIDATE_STEP);

        if (args.Cancel)
        {
            // Cancel if not validated
            return;
        }

        // Fire the event to finish current step
        ComponentEvents.RequestEvents.RaiseEvent(this, args, ComponentEvents.FINISH_STEP);

        if (args.Cancel)
        {
            // Cancel if not finished
            return;
        }

        // Close dialog and refresh parent page
        ScriptHelper.RegisterStartupScript(this, GetType(), "ClosePage", "RefreshPage(); setTimeout('CloseDialog()',200);", true);
    }
Ejemplo n.º 45
0
    /// <summary>
    /// Finishes the wizard
    /// </summary>
    protected void Finish(object sender, EventArgs e)
    {
        // Fire the event to validate current step
        var args = new StepEventArgs(Steps, CurrentStepIndex);

        ComponentEvents.RequestEvents.RaiseEvent(this, args, ComponentEvents.VALIDATE_STEP);

        if (args.Cancel)
        {
            // Cancel if not validated
            return;
        }

        // Fire the event to finish current step
        ComponentEvents.RequestEvents.RaiseEvent(this, args, ComponentEvents.FINISH_STEP);

        if (args.Cancel)
        {
            // Cancel if not finished
            return;
        }

        // Redirect to the given URL
        string url = FinishRedirectUrl;
        if (!String.IsNullOrEmpty(url))
        {
            URLHelper.Redirect(url);
        }
    }
    /// <summary>
    /// Reloads the texts of the control
    /// </summary>
    /// <param name="e">Step event arguments</param>
    /// <param name="forceLoad">If true, the load is forced</param>
    protected void ReloadTexts(StepEventArgs e, bool forceLoad)
    {
        if (loaded && !forceLoad)
        {
            return;
        }
        loaded = true;

        string header = null;
        string info = null;
        string icon = null;

        int current = 1;
        int steps = 1;

        if (e != null)
        {
            // Use custom header/info/icon
            header = e["StepHeader"] as string;
            info = e["StepInfo"] as string;
            icon = e["StepIcon"] as string;

            current = e.CurrentStep;
            steps = e.Steps;
        }

        // Setup the default texts
        if (header == null)
        {
            header = HeaderText;
        }

        if (icon == null)
        {
            icon = Icon;
        }

        if (info == null)
        {
            info = InfoText;
        }

        // Format the header {0} = current step index, {1} = total number of steps
        header = String.Format(header, current, steps);
        info = String.Format(info, current, steps);
        icon = String.Format(icon, current, steps);

        this.ltlHeader.Text = header;
        this.ltlInfo.Text = info;
        this.imgIcon.ImageUrl = icon;
    }
    protected override void ValidateStepData(object sender, StepEventArgs e)
    {
        base.ValidateStepData(sender, e);

        bool valid = ApplyDiscountCoupon();

        // Applying discount coupon changes ShoppingCartCouponCode property which invalidates and recalculates shopping cart -> other web parts must be informed
        ComponentEvents.RequestEvents.RaiseEvent(sender, e, SHOPPING_CART_CHANGED);

        if (!valid)
        {
            pnlError.Visible = true;
            e.CancelEvent = true;
        }
        else
        {
            pnlError.Visible = false;
        }
    }
    protected override void ValidateStepData(object sender, StepEventArgs e)
    {
        base.ValidateStepData(sender, e);

        bool valid = ApplyDiscountCoupon();

        if (!valid)
        {
            pnlError.Visible = true;
            e.CancelEvent = true;
        }
        else
        {
            pnlError.Visible = false;
        }
    }
Ejemplo n.º 49
0
    /// <summary>
    /// Validates the data.
    /// </summary>
    /// <param name="sender">Sender</param>
    /// <param name="e">The StepEventArgs instance containing the event data.</param>
    protected override void ValidateStepData(object sender, StepEventArgs e)
    {
        base.ValidateStepData(sender, e);

        bool valid = true;
        lblError.Visible = false;
        string message;

        if (drpPayment.SelectedID == 0)
        {
            message = ResHelper.GetString("com.checkoutprocess.paymentneeded");
            valid = false;
        }
        // Check whether payment option is valid for user.
        else if (!CheckPaymentOptionIsValidForUser(ShoppingCart, out message))
        {
            valid = false;
        }

        if (!valid)
        {
            e.CancelEvent = true;
            lblError.Text = message;
            lblError.Visible = true;
        }
    }
    protected override void SaveStepData(object sender, StepEventArgs e)
    {
        base.SaveStepData(sender, e);

        // Just set current filed values into EditableObject, saving was canceled in OnBeforeSave
        customerForm.SaveData(null, false);

        CustomerInfo customer = customerForm.EditedObject as CustomerInfo;
        FormEngineUserControl typeSelector = TypeSelector;

        // Clear company fields for non-company type
        if ((typeSelector != null) && (!typeSelector.Value.Equals(COMPANY_TYPE)))
        {
            customer.CustomerCompany = "";
            customer.CustomerOrganizationID = "";
            customer.CustomerTaxRegistrationID = "";
        }

        ShoppingCart.Customer = customer;

        // Update contact with customer details
        ModuleCommands.OnlineMarketingUpdateContactFromExternalData(customer, ContactID);
    }
    /// <summary>
    /// Reloads the texts of the control
    /// </summary>
    /// <param name="e">Step event arguments</param>
    /// <param name="forceLoad">If true, the load is forced</param>
    protected void ReloadTexts(StepEventArgs e, bool forceLoad)
    {
        if (loaded && !forceLoad)
        {
            return;
        }
        loaded = true;

        // Setup the default texts
        string header = this.HeaderText;
        string info = this.InfoText;
        string icon = this.Icon;

        int current = 1;
        int steps = 1;

        if (e != null)
        {
            // Use custom header
            if (e.StepHeader != null)
            {
                header = e.StepHeader;
            }

            // Use custom info
            if (e.StepInfo != null)
            {
                info = e.StepInfo;
            }

            // Use custom icon
            if (e.StepIcon != null)
            {
                icon = e.StepIcon;
            }

            current = e.CurrentStep;
            steps = e.Steps;
        }

        // Format the header {0} = current step index, {1} = total number of steps
        header = String.Format(header, current, steps);
        info = String.Format(info, current, steps);
        icon = String.Format(icon, current, steps);

        this.ltlHeader.Text = header;
        this.ltlInfo.Text = info;
        this.imgIcon.ImageUrl = icon;
    }
Ejemplo n.º 52
0
    /// <summary>
    /// Next step
    /// </summary>
    private void ProcessNextStep(object sender, StepEventArgs e, bool raiseEvents)
    {
        if (raiseEvents)
        {
            ComponentEvents.RequestEvents.RaiseEvent(this, e, ComponentEvents.VALIDATE_STEP);

            // Cancel if not validated
            if (e.CancelEvent)
            {
                ComponentEvents.RequestEvents.RaiseEvent(this, e, ComponentEvents.CANCEL_STEP);
                return;
            }

            // Fire the event to finish current step
            ComponentEvents.RequestEvents.RaiseEvent(this, e, ComponentEvents.FINISH_STEP);

            // Cancel if not validated
            if (e.CancelEvent)
            {
                ComponentEvents.RequestEvents.RaiseEvent(this, e, ComponentEvents.CANCEL_STEP);
                return;
            }

            // Fire the event to finished state
            ComponentEvents.RequestEvents.RaiseEvent(this, e, ComponentEvents.STEP_FINISHED);

            // Cancel if not validated
            if (e.CancelEvent)
            {
                ComponentEvents.RequestEvents.RaiseEvent(this, e, ComponentEvents.CANCEL_STEP);
                return;
            }
        }

        if (RestrictStepOrder)
        {
            // Keep last confirmed step index
            LastConfirmedStepIndex = CurrentStep.StepIndex;
        }

        // Use step custom URL if set
        string url = e["NextStepUrl"] as string;

        // Use default step URL
        if (String.IsNullOrEmpty(url))
        {
            // Next step
            if (!e.IsLastStep)
            {
                url = Steps[CurrentStep.StepIndex + 1].StepUrl;
            }
            // URL after final step
            else
            {
                url = String.IsNullOrEmpty(e.FinalStepUrl) ? FinalStepNextUrl : e.FinalStepUrl;

                // Reset last confirmed step
                LastConfirmedStepIndex = -1;
            }
        }

        // Redirect to the URL
        if (!String.IsNullOrEmpty(url))
        {
            URLHelper.Redirect(url);
        }
    }
    /// <summary>
    /// Saves current settings and close dialog.
    /// </summary>
    protected void SaveAndClose(object sender, EventArgs e)
    {
        // Fire the event to validate current step
        var args = new StepEventArgs(Steps, CurrentStepIndex);

        ComponentEvents.RequestEvents.RaiseEvent(this, args, ComponentEvents.VALIDATE_STEP);

        if (args.Cancel)
        {
            // Cancel if not validated
            return;
        }

                // Save newsletter settings
                string errMessage = SaveSettings();
                if (!String.IsNullOrEmpty(errMessage))
                {
                    args.Cancel = true;
                    // Display error message
                    MessagesPlaceHolder.ShowError(errMessage, null, null);
                }

        if (args.Cancel)
        {
            // Cancel if not finished
            return;
        }

        // Close dialog and refresh parent page
        ScriptHelper.RegisterStartupScript(this, GetType(), "ClosePage", "RefreshPage(); setTimeout('CloseDialog()',200);", true);
    }
    protected override void LoadStep(object sender, StepEventArgs e)
    {
        base.LoadStep(sender, e);

        // Hide/show display form checkbox
        EnsureOptionalCheckBox();

        // Clear shipping address if show check box is not checked and recalculate cart price
        if (PropagateChangesOnPostback && (AddressType == SHIPPING) && (!chkShowAddress.Checked))
        {
            CurrentCartAddress = null;
            ShoppingCart.InvalidateCalculations();
            drpAddresses.SelectedValue = "0";
        }

        if (!StopProcessing)
        {
            SetupSelectedAddress();
            // Set default error label
            addressForm.ErrorLabel = lblError;

            drpAddresses.SelectedIndexChanged += drpAddresses_SelectedIndexChanged;
        }
    }
 protected override void LoadStep(object sender, StepEventArgs e)
 {
     base.LoadStep(sender, e);
     ShoppingCart.InvalidateCalculations();
 }
    /// <summary>
    /// Saves data
    /// </summary>
    protected override void SaveStepData(object sender, StepEventArgs e)
    {
        base.SaveStepData(sender, e);

        if (!StopProcessing)
        {
            // Set current address
            AddressInfo ai = addressForm.EditedObject as AddressInfo;
            if (ai != null)
            {
                CurrentCartAddress = ai;
                var customer = ShoppingCart.Customer;

                if (string.IsNullOrEmpty(ai.AddressPersonalName) && (customer != null))
                {
                    ai.AddressPersonalName = TextHelper.LimitLength(string.Format("{0} {1}", customer.CustomerFirstName, customer.CustomerLastName), 200);
                }

                if (ai.AddressID != 0)
                {
                    // Save potential customer changes before address is updated
                    if ((customer != null) && (customer.CustomerID != 0))
                    {
                        customer.Update();
                    }

                    ai.Update();
                }
            }
        }

        // Clear shipping address if shipping checkbox is unchecked
        if ((AddressType == SHIPPING) && (!chkShowAddress.Checked))
        {
            ShoppingCart.ShoppingCartShippingAddress = null;
        }

        // Set shopping cart with current address change
        ShoppingCartInfoProvider.SetShoppingCartInfo(ShoppingCart);
        ShoppingCart.InvalidateCalculations();
    }
Ejemplo n.º 57
0
    /// <summary>
    /// Changes the current step
    /// </summary>
    /// <param name="offset">Offset by which the step should move</param>
    /// <param name="eventName">Event name to fire prior to step change</param>
    protected void ChangeStep(int offset)
    {
        if (offset == 0)
        {
            return;
        }

        int steps = Steps;
        int original = CurrentStepIndex;

        // Fire the event to validate current step
        var args = new StepEventArgs(steps, original);

        ComponentEvents.RequestEvents.RaiseEvent(this, args, ComponentEvents.VALIDATE_STEP);

        if (args.Cancel)
        {
            // Cancel if not validated
            return;
        }

        // Fire the event to finish current step
        ComponentEvents.RequestEvents.RaiseEvent(this, args, ((offset > 0) ? ComponentEvents.FINISH_STEP : ComponentEvents.CANCEL_STEP));

        if (args.Cancel)
        {
            // Cancel if not finished
            return;
        }

        // Reevaluate the current item index
        int current = original + offset;
        if (current < 1)
        {
            current = 1;
        }
        if (current > Steps)
        {
            current = Steps;
        }

        if (IsDesign)
        {
            // Change only by javascript
            ScriptHelper.RegisterStartupScript(this, typeof(string), this.ClientID + "_change", ScriptHelper.GetScript("ChangeLayoutItem('" + this.InstanceGUID + "', '" + this.ClientID + "', " + offset + ");"));

            // Load the step
            LoadStep(args, current);
        }
        else
        {
            // Move the step by the given index
            CurrentStepIndex = current;

            // Change the step
            if (original != current)
            {
                mStepContainer.Controls.Clear();

                // Create the zone
                var zone = RenderStep(current, NO_CONTAINER);

                zone.Page = this.Page;

                // Load the zone content
                var zoneInstance = this.PagePlaceholder.TemplateInstance.GetZone(ID + "_" + current);

                zone.LoadWebParts(zoneInstance);
                zone.LoadWebPartsContent(false);
                zone.OnContentLoaded();
                zone.LoadRegionsContent(true);

                // Add to the controls collection so it catches up the control cycle
                mStepContainer.Controls.Add(zone);

                // Load the step
                LoadStep(args, current);
            }
        }
    }
    protected override void StepFinished(object sender, StepEventArgs e)
    {
        base.StepFinished(sender, e);
        // We are on last step and checkout process has not been finalized yet by any web part
        if (e.IsLastStep && (e.GetValue(CHOP_FINALIZED_KEY) == null))
        {
            string validationMessage;
            // Validate cart; in case of failure user is able to go through checkout process and fix errors
            if (!ValidateShoppingCart(ShoppingCart, out validationMessage))
            {
                e.CancelEvent = true;
                ShowError(validationMessage);
                e.SetValue(CHOP_FINALIZED_KEY, true);
                return;
            }

            if (FinalizeCheckout())
            {
                int orderId = ShoppingCart.OrderId;
                string orderHash = ShoppingCart.GetHashCode().ToString();
                WindowHelper.Add(orderHash, orderId);
                // Create URL for payment page with order id hidden in hash
                e.FinalStepUrl = URLHelper.AddParameterToUrl(e.FinalStepUrl, "o", orderHash);
            }
            else
            {
                // Log events created in transaction
                foreach (Tuple<string, string> error in loggedErrors)
                {
                    EventLogProvider.LogEvent(EventType.ERROR, EVENT_SOURCE, error.Item2, error.Item1);
                }

                foreach (Exception ex in loggedExceptions)
                {
                    EventLogProvider.LogException(EVENT_SOURCE, EVENT_CODE_EXCEPTION, ex);
                }

                e.CancelEvent = true;
                // Get error text
                string errorMessage = HTMLHelper.HTMLEncode(ResHelper.GetString("ecommerce.orderpreview.errorordersave"));

                if (!string.IsNullOrEmpty(registrationBanned))
                {
                    errorMessage += HTMLHelper.HTMLEncode(Environment.NewLine + registrationBanned);
                }

                ShowError(errorMessage);
            }

            CleanUpShoppingCart();
            DocumentWizardManager.ResetWizard();

            e.SetValue(CHOP_FINALIZED_KEY, true);
        }
    }
Ejemplo n.º 59
0
    /// <summary>
    /// Loads the given step
    /// </summary>
    /// <param name="args">Step arguments</param>
    /// <param name="current">Step index</param>
    private void LoadStep(StepEventArgs args, int current)
    {
        // Ensure the event arguments
        if (args == null)
        {
            args = new StepEventArgs(this.Steps, current);
        }

        args.CurrentStep = current;

        // Fire the event to finish current step
        ComponentEvents.RequestEvents.RaiseEvent(this, args, ComponentEvents.LOAD_STEP);

        // Skip the current step if requested
        if (args.Skip)
        {
            ChangeStep(1);
        }
        else
        {
            // Use the custom step header if set
            string header = GetHeader(current);
            if (!String.IsNullOrEmpty(header))
            {
                args.StepHeader = header;
            }

            // Use the custom step icon if set
            string icon = GetIcon(current);
            if (!String.IsNullOrEmpty(icon))
            {
                args.StepIcon = icon;
            }

            // Use the custom step description if set
            string description = GetDescription(current);
            if (!String.IsNullOrEmpty(description))
            {
                args.StepInfo = description;
            }

            // Handle the next button display
            if ((args.Steps == current) && String.IsNullOrEmpty(FinishRedirectUrl))
            {
                args.HideNextButton = true;
            }

            // Fire the event to notify that the step was loaded
            ComponentEvents.RequestEvents.RaiseEvent(this, args, ComponentEvents.STEP_LOADED);
        }
    }
    /// <summary>
    /// Changes the current step
    /// </summary>
    /// <param name="offset">Offset by which the step should move</param>
    /// <param name="eventName">Event name to fire prior to step change</param>
    protected void ChangeStep(int offset)
    {
        if (offset == 0)
        {
            return;
        }

        int steps = Steps;
        int original = CurrentStepIndex;

        // Fire the event to validate current step
        var args = new StepEventArgs(steps, original);

        if (stepLoaded)
        {
            ComponentEvents.RequestEvents.RaiseEvent(this, args, ComponentEvents.VALIDATE_STEP);

            if (args.Cancel)
            {
                // Cancel if not validated
                return;
            }

            // Fire the event to finish current step
            ComponentEvents.RequestEvents.RaiseEvent(this, args, ((offset > 0) ? ComponentEvents.FINISH_STEP : ComponentEvents.CANCEL_STEP));

            if (args.Cancel)
            {
                // Cancel if not finished
                return;
            }
        }

        // Reevaluate the current item index
        int current = original + offset;
        if (current < 1)
        {
            current = 1;
        }
        if (current > Steps)
        {
            current = Steps;
        }

        // Move the step by the given index
        CurrentStepIndex = current;

        // Change the step
        if (original != current)
        {
            // Load the step
            LoadStep(args, current);
        }
    }