private void CreateAddressControlForBilling()
        {
            addressControl = new AddressControl
            {
                Dock         = DockStyle.Fill,
                CoName       = address.Data.Name,
                Line1        = address.Data.Line1,
                Line2        = address.Data.Line2,
                City         = address.Data.City,
                State        = address.Data.State,
                ZipCode      = address.Data.Zip,
                Country      = address.Data.Country,
                TaxKey       = address.SalesTaxKey,
                Residential  = address.Data.Residential,
                IsGovernment = address.IsGovernment
            };

            addressControl.HideCustId();
            addressControl.HideStatus();

            addressControl.Done         += AddressControl_Done;
            addressControl.Invalid      += AddressControl_Invalid;
            addressControl.FormCleared  += () => chkSameAsPrim.Checked = false;
            addressControl.EnterPressed += () => EnterPressed();

            panelAddress.Controls.Clear();
            panelAddress.Controls.Add(addressControl);
        }
Esempio n. 2
0
        /// <summary>
        /// Creates the child controls.
        /// </summary>
        /// <param name="entityType">Type of the entity.</param>
        /// <param name="parentControl">The parent control.</param>
        /// <returns></returns>
        public override Control[] CreateChildControls(Type entityType, FilterField parentControl)
        {
            // Define Control: Location Type DropDown List
            var ddlLocationType = new RockDropDownList();

            ddlLocationType.ID    = parentControl.GetChildControlInstanceName(_CtlLocationType);
            ddlLocationType.Label = "Address Type";
            ddlLocationType.Help  = "Specifies the type of address the filter will be applied to. If no value is selected, all of the Person's addresses will be considered.";

            var familyLocations = GroupTypeCache.GetFamilyGroupType().LocationTypeValues.OrderBy(a => a.Order).ThenBy(a => a.Value);

            foreach (var value in familyLocations)
            {
                ddlLocationType.Items.Add(new ListItem(value.Value, value.Guid.ToString()));
            }

            ddlLocationType.Items.Insert(0, None.ListItem);

            parentControl.Controls.Add(ddlLocationType);

            // Define Control: Address Control
            var acAddress = new AddressControl();

            acAddress.ID    = parentControl.GetChildControlInstanceName(_CtlLocationAddress);
            acAddress.Label = "Address";
            acAddress.Help  = "All or part of an address to which the Person is associated.";
            acAddress.AddCssClass("js-addresscontrol");
            parentControl.Controls.Add(acAddress);

            return(new Control[] { acAddress, ddlLocationType });
        }
Esempio n. 3
0
 private void CountryDropDownData(AddressControl ctrlAddress)
 {
     //Assign Datasource for the country dropdown
     ctrlAddress.CountryDataSource     = Country.GetAll();
     ctrlAddress.CountryDataTextField  = "Name";
     ctrlAddress.CountryDataValueField = "Name";
 }
Esempio n. 4
0
    private void unbindObjectFromPage()
    {
        targetSection.Name        = tbName.Text;
        targetSection.Description = reDescription.Content;

        // custom fields
        cfsSectionFields.Harvest();

        if (linkedOrganization == null)
        {
            return;
        }

        // now, the phone numbers
        foreach (GridViewRow grvPhoneNumberType in gvPhoneNumbers.Rows)
        {
            DataKey dataKey = gvPhoneNumbers.DataKeys[grvPhoneNumberType.RowIndex];
            if (dataKey == null)
            {
                continue;
            }

            var     code = dataKey.Value;
            TextBox tb   = grvPhoneNumberType.FindControl("tbPhoneNumber") as TextBox;


            if (tb == null)
            {
                return;
            }
            linkedOrganization[code + "_PhoneNumber"] = tb.Text;
        }

        // the preferred
        string preferredPhoneNumberID = Request.Form["PhoneNumberPreferredType"];

        if (preferredPhoneNumberID != null)
        {
            linkedOrganization.PreferredPhoneNumberType = preferredPhoneNumberID;
        }


        // now, let's unbind the addresses
        foreach (RepeaterItem riAddress in rptAddresses.Items)
        {
            AddressControl ac            = (AddressControl)riAddress.FindControl("acAddress");
            HiddenField    hfAddressCode = (HiddenField)riAddress.FindControl("hfAddressCode");

            if (ac == null || hfAddressCode == null)
            {
                continue;                       // defensive programmer
            }
            string code = hfAddressCode.Value;  // remember we stuck the code in there during databinding
            linkedOrganization[code + "_Address"] = ac.Address;
        }

        // let's get the preferred address
        linkedOrganization.PreferredAddressType = ddlPreferredAddress.SelectedValue;
    }
Esempio n. 5
0
 protected Location GetLocationFromControl(LocationService locationService, AddressControl control, Group family)
 {
     if (control.IsValid && !string.IsNullOrWhiteSpace(control.Street1) && !string.IsNullOrWhiteSpace(control.City) && !string.IsNullOrWhiteSpace(control.State) && !string.IsNullOrWhiteSpace(control.PostalCode))
     {
         return(locationService.Get(control.Street1, control.Street2, control.City, control.State, control.PostalCode, control.Country, family, true));
     }
     return(null);
 }
Esempio n. 6
0
 /// <summary>
 /// Event Handler for the ItemCreated event of the Repeater control
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void ctrlCartItemAddresses_ItemCreated(object sender, RepeaterItemEventArgs e)
 {
     if (e.Item.ItemType == ListItemType.Item ||
         e.Item.ItemType == ListItemType.AlternatingItem)
     {
         AddressControl ctrlAddress = e.Item.FindControl("ctrlAddress") as AddressControl;
         ctrlAddress.SelectedCountryChanged += new EventHandler(ctrlAddress_SelectedCountryChanged);
     }
 }
Esempio n. 7
0
        private void ctrlAddress_SelectedCountryChanged(object sender, EventArgs e)
        {
            AddressControl ctrlAddress = sender as AddressControl;

            //LoadStateForCountry(ctrlAddress, ctrlAddress.Country);
            //Assign Datasource for the state dropdown
            ctrlAddress.StateDataSource = State.GetAllStateForCountry(AppLogic.GetCountryID(ctrlAddress.Country), ThisCustomer.LocaleSetting);
            ctrlAddress.ShowZip         = AppLogic.GetCountryPostalCodeRequired(AppLogic.GetCountryID(ctrlAddress.Country));
        }
Esempio n. 8
0
 /// <summary>
 /// Updates the address fields from an address control.
 /// </summary>
 /// <param name="addressControl">The address control.</param>
 public void UpdateAddressFieldsFromAddressControl(AddressControl addressControl)
 {
     Street1    = addressControl.Street1;
     Street2    = addressControl.Street2;
     City       = addressControl.City;
     State      = addressControl.State;
     PostalCode = addressControl.PostalCode;
     Country    = addressControl.Country;
 }
Esempio n. 9
0
    protected void rptAddresses_OnItemCreated(object sender, RepeaterItemEventArgs e)
    {
        // we need to set the control host property every time the item is created
        AddressControl acAddress = (AddressControl)e.Item.FindControl("acAddress");

        if (acAddress != null)
        {
            acAddress.Host = this;
        }
    }
Esempio n. 10
0
        protected void ctrlAddress_SelectedCountryChanged(object sender, EventArgs e)
        {
            AddressControl ctrlAddress = sender as AddressControl;

            if (ctrlAddress != null)
            {
                StateDropdownData(ctrlAddress);
                ctrlAddress.ShowZip = AppLogic.GetCountryPostalCodeRequired(AppLogic.GetCountryID(ctrlAddress.Country));
            }
        }
Esempio n. 11
0
 private void CountryDropdownData(AddressControl ctrlAddress)
 {
     if (ctrlAddress != null)
     {
         //Billing Country DropDown
         ctrlAddress.CountryDataSource     = Country.GetAll();
         ctrlAddress.CountryDataTextField  = "Name";
         ctrlAddress.CountryDataValueField = "Name";
     }
 }
        private void RenderDeletePickupView()
        {
            bool isXML = true;

            this.divAddPickUp.Visible    = false;
            this.divDeletePickUp.Visible = true;
            this.btnContinue.Text        = GetLocalResourceObject("btnContinueDelete") as string;

            ShippingAddress_V01 shipAddr = new ShippingAddress_V01();

            shipAddr.Address         = new Address_V01();
            shipAddr.Address.Country = CountryCode;

            var deliveryOptionList = (this.Page as ProductsBase).GetShippingProvider().
                                     GetDeliveryOptions(DeliveryOptionType.Pickup, shipAddr);

            DeliveryOption pickupDeliveryOption = deliveryOptionList.Find(p => p.Id == this.WorkedUponDeliveryOptionId);

            this.lblName.Text = pickupDeliveryOption.Description;

            string      controlPath = getDeleteAddressControlPath(ref isXML);
            AddressBase addressBase = new AddressControl();

            addressBase.XMLFile = controlPath;
            this.colDeletePickUp.Controls.Add((Control)addressBase);

            addressBase.DataContext = pickupDeliveryOption;

            var pickUpLocationPreferences = (this.Page as ProductsBase).GetShippingProvider().
                                            GetPickupLocationsPreferences(
                (this.Page as ProductsBase).DistributorID,
                CountryCode);
            PickupLocationPreference_V01 selectedPickupPreference = pickUpLocationPreferences.Find
                                                                        (p => p.PickupLocationID == this.WorkedUponDeliveryOptionId);

            if (selectedPickupPreference != null)
            {
                this.lblDeleteIsPrimaryText.Text = selectedPickupPreference.IsPrimary
                                                       ? GetLocalResourceObject("PrimaryYes.Text") as string
                                                       : GetLocalResourceObject("PrimaryNo.Text") as string;
                this.lblDeleteNicknameText.Text = selectedPickupPreference.PickupLocationNickname;

                if (selectedPickupPreference.IsPrimary) //Eval UC:3.5.3.7 (deleting primary)
                {
                    this.lblErrors.Text = PlatformResources.GetGlobalResourceString("ErrorMessage",
                                                                                    "PrimaryPickupPreferenceDeleteNotAllowed");
                    this.btnContinue.Enabled = false;
                    return;
                }
                else //Eval UC:3.5.3.6 (deleting non-primary)
                {
                    this.btnContinue.Enabled = true;
                }
            }
        }
Esempio n. 13
0
    protected void rptAddresses_OnItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        msAddressType at = (msAddressType)e.Item.DataItem;

        if (Page.IsPostBack)
        {
            return;                             // only do this if there's a postback - otherwise, preserve ViewState
        }
        switch (e.Item.ItemType)
        {
        case ListItemType.Header:
            break;

        case ListItemType.Footer:
            break;

        case ListItemType.AlternatingItem:
            goto case ListItemType.Item;

        case ListItemType.Item:
            Label          lblAddressType = (Label)e.Item.FindControl("lblAddressType");
            AddressControl acAddress      = (AddressControl)e.Item.FindControl("acAddress");
            Literal        lNewRowTag     = (Literal)e.Item.FindControl("lNewRowTag");
            HiddenField    hfAddressCode  = (HiddenField)e.Item.FindControl("hfAddressCode");


            /* We need to extract the adress from the underlying MemberSuiteObject
             * address are flattened, and they are in the format of <Code>_Address
             * where <Code> is the API Code of the address type*/


            lblAddressType.Text = at.Name;
            hfAddressCode.Value = at.Code;      // we'll need this for when we unbind
            acAddress.Address   = targetObject.SafeGetValue <Address>(at.Code + "_Address");


            /* we're doing THREE columns, so if the index is divisible by three, we want to generate a
             * start row tag (<tr>)and an end row tag (</tr>)
             */

            if (e.Item.ItemIndex != 0 && (e.Item.ItemIndex + 1) % 3 == 0)
            {
                lNewRowTag.Text = "</TR><TR>";
            }



            break;
        }
    }
        //ADDRESS CONTROL
        private void SetUpAddressEditorControl()
        {
            addressControl = new AddressControl {
                Dock = DockStyle.Fill
            };
            addressControl.HideStatus();
            addressControl.HideCustId();
            addressControl.StatusChanged += AddressControl_StatusChanged;
            addressControl.Done          += AddressControl_Done;
            addressControl.Invalid       += AddressControl_Invalid;
            addressControl.EnterPressed  += AddressControl_EnterPressed;
            addressControl.CustKey        = customer.Key;

            panelAddress.Controls.Add(addressControl);
        }
Esempio n. 15
0
        private void loadAddressReadonly()
        {
            var    addressBase = new AddressControl();
            string xmlFile;

            if (!string.IsNullOrEmpty(xmlFile = HLConfigManager.Configurations.AddressingConfiguration.GDOStaticAddress))
            {
                addressBase.XMLFile = xmlFile;
                if (ShoppingCart.DeliveryInfo != null)
                {
                    addressBase.DataContext = ShoppingCart.DeliveryInfo.Address;
                }
                divAddreaddReadOnly.Controls.Add(addressBase);
            }
        }
        //-------------------------PRIMARY ADDRESS-------------------------------
        private void NavigateToPrimaryAddressPage()
        {
            string companyName = newCustomer.Name ?? "";
            string custId      = newCustomer.Id ?? "";
            string line1       = newCustomer.PrimaryAddress.Line1 ?? "";
            string line2       = newCustomer.PrimaryAddress.Line2 ?? "";
            string city        = newCustomer.PrimaryAddress.City ?? "";
            string state       = newCustomer.PrimaryAddress.State ?? "";
            string country     = newCustomer.PrimaryAddress.Country ?? "";
            string zip         = newCustomer.PrimaryAddress.Zip ?? "";
            short  residential = newCustomer.PrimaryAddress.Residential;

            var primaryCustAddr = newCustomer.CustAddresses.FirstOrDefault(c => c.Type == CustAddrType.Primary);

            int taxRateKey = primaryCustAddr == null ? 0 : primaryCustAddr.STaxSchdKey == null ? 0 : (int)primaryCustAddr.STaxSchdKey;

            var addressPage = new AddressControl()
            {
                Dock         = DockStyle.Fill,
                ZipCode      = zip,
                CoName       = companyName,
                CustId       = custId,
                Line1        = line1,
                Line2        = line2,
                City         = city,
                State        = state,
                Country      = country,
                TaxKey       = taxRateKey,
                Residential  = residential,
                IsGovernment = primaryIsGov
            };

            addressPage.Done         += AddressPage_Done;
            addressPage.Invalid      += () => btnNext.Enabled = false;
            addressPage.EnterPressed += () => btnNext.PerformClick();

            mainPanel.Controls.Clear();
            mainPanel.Controls.Add(addressPage);

            lblCurrent.Text = "Billing Address";
        }
        protected AddressBase createAddress(string controlPath, bool isXML)
        {
            AddressBase addressBase = null;

            try
            {
                if (!isXML)
                {
                    addressBase = LoadControl(controlPath) as AddressBase;
                }
                else
                {
                    addressBase         = new AddressControl();
                    addressBase.XMLFile = controlPath;
                }
            }
            catch (HttpException ex)
            {
                LoggerHelper.Error(ex.ToString());
            }
            return(addressBase);
        }
Esempio n. 18
0
        /// <summary>
        /// Sets the country and state dropdown datasource
        /// </summary>
        /// <param name="ctrlAddress"></param>
        private void SetupAddressControl(AddressControl ctrlAddress)
        {
            List <string> countries = new List <string>();

            using (SqlConnection con = DB.dbConn())
            {
                con.Open();
                using (IDataReader reader = DB.GetRS("SELECT Name FROM Country", con))
                {
                    while (reader.Read())
                    {
                        countries.Add(DB.RSField(reader, "Name"));
                    }
                }
            }

            ctrlAddress.CountryDataSource = countries;

            // populate the available states for this country
            //LoadStateForCountry(ctrlAddress, ctrlAddress.Country);
            ctrlAddress.StateDataSource = State.GetAllStateForCountry(AppLogic.GetCountryID(ctrlAddress.Country), ThisCustomer.LocaleSetting);
        }
Esempio n. 19
0
    private bool unbindObjectFromPage()
    {
        targetObject.Title      = tbTitle.Text;
        targetObject.Prefix     = tbPrefix.Text;
        targetObject.FirstName  = tbFirstName.Text;
        targetObject.MiddleName = tbMiddleName.Text;
        targetObject.LastName   = tbLastName.Text;
        targetObject.Nickname   = tbNickName.Text;
        targetObject.Suffix     = tbSuffix.Text;

        //unbind the image if applicable
        if (imageUpload.HasFile)
        {
            targetObject["Image_Contents"] = getImageFile();

            //Set the session variable forcing any cached images to be refreshed from the MemberSuite Image content server
            SessionManager.Set("ImageUrlUpper", !SessionManager.Get <bool>("ImageUrlUpper"));
        }

        // now, the email
        targetObject.EmailAddress  = tbEmail.Text;
        targetObject.EmailAddress2 = tbEmail2.Text;
        targetObject.EmailAddress3 = tbEmail3.Text;

        // now, the phone numbers
        foreach (GridViewRow grvPhoneNumberType in gvPhoneNumbers.Rows)
        {
            DataKey dataKey = gvPhoneNumbers.DataKeys[grvPhoneNumberType.RowIndex];
            if (dataKey == null)
            {
                continue;
            }

            var     code = dataKey.Value;
            TextBox tb   = grvPhoneNumberType.FindControl("tbPhoneNumber") as TextBox;


            if (tb == null)
            {
                continue;
            }
            targetObject[code + "_PhoneNumber"] = tb.Text;
        }

        //if (!atLeastOnePhoneNumber)
        //{
        //    cvPhoneNumber.IsValid = false;
        //    return false;
        //}

        // the preferred
        string preferredPhoneNumberID = Request.Form["PhoneNumberPreferredType"];

        if (preferredPhoneNumberID != null)
        {
            targetObject.PreferredPhoneNumberType = preferredPhoneNumberID;
        }


        // now, let's unbind the addresses
        foreach (RepeaterItem riAddress in rptAddresses.Items)
        {
            AddressControl ac            = (AddressControl)riAddress.FindControl("acAddress");
            HiddenField    hfAddressCode = (HiddenField)riAddress.FindControl("hfAddressCode");

            if (ac == null || hfAddressCode == null)
            {
                continue;                       // defensive programmer
            }
            string code = hfAddressCode.Value;  // remember we stuck the code in there during databinding
            targetObject[code + "_Address"] = ac.Address;
        }

        //if (!atLeastOneAddress)
        //{
        //    cvAddress.IsValid = false;
        //    return false;
        //}

        // let's get the preferred address
        targetObject.PreferredAddressType = ddlPreferredAddress.SelectedValue;

        // and, the seasonal settings
        if (rbSeasonalNo.Checked)
        {
            targetObject.SeasonalAddressStart = null;
            targetObject.SeasonalAddressEnd   = null;
        }
        else
        {
            targetObject.SeasonalAddressStart = mdpSeasonalStart.Date;
            targetObject.SeasonalAddressEnd   = mdpSeasonalEnd.Date;
        }

        //Communication Preferences
        targetObject.DoNotEmail = chkDoNotEmail.Checked;
        targetObject.DoNotFax   = chkDoNotFax.Checked;
        targetObject.DoNotMail  = chkDoNotMail.Checked;
        targetObject.CommunicationsLastVerified     = DateTime.UtcNow;
        targetObject.CommunicationsLastVerifiedFrom = Utils.GetIP();

        //Unbind selected opt out message categories
        targetObject.OptOuts = (from category in dlbMessageCategories.Destination.Items
                                select category.Value).ToList();

        // finally, the custom fields
        CustomFieldSet1.Harvest();

        return(true);
    }
 public static void DisplayAddress(this Address add, AddressControl control)
 {
Esempio n. 21
0
        protected void btnNewAddress_Click(object sender, EventArgs e)
        {
            AddressControl ctrlNewAddress = pnlContent.FindControl("ctrlNewAddress") as AddressControl;

            if (ctrlNewAddress != null)
            {
                ctrlNewAddress.CountryIDToValidateZipCode = AppLogic.GetCountryID(ctrlNewAddress.Country);
            }

            Page.Validate("AddAddress");

            if (Page.IsValid)
            {
                AspDotNetStorefrontCore.Address anyAddress = new AspDotNetStorefrontCore.Address();

                if (ctrlNewAddress != null)
                {
                    anyAddress.CustomerID = ThisCustomer.CustomerID;
                    anyAddress.NickName   = ctrlNewAddress.NickName;
                    anyAddress.FirstName  = ctrlNewAddress.FirstName;
                    anyAddress.LastName   = ctrlNewAddress.LastName;
                    anyAddress.Company    = ctrlNewAddress.Company;
                    anyAddress.Address1   = ctrlNewAddress.Address1;
                    anyAddress.Address2   = ctrlNewAddress.Address2;
                    anyAddress.Suite      = ctrlNewAddress.Suite;
                    anyAddress.City       = ctrlNewAddress.City;
                    anyAddress.State      = ctrlNewAddress.State;
                    anyAddress.Zip        = ctrlNewAddress.ZipCode;
                    anyAddress.Country    = ctrlNewAddress.Country;
                    anyAddress.Phone      = ctrlNewAddress.PhoneNumber;
                    //anyAddress.ResidenceType = (ResidenceTypes)addressType;
                    anyAddress.ResidenceType = (ResidenceTypes)Enum.Parse(typeof(ResidenceTypes), ctrlNewAddress.ResidenceType, true);

                    anyAddress.InsertDB();

                    int addressID = anyAddress.AddressID;

                    if (ThisCustomer.PrimaryBillingAddressID == 0)
                    {
                        DB.ExecuteSQL("Update Customer set BillingAddressID=" + addressID + " where CustomerID=" + ThisCustomer.CustomerID.ToString());
                    }
                    if (ThisCustomer.PrimaryShippingAddressID == 0)
                    {
                        DB.ExecuteSQL("Update Customer set ShippingAddressID=" + addressID + " where CustomerID=" + ThisCustomer.CustomerID.ToString());
                        ThisCustomer.SetPrimaryShippingAddressForShoppingCart(ThisCustomer.PrimaryShippingAddressID, addressID);
                    }
                    if (AppLogic.AppConfig("VerifyAddressesProvider") != "")
                    {
                        AspDotNetStorefrontCore.Address standardizedAddress = new AspDotNetStorefrontCore.Address();
                        String validateResult = AddressValidation.RunValidate(anyAddress, out standardizedAddress);
                        validateResult = "address.validation.errormsg".StringResource() + validateResult;

                        if (validateResult != AppLogic.ro_OK)
                        {
                            Session["ErrorMsgLabelText"] = System.Web.HttpUtility.HtmlEncode(validateResult);
                        }
                        else
                        {
                            anyAddress = standardizedAddress;
                            anyAddress.UpdateDB();
                        }
                    }

                    String sURL = CommonLogic.ServerVariables("URL") + CommonLogic.IIF(CommonLogic.ServerVariables("QUERY_STRING").Length > 0, "?" + CommonLogic.ServerVariables("QUERY_STRING"), "");
                    if (!CommonLogic.IsStringNullOrEmpty(sURL))
                    {
                        Response.Redirect(sURL);
                    }
                }
            }
        }
        /// <summary>
        /// Gets the person control for this field's <see cref="PersonFieldType"/>
        /// </summary>
        /// <param name="setValue">if set to <c>true</c> [set value].</param>
        /// <param name="fieldValue">The field value.</param>
        /// <param name="familyMemberSelected">if set to <c>true</c> [family member selected].</param>
        /// <param name="validationGroup">The validation group.</param>
        /// <returns></returns>
        public Control GetPersonControl(bool setValue, object fieldValue, bool familyMemberSelected, string validationGroup)
        {
            RegistrationTemplateFormField field = this;
            Control personFieldControl          = null;

            switch (field.PersonFieldType)
            {
            case RegistrationPersonFieldType.FirstName:
                var tbFirstName = new RockTextBox
                {
                    ID              = "tbFirstName",
                    Label           = "First Name",
                    Required        = field.IsRequired,
                    CssClass        = "js-first-name",
                    ValidationGroup = validationGroup,
                    Enabled         = !familyMemberSelected,
                    Text            = setValue && fieldValue != null?fieldValue.ToString() : string.Empty
                };

                personFieldControl = tbFirstName;
                break;

            case RegistrationPersonFieldType.LastName:
                var tbLastName = new RockTextBox
                {
                    ID              = "tbLastName",
                    Label           = "Last Name",
                    Required        = field.IsRequired,
                    ValidationGroup = validationGroup,
                    Enabled         = !familyMemberSelected,
                    Text            = setValue && fieldValue != null?fieldValue.ToString() : string.Empty
                };

                personFieldControl = tbLastName;
                break;

            case RegistrationPersonFieldType.MiddleName:
                var tbMiddleName = new RockTextBox
                {
                    ID              = "tbMiddleName",
                    Label           = "Middle Name",
                    Required        = field.IsRequired,
                    ValidationGroup = validationGroup,
                    Enabled         = !familyMemberSelected,
                    Text            = setValue && fieldValue != null?fieldValue.ToString() : string.Empty
                };

                // Enable the middle name field if it is currently disabled but required and there is no value.
                if (!tbMiddleName.Enabled && tbMiddleName.Required && tbMiddleName.Text.IsNullOrWhiteSpace())
                {
                    tbMiddleName.Enabled = true;
                }

                personFieldControl = tbMiddleName;
                break;

            case RegistrationPersonFieldType.Campus:
                var cpHomeCampus = new CampusPicker
                {
                    ID               = "cpHomeCampus",
                    Label            = "Campus",
                    Required         = field.IsRequired,
                    ValidationGroup  = validationGroup,
                    Campuses         = CampusCache.All(false),
                    SelectedCampusId = setValue && fieldValue != null?fieldValue.ToString().AsIntegerOrNull() : null
                };

                personFieldControl = cpHomeCampus;
                break;

            case RegistrationPersonFieldType.Address:
                var acAddress = new AddressControl
                {
                    ID    = "acAddress",
                    Label = "Address",
                    UseStateAbbreviation   = true,
                    UseCountryAbbreviation = false,
                    Required        = field.IsRequired,
                    ValidationGroup = validationGroup
                };

                if (setValue && fieldValue != null)
                {
                    acAddress.SetValues(fieldValue as Location);
                }

                personFieldControl = acAddress;
                break;

            case RegistrationPersonFieldType.Email:
                var tbEmail = new EmailBox
                {
                    ID              = "tbEmail",
                    Label           = "Email",
                    Required        = field.IsRequired,
                    ValidationGroup = validationGroup,
                    Text            = setValue && fieldValue != null?fieldValue.ToString() : string.Empty
                };

                personFieldControl = tbEmail;
                break;

            case RegistrationPersonFieldType.Birthdate:
                var bpBirthday = new BirthdayPicker
                {
                    ID              = "bpBirthday",
                    Label           = "Birthday",
                    Required        = field.IsRequired,
                    ValidationGroup = validationGroup,
                    SelectedDate    = setValue && fieldValue != null ? fieldValue as DateTime? : null
                };

                personFieldControl = bpBirthday;
                break;

            case RegistrationPersonFieldType.Grade:
                var gpGrade = new GradePicker
                {
                    ID                    = "gpGrade",
                    Label                 = "Grade",
                    Required              = field.IsRequired,
                    ValidationGroup       = validationGroup,
                    UseAbbreviation       = true,
                    UseGradeOffsetAsValue = true,
                    CssClass              = "input-width-md"
                };

                personFieldControl = gpGrade;

                if (setValue && fieldValue != null)
                {
                    var value = fieldValue.ToString().AsIntegerOrNull();
                    gpGrade.SetValue(Person.GradeOffsetFromGraduationYear(value));
                }

                break;

            case RegistrationPersonFieldType.Gender:
                var ddlGender = new RockDropDownList
                {
                    ID              = "ddlGender",
                    Label           = "Gender",
                    Required        = field.IsRequired,
                    ValidationGroup = validationGroup,
                };

                ddlGender.BindToEnum <Gender>(true, new Gender[1] {
                    Gender.Unknown
                });

                personFieldControl = ddlGender;

                if (setValue && fieldValue != null)
                {
                    var value = fieldValue.ToString().ConvertToEnumOrNull <Gender>() ?? Gender.Unknown;
                    ddlGender.SetValue(value.ConvertToInt());
                }

                break;

            case RegistrationPersonFieldType.MaritalStatus:
                var dvpMaritalStatus = new DefinedValuePicker
                {
                    ID              = "dvpMaritalStatus",
                    Label           = "Marital Status",
                    Required        = field.IsRequired,
                    ValidationGroup = validationGroup
                };

                dvpMaritalStatus.DefinedTypeId = DefinedTypeCache.Get(Rock.SystemGuid.DefinedType.PERSON_MARITAL_STATUS.AsGuid()).Id;
                personFieldControl             = dvpMaritalStatus;

                if (setValue && fieldValue != null)
                {
                    var value = fieldValue.ToString().AsInteger();
                    dvpMaritalStatus.SetValue(value);
                }

                break;

            case RegistrationPersonFieldType.AnniversaryDate:
                var dppAnniversaryDate = new DatePartsPicker
                {
                    ID              = "dppAnniversaryDate",
                    Label           = "Anniversary Date",
                    Required        = field.IsRequired,
                    ValidationGroup = validationGroup,
                    SelectedDate    = setValue && fieldValue != null ? fieldValue as DateTime? : null
                };

                personFieldControl = dppAnniversaryDate;
                break;

            case RegistrationPersonFieldType.MobilePhone:
                var dvMobilePhone = DefinedValueCache.Get(Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_MOBILE);
                if (dvMobilePhone == null)
                {
                    break;
                }

                var ppMobile = new PhoneNumberBox
                {
                    ID              = "ppMobile",
                    Label           = dvMobilePhone.Value,
                    Required        = field.IsRequired,
                    ValidationGroup = validationGroup,
                    CountryCode     = PhoneNumber.DefaultCountryCode()
                };

                var mobilePhoneNumber = setValue && fieldValue != null ? fieldValue as PhoneNumber : null;
                ppMobile.CountryCode = mobilePhoneNumber != null ? mobilePhoneNumber.CountryCode : string.Empty;
                ppMobile.Number      = mobilePhoneNumber != null?mobilePhoneNumber.ToString() : string.Empty;

                personFieldControl = ppMobile;
                break;

            case RegistrationPersonFieldType.HomePhone:
                var dvHomePhone = DefinedValueCache.Get(Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_HOME);
                if (dvHomePhone == null)
                {
                    break;
                }

                var ppHome = new PhoneNumberBox
                {
                    ID              = "ppHome",
                    Label           = dvHomePhone.Value,
                    Required        = field.IsRequired,
                    ValidationGroup = validationGroup,
                    CountryCode     = PhoneNumber.DefaultCountryCode()
                };

                var homePhoneNumber = setValue && fieldValue != null ? fieldValue as PhoneNumber : null;
                ppHome.CountryCode = homePhoneNumber != null ? homePhoneNumber.CountryCode : string.Empty;
                ppHome.Number      = homePhoneNumber != null?homePhoneNumber.ToString() : string.Empty;

                personFieldControl = ppHome;
                break;

            case RegistrationPersonFieldType.WorkPhone:
                var dvWorkPhone = DefinedValueCache.Get(Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_WORK);
                if (dvWorkPhone == null)
                {
                    break;
                }

                var ppWork = new PhoneNumberBox
                {
                    ID              = "ppWork",
                    Label           = dvWorkPhone.Value,
                    Required        = field.IsRequired,
                    ValidationGroup = validationGroup,
                    CountryCode     = PhoneNumber.DefaultCountryCode()
                };

                var workPhoneNumber = setValue && fieldValue != null ? fieldValue as PhoneNumber : null;
                ppWork.CountryCode = workPhoneNumber != null ? workPhoneNumber.CountryCode : string.Empty;
                ppWork.Number      = workPhoneNumber != null?workPhoneNumber.ToString() : string.Empty;

                personFieldControl = ppWork;
                break;

            case RegistrationPersonFieldType.ConnectionStatus:
                var dvpConnectionStatus = new DefinedValuePicker
                {
                    ID              = "dvpConnectionStatus",
                    Label           = "Connection Status",
                    Required        = field.IsRequired,
                    ValidationGroup = validationGroup
                };

                dvpConnectionStatus.DefinedTypeId = DefinedTypeCache.Get(new Guid(Rock.SystemGuid.DefinedType.PERSON_CONNECTION_STATUS)).Id;

                if (setValue && fieldValue != null)
                {
                    var value = fieldValue.ToString().AsInteger();
                    dvpConnectionStatus.SetValue(value);
                }

                personFieldControl = dvpConnectionStatus;
                break;
            }

            return(personFieldControl);
        }
Esempio n. 23
0
        protected void dlAddress_UpdateCommand(object sender, DataListCommandEventArgs e)
        {
            CreditCardPanel ctrlCreditCard = e.Item.FindControl("ctrlCreditCard") as CreditCardPanel;
            Panel           pnlCCData      = e.Item.FindControl("pnlCCData") as Panel;
            Panel           pnlECData      = e.Item.FindControl("pnlECData") as Panel;

            AddressControl ctrlAddress = e.Item.FindControl("ctrlAddress") as AddressControl;

            if (ctrlAddress != null)
            {
                ctrlAddress.CountryIDToValidateZipCode = AppLogic.GetCountryID(ctrlAddress.Country);
            }
            Page.Validate("EditAddress");

            if (AddressMode == AddressTypes.Billing && pnlCCData.Visible)
            {
                if (ctrlCreditCard.CreditCardType == AppLogic.GetString("address.cs.32", SkinID, ThisCustomer.LocaleSetting))
                {
                    pnlCCTypeErrorMsg.Visible = true;
                }
                else
                {
                    pnlCCTypeErrorMsg.Visible = false;
                }
                if (ctrlCreditCard.CardExpMonth == AppLogic.GetString("address.cs.34", SkinID, ThisCustomer.LocaleSetting))
                {
                    pnlCCExpMonthErrorMsg.Visible = true;
                }
                else
                {
                    pnlCCExpMonthErrorMsg.Visible = false;
                }
                if (ctrlCreditCard.CardExpYr == AppLogic.GetString("address.cs.35", 1, ThisCustomer.LocaleSetting))
                {
                    pnlCCExpYrErrorMsg.Visible = true;
                }
                else
                {
                    pnlCCExpYrErrorMsg.Visible = false;
                }

                CardType            Type      = CardType.Parse(ctrlCreditCard.CreditCardType);
                CreditCardValidator validator = new CreditCardValidator(ctrlCreditCard.CreditCardNumber, Type);
                bool isValid = validator.Validate();

                if (!isValid && AppLogic.AppConfigBool("ValidateCreditCardNumbers"))
                {
                    ctrlCreditCard.CreditCardNumber = string.Empty;
                    // clear the card extra code
                    AppLogic.StoreCardExtraCodeInSession(ThisCustomer, string.Empty);
                    pnlCCNumberErrorMsg.Visible = true;
                }
                else
                {
                    pnlCCNumberErrorMsg.Visible = false;
                }
            }

            bool isValidCCDropdown = !(pnlCCTypeErrorMsg.Visible || pnlCCExpMonthErrorMsg.Visible ||
                                       pnlCCExpYrErrorMsg.Visible || pnlCCNumberErrorMsg.Visible);

            if (dlAddress != null && Page.IsValid && isValidCCDropdown)
            {
                AspDotNetStorefrontCore.Address anyAddress = new AspDotNetStorefrontCore.Address();
                Echeck ctrlECheck = e.Item.FindControl("ctrlECheck") as Echeck;

                if (ctrlAddress != null)
                {
                    anyAddress.AddressID     = int.Parse((e.Item.FindControl("hfAddressID") as HiddenField).Value);
                    anyAddress.CustomerID    = ThisCustomer.CustomerID;
                    anyAddress.NickName      = ctrlAddress.NickName;
                    anyAddress.FirstName     = ctrlAddress.FirstName;
                    anyAddress.LastName      = ctrlAddress.LastName;
                    anyAddress.Phone         = ctrlAddress.PhoneNumber;
                    anyAddress.Company       = ctrlAddress.Company;
                    anyAddress.AddressType   = AddressMode;
                    anyAddress.ResidenceType = (ResidenceTypes)Enum.Parse(typeof(ResidenceTypes), ctrlAddress.ResidenceType, true);
                    anyAddress.Address1      = ctrlAddress.Address1;
                    anyAddress.Address2      = ctrlAddress.Address2;
                    anyAddress.City          = ctrlAddress.City;
                    anyAddress.Suite         = ctrlAddress.Suite;
                    anyAddress.Zip           = ctrlAddress.ZipCode;
                    anyAddress.Country       = ctrlAddress.Country;
                    anyAddress.State         = ctrlAddress.State;

                    if (CustomerCCRequired && AddressMode == AddressTypes.Billing)
                    {
                        Address BillingAddress = new Address();
                        BillingAddress.LoadByCustomer(ThisCustomer.CustomerID, ThisCustomer.PrimaryBillingAddressID, AddressTypes.Billing);

                        if (ctrlCreditCard != null)
                        {
                            anyAddress.CardName = ctrlCreditCard.CreditCardName;

                            if (!ctrlCreditCard.CreditCardNumber.StartsWith("*"))
                            {
                                anyAddress.CardNumber = ctrlCreditCard.CreditCardNumber;
                            }
                            else
                            {
                                anyAddress.CardNumber = BillingAddress.CardNumber;
                            }

                            anyAddress.CardType            = ctrlCreditCard.CreditCardType;
                            anyAddress.CardExpirationMonth = ctrlCreditCard.CardExpMonth;
                            anyAddress.CardExpirationYear  = ctrlCreditCard.CardExpYr;

                            if (AppLogic.AppConfigBool("ShowCardStartDateFields"))
                            {
                                string cardStartDate = "";
                                if (ctrlCreditCard.CardExpMonth != AppLogic.GetString("address.cs.34", SkinID, ThisCustomer.LocaleSetting))
                                {
                                    cardStartDate = ctrlCreditCard.CardStartMonth;
                                }
                                if (ctrlCreditCard.CardExpYr != AppLogic.GetString("address.cs.35", SkinID, ThisCustomer.LocaleSetting))
                                {
                                    cardStartDate += ctrlCreditCard.CardStartYear;
                                }
                                anyAddress.CardStartDate = cardStartDate;
                            }
                            if (AppLogic.AppConfigBool("CardExtraCodeIsOptional"))
                            {
                                anyAddress.CardIssueNumber = ctrlCreditCard.CreditCardIssueNumber;
                            }
                        }

                        if (ShowEcheck && ctrlECheck != null)
                        {
                            anyAddress.ECheckBankAccountName = ctrlECheck.ECheckBankAccountName;
                            anyAddress.ECheckBankName        = ctrlECheck.ECheckBankName;

                            if (!ctrlECheck.ECheckBankABACode.StartsWith("*"))
                            {
                                anyAddress.ECheckBankABACode = ctrlECheck.ECheckBankABACode;
                            }
                            else
                            {
                                anyAddress.ECheckBankABACode = BillingAddress.ECheckBankABACode;
                            }

                            if (!ctrlECheck.ECheckBankAccountNumber.StartsWith("*"))
                            {
                                anyAddress.ECheckBankAccountNumber = ctrlECheck.ECheckBankAccountNumber;
                            }
                            else
                            {
                                anyAddress.ECheckBankAccountNumber = BillingAddress.ECheckBankAccountNumber;
                            }

                            anyAddress.ECheckBankAccountType = ctrlECheck.ECheckBankAccountType;
                        }

                        if (pnlCCData.Visible)
                        {
                            anyAddress.PaymentMethodLastUsed = AppLogic.ro_PMCreditCard;
                        }
                        else if (pnlECData.Visible)
                        {
                            anyAddress.PaymentMethodLastUsed = AppLogic.ro_PMECheck;
                        }
                        else
                        {
                            anyAddress.PaymentMethodLastUsed = BillingAddress.PaymentMethodLastUsed;
                        }
                    }

                    anyAddress.UpdateDB();

                    if (AppLogic.AppConfig("VerifyAddressesProvider") != "")
                    {
                        AspDotNetStorefrontCore.Address standardizedAddress = new AspDotNetStorefrontCore.Address();
                        string validateResult = AddressValidation.RunValidate(anyAddress, out standardizedAddress);
                        anyAddress = standardizedAddress;
                        anyAddress.UpdateDB();

                        if (validateResult != AppLogic.ro_OK)
                        {
                        }
                    }

                    dlAddress.EditItemIndex = -1;
                    LoadData();
                }
            }
        }
    private void unbindObjectFromPage()
    {
        targetObject.Name = tbName.Text;

        //unbind the image if applicable
        if (imageUpload.HasFile)
        {
            targetObject["Image_Contents"] = getImageFile();

            //Set the session variable forcing any cached images to be refreshed from the MemberSuite Image content server
            SessionManager.Set("ImageUrlUpper", !SessionManager.Get <bool>("ImageUrlUpper"));
        }

        // now, the email
        targetObject.EmailAddress                 = tbEmail.Text;
        targetObject["BillingContactName"]        = tbBillingContactName.Text;
        targetObject["BillingContactPhoneNumber"] = tbBillingContactPhoneNumber.Text;

        // now, the phone numbers
        foreach (GridViewRow grvPhoneNumberType in gvPhoneNumbers.Rows)
        {
            DataKey dataKey = gvPhoneNumbers.DataKeys[grvPhoneNumberType.RowIndex];
            if (dataKey == null)
            {
                continue;
            }

            var     code = dataKey.Value;
            TextBox tb   = grvPhoneNumberType.FindControl("tbPhoneNumber") as TextBox;


            if (tb == null)
            {
                return;
            }
            targetObject[code + "_PhoneNumber"] = tb.Text;
        }

        // the preferred
        string preferredPhoneNumberID = Request.Form["PhoneNumberPreferredType"];

        if (preferredPhoneNumberID != null)
        {
            targetObject.PreferredPhoneNumberType = preferredPhoneNumberID;
        }


        // now, let's unbind the addresses
        foreach (RepeaterItem riAddress in rptAddresses.Items)
        {
            AddressControl ac            = (AddressControl)riAddress.FindControl("acAddress");
            HiddenField    hfAddressCode = (HiddenField)riAddress.FindControl("hfAddressCode");

            if (ac == null || hfAddressCode == null)
            {
                continue;                       // defensive programmer
            }
            string code = hfAddressCode.Value;  // remember we stuck the code in there during databinding
            targetObject[code + "_Address"] = ac.Address;
        }

        // let's get the preferred address
        targetObject.PreferredAddressType = ddlPreferredAddress.SelectedValue;



        // finally, the custom fields
        CustomFieldSet1.Harvest();
    }
Esempio n. 25
0
        /// <summary>
        /// Event Handler for the ItemCommand event of the Repeater Control
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        protected void ctrlCartItemAddresses_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            HtmlInputHidden addressOption = e.Item.FindControl("ShipAddressOption") as HtmlInputHidden;

            if (e.CommandName == "UseExistingAddress")
            {
                ShowHideContainedControl(e.Item, "cboShipToAddress", true);

                ShowHideContainedControl(e.Item, "pnlAddNewAddress", false);
                ShowHideContainedControl(e.Item, "ctrlAddress", false);
                ShowHideContainedControl(e.Item, "btnSaveNewAddress", false);
                ShowHideContainedControl(e.Item, "lnkCancelAddNew", false);
                ShowHideContainedControl(e.Item, "lnkAddNewAddress", true);
                ShowHideContainedControl(e.Item, "lnkAddNewAddress", true);
                ShowHideContainedControl(e.Item, "lnkUseGiftRefistryAddress", true);
                ShowHideContainedControl(e.Item, "lnkUseExistingAddress", false);
                ShowHideContainedControl(e.Item, "giftShipType", false);
                addressOption.Value = Boolean.TrueString;
            }
            else if (e.CommandName == "UseGiftRegistryAddress")
            {
                addressOption.Value = Boolean.FalseString;
                ShowHideContainedControl(e.Item, "lnkUseGiftRefistryAddress", false);
                ShowHideContainedControl(e.Item, "lnkUseExistingAddress", true);
                ShowHideContainedControl(e.Item, "giftShipType", true);


                ShowHideContainedControl(e.Item, "cboShipToAddress", false);
                ShowHideContainedControl(e.Item, "pnlAddNewAddress", false);
                ShowHideContainedControl(e.Item, "ctrlAddress", false);
                ShowHideContainedControl(e.Item, "btnSaveNewAddress", false);
                ShowHideContainedControl(e.Item, "lnkCancelAddNew", false);
                ShowHideContainedControl(e.Item, "lnkAddNewAddress", true);
            }
            else if (e.CommandName == "AddNewAddress")
            {
                addressOption.Value = Boolean.TrueString;
                ShowHideContainedControl(e.Item, "giftShipType", false);
                ShowHideContainedControl(e.Item, "pnlAddNewAddress", true);
                ShowHideContainedControl(e.Item, "ctrlAddress", true);
                ShowHideContainedControl(e.Item, "btnSaveNewAddress", true);
                ShowHideContainedControl(e.Item, "lnkCancelAddNew", true);
                ShowHideContainedControl(e.Item, "lnkAddNewAddress", false);

                AddressControl ctrlAddress = e.Item.FindControl("ctrlAddress") as AddressControl;
                if (ctrlAddress != null)
                {
                    SetupAddressControl(ctrlAddress);
                    FindLocaleStrings(ctrlAddress);
                }
            }
            else if (e.CommandName == "CancelAddNew")
            {
                addressOption.Value = Boolean.TrueString;
                ShowHideContainedControl(e.Item, "giftShipType", false);
                ShowHideContainedControl(e.Item, "pnlAddNewAddress", false);
                ShowHideContainedControl(e.Item, "ctrlAddress", false);
                ShowHideContainedControl(e.Item, "btnSaveNewAddress", false);
                ShowHideContainedControl(e.Item, "lnkCancelAddNew", false);
                ShowHideContainedControl(e.Item, "lnkAddNewAddress", true);
            }
            else if (e.CommandName == "SaveNewAddress")
            {
                AddressControl ctrlAddress = e.Item.FindControl("ctrlAddress") as AddressControl;
                ctrlAddress.CountryIDToValidateZipCode = AppLogic.GetCountryID(ctrlAddress.Country);

                Page.Validate("SaveAddress");
                if (Page.IsValid)
                {
                    if (ctrlAddress != null)
                    {
                        Address addr = new Address();
                        addr.CustomerID = ThisCustomer.CustomerID;
                        addr.NickName   = ctrlAddress.NickName;
                        addr.FirstName  = ctrlAddress.FirstName;
                        addr.LastName   = ctrlAddress.LastName;
                        addr.Address1   = ctrlAddress.Address1;
                        addr.Address2   = ctrlAddress.Address2;
                        addr.Company    = ctrlAddress.Company;
                        // TBD: Suite is not yet Mapped!!!
                        addr.Suite   = string.Empty;
                        addr.City    = ctrlAddress.City;
                        addr.State   = ctrlAddress.State;
                        addr.Zip     = ctrlAddress.ZipCode;
                        addr.Country = ctrlAddress.Country;
                        addr.Phone   = ctrlAddress.PhoneNumber;

                        addr.AddressType = AddressTypes.Shipping;
                        addr.InsertDB();

                        ReLoadCustomerShipToAddresses();

                        // rebind all controls
                        InitializeDataSource();
                    }

                    addressOption.Value = Boolean.TrueString;
                    ShowHideContainedControl(e.Item, "giftShipType", false);
                    ShowHideContainedControl(e.Item, "pnlAddNewAddress", false);
                    ShowHideContainedControl(e.Item, "ctrlAddress", false);
                    ShowHideContainedControl(e.Item, "btnSaveNewAddress", false);
                    ShowHideContainedControl(e.Item, "lnkCancelAddNew", false);
                    ShowHideContainedControl(e.Item, "lnkAddNewAddress", true);
                }
            }
        }
Esempio n. 26
0
 private void StateDropdownData(AddressControl ctrlBilling, AddressControl ctrlShipping)
 {
     ctrlShipping.StateDataSource = State.GetAllStateForCountry(AppLogic.GetCountryID(ctrlBilling.Country), ThisCustomer.LocaleSetting);
 }
Esempio n. 27
0
        protected void dlAddress_ItemDataBound(object sender, DataListItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.EditItem)
            {
                AddressControl  ctrlAddress    = e.Item.FindControl("ctrlAddress") as AddressControl;
                CreditCardPanel ctrlCreditCard = e.Item.FindControl("ctrlCreditCard") as CreditCardPanel;
                Echeck          ctrlECheck     = e.Item.FindControl("ctrlECheck") as Echeck;
                int             addyID         = Convert.ToInt32(DataBinder.Eval(e.Item.DataItem, "AddressID"));
                PopulateAddressControlValues(ctrlAddress, ctrlCreditCard, ctrlECheck, e.Item.ItemIndex, addyID);

                if (CustomerCCRequired)
                {
                    TableRow trCCInformation = e.Item.FindControl("trCCInformation") as TableRow;
                    if (trCCInformation != null)
                    {
                        if (AddressMode == AddressTypes.Billing)
                        {
                            RadioButtonList rblPaymentMethodInfo = e.Item.FindControl("rblPaymentMethodInfo") as RadioButtonList;
                            Panel           pnlCCData            = e.Item.FindControl("pnlCCData") as Panel;
                            Panel           pnlECData            = e.Item.FindControl("pnlECData") as Panel;

                            if (rblPaymentMethodInfo.SelectedValue.Equals(AppLogic.ro_PMCreditCard,
                                                                          StringComparison.InvariantCultureIgnoreCase))
                            {
                                trCCInformation.Visible = true;
                                rblPaymentMethodInfo.Items[0].Enabled = true;
                                pnlCCData.Visible = true;
                            }
                            if (!ShowEcheck)
                            {
                                rblPaymentMethodInfo.Items.Remove(rblPaymentMethodInfo.Items[1]);
                            }

                            //Image for eCheck
                            if (ShowEcheck && ctrlECheck != null)
                            {
                                ctrlECheck = e.Item.FindControl("ctrlECheck") as Echeck;
                                ctrlECheck.ECheckBankABAImage1    = AppLogic.LocateImageURL(String.Format("~/App_Themes/skin_{0}/images/check_aba.gif", SkinID.ToString()));
                                ctrlECheck.ECheckBankABAImage2    = AppLogic.LocateImageURL(String.Format("~/App_Themes/skin_{0}/images/check_aba.gif", SkinID.ToString()));
                                ctrlECheck.ECheckBankAccountImage = AppLogic.LocateImageURL(String.Format("~/App_Themes/skin_{0}/images/check_account.gif", SkinID.ToString()));
                                ctrlECheck.ECheckNoteLabel        = string.Format(AppLogic.GetString("address.cs.48", SkinID, ThisCustomer.LocaleSetting), AppLogic.LocateImageURL("App_Themes/skin_" + SkinID.ToString() + "/images/check_micr.gif"));
                            }

                            //hide payment methods if storeccindb = false
                        }
                        else if (AddressMode == AddressTypes.Shipping)
                        {
                            trCCInformation.Visible = false;
                        }
                    }
                }
            }

            if (e.Item.ItemType == ListItemType.Footer)
            {
                LinkButton  lbAddNewAddress = e.Item.FindControl("lbAddNewAddress") as LinkButton;
                ImageButton ibAddNewAddress = e.Item.FindControl("ibAddNewAddress") as ImageButton;

                if (lbAddNewAddress != null)
                {
                    if (AddressMode == AddressTypes.Billing)
                    {
                        string billingText = AppLogic.GetString("address.cs.70", SkinID, ThisCustomer.LocaleSetting);
                        lbAddNewAddress.Text = billingText;
                        if (ibAddNewAddress != null)
                        {
                            ibAddNewAddress.ToolTip       = billingText;
                            ibAddNewAddress.AlternateText = billingText;
                        }
                    }
                    else if (AddressMode == AddressTypes.Shipping)
                    {
                        string shippingText = AppLogic.GetString("address.cs.71", SkinID, ThisCustomer.LocaleSetting);
                        lbAddNewAddress.Text = shippingText;
                        if (ibAddNewAddress != null)
                        {
                            ibAddNewAddress.ToolTip       = shippingText;
                            ibAddNewAddress.AlternateText = shippingText;
                        }
                    }
                }
            }

            if ((e.Item.ItemType == ListItemType.Item ||
                 e.Item.ItemType == ListItemType.AlternatingItem))
            {
                //Assign numbering for individual address
                (e.Item.FindControl("lblIndexOrder") as Label).Text = String.Format("{0}.", (e.Item.ItemIndex + 1).ToString());
                int itemAddressID = Int32.Parse((e.Item.FindControl("hfAddressID") as HiddenField).Value);
                int primaryID     = 0;

                ImageButton ibDelete = e.Item.FindControl("ibDelete") as ImageButton;
                ImageButton ibEdit   = e.Item.FindControl("ibEdit") as ImageButton;

                DisableEditButtonsForAddressWithOpenOrder(ibDelete, ibEdit, itemAddressID);


                ImageButton ibMakePrimaryAddress = e.Item.FindControl("ibMakePrimary") as ImageButton;
                //Check if the address mode from the querystring to know what will be the primary address
                if (AddressMode == AddressTypes.Billing)
                {
                    primaryID = AppLogic.GetPrimaryBillingAddressID(ThisCustomer.CustomerID);
                    ibMakePrimaryAddress.ToolTip  = AppLogic.GetString("account.aspx.87", SkinID, ThisCustomer.LocaleSetting);
                    ibMakePrimaryAddress.ImageUrl = String.Format("~/App_Themes/Skin_{0}/images/icons/check_disabled.png", SkinID);
                }
                else if (AddressMode == AddressTypes.Shipping)
                {
                    primaryID = AppLogic.GetPrimaryShippingAddressID(ThisCustomer.CustomerID);
                    ibMakePrimaryAddress.ToolTip  = AppLogic.GetString("account.aspx.88", SkinID, ThisCustomer.LocaleSetting);
                    ibMakePrimaryAddress.ImageUrl = String.Format("~/App_Themes/Skin_{0}/images/icons/check_disabled.png", SkinID);
                }

                if (itemAddressID == primaryID)
                {
                    Label AddressHTML = e.Item.FindControl("lblAddressHTML") as Label;

                    //Display the last payment method used
                    if (CustomerCCRequired && AddressMode == AddressTypes.Billing)
                    {
                        string paymentMethodDisplay = DisplayPaymentMethod(primaryID);
                        if (!CommonLogic.IsStringNullOrEmpty(paymentMethodDisplay))
                        {
                            AddressHTML.Text += paymentMethodDisplay;
                        }
                    }

                    AddressHTML.Style["font-weight"] = "bold";
                    if (AddressMode == AddressTypes.Billing)
                    {
                        ibMakePrimaryAddress.ToolTip = AppLogic.GetString("account.aspx.89", SkinID, ThisCustomer.LocaleSetting);
                    }
                    else if (AddressMode == AddressTypes.Shipping)
                    {
                        ibMakePrimaryAddress.ToolTip = AppLogic.GetString("account.aspx.90", SkinID, ThisCustomer.LocaleSetting);
                    }
                    ibMakePrimaryAddress.ImageUrl = String.Format("~/App_Themes/Skin_{0}/images/icons/check_enabled.png", SkinID);
                }

                //shows the footer where you can click add
                dlAddress.ShowFooter = !tblNewAddress.Visible;
            }
        }
Esempio n. 28
0
        protected void btnNewAddress_Click(object sender, EventArgs e)
        {
            AddressControl ctrlNewAddress = pnlContent.FindControl("ctrlNewAddress") as AddressControl;

            if (ctrlNewAddress != null)
            {
                ctrlNewAddress.CountryIDToValidateZipCode = AppLogic.GetCountryID(ctrlNewAddress.Country);
            }

            Page.Validate("AddAddress");

            if (Page.IsValid)
            {
                AddressTypes addressType = AddressMode;
                bool         AllowShipToDifferentThanBillTo = AppLogic.AppConfigBool("AllowShipToDifferentThanBillTo") &&
                                                              !AppLogic.AppConfigBool("SkipShippingOnCheckout");

                if (!AllowShipToDifferentThanBillTo)
                {
                    //Shipping and Billing address must be the same so save both
                    addressType = AddressTypes.Billing | AddressTypes.Shipping;
                }

                AspDotNetStorefrontCore.Address anyAddress = new AspDotNetStorefrontCore.Address();

                if (ctrlNewAddress != null)
                {
                    anyAddress.CustomerID    = ThisCustomer.CustomerID;
                    anyAddress.NickName      = ctrlNewAddress.NickName;
                    anyAddress.FirstName     = ctrlNewAddress.FirstName;
                    anyAddress.LastName      = ctrlNewAddress.LastName;
                    anyAddress.Company       = ctrlNewAddress.Company;
                    anyAddress.Address1      = ctrlNewAddress.Address1;
                    anyAddress.Address2      = ctrlNewAddress.Address2;
                    anyAddress.Suite         = ctrlNewAddress.Suite;
                    anyAddress.City          = ctrlNewAddress.City;
                    anyAddress.State         = ctrlNewAddress.State;
                    anyAddress.Zip           = ctrlNewAddress.ZipCode;
                    anyAddress.Country       = ctrlNewAddress.Country;
                    anyAddress.Phone         = ctrlNewAddress.PhoneNumber;
                    anyAddress.ResidenceType = (ResidenceTypes)addressType;

                    anyAddress.InsertDB();

                    int addressID = anyAddress.AddressID;

                    if (ThisCustomer.PrimaryBillingAddressID == 0)
                    {
                        DB.ExecuteSQL("Update Customer set BillingAddressID=" + addressID + " where CustomerID=" + ThisCustomer.CustomerID.ToString());
                    }
                    if (ThisCustomer.PrimaryShippingAddressID == 0)
                    {
                        DB.ExecuteSQL("Update Customer set ShippingAddressID=" + addressID + " where CustomerID=" + ThisCustomer.CustomerID.ToString());
                        ThisCustomer.SetPrimaryShippingAddressForShoppingCart(ThisCustomer.PrimaryShippingAddressID, addressID);
                    }

                    if (AppLogic.AppConfig("VerifyAddressesProvider") != "")
                    {
                        AspDotNetStorefrontCore.Address standardizedAddress = new AspDotNetStorefrontCore.Address();
                        String VerifyResult        = AddressValidation.RunValidate(anyAddress, out standardizedAddress);
                        bool   verifyAddressPrompt = (VerifyResult != AppLogic.ro_OK);

                        if (verifyAddressPrompt)
                        {
                            anyAddress = standardizedAddress;
                            anyAddress.UpdateDB();
                        }
                    }

                    String sURL = CommonLogic.ServerVariables("URL") + CommonLogic.IIF(CommonLogic.ServerVariables("QUERY_STRING") != "", "?" + CommonLogic.ServerVariables("QUERY_STRING"), "");

                    if (!CommonLogic.IsStringNullOrEmpty(sURL))
                    {
                        Response.Redirect(sURL);
                    }
                }
            }
        }
Esempio n. 29
0
        private void PopulateAddressControlValues(AddressControl ctrlAddress, CreditCardPanel ctrlCreditCard, Echeck ctrlEcheck, int Index, int?editAddressId)
        {
            Addresses allAddress = GetAddresses();

            if (editAddressId.HasValue)
            {
                for (int i = 0; i < allAddress.Count; i++)
                {
                    if (allAddress[i].AddressID == editAddressId)
                    {
                        Index = i;
                    }
                }
            }
            AspDotNetStorefrontCore.Address anyAddress = allAddress[Index];

            if (ctrlAddress != null)
            {
                ctrlAddress.NickName      = anyAddress.NickName;
                ctrlAddress.FirstName     = anyAddress.FirstName;
                ctrlAddress.LastName      = anyAddress.LastName;
                ctrlAddress.PhoneNumber   = anyAddress.Phone;
                ctrlAddress.Company       = anyAddress.Company;
                ctrlAddress.ResidenceType = anyAddress.ResidenceType.ToString();
                ctrlAddress.Address1      = anyAddress.Address1;
                ctrlAddress.Address2      = anyAddress.Address2;
                ctrlAddress.Suite         = anyAddress.Suite;
                ctrlAddress.City          = anyAddress.City;
                ctrlAddress.ZipCode       = anyAddress.Zip;
                CountryDropDownData(ctrlAddress);
                ctrlAddress.Country = anyAddress.Country;
                StateDropDownData(ctrlAddress, ThisCustomer.LocaleSetting);
                ctrlAddress.State   = anyAddress.State;
                ctrlAddress.ShowZip = AppLogic.GetCountryPostalCodeRequired(AppLogic.GetCountryID(ctrlAddress.Country));
            }

            if (CustomerCCRequired)
            {
                if (ctrlCreditCard != null)
                {
                    ctrlCreditCard.CreditCardName   = anyAddress.CardName;
                    ctrlCreditCard.CreditCardNumber = AppLogic.SafeDisplayCardNumber(anyAddress.CardNumber, "Address", anyAddress.AddressID);
                    ctrlCreditCard.CreditCardType   = anyAddress.CardType;
                    ctrlCreditCard.CardExpMonth     = anyAddress.CardExpirationMonth;
                    ctrlCreditCard.CardExpYr        = anyAddress.CardExpirationYear;
                    if (AppLogic.AppConfigBool("Misc.ShowCardStartDateFields"))
                    {
                        if (!CommonLogic.IsStringNullOrEmpty(anyAddress.CardStartDate))
                        {
                            if (anyAddress.CardStartDate.Length >= 6)
                            {
                                ctrlCreditCard.CardStartMonth = anyAddress.CardStartDate.Substring(0, 2);
                                ctrlCreditCard.CardStartYear  = anyAddress.CardStartDate.Substring(2, 4);
                            }
                        }
                    }
                    if (AppLogic.AppConfigBool("CardExtraCodeIsOptional"))
                    {
                        ctrlCreditCard.CreditCardIssueNumber = anyAddress.CardIssueNumber;
                    }
                }
            }

            if (ShowEcheck)
            {
                if (ctrlEcheck != null)
                {
                    ctrlEcheck.ECheckBankAccountName   = anyAddress.ECheckBankAccountName;
                    ctrlEcheck.ECheckBankName          = anyAddress.ECheckBankName;
                    ctrlEcheck.ECheckBankABACode       = AppLogic.SafeDisplayCardNumber(anyAddress.ECheckBankABACode, "Address", anyAddress.AddressID);
                    ctrlEcheck.ECheckBankAccountNumber = anyAddress.ECheckBankAccountNumberMasked;
                    ctrlEcheck.ECheckBankAccountType   = anyAddress.ECheckBankAccountType;
                }
            }
        }
Esempio n. 30
0
 private void StateDropDownData(AddressControl ctrlAddress, String LocaleSetting)
 {
     //Assign Datasource for the state dropdown
     ctrlAddress.StateDataSource = State.GetAllStateForCountry(AppLogic.GetCountryID(ctrlAddress.Country), LocaleSetting);
 }