コード例 #1
0
        protected void CountryChanged(object sender, EventArgs e)
        {
            //LOAD PROVINCES FOR SELECTED COUNTRY
            int provincesCount = ProvinceDataSource.CountForCountry(CountryFilter.SelectedValue);

            //WE WANT TO SHOW THE DROP DOWN IF THE COUNTRY HAS BEEN CHANGED BY THE CLIENT
            //AND ALSO IF PROVINCES ARE AVAILABLE FOR THIS COUNTRY
            if (provincesCount > 0)
            {
                Province.Visible  = false;
                Province2.Visible = true;
                Country county = CountryDataSource.Load(CountryFilter.SelectedValue);
                if (county != null)
                {
                    Province2.Items.Clear();
                    Province2.Items.Add(new ListItem("All Provinces", ""));
                    Province2.DataSource = county.Provinces;
                    Province2.DataBind();
                }
            }
            else
            {
                //WE ONLY WANT A TEXTBOX TO SHOW
                //REQUIRE THE TEXTBOX IF THERE ARE PROVINCES
                Province.Visible  = true;
                Province2.Visible = false;
            }
        }
コード例 #2
0
        private void BindBillToAddress()
        {
            string  pattern = "[Company]\r\n[Name]\r\n[Address1]\r\n[Address2]\r\n[City], [Province] [PostalCode]\r\n[Country_U]\r\n";
            Country country = CountryDataSource.Load(_order.BillToCountryCode);

            if (country != null)
            {
                if (!string.IsNullOrEmpty(country.AddressFormat))
                {
                    pattern = country.AddressFormat;
                }
            }
            BillingAddress.Text         = _order.FormatAddress(pattern, true);
            BillToEmail.Text            = _order.BillToEmail;
            MoveOrderButton.NavigateUrl = string.Format(MoveOrderButton.NavigateUrl, _order.OrderNumber.ToString());
            string returnUrl = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes("~/Admin/Orders/ViewOrder.aspx?OrderNumber=" + _order.OrderNumber.ToString()));

            BillToEmail.NavigateUrl += "?OrderNumber=" + _order.OrderNumber.ToString() + "&ReturnUrl=" + returnUrl;
            if (!string.IsNullOrEmpty(_order.BillToPhone))
            {
                BillToPhone.Text = string.Format(BillToPhone.Text, _order.BillToPhone);
            }
            else
            {
                BillToPhone.Visible = false;
            }
            if (!string.IsNullOrEmpty(_order.BillToFax))
            {
                BillToFax.Text = string.Format(BillToFax.Text, _order.BillToFax);
            }
            else
            {
                BillToFax.Visible = false;
            }
        }
コード例 #3
0
        protected void ChangeCountryListOKButton_Click(object sender, System.EventArgs e)
        {
            string controlName = HiddenSelectedCountries.UniqueID;
            string postedValue = Request.Form[controlName];

            //REMOVE ALL COUNTRIES ASSOCIATED WITH SHIPZONE
            _ShipZone.Countries.Clear();
            _ShipZone.Save();
            if (!string.IsNullOrEmpty(postedValue))
            {
                //GET LIST OF VALID COUNTRY CODES
                List <string> validCountryCodes = GetValidCountryCodes();
                //ADD SELECTED COUNTRIES BACK IN
                string[] postedCountryCodes = postedValue.Split(",".ToCharArray());
                foreach (string tempCode in postedCountryCodes)
                {
                    string countryCode = tempCode.Trim();
                    if (validCountryCodes.Contains(countryCode))
                    {
                        Country country = CountryDataSource.Load(countryCode);
                        _ShipZone.Countries.Add(country);
                    }
                }
                _ShipZone.Save();
            }
            CountryList.Text = GetCountryList();
        }
コード例 #4
0
        public void LoadDialog(string countryCode)
        {
            this.CountryCode = countryCode;
            Country country = CountryDataSource.Load(countryCode);

            Caption.Text           = string.Format(Caption.Text, country.Name);
            CountryCodeLabel2.Text = countryCode;
            Name.Text          = country.Name;
            AddressFormat.Text = country.AddressFormat;
        }
コード例 #5
0
        protected void CountryGrid_RowEditing(object sender, GridViewEditEventArgs e)
        {
            string  countryCode = CountryGrid.DataKeys[e.NewEditIndex].Value.ToString();
            Country country     = CountryDataSource.Load(countryCode);

            if (country != null)
            {
                AddCountryDialog1.Visible  = false;
                EditCountryDialog1.Visible = true;
                EditCountryDialog1.LoadDialog(countryCode);
            }
        }
コード例 #6
0
 protected void SaveButton_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         Country country = CountryDataSource.Load(CountryCode);
         country.Name          = Name.Text;
         country.AddressFormat = AddressFormat.Text.Replace("\r\n", "\n").Replace("\n", "\r\n");
         country.Save();
         //TRIGER ANY EVENT ATTACHED TO THE UPDATE
         if (ItemUpdated != null)
         {
             ItemUpdated(this, new EventArgs());
         }
     }
 }
コード例 #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string countryCode = Request.QueryString["CountryCode"];

            if (!Page.IsPostBack)
            {
                Country country = CountryDataSource.Load(countryCode);
                if (country != null)
                {
                    Caption.Text = string.Format(Caption.Text, country.Name);
                }
            }
            AddProvinceDialog1.ItemAdded += new EventHandler(AddProvinceDialog1_ItemAdded);
            ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "provinceCountryCode", "var countryCode = '" + countryCode + "';", true);
        }
コード例 #8
0
        public static bool DeleteAllProvinces(string countryCode)
        {
            Country country = CountryDataSource.Load(countryCode);

            if (country != null)
            {
                IDatabaseSessionManager database = AbleContext.Current.Database;
                database.BeginTransaction();
                country.Provinces.DeleteAll();
                database.CommitTransaction();
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #9
0
        /// <summary>
        /// Formats the address using the default address format for the given country.
        /// </summary>
        /// <param name="name">The name in address</param>
        /// <param name="company">The company name</param>
        /// <param name="address1">Address line 1</param>
        /// <param name="address2">Address line 2</param>
        /// <param name="city">The city</param>
        /// <param name="province">The province</param>
        /// <param name="postalCode">The postal code</param>
        /// <param name="countryCode">The country code</param>
        /// <param name="phone">The phone number</param>
        /// <param name="fax">The fax number</param>
        /// <param name="email">The email address</param>
        /// <param name="isHtml">If true address is formatted in HTML otherwise plain text.</param>
        /// <returns>Formatted address</returns>
        public static string Format(string name, string company, string address1, string address2, string city, string province, string postalCode, string countryCode, string phone, string fax, string email, bool isHtml)
        {
            string pattern     = string.Empty;
            string countryName = countryCode;

            //NEED TO GET FORMAT FOR pattern FOR THIS COUNTRY
            Country country = CountryDataSource.Load(countryCode);

            if (country != null)
            {
                //GET pattern FORMAT FROM COUNTRY RECORD
                pattern     = country.AddressFormat;
                countryName = country.Name;
            }

            return(AddressFormatter.Format(pattern, name, company, address1, address2, city, province, postalCode, countryName, phone, fax, email, isHtml));
        }
コード例 #10
0
        protected void OnCountryDataBound(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                string   warehouseCountry = AbleContext.Current.Store.DefaultWarehouse.CountryCode;
                ListItem defaultCountry   = CountryFilter.Items.FindByValue(warehouseCountry);
                if (defaultCountry != null)
                {
                    CountryFilter.SelectedIndex = CountryFilter.Items.IndexOf(defaultCountry);
                }
            }

            Country county = CountryDataSource.Load(CountryFilter.SelectedValue);

            if (county != null)
            {
                Province2.Visible = county.Provinces.Count > 0;
                if (Province2.Visible)
                {
                    Province2.Items.Clear();
                    Province2.Items.Add(new ListItem("All Provinces", ""));
                    Province2.DataSource = county.Provinces;
                    Province2.DataBind();
                }

                Province.Visible = !Province2.Visible;
            }

            if (!Page.IsPostBack)
            {
                string warehouseProvince = AbleContext.Current.Store.DefaultWarehouse.Province;
                if (county.Provinces.Count > 0)
                {
                    ListItem defaultProvince = Province2.Items.FindByValue(warehouseProvince);
                    if (defaultProvince != null)
                    {
                        Province2.SelectedIndex = Province2.Items.IndexOf(defaultProvince);
                    }
                }
                else
                {
                    Province.Text = warehouseProvince;
                }
            }
        }
コード例 #11
0
 protected void AddButton_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         string code = CountryCode.Text.ToUpperInvariant();
         //VERIFY THIS CODE IS NOT ALREADY PRESENT
         Country t = CountryDataSource.Load(code);
         if (t == null)
         {
             t               = new Country();
             t.Id            = code;
             t.Name          = Name.Text.Trim();
             t.AddressFormat = AddressFormat.Text.Replace("\r\n", "\n").Replace("\n", "\r\n");
             t.Save();
             CountryCode.Text     = string.Empty;
             Name.Text            = string.Empty;
             AddedMessage.Text    = string.Format(AddedMessage.Text, t.Name);
             AddedMessage.Visible = true;
             //TRIGER ANY EVENT ATTACHED TO THE UPDATE
             if (ItemAdded != null)
             {
                 ItemAdded(this, new EventArgs());
             }
         }
         else
         {
             CustomValidator existingCode = new CustomValidator();
             existingCode.ValidationGroup = "AddCountry";
             existingCode.IsValid         = false;
             existingCode.Text            = "*";
             existingCode.ErrorMessage    = "A country with the code " + code + " is already defined.";
             tdCountryCode.Controls.Add(existingCode);
             //ValidationSummary1.Visible = true;
             //ValidationSummary1.Controls.Add(existingCode);
             //ValidationSummary1.Visible = true;
         }
     }
 }