Esempio n. 1
0
    /// <summary>
    /// BtnEdit click event handler.
    /// </summary>
    protected void btnEdit_Click(object sender, EventArgs e)
    {
        ListingMode             = false;
        plcDefaultTypes.Visible = EnableDefaultCheckoutProcessTypes;

        // Load step data to the form
        CheckoutProcessStepInfo stepObj = CheckoutProcess.GetCheckoutProcessStepInfo(((ImageButton)(sender)).CommandArgument);

        if (stepObj != null)
        {
            lblCurrentStep.Text = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(stepObj.Caption));

            txtStepCaption.Text          = stepObj.Caption;
            txtStepControlPath.Text      = stepObj.ControlPath;
            txtStepImageUrl.Text         = stepObj.Icon;
            txtStepName.Text             = stepObj.Name;
            chkLiveSite.Checked          = stepObj.ShowOnLiveSite;
            chkCMSDeskOrder.Checked      = stepObj.ShowInCMSDeskOrder;
            chkCMSDeskCustomer.Checked   = stepObj.ShowInCMSDeskCustomer;
            chkCMSDeskOrderItems.Checked = stepObj.ShowInCMSDeskOrderItems;

            // Save original step name
            OriginalStepName = stepObj.Name;
        }
    }
    /// <summary>
    /// BtnOk click event handler.
    /// </summary>
    protected void btnOk_Click(object sender, EventArgs e)
    {
        breadcrumbsText = GetString("CheckoutProcess.NewStep");

        string errorMessage = ValidateForm();

        if (errorMessage == "")
        {
            CheckoutProcessStepInfo stepObj = CheckoutProcess.GetCheckoutProcessStepInfo(txtStepName.Text.Trim());
            if ((stepObj == null) || (stepObj.Name.ToLowerCSafe() == OriginalStepName.ToLowerCSafe()))
            {
                if (stepObj == null)
                {
                    stepObj = new CheckoutProcessStepInfo();
                }

                // Save localization
                txtStepCaption.Save();

                // Get step data from form
                stepObj.Caption                 = txtStepCaption.Text.Trim();
                stepObj.Name                    = txtStepName.Text.Trim();
                stepObj.ControlPath             = txtStepControlPath.Text.Trim();
                stepObj.Icon                    = txtStepImageUrl.Text.Trim();
                stepObj.ShowInCMSDeskCustomer   = chkCMSDeskCustomer.Checked;
                stepObj.ShowInCMSDeskOrder      = chkCMSDeskOrder.Checked;
                stepObj.ShowOnLiveSite          = chkLiveSite.Checked;
                stepObj.ShowInCMSDeskOrderItems = chkCMSDeskOrderItems.Checked;

                if ((OriginalStepName != "") && (OriginalStepName.ToLowerCSafe() != txtStepName.Text.ToLowerCSafe()))
                {
                    // Replace node
                    CheckoutProcess.ReplaceCheckoutProcessStepNode(stepObj, OriginalStepName);
                }
                else
                {
                    // Update or insert node
                    CheckoutProcess.SetCheckoutProcessStepNode(stepObj);
                }

                // Update Xml definition in viewstate
                CheckoutProcessXml = CheckoutProcess.GetXmlDefinition();

                if (OnCheckoutProcessDefinitionUpdate != null)
                {
                    OnCheckoutProcessDefinitionUpdate("update");
                }

                breadcrumbsText = ResHelper.LocalizeString(stepObj.Caption);

                ListingMode = true;
                ReloadData();
                ugSteps.ReloadData();
            }
            else
            {
                errorMessage = GetString("CheckoutProcess.ErrorStepNameNotUnique");
            }
        }

        // Show error message
        if (errorMessage != "")
        {
            plcMessNew.ShowError(errorMessage);

            // If error during editing, set original caption to breadcrumbs
            if (!string.IsNullOrEmpty(OriginalStepName))
            {
                CheckoutProcessStepInfo stepObj = CheckoutProcess.GetCheckoutProcessStepInfo(OriginalStepName);
                if (stepObj != null)
                {
                    breadcrumbsText = ResHelper.LocalizeString(stepObj.Caption);
                }
            }
        }
    }
    /// <summary>
    /// Handles unigrid actions.
    /// </summary>
    protected void ugSteps_OnAction(string actionName, object actionArgument)
    {
        // Name of checkout process step
        string stepName = ValidationHelper.GetString(actionArgument, "");

        switch (actionName.ToLowerCSafe())
        {
        case "up":
            // Move node up in xml
            CheckoutProcess.MoveCheckoutProcessStepNodeUp(stepName);

            // Update xml definition in view state
            CheckoutProcessXml = CheckoutProcess.GetXmlDefinition();

            RaiseDefinitionUpdate("moveup");

            ReloadData();
            break;

        case "down":
            // Move node down in xml definition
            CheckoutProcess.MoveCheckoutProcessStepNodeDown(stepName);

            // Update xml definition in viewstate
            CheckoutProcessXml = CheckoutProcess.GetXmlDefinition();

            RaiseDefinitionUpdate("movedown");

            ReloadData();
            break;

        case "edit":
            ListingMode             = false;
            plcDefaultTypes.Visible = EnableDefaultCheckoutProcessTypes;

            // Load step data to the form
            CheckoutProcessStepInfo stepObj = CheckoutProcess.GetCheckoutProcessStepInfo(stepName);
            if (stepObj != null)
            {
                breadcrumbsText = ResHelper.LocalizeString(stepObj.Caption);

                txtStepCaption.Text          = stepObj.Caption;
                txtStepControlPath.Text      = stepObj.ControlPath;
                txtStepImageUrl.Text         = stepObj.Icon;
                txtStepName.Text             = stepObj.Name;
                chkLiveSite.Checked          = stepObj.ShowOnLiveSite;
                chkCMSDeskOrder.Checked      = stepObj.ShowInCMSDeskOrder;
                chkCMSDeskCustomer.Checked   = stepObj.ShowInCMSDeskCustomer;
                chkCMSDeskOrderItems.Checked = stepObj.ShowInCMSDeskOrderItems;

                // Save original step name
                OriginalStepName = stepObj.Name;
            }
            break;

        case "delete":
            // Remove node from xml
            CheckoutProcess.RemoveCheckoutProcessStepNode(stepName);
            // Update xml definition in view state
            CheckoutProcessXml = CheckoutProcess.GetXmlDefinition();

            RaiseDefinitionUpdate("delete");

            ReloadData();
            break;
        }
    }