Ejemplo n.º 1
0
        protected string GetShipToAddress(object dataItem)
        {
            OrderShipment shipment = (OrderShipment)dataItem;
            string        pattern  = shipment.ShipToCountry.AddressFormat;

            if (!string.IsNullOrEmpty(shipment.ShipToEmail) && !pattern.Contains("[Email]") && !pattern.Contains("[Email_U]"))
            {
                pattern += "\r\nEmail: [Email]";
            }
            if (!string.IsNullOrEmpty(shipment.ShipToPhone) && !pattern.Contains("[Phone]") && !pattern.Contains("[Phone_U]"))
            {
                pattern += "\r\nPhone: [Phone]";
            }
            if (!string.IsNullOrEmpty(shipment.ShipToFax) && !pattern.Contains("[Fax]") && !pattern.Contains("[Fax_U]"))
            {
                pattern += "\r\nFax: [Fax]";
            }
            return(shipment.FormatToAddress(pattern, true).Replace("<br />", ", "));
        }
        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();
        }
 private void BindShippingAddress(Order order)
 {
     if (order.Shipments.Count == 1)
     {
         OrderShipment firstShipment = order.Shipments[0];
         ShippingAddress.Text = firstShipment.FormatToAddress(true);
         if (!string.IsNullOrEmpty(firstShipment.ShipToEmail))
         {
             ShipToEmail.Text = string.Format(ShipToEmail.Text, firstShipment.ShipToEmail);
         }
         else
         {
             ShipToEmail.Visible = false;
         }
         if (!string.IsNullOrEmpty(firstShipment.ShipToPhone))
         {
             ShipToPhone.Text = string.Format(ShipToPhone.Text, firstShipment.ShipToPhone);
         }
         else
         {
             ShipToPhone.Visible = false;
         }
         if (!string.IsNullOrEmpty(firstShipment.ShipToFax))
         {
             ShipToFax.Text = string.Format(ShipToFax.Text, firstShipment.ShipToFax);
         }
         else
         {
             ShipToFax.Visible = false;
         }
     }
     else
     {
         ShippingAddressPanel.Visible = false;
     }
 }
        protected string GetShipToAddress(object dataItem)
        {
            OrderShipment shipment = (OrderShipment)dataItem;

            return(shipment.FormatToAddress(true));
        }
Ejemplo n.º 5
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("../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();
        }