protected string GetShipFromAddress(object dataItem)
        {
            OrderShipment shipment = (OrderShipment)dataItem;
            string        pattern  = shipment.ShipToCountry.AddressFormat;

            if (!string.IsNullOrEmpty(shipment.Warehouse.Email) && !pattern.Contains("[Email]") && !pattern.Contains("[Email_U]"))
            {
                pattern += "\r\nEmail: [Email]";
            }
            if (!string.IsNullOrEmpty(shipment.Warehouse.Phone) && !pattern.Contains("[Phone]") && !pattern.Contains("[Phone_U]"))
            {
                pattern += "\r\nPhone: [Phone]";
            }
            if (!string.IsNullOrEmpty(shipment.Warehouse.Fax) && !pattern.Contains("[Fax]") && !pattern.Contains("[Fax_U]"))
            {
                pattern += "\r\nFax: [Fax]";
            }
            return(shipment.FormatFromAddress(pattern, true));
        }
        protected void Page_Init(object sender, EventArgs e)
        {
            int shipmentId = AlwaysConvert.ToInt(Request.QueryString["ShipmentId"]);

            _OrderShipment = OrderShipmentDataSource.Load(shipmentId);
            if (_OrderShipment == null)
            {
                int orderId     = AbleCommerce.Code.PageHelper.GetOrderId();
                int orderNumber = OrderDataSource.LookupOrderNumber(orderId);
                Response.Redirect("Default.aspx?OrderNumber=" + orderNumber.ToString());
            }
            Caption.Text            = string.Format(Caption.Text, _OrderShipment.ShipmentNumber);
            CancelLink.NavigateUrl += "?OrderNumber=" + _OrderShipment.Order.OrderNumber.ToString();

            // BIND ITEMS
            ShipTo.Text              = _OrderShipment.FormatToAddress(true);
            ShipFrom.Text            = _OrderShipment.FormatFromAddress(true);
            ShippingMethod.Text      = _OrderShipment.ShipMethodName;
            ShipmentItems.DataSource = _OrderShipment.OrderItems;
            ShipmentItems.DataBind();
        }
        protected string GetShipFromAddress(object dataItem)
        {
            OrderShipment shipment = (OrderShipment)dataItem;

            return(shipment.FormatFromAddress(true));
        }
        protected void Page_Init(object sender, EventArgs e)
        {
            int shipmentId = AlwaysConvert.ToInt(Request.QueryString["OrderShipmentId"]);

            _OrderShipment = OrderShipmentDataSource.Load(shipmentId);
            if (_OrderShipment == null)
            {
                Response.Redirect("../Default.aspx");
            }
            _Order                   = _OrderShipment.Order;
            Caption.Text             = string.Format(Caption.Text, _Order.OrderNumber);
            ShipmentNumber.Text      = string.Format(ShipmentNumber.Text, _Order.Shipments.IndexOf(_OrderShipment.Id) + 1, _Order.Shipments.Count);
            ShippingMethod.Text      = _OrderShipment.ShipMethodName;
            trShipMessage.Visible    = !string.IsNullOrEmpty(_OrderShipment.ShipMessage);
            ShipMessage.Text         = _OrderShipment.ShipMessage;
            ShipFrom.Text            = _OrderShipment.FormatFromAddress();
            ShipTo.Text              = _OrderShipment.FormatToAddress();
            ShipmentItems.DataSource = GetShipmentItems();
            ShipmentItems.DataBind();

            // check if ship gateway supports shipping feature
            CommerceBuilder.Shipping.ShipGateway shipGateway = _OrderShipment.ShipMethod != null ?_OrderShipment.ShipMethod.ShipGateway : null;
            IShippingProvider shipProvider = null;

            if (shipGateway != null)
            {
                shipProvider = shipGateway.GetProviderInstance();
                _IsProviderSupportShipping = shipProvider != null && shipProvider.IsShippingSupported;
            }

            ShipGateway.DataSource = ShipGatewayDataSource.LoadAll();
            ShipGateway.DataBind();
            if (ShipGateway.Items.Count > 1)
            {
                //TRY TO PRESET THE CORRECT GATEWAY
                if (_OrderShipment.ShipMethod != null)
                {
                    ListItem item = ShipGateway.Items.FindByValue(_OrderShipment.ShipMethod.ShipGatewayId.ToString());
                    if (item != null)
                    {
                        item.Selected = true;
                    }
                }
            }
            else
            {
                ShipGateway.Visible = false;
            }

            if (_IsProviderSupportShipping)
            {
                autoTrackingInputPanel.Visible = true;

                // update the provider name
                ProviderInstructionText.Text    = string.Format(ProviderInstructionText.Text, shipProvider.Name);
                ProviderInstructionText.Visible = true;
            }
            else
            {
                autoTrackingInputPanel.Visible = false;
            }

            CancelButton.NavigateUrl += "?OrderNumber=" + _OrderShipment.Order.OrderNumber.ToString();
        }