override protected void OnInit(EventArgs e)
 {
     Page.RegisterRequiresControlState(this);
     if (!IsPostBack)
     {
         // Initialize data binding fields
         lstBillAddress.DataTextField  = "Description";
         lstBillAddress.DataValueField = "AddressID";
         lstShipAddress.DataTextField  = "Description";
         lstShipAddress.DataValueField = "AddressID";
         // Get address settings
         AddressSettings addressSettings = _controller.GetAddressSettings(PortalId);
         // Set Billing and Shipping address settings
         addressBilling.Settings  = addressSettings;
         addressShipping.Settings = addressSettings;
         // Hide 'Pick-Up' option if not enabled
         if (!addressSettings.AllowPickup)
         {
             radNone.Visible = false;
         }
     }
     base.OnInit(e);
 }
Ejemplo n.º 2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     valReqAuthorizedCountries.ErrorMessage = Localization.GetString("valReqAuthorizedCountries.Error", LocalResourceFile);
     if (!IsReady)
     {
         AddressController controller = new AddressController();
         AddressSettings   settings   = controller.GetAddressSettings(PortalId);
         cbAllowPickup.Checked = settings.AllowPickup;
         ddlFirstNameRowOrder.SelectedIndex = settings.FirstNameRow;
         ddlLastNameRowOrder.SelectedIndex  = settings.LastNameRow;
         cbShowStreet.Checked            = settings.ShowStreet;
         ddlStreetRowOrder.SelectedIndex = settings.StreetRow;
         cbShowUnit.Checked               = settings.ShowUnit;
         ddlUnitRowOrder.SelectedIndex    = settings.UnitRow;
         cbRequireUnit.Checked            = settings.RequireUnit;
         cbShowPostal.Checked             = settings.ShowPostal;
         ddlPostalRowOrder.SelectedIndex  = settings.PostalRow;
         cbShowCity.Checked               = settings.ShowCity;
         ddlCityRowOrder.SelectedIndex    = settings.CityRow;
         cbShowCountry.Checked            = settings.ShowCountry;
         ddlCountryRowOrder.SelectedIndex = settings.CountryRow;
         trRestrictToCountries.Visible    = cbShowCountry.Checked;
         cbRestrictToCountry.Checked      = settings.RestrictToCountries;
         trAuthorizedCountries.Visible    = cbRestrictToCountry.Checked;
         FillAuthorizedCountries(settings.AuthorizedCountries);
         cbShowRegion.Checked               = settings.ShowRegion;
         ddlRegionRowOrder.SelectedIndex    = settings.RegionRow;
         cbRequireRegion.Checked            = settings.RequireRegion;
         ddlEmailRowOrder.SelectedIndex     = settings.EmailRow;
         cbShowTelephone.Checked            = settings.ShowTelephone;
         cbRequireTelephone.Checked         = settings.RequireTelephone;
         ddlTelephoneRowOrder.SelectedIndex = settings.TelephoneRow;
         cbShowCell.Checked            = settings.ShowCell;
         cbRequireCell.Checked         = settings.RequireCell;
         ddlCellRowOrder.SelectedIndex = settings.CellRow;
     }
 }
Ejemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                // Get localized default address description
                _addressDefaultDescription = Localization.GetString("AddressDefaultDescription", LocalResourceFile);
                // Get the navigation settings and AddressID
                _addressNav = new AddressNavigation(Request.QueryString);
                _addressID  = _addressNav.AddressID;

                if (!IsPostBack)
                {
                    // Get an Address controler
                    AddressController controller = new AddressController();

                    // Define default address settings
                    AddressSettings addressSettings = controller.GetAddressSettings(PortalId);
                    addressEdit.Settings = addressSettings;

                    // Edit Address
                    if (_addressID > 0)
                    {
                        plhGrid.Visible        = false;
                        plhEditAddress.Visible = true;

                        AddressInfo address        = (AddressInfo)controller.GetAddress(_addressID);
                        bool        authorizedUser = (address.UserID == UserId);

                        if (authorizedUser)
                        {
                            if (string.IsNullOrEmpty(address.Email))
                            {
                                address.Email = UserInfo.Email;
                            }
                            addressEdit.Address         = address;
                            addressEdit.ShowUserSaved   = false;
                            addressEdit.ShowDescription = true;
                            // Set delete confirmation
                            cmdDelete.Attributes.Add("onClick", "javascript:return confirm('" + Localization.GetString("DeleteItem") + "');");
                            cmdDelete.Visible = true;
                        }
                        else
                        {
                            ErrorMessage = Localization.GetString("ErrorLoading", LocalResourceFile);
                            // Someone is trying to steal an address!
                            // A log entry will be added in the parent control
                            InvokeSecurityProviderError();
                        }
                    }
                    // Add Address
                    else if (_addressID == 0)
                    {
                        plhGrid.Visible        = false;
                        plhEditAddress.Visible = true;
                        addressEdit.Address    = new AddressInfo {
                            UserSaved = true
                        };
                        addressEdit.ShowUserSaved   = false;
                        addressEdit.ShowDescription = true;
                    }
                    // Display user's addresses
                    else
                    {
                        List <AddressInfo> addresses = controller.GetAddresses <AddressInfo>(PortalId, UserId, _addressDefaultDescription);

                        if (addresses.Count > 0)
                        {
                            grdAddresses.DataSource = addresses;
                            grdAddresses.DataBind();
                        }

                        plhGrid.Visible        = true;
                        plhEditAddress.Visible = false;
                    }
                }
            }
            catch (Exception ex)
            {
                Exceptions.ProcessModuleLoadException(this, ex);
            }
        }