示例#1
0
        protected void Page_Init(object sender, EventArgs e)
        {
            int shipmentId = AlwaysConvert.ToInt(Request.QueryString["OrderShipmentId"]);

            _OrderShipment = OrderShipmentDataSource.Load(shipmentId);
            if (_OrderShipment == null)
            {
                Response.Redirect(CancelLink.NavigateUrl);
            }

            // BIND THE ADDRESS
            initAddress();

            // BIND ADDITIONAL DETAILS
            ShipFrom.DataSource = AbleContext.Current.Store.Warehouses;
            ShipFrom.DataBind();
            if (!Page.IsPostBack)
            {
                ListItem selectedItem = ShipFrom.Items.FindByValue(_OrderShipment.WarehouseId.ToString());
                if (selectedItem != null)
                {
                    selectedItem.Selected = true;
                }
            }
            ShipMessage.Text             = _OrderShipment.ShipMessage;
            Caption.Text                 = string.Format(Caption.Text, _OrderShipment.Order.OrderNumber);
            EditShipmentCaption.Text     = string.Format(EditShipmentCaption.Text, _OrderShipment.ShipmentNumber);
            CancelLink.NavigateUrl      += "?OrderNumber=" + _OrderShipment.Order.OrderNumber.ToString();
            TrackingNumbersLabel.Visible = (_OrderShipment.TrackingNumbers != null && _OrderShipment.TrackingNumbers.Count > 0);
            ShipGateway.DataSource       = ShipGatewayDataSource.LoadAll();
            ShipGateway.DataBind();
            trAddTrackingNumber.Visible = (_OrderShipment.TrackingNumbers.Count == 0);
        }
        private void DisplayOrderShipmentFields(bool show)
        {
            if (show)
            {
                ShipFrom.DataSource = AbleContext.Current.Store.Warehouses;
                ShipFrom.DataBind();
                if (AddressList.Items.Count <= 1)
                {
                    BindShippingAddresses(this.AddressList);
                }
            }

            trNewShipmentFrom.Visible       = show;
            trNewShipmentAddress.Visible    = show;
            trNewShipmentShipMethod.Visible = show;
        }
        protected void Page_Init(object sender, EventArgs e)
        {
            int orderId = AbleCommerce.Code.PageHelper.GetOrderId();

            _Order = OrderDataSource.Load(orderId);
            if (_Order == null)
            {
                Response.Redirect("../Default.aspx");
            }
            Caption.Text        = string.Format(Caption.Text, _Order.OrderNumber);
            ShipFrom.DataSource = AbleContext.Current.Store.Warehouses;
            ShipFrom.DataBind();
            ShipToCountryCode.DataSource     = AbleContext.Current.Store.Countries;
            ShipToCountryCode.DataTextField  = "Name";
            ShipToCountryCode.DataValueField = "CountryCode";
            ShipToCountryCode.DataBind();
            BindShippingAddresses(this.AddressList);
        }
        public void Page_Init(object sender, EventArgs e)
        {
            if (_Order == null)
            {
                OrderId = AbleCommerce.Code.PageHelper.GetOrderId();
            }
            if (_OrderShipment == null)
            {
                OrderShipmentId = AlwaysConvert.ToInt(Request.QueryString["OrderShipmentId"]);
            }
            if (_Order == null)
            {
                Response.Redirect("~/Admin/Orders/Default.aspx");
            }
            _ProductId = AlwaysConvert.ToInt(Request.QueryString["ProductId"]);
            _Product   = ProductDataSource.Load(_ProductId);


            if (_Product == null)
            {
                if (_OrderShipment == null)
                {
                    Response.Redirect("~/Admin/Orders/Edit/FindProduct.aspx?OrderNumber=" + _Order.OrderNumber.ToString());
                }
                else
                {
                    Response.Redirect("~/Admin/Orders/Shipments/FindProduct.aspx?OrderShipmentId=" + _OrderShipmentId.ToString());
                }
            }

            if (_OrderShipment == null)
            {
                BackButton.NavigateUrl = "~/Admin/Orders/Edit/EditOrderItems.aspx?OrderNumber=" + _Order.OrderNumber.ToString();
            }
            else
            {
                BackButton.NavigateUrl = "~/Admin/Orders/Shipments/EditShipment.aspx?OrderShipmentId=" + _OrderShipmentId.ToString();
            }

            // update instruction text
            GiftCertMessage.Visible     = _Product.IsGiftCertificate;
            DigitalGoodsMessage.Visible = _Product.IsDigitalGood;
            SubscriptionMessage.Visible = _Product.IsSubscription;

            //SET NAME AND PRICE
            Name.Text             = _Product.Name;
            HiddenProductId.Value = _Product.Id.ToString();
            //BUILD PRODUCT ATTRIBUTES
            _SelectedOptions = AbleCommerce.Code.ProductHelper.BuildProductOptions(_Product, phOptions, true);
            //BUILD PRODUCT CHOICES
            AbleCommerce.Code.ProductHelper.BuildProductChoices(_Product, phOptions);
            //BUILD KIT OPTIONS
            _SelectedKitProducts = AbleCommerce.Code.ProductHelper.BuildKitOptions(_Product, phOptions);
            //SET PRICE
            string            optionList = ProductVariantDataSource.GetOptionList(_Product.Id, _SelectedOptions, true);
            ProductCalculator pcalc      = ProductCalculator.LoadForProduct(_Product.Id, 1, optionList, AlwaysConvert.ToList(",", _SelectedKitProducts), _Order.UserId);

            Price.Text = string.Format("{0:F2}", pcalc.Price);
            // IF ALL OPTIONS HAVE A VALUE SELECTED, SHOW THE BASKET CONTROLS
            SaveButton.Visible = (_SelectedOptions.Count >= _Product.ProductOptions.Count);
            //BackButton.NavigateUrl += "?OrderNumber=" + _Order.OrderNumber.ToString();


            //CHECK IF SHIPMENTS NEED TO BE DISPLAYED
            trShipment.Visible = (_OrderShipment == null && _Product.Shippable != Shippable.No);
            if (trShipment.Visible)
            {
                //BIND SHIPMENT LIST
                foreach (OrderShipment shipment in _Order.Shipments)
                {
                    string address = string.Format("{0} {1} {2} {3}", shipment.ShipToFirstName, shipment.ShipToLastName, shipment.ShipToAddress1, shipment.ShipToCity);
                    if (address.Length > 50)
                    {
                        address = address.Substring(0, 47) + "...";
                    }
                    string name = "Shipment #" + shipment.ShipmentNumber + " to " + address;
                    ShipmentsList.Items.Add(new ListItem(name, shipment.Id.ToString()));
                }

                if (_Order.Shipments != null && _Order.Shipments.Count == 1)
                {
                    // IF THERE IS JUST ONLY ONE SHIPMENT THEN SELECT IT
                    ShipmentsList.SelectedIndex = 2;
                }
            }

            // if a new shipment option is selected then initialize the related fields
            DisplayOrderShipmentFields(ShipmentsList.SelectedValue == "-1"); ShipFrom.DataSource = AbleContext.Current.Store.Warehouses;
            ShipFrom.DataBind();
            if (AddressList.Items.Count <= 1)
            {
                BindShippingAddresses(this.AddressList);
            }
        }