Exemplo n.º 1
0
    /// <summary>
    /// 
    /// </summary>
    public void BindShipping()
    {
        if (UserAccount.AccountID > 0)
        {
            if (lstShipping.Items.Count == 0)
            {

                Account userAccount = UserAccount;

                int profileID = userAccount.ProfileID.Value;

                ShippingService shipServ = new ShippingService();
                TList<Shipping> shippingList = shipServ.GetAll();
                shippingList.Sort("DisplayOrder Asc");
                shippingList.ApplyFilter(delegate(ZNode.Libraries.DataAccess.Entities.Shipping shipping) { return (shipping.ActiveInd == true && (shipping.ProfileID == null || shipping.ProfileID == profileID)); });

                DataSet ds = shippingList.ToDataSet(false);
                DataView dv = new DataView(ds.Tables[0]);

                if (userAccount.BillingCountryCode == userAccount.ShipCountryCode)
                {
                    dv.RowFilter = "DestinationCountryCode = '" + userAccount.BillingCountryCode + "' or DestinationCountryCode is null";
                }
                else
                {
                    dv.RowFilter = "DestinationCountryCode = '" + userAccount.ShipCountryCode + "' or DestinationCountryCode is null";
                }

                if (dv.ToTable().Rows.Count > 0)
                {
                    foreach (DataRow dr in dv.ToTable().Rows)
                    {
                        string description = dr["Description"].ToString();

                        System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex("&reg;");
                        description = regex.Replace(description, "®");
                        ListItem li = new ListItem(description, dr["ShippingID"].ToString());
                        lstShipping.Items.Add(li);
                    }

                    lstShipping.SelectedIndex = 0;
                }
            }
        }
    }