protected void Page_PreRender(object sender, EventArgs e)
        {
            if (Purchasable == null)
            {
                PurchaseSummary.Visible     = false;
                GeneralErrorMessage.Visible = true;

                WebForm.EnableDisableNextButton(false);

                return;
            }

            PurchaseSummary.Visible     = true;
            GeneralErrorMessage.Visible = false;
            Shipping.Visible            = Purchasable.RequiresShipping;

            PurchaseDiscounts.DataSource = Purchasable.Discounts;
            PurchaseDiscounts.DataBind();

            PurchaseItems.DataSource = Purchasable.Items;
            PurchaseItems.DataBind();

            QuoteId.Value = Purchasable.Quote.Id.ToString();

            if (Purchasable.RequiresShipping && Purchasable.ShipToAddress != null)
            {
                ShippingCity.Text          = Purchasable.ShipToAddress.City;
                ShippingCountry.Text       = Purchasable.ShipToAddress.Country;
                ShippingName.Text          = Purchasable.ShipToAddress.Name;
                ShippingPostalCode.Text    = Purchasable.ShipToAddress.PostalCode;
                ShippingStateProvince.Text = Purchasable.ShipToAddress.StateOrProvince;
                ShippingAddressLine1.Text  = Purchasable.ShipToAddress.Line1;
                ShippingAddressLine2.Text  = Purchasable.ShipToAddress.Line2;
            }
        }
Exemplo n.º 2
0
 protected void Page_PreRender(object sender, EventArgs e)
 {
     if (Purchasable == null)
     {
         WebForm.EnableDisableNextButton(false);
     }
 }
        protected override void OnSubmit(object sender, WebFormSubmitEventArgs e)
        {
            if (Purchasable == null)
            {
                e.Cancel = true;

                PurchaseSummary.Visible     = false;
                GeneralErrorMessage.Visible = true;

                WebForm.EnableDisableNextButton(false);

                return;
            }

            WebForm.CurrentSessionHistory.QuoteId = Purchasable.Quote.Id;

            Page.Validate();

            if (!Page.IsValid)
            {
                e.Cancel = true;

                return;
            }

            if (Purchasable.RequiresShipping)
            {
                var dataAdapter = CreatePurchaseDataAdapter(Target, CurrentStepEntityPrimaryKeyLogicalName);

                dataAdapter.UpdateShipToAddress(new PurchaseAddress
                {
                    City            = ShippingCity.Text,
                    Country         = ShippingCountry.Text,
                    Line1           = ShippingAddressLine1.Text,
                    Line2           = ShippingAddressLine2.Text,
                    Name            = ShippingName.Text,
                    PostalCode      = ShippingPostalCode.Text,
                    StateOrProvince = ShippingStateProvince.Text
                });
            }

            SetAttributeValuesAndSave();
        }