private TextBox AddTextBoxToPanel(Panel panel, Label lbl, string fieldname, PersonalDataSectionElements personalDataSectionElements)
 {
     TextBox t = new TextBox();
     t.ID = "Uxd_Lit_" + fieldname;
     t.CssClass = WebConstants.CssClassInputfield;
     lbl.AssociatedControlID = t.ID;
     panel.Controls.Add(t);
     _controls.Add(new Triple<PersonalDataSectionElements, WebControl, Label>(personalDataSectionElements, t, lbl));
     return t;
 }
 private DropDownList AddSelectControlToPanel(Panel panel, Label lbl, PersonalDataSectionElements personalDataSectionElements, string label)
 {
     DropDownList rList = new DropDownList();
     rList.ID = "Uxd_Lit_List_" + personalDataSectionElements;
     rList.CausesValidation = false;
     rList.CssClass = WebConstants.CssClassInputfield;
     lbl.AssociatedControlID = rList.ID;
     panel.Controls.Add(rList);
     _controls.Add(new Triple<PersonalDataSectionElements, WebControl, Label>(personalDataSectionElements, rList, lbl));
     return rList;
 }
        private void AddTextControl(PersonalDataSectionElements personalDataSectionElements, string label, bool mandatory, bool prefilled)
        {
            Panel p = new Panel();
            p.ID = "Uxd_Lit_Holder_" + personalDataSectionElements;
            p.CssClass = WebConstants.CssClassFormItem;
            Label l = new Label();
            l.ID = "Uxd_Lit_Label_" + personalDataSectionElements;
            l.CssClass = WebConstants.CssClassLabelNoValidationError;
            if (mandatory)
            {
                l.Text = WebConstants.ToRequired(label);
            }
            else
            {
                l.Text = WebConstants.ToLabelWithErrorBullet(label);
            }

            TextBox t = new TextBox();
            t.ID = "Uxd_Lit_" + personalDataSectionElements;
            t.CssClass = WebConstants.CssClassInputfield;
            l.AssociatedControlID = t.ID;
            p.Controls.Add(l);
            p.Controls.Add(t);
            Ux_Questions.Controls.Add(p);
            _controls.Add(new Triple<PersonalDataSectionElements, WebControl, Label>(personalDataSectionElements, t, l));
            if (personalDataSectionElements == PersonalDataSectionElements.Email)
            {
                t.Attributes.Add("onblur", "validate('" + t.ClientID + "')");
            }
        }
        private DropDownList AddSelectControl(PersonalDataSectionElements personalDataSectionElements, string label, List<Pair<string, string>> list, bool mandatory, bool prefilled)
        {
            Panel p = new Panel();
            p.ID = "Uxd_Lit_Holder_" + personalDataSectionElements;
            p.CssClass = WebConstants.CssClassFormItem;
            Label l = new Label();
            l.ID = "Uxd_Lit_Label_" + personalDataSectionElements;
            l.CssClass = WebConstants.CssClassLabelNoValidationError;
            if (mandatory)
            {
                l.Text = WebConstants.ToRequired(label);
            }
            else
            {
                l.Text = WebConstants.ToLabelWithErrorBullet(label);
            }

            DropDownList rList = new DropDownList();
            rList.ID = "Uxd_Lit_List_" + personalDataSectionElements;
            
            rList.CssClass = WebConstants.CssClassInputfield;
            l.AssociatedControlID = rList.ID;
            if (list != null)
            {
                foreach (Pair<string, string> element in list)
                {
                    rList.Items.Add(new ListItem(element.Second, "Lit_" + element.First));
                }
            }
            p.Controls.Add(l);
            p.Controls.Add(rList);
            Ux_Questions.Controls.Add(p);
            _controls.Add(new Triple<PersonalDataSectionElements, WebControl, Label>(personalDataSectionElements, rList, l));
            if (personalDataSectionElements == PersonalDataSectionElements.CountryRegion)
            {
                rList.AutoPostBack = true;
                countryRegionControl = new Triple<PersonalDataSectionElements, WebControl, Label>(personalDataSectionElements, rList, l);
            }

            return rList;
        }
Exemplo n.º 5
0
 private int DoTheSwitch(PersonalDataSectionElements elementToCheck, ShippingAddressResponseDto response, PersonalDataSectionDto personalDataSection)
 {
     int validationHint = -1;
     switch (elementToCheck)
     {
         case PersonalDataSectionElements.Address:
             if (String.IsNullOrEmpty(response.Address1))
                 validationHint = PersonalDataSectionDto.InvalidAddress1;
             break;
         case PersonalDataSectionElements.Address2:
             if (String.IsNullOrEmpty(response.Address2))
                 validationHint = PersonalDataSectionDto.InvalidAddress2;
             break;
         case PersonalDataSectionElements.Address3:
             if (String.IsNullOrEmpty(response.Address3))
                 validationHint = PersonalDataSectionDto.InvalidAddress3;
             break;
         case PersonalDataSectionElements.Town:
             if (String.IsNullOrEmpty(response.Town))
                 validationHint = PersonalDataSectionDto.InvalidTown;
             break;
         case PersonalDataSectionElements.County:
             if (String.IsNullOrEmpty(response.County))
                 validationHint = PersonalDataSectionDto.InvalidCounty;
             break;
         case PersonalDataSectionElements.PostalCode:
             if (String.IsNullOrEmpty(response.Postcode))
                 validationHint = PersonalDataSectionDto.InvalidPostcode;
             break;
         case PersonalDataSectionElements.CountryRegion:                    
             if (!IsValidSelection(personalDataSection.CountryRegionChoices, response.CountryCode))
                 validationHint = PersonalDataSectionDto.InvalidCountryCode;
             break;
         case PersonalDataSectionElements.Email:
             if (!DataValidation.ValidateEmail(response.EmailAddress, true))
                 validationHint = PersonalDataSectionDto.InvalidEmailAddress;
             break;
     }
     return validationHint;
 }
        private void AddTextControl(PersonalDataSectionElements personalDataSectionElements, string label, bool mandatory, bool prefilled)
        {
            Panel p = new Panel();
            p.ID = "Uxd_Holder_" + personalDataSectionElements;
            p.CssClass = WebConstants.CssClassFormItem;
            Label l = new Label();
            l.ID = "Uxd_Label_" + personalDataSectionElements;
            l.CssClass = WebConstants.CssClassLabelNoValidationError;
            if (mandatory)
            {
                l.Text = WebConstants.ToRequired(label);
            }
            else
            {
                l.Text = WebConstants.ToLabelWithErrorBullet(label);
            }

            TextBox t = new TextBox();
            t.ID = "Uxd_" + personalDataSectionElements; 
            t.CssClass = WebConstants.CssClassInputfield;            
            l.AssociatedControlID = t.ID;            
            p.Controls.Add(l);
            p.Controls.Add(t);            
            Ux_Questions.Controls.Add(p);
            _controls.Add(new Triple<PersonalDataSectionElements, WebControl, Label>(personalDataSectionElements, t, l));
            if (personalDataSectionElements == PersonalDataSectionElements.Email)
            {
                t.Attributes.Add("onblur", "validate('" + t.ClientID + "')");
            }

            if ((!IsPostBack) && prefilled)
            {
                switch (personalDataSectionElements)
                {
                    case PersonalDataSectionElements.PreferredLanguage:
                        t.Text = _customer.PreferredLanguage;
                        break;
                    case PersonalDataSectionElements.PersonalTitle:
                        t.Text = _customer.PersonalTitle;
                        break;
                    case PersonalDataSectionElements.FirstName:
                        t.Text = _customer.FirstName;
                        break;
                    case PersonalDataSectionElements.LastName:
                        t.Text = _customer.LastName;
                        break;
                    //case PersonalDataSectionElements.JobSelectName:
                    //    break;
                    case PersonalDataSectionElements.JobEnterName:
                        t.Text = _customer.JobTitle;
                        break;
                    case PersonalDataSectionElements.CompanyName:
                        t.Text = _customer.CompanyName;
                        break;

                    //RFG 2.11 | Added by Raju
                    case PersonalDataSectionElements.CompanyWebsite:
                        t.Text = _customer.CompanyWebsite;
                        break;
                    case PersonalDataSectionElements.CompanyRevenue:
                        t.Text = _customer.CompanyRevenue;
                        break;

                    case PersonalDataSectionElements.Town:
                        t.Text = _customer.Town;
                        break;
                    case PersonalDataSectionElements.County:
                        t.Text = _customer.County;
                        break;
                    case PersonalDataSectionElements.PostalCode:
                        t.Text = _customer.Postcode;
                        break;
                    case PersonalDataSectionElements.CountryRegion:
                        throw new NotImplementedException(); // which field in _customer?
                        break;
                    case PersonalDataSectionElements.Email:
                        t.Text = _customer.EmailAddress;
                        break;
                    //case PersonalDataSectionElements.EmailPreferences:
                    //    break;
                    case PersonalDataSectionElements.Telephone:
                        t.Text = _customer.TelephoneNumber;
                        break;
                    case PersonalDataSectionElements.PrimaryBusiness:
                        t.Text = _customer.BusinessCode;
                        break;
                    case PersonalDataSectionElements.CompanySize:
                        t.Text = _customer.WorldSize;
                        break;
                    case PersonalDataSectionElements.Fax:
                        t.Text = _customer.FaxNumber;
                        break;
                    case PersonalDataSectionElements.Mobile:
                        t.Text = _customer.MobileNumber;
                        break;
                    case PersonalDataSectionElements.Address:
                        t.Text = this._customer.Address1;
                        break;
                    case PersonalDataSectionElements.Address2:
                        t.Text = this._customer.Address2;
                        break;
                    case PersonalDataSectionElements.Address3:
                        t.Text = this._customer.Address3;
                        break;
                    default:
                        break;
                }
            }
        }
        private void AddPrefilledSelectControl(PersonalDataSectionElements personalDataSectionElements, string label, List<Pair<string, string>> list, bool mandatory, bool prefilled)
        {
            DropDownList rList = AddSelectControl(personalDataSectionElements, label, list, mandatory, prefilled);
            if (!IsPostBack)
            {
                if (personalDataSectionElements == PersonalDataSectionElements.CountryRegion)
                {
                    _isPrefilledCountry = prefilled; // is currently always false, as the user can not change in backend: 2011 11 29
                    int selected = -1;
                    if (prefilled)
                    {
                        selected = list.FindIndex(cur => (cur.First.ToLower() == _customer.CountryCode.ToLower()));
                    }
                    if (selected == -1)
                    {
                        _isPrefilledCountry = false;
                        selected = list.FindIndex(cur => (cur.First.ToLower() == _questionnaire.CountryCode.ToLower()));
                    }
                    if (selected != -1)
                    {
                        rList.SelectedIndex = selected;
                    }
                }
                else if (personalDataSectionElements == PersonalDataSectionElements.PreferredLanguage)
                {
                    int selected = -1;

                    if (prefilled && (_customer.PreferredLanguage != null))
                        selected = list.FindIndex(cur => cur.First.ToLower() == _customer.PreferredLanguage.ToLower() );

                    if (selected == -1)
                    {
                        string languageFromQuestionnaire = QuestionnaireFacade.GetPrefilledPreferredLanguage(_questionnaire.LanguageCode, _questionnaire.CountryCode);
                        if (!String.IsNullOrEmpty(languageFromQuestionnaire))
                        {
                            selected = list.FindIndex(delegate(Pair<string, string> cur) { return cur.First.ToLower() == languageFromQuestionnaire.ToLower(); });
                        }
                    }
                    if (selected != -1)
                    {
                        rList.SelectedIndex = selected;
                    }
                }
            }
            else
                _isPrefilledCountry = false;
        }
 private string FindValueForSelect(PersonalDataSectionElements currentElement)
 {
     string retval = null;
     _currentElement = currentElement;
     Triple<PersonalDataSectionElements, WebControl, Label> element = _controls.Find(IsCurrent);
     if (element != null)
     {
         DropDownList control = element.Second as DropDownList;
         if (control != null)
         {
             if (control.SelectedIndex != 0)
             {
                 if (currentElement.Equals(PersonalDataSectionElements.County))
                 {
                     retval = control.SelectedItem.Text;
                     boolCountyDDLExists = true;
                 }
                 else
                 {
                     retval = control.SelectedValue;
                 }
                 _hasData = true;                        
             }
         }
     }
     return retval;
 }
        private string FindValueForSelect(PersonalDataSectionElements currentElement)
        {
            string retval = null;
            _currentElement = currentElement;
            Triple<PersonalDataSectionElements, WebControl, Label> element = _controls.Find(IsCurrent);
            if (element != null)
            {
                DropDownList control = element.Second as DropDownList;
                if (control != null)
                {
                    if (control.SelectedIndex != 0)
                    {
                        if(currentElement.Equals(PersonalDataSectionElements.County))
                        {
                            //use control.SelectedValue to look up the standard english value to be used for insertion to database and crm_records
                            string countyValue = control.SelectedItem.Text;
                            int countyFKInt;
                            if (int.TryParse(control.SelectedItem.Value, out countyFKInt))
                            {
                                StandardCountyDto countyDto = FormRegistry.ResponseDao.GetStandardCounty(countyFKInt, _questionnaire.CountryCode, _questionnaire.LanguageCode);
                                if (countyDto != null)
                                {
                                    countyValue = countyDto.CountyName; //english name instead of localized name
                                }
                            }

                            retval = countyValue;
                        }     
                        else
                        {
                            retval = control.SelectedValue;
                        }
                        _hasData = true;

                        if (currentElement.Equals(PersonalDataSectionElements.County))
                            boolCountyDDLExists = true;  
                    }
                }
            }
            return retval;
        }
        private void AddEmailControl(PersonalDataSectionElements personalDataSectionElements, string label, string preferHtml, string preferText, bool mandatory, bool prefilled)
        {
            Panel p = new Panel();
            p.ID = "Uxd_Holder_" + personalDataSectionElements;
            p.CssClass = WebConstants.CssClassFormItem;
            Label l = new Label();
            l.ID = "Uxd_Label_" + personalDataSectionElements;
            l.CssClass = WebConstants.CssClassLabelNoValidationError;
            if (mandatory)
            {
                l.Text = WebConstants.ToRequired(label);
            }
            else
            {
                l.Text = WebConstants.ToLabelWithErrorBullet(label);
            }

            RadioButtonList rList = new RadioButtonList();
            rList.ID = "Uxd_List_" + personalDataSectionElements;
            rList.RepeatLayout = RepeatLayout.Table;
            rList.RepeatDirection = RepeatDirection.Horizontal;
            rList.CssClass = WebConstants.CssClassFormItemNoMargin;
            l.AssociatedControlID = rList.ID;

            rList.Items.Add(new ListItem(preferHtml, rList.ID + "_html"));
            rList.Items.Add(new ListItem(preferText, rList.ID + "_text"));
            p.Controls.Add(l);
            p.Controls.Add(rList);
            Ux_Questions.Controls.Add(p);
            _controls.Add(new Triple<PersonalDataSectionElements, WebControl, Label>(personalDataSectionElements, rList, l));

            if ((!IsPostBack) && prefilled)
            {
                if (_customer.EmailPreferences.HasValue)
                    rList.SelectedIndex = (((EmailPreferences)_customer.EmailPreferences) == EmailPreferences.Html) ? 0 : 1;
            }
        }
        public override List<ResponseDto> GetResponseDto(long responseId)
        {
            IResponseProvider provider = Page as IResponseProvider;
            if (provider == null)
            {
                throw new BugException(GetType().Name + " only supported in response providers");
            }

            List<ResponseDto> retval = null;
            _hasData = false;
            PersonalResponseDto personalDto = null;
            Triple<PersonalDataSectionElements, WebControl, Label> element = null;
            #region init variables and flex fields
            string address1 = null;
            string address2 = null;
            string address3 = null;
            string businessCode = null;
            string businessSiebel63 = null;
            string companyName = null;
            string companyWebsite = null;  //RFG 2.11 | Added by Raju
            string companyRevenue = null;  
            string countryCode = null;
            string county = null;
            string customerId = provider.CustomerId;
            string emailAddress = null;
            string firstName = null;
            string flexField1 = GetFlexField(1);
            string flexField10 = GetFlexField(10);
            string flexField11 = GetFlexField(11);
            string flexField12 = GetFlexField(12);
            string flexField13 = GetFlexField(13);
            string flexField14 = GetFlexField(14);
            string flexField15 = GetFlexField(15);
            string flexfield2 = GetFlexField(2);
            string flexField3 = GetFlexField(3);
            string flexField4 = GetFlexField(4);
            string flexField5 = GetFlexField(5);
            string flexField6 = GetFlexField(6);
            string flexField7 = GetFlexField(7);
            string flexField8 = GetFlexField(8);
            string flexField9 = GetFlexField(9);
            string jobCode = null;
            string jobSiebel63 = null;
            string jobTitle = null;
            string lastName = null;
            string personalTitle = null;
            string language = null;
            string postcode = null;
            string pwd = null;
            string telephoneCountry = null;
            string telephoneArea = null;
            string telephoneNumber = null;
            string telephoneExt = null;
            string faxCountry = null;
            string faxArea = null;
            string faxNumber = null;
            string faxExt = null;
            string mobileCountry = null;
            string mobileNumber = null;

            string town = null;
            string worldSize = null;
            string worldSize63 = null;
            string countryName = null;
            EmailPreferences? emailPreferences = null;
            #endregion

            #region address
            //_currentElement = PersonalDataSectionElements.Address;
            //element = _controls.Find(IsCurrent);
            //if (element != null)
            //{
            //    TextBox control = element.Second.FindControl("Uxd_" + _currentElement) as TextBox;
            //    if (control != null)
            //    {
            //        address1 = control.Text;
            //    }
            //    control = element.Second.FindControl("Uxd_" + _currentElement + "2") as TextBox;
            //    if (control != null)
            //    {
            //        address2 = control.Text;
            //    }
            //    control = element.Second.FindControl("Uxd_" + _currentElement + "3") as TextBox;
            //    if (control != null)
            //    {
            //        address3 = control.Text;
            //    }
            //    if (!String.IsNullOrEmpty(address1) || !String.IsNullOrEmpty(address2) || !String.IsNullOrEmpty(address3))
            //    {
            //        _hasData = true;
            //    }
            //}
            #endregion

            #region telephone
            _currentElement = PersonalDataSectionElements.Telephone;
            element = _controls.Find(IsCurrent);
            /*AddTextFieldToPanel(p, _element.TelephoneCountry, "TelephoneCountry", mandatory, control.Third);
            AddTextFieldToPanel(p, _element.TelephoneArea, "TelephoneArea", mandatory, control.Third);
            AddTextFieldToPanel(p, _element.TelephoneNumber, "TelephoneNumber", mandatory, control.Third);
            AddTextFieldToPanel(p, _element.TelephoneExt, "TelephoneExt", mandatory, control.Third);*/
            if (element != null)
            {
                TextBox control = element.Second.FindControl("Uxd_TelephoneCountry") as TextBox;
                if (control != null)
                {
                    telephoneCountry = control.Text;
                }
                control = element.Second.FindControl("Uxd_TelephoneArea") as TextBox;
                if (control != null)
                {
                    telephoneArea = control.Text;
                }
                control = element.Second.FindControl("Uxd_TelephoneNumber") as TextBox;
                if (control != null)
                {
                    telephoneNumber = control.Text;
                }
                control = element.Second.FindControl("Uxd_TelephoneExt") as TextBox;
                if (control != null)
                {
                    telephoneExt = control.Text;
                }
                if (!String.IsNullOrEmpty(telephoneCountry) || !String.IsNullOrEmpty(telephoneArea) || !String.IsNullOrEmpty(telephoneNumber) || !String.IsNullOrEmpty(telephoneExt))
                {
                    _hasData = true;
                }
            }
            #endregion
            #region fax
            _currentElement = PersonalDataSectionElements.Fax;
            element = _controls.Find(IsCurrent);
            /*AddTextFieldToPanel(p, _element.FaxCountry, "FaxCountry", mandatory, control.Third);
            AddTextFieldToPanel(p, _element.FaxArea, "FaxArea", mandatory, control.Third);
            AddTextFieldToPanel(p, _element.FaxNumber, "FaxNumber", mandatory, control.Third);
            AddTextFieldToPanel(p, _element.FaxExt, "FaxExt", mandatory, control.Third);*/
            if (element != null)
            {
                TextBox control = element.Second.FindControl("Uxd_FaxCountry") as TextBox;
                if (control != null)
                {
                    faxCountry = control.Text;
                }
                control = element.Second.FindControl("Uxd_FaxArea") as TextBox;
                if (control != null)
                {
                    faxArea = control.Text;
                }
                control = element.Second.FindControl("Uxd_FaxNumber") as TextBox;
                if (control != null)
                {
                    faxNumber = control.Text;
                }
                control = element.Second.FindControl("Uxd_FaxExt") as TextBox;
                if (control != null)
                {
                    faxExt = control.Text;
                }
                if (!String.IsNullOrEmpty(faxCountry) || !String.IsNullOrEmpty(faxArea) || !String.IsNullOrEmpty(faxNumber) || !String.IsNullOrEmpty(faxExt))
                {
                    _hasData = true;
                }
            }
            #endregion
            #region Mobile
            // mobile number fix in crm_records for 2.1.2
            _currentElement = PersonalDataSectionElements.Mobile;
            element = _controls.Find(IsCurrent);
            /*AddTextFieldToPanel(p, _element.MobileCountry, "MobileCountry", mandatory, control.Third);
            AddTextFieldToPanel(p, _element.MobileNumber, "MobileArea", mandatory, control.Third);*/
            if (element != null)
            {
                TextBox control = element.Second.FindControl("Uxd_MobileCountry") as TextBox;
                if (control != null)
                {
                    mobileCountry = control.Text;
                }
                control = element.Second.FindControl("Uxd_MobileNumber") as TextBox;
                if (control != null)
                {
                    mobileNumber = control.Text;
                }
                if (!String.IsNullOrEmpty(mobileCountry) || !String.IsNullOrEmpty(mobileNumber))
                {
                    _hasData = true;
                }
            }
            #endregion




            #region email pref
            _currentElement = PersonalDataSectionElements.EmailPreferences;
            element = _controls.Find(IsCurrent);
            if (element != null)
            {
                RadioButtonList control = element.Second as RadioButtonList;
                if (control != null)
                {
                    if (control.SelectedItem != null)
                    {
                        if (control.SelectedItem.Value.EndsWith("html"))
                        {
                            emailPreferences = EmailPreferences.Html;
                            _hasData = true;
                        }
                        else if (control.SelectedItem.Value.EndsWith("text"))
                        {
                            emailPreferences = EmailPreferences.Text;
                            _hasData = true;
                        }
                    }
                }
            }
            #endregion

            #region select
            PersonalDataSectionElements[] selects = SelectControls;
            foreach (PersonalDataSectionElements currentElement in selects)
            {
                string selectedValue = FindValueForSelect(currentElement);
                switch (currentElement)
                {
                    case PersonalDataSectionElements.PersonalTitle:
                        personalTitle = selectedValue;
                        break;
                    case PersonalDataSectionElements.JobSelectName:
                        jobCode = selectedValue;
                        if (!String.IsNullOrEmpty(jobCode) && jobCode.StartsWith("s"))
                        {
                            jobSiebel63 = selectedValue;
                        }
                        break;
                    case PersonalDataSectionElements.CountryRegion:
                        countryCode = selectedValue;

                        if (countryCode == null)
                            countryCode = _questionnaire.CountryCode;                       
                        
                        break;
                    case PersonalDataSectionElements.County:  
                        if(boolCountyDDLExists == true)
                            county = selectedValue;                        
                        break;
                    case PersonalDataSectionElements.PrimaryBusiness:
                        businessCode = selectedValue;
                        if (!String.IsNullOrEmpty(businessCode) && businessCode.StartsWith("s"))
                        {
                            businessSiebel63 = businessCode;
                        }
                        break;
                    case PersonalDataSectionElements.CompanySize:
                        worldSize = selectedValue;
                        if (!String.IsNullOrEmpty(worldSize) && worldSize.StartsWith("s"))
                        {
                            worldSize63 = worldSize;
                        }
                        break;
                    case PersonalDataSectionElements.PreferredLanguage:
                        language = selectedValue;
                        break;
                    //RFG 2.11
                    case PersonalDataSectionElements.CompanyRevenue:
                        companyRevenue = selectedValue;
                        break;
                    default:
                        throw new BugException("personal data section element \"" + currentElement + "\" is not a select");
                }
            }
            #endregion

            #region texts

            selects = TextControls;
            foreach (PersonalDataSectionElements currentElement in selects)
            {
                string selectedValue = FindValueForText(currentElement);
                switch (currentElement)
                {
                    case PersonalDataSectionElements.FirstName:
                        firstName = selectedValue;
                        break;
                    case PersonalDataSectionElements.LastName:
                        lastName = selectedValue;
                        break;
                    case PersonalDataSectionElements.JobEnterName:
                        jobTitle = selectedValue;
                        break;
                    case PersonalDataSectionElements.CompanyName:
                        companyName = selectedValue;
                        break;

                    //RFG 2.11 | Added by Raju
                    case PersonalDataSectionElements.CompanyWebsite:
                        companyWebsite = selectedValue;
                        break;
                    case PersonalDataSectionElements.CompanyRevenue:
                        companyRevenue = selectedValue;
                        break;

                    case PersonalDataSectionElements.Town:
                        town = selectedValue;
                        break;
                    case PersonalDataSectionElements.County:    
                        if(boolCountyExists == true)
                             county = selectedValue;                         
                        break;
                    case PersonalDataSectionElements.PostalCode:
                        postcode = selectedValue;
                        break;
                    case PersonalDataSectionElements.Email:
                        emailAddress = selectedValue;
                        break;

                    case PersonalDataSectionElements.Address:
                        address1 = selectedValue;
                        break;
                    case PersonalDataSectionElements.Address2:
                        address2 = selectedValue;
                        break;
                    case PersonalDataSectionElements.Address3:
                        address3 = selectedValue;
                        break;


                    default:
                        throw new BugException("personal data text element \"" + currentElement + "\" is not a text");
                }
            }

            #endregion

            if (_hasData)
            {
                personalDto = new PersonalResponseDto(responseId, address1, address2, address3, businessCode, businessSiebel63,
                    companyName, countryCode, county, customerId, emailAddress, firstName, flexField1, flexField10,
                    flexField11, flexField12, flexField13, flexField14, flexField15, flexfield2, flexField3, flexField4,
                    flexField5, flexField6, flexField7, flexField8, flexField9, jobCode, jobSiebel63, jobTitle, lastName,
                    personalTitle, postcode, pwd, telephoneCountry, telephoneArea, telephoneNumber, telephoneExt, faxCountry, faxArea, faxNumber, faxExt, mobileCountry, mobileNumber, town, worldSize, worldSize63, countryName, emailPreferences, language, companyWebsite,companyRevenue);  //RFG 2.11
                retval = new List<ResponseDto>();
                retval.Add(personalDto);
            }
            return retval;
        }
        private bool IsInvalid(PersonalDataSectionElements personalDataSectionElements)
        {
            bool retval = false;            
            int validationHint = -1;
  
            switch (personalDataSectionElements)
            {
                case PersonalDataSectionElements.PersonalTitle:
                    validationHint = PersonalDataSectionDto.InvalidPersonalTitle;
                    break;
                case PersonalDataSectionElements.FirstName:
                    validationHint = PersonalDataSectionDto.InvalidFirstName;
                    break;
                case PersonalDataSectionElements.LastName:
                    validationHint = PersonalDataSectionDto.InvalidLastName;
                    break;
                case PersonalDataSectionElements.JobSelectName:
                    validationHint = PersonalDataSectionDto.InvalidJobCode;
                    break;
                case PersonalDataSectionElements.JobEnterName:
                    validationHint = PersonalDataSectionDto.InvalidJobTitle;
                    break;
                case PersonalDataSectionElements.CompanyName:
                    validationHint = PersonalDataSectionDto.InvalidCompanyName;
                    break;
                case PersonalDataSectionElements.Address:
                    validationHint = PersonalDataSectionDto.InvalidAddress1;
                    break;
                case PersonalDataSectionElements.Address2:
                    validationHint = PersonalDataSectionDto.InvalidAddress2;
                    break;
                case PersonalDataSectionElements.Address3:
                    validationHint = PersonalDataSectionDto.InvalidAddress3;
                    break;
                case PersonalDataSectionElements.Town:
                    validationHint = PersonalDataSectionDto.InvalidTown;
                    break;
                case PersonalDataSectionElements.County:
                    validationHint = PersonalDataSectionDto.InvalidCounty;
                    break;
                case PersonalDataSectionElements.PostalCode:
                    validationHint = PersonalDataSectionDto.InvalidPostcode;
                    break;
                case PersonalDataSectionElements.CountryRegion:
                    validationHint = PersonalDataSectionDto.InvalidCountryCode;
                    break;
                case PersonalDataSectionElements.Email:
                    validationHint = PersonalDataSectionDto.InvalidEmailAddress;
                    break;
                case PersonalDataSectionElements.EmailPreferences:
                    validationHint = PersonalDataSectionDto.InvalidEmailPreferences;
                    break;
                case PersonalDataSectionElements.Telephone:
                    validationHint = PersonalDataSectionDto.InvalidTelephone;
                    break;
                case PersonalDataSectionElements.Fax:
                    validationHint = PersonalDataSectionDto.InvalidFax;
                    break;
                case PersonalDataSectionElements.Mobile:
                    validationHint = PersonalDataSectionDto.InvalidMobile;
                    break;

                case PersonalDataSectionElements.PrimaryBusiness:
                    validationHint = PersonalDataSectionDto.InvalidBusinessCode;
                    break;
                case PersonalDataSectionElements.CompanySize:
                    validationHint = PersonalDataSectionDto.InvalidWorldSize;
                    break;
                case PersonalDataSectionElements.PreferredLanguage:
                    validationHint = PersonalDataSectionDto.InvalidPreferredLanguage;
                    break;

                //RFG 2.11 | Added by Raju
                case PersonalDataSectionElements.CompanyWebsite: 
                    validationHint = PersonalDataSectionDto.InvalidCompanyWebsite;
                    break; 
                case PersonalDataSectionElements.CompanyRevenue:
                    validationHint = PersonalDataSectionDto.InvalidCompanyRevenue;
                    break;  
            }
            if (validationHint > 0)
            {
                retval = _validationHints.Exists(delegate(int cur) { return cur == validationHint; });
                if(retval == false)
                    retval = _validationNumberHints.Exists(delegate(int cur) { return cur == validationHint; });

            }
            return retval;
        }
        private void AddTextFieldToPanel(Panel p, string label, string fieldname, bool mandatory, PersonalDataSectionElements personalDataSectionElements)
        {
            Label l = new Label();
            l.ID = "Uxd_Label_" + fieldname;
            l.CssClass = WebConstants.CssClassLabelNoValidationError;
            if (mandatory)
            {
                l.Text = WebConstants.ToRequired(label);
            }
            else
            {
                l.Text = WebConstants.ToLabelWithErrorBullet(label);
            }

            TextBox t = new TextBox();
            t.ID = "Uxd_" + fieldname;
            t.CssClass = WebConstants.CssClassInputfield;
            l.AssociatedControlID = t.ID;
            p.Controls.Add(l);
            p.Controls.Add(t);
            _controls.Add(new Triple<PersonalDataSectionElements, WebControl, Label>(personalDataSectionElements, t, l));
        }       
 private void AddCountrySelectControl(PersonalDataSectionElements personalDataSectionElements, string label, List<Pair<string, string>> list, bool mandatory, bool prefilled)
 {
     DropDownList rList = AddSelectControl(personalDataSectionElements, label, list, mandatory, prefilled);
     if (!IsPostBack)
     {
         int selected = list.FindIndex(delegate(Pair<string, string> cur) { return cur.First.ToLower() == _questionnaire.CountryCode.ToLower(); }); ;
         if (selected != -1)
         {
             rList.SelectedIndex = selected;
         }
     }
 }
        private DropDownList AddSelectControl(PersonalDataSectionElements personalDataSectionElements, string label, List<Pair<string, string>> list, bool mandatory, bool prefilled)
        {
            Panel p = new Panel();
            p.ID = "Uxd_Holder_" + personalDataSectionElements;
            p.CssClass = WebConstants.CssClassFormItem;
            Label l = new Label();
            l.ID = "Uxd_Label_" + personalDataSectionElements;
            l.CssClass = WebConstants.CssClassLabelNoValidationError;
            if (mandatory)
            {
                l.Text = WebConstants.ToRequired(label);
            }
            else
            {
                l.Text = WebConstants.ToLabelWithErrorBullet(label);
            }

            DropDownList rList = new DropDownList();
            rList.ID = "Uxd_List_" + personalDataSectionElements;
            rList.CssClass = WebConstants.CssClassInputfield;
            l.AssociatedControlID = rList.ID;            

            if (list != null)
            {
                foreach (Pair<string, string> element in list)
                {
                    rList.Items.Add(new ListItem(element.Second, element.First));
                }
            }
            p.Controls.Add(l);
            p.Controls.Add(rList);
            Ux_Questions.Controls.Add(p);
            _controls.Add(new Triple<PersonalDataSectionElements, WebControl, Label>(personalDataSectionElements, rList, l));
            if (personalDataSectionElements == PersonalDataSectionElements.CountryRegion)
            {
                rList.AutoPostBack = true;                
                countryRegionControl = new Triple<PersonalDataSectionElements, WebControl, Label>(personalDataSectionElements, rList, l);
            }

            if ((!IsPostBack) && prefilled)
            {
                string value = null;
                switch (personalDataSectionElements)
                {
                    case PersonalDataSectionElements.PreferredLanguage:
                        value = _customer.PreferredLanguage;
                        break;
                    case PersonalDataSectionElements.PersonalTitle:
                        value = _customer.PersonalTitle;
                        break;
                    //case PersonalDataSectionElements.FirstName:
                    //    break;
                    //case PersonalDataSectionElements.LastName:
                    //    break;
                    case PersonalDataSectionElements.JobSelectName:
                        value = _customer.JobCode;
                        break;
                    //case PersonalDataSectionElements.JobEnterName:
                    //    break;
                    //case PersonalDataSectionElements.CompanyName:
                    //    break;
                    //case PersonalDataSectionElements.Town:
                    //    break;
                    //case PersonalDataSectionElements.County:
                    //    break;
                    //case PersonalDataSectionElements.PostalCode:
                    //    break;

                    //case PersonalDataSectionElements.CountryRegion: => this is done in AddCountrySelectControl
                        // value = _customer.CountryCode;
                        // break;

                    //case PersonalDataSectionElements.Email:
                    //    break;
                    //case PersonalDataSectionElements.EmailPreferences:
                    //    break;
                    //case PersonalDataSectionElements.Telephone:
                    //    break;
                    case PersonalDataSectionElements.PrimaryBusiness:
                        value = _customer.BusinessCode;
                        break;
                    case PersonalDataSectionElements.CompanySize:
                        value = _customer.WorldSize;
                        break;
                    //case PersonalDataSectionElements.Fax:
                    //    break;
                    //case PersonalDataSectionElements.Mobile:
                    //    break;
                    default:
                        break;
                }
                if (value != null)
                {
                    int index = list.FindIndex( cur => ( cur.First.ToLower() == value.ToLower() ) );
                    if (index > -1)
                    {
                        rList.SelectedIndex = index;
                    }
                }
            }

            return rList;
        }       
 private string FindValueForText(PersonalDataSectionElements currentElement)
 {
     string retval = null;
     _currentElement = currentElement;
     Triple<PersonalDataSectionElements, WebControl, Label> element = _controls.Find(IsCurrent);
     if (element != null)
     {
         TextBox control = element.Second as TextBox;
         if (control != null)
         {
             retval = control.Text;
             if (!String.IsNullOrEmpty(retval))
             {
                 _hasData = true;
             }
             if (currentElement.Equals(PersonalDataSectionElements.County))
                 boolCountyExists = true;
         }
     }
     return retval;
 }
        private void AddAddressControlSpecial(PersonalDataSectionElements personalDataSectionElements, string label, bool mandatory, bool prefilled, Panel p)
        {
            Panel container = new Panel();
            container.CssClass = WebConstants.CssClassFormItem;
            Label l = new Label();
            l.ID = "Uxd_Label_" + personalDataSectionElements;
            l.CssClass = WebConstants.CssClassLabelNoValidationError;
            if (mandatory)
            {
                l.Text = WebConstants.ToRequired(label);
            }
            else
            {
                l.Text = WebConstants.ToLabelWithErrorBullet(label);
            }

            TextBox t = new TextBox();
            t.ID = "Uxd_" + personalDataSectionElements;
            t.CssClass = WebConstants.CssClassInputfield;
            l.AssociatedControlID = t.ID;
            container.Controls.Add(l);
            container.Controls.Add(t);
            Ux_Questions.Controls.Add(container);
            _controls.Add(new Triple<PersonalDataSectionElements, WebControl, Label>(personalDataSectionElements, t, l));
            if ((!IsPostBack) && prefilled)
            {
                switch (personalDataSectionElements)
                {
                    case PersonalDataSectionElements.Address:
                        t.Text = this._customer.Address1;
                        break;
                    case PersonalDataSectionElements.Address2:
                        t.Text = this._customer.Address2;
                        break;
                    case PersonalDataSectionElements.Address3:
                        t.Text = this._customer.Address3;
                        break;
                    default:
                        break;
                }
            }
        }
        private bool IsInvalid(PersonalDataSectionElements personalDataSectionElements)
        {
            bool retval = false;            
            int validationHint = -1;

            switch (personalDataSectionElements)
            {
                case PersonalDataSectionElements.Address:
                    validationHint = PersonalDataSectionDto.InvalidAddress1;
                    break;
                case PersonalDataSectionElements.Town:
                    validationHint = PersonalDataSectionDto.InvalidTown;
                    break;
                case PersonalDataSectionElements.County:
                    validationHint = PersonalDataSectionDto.InvalidCounty;
                    break;
                case PersonalDataSectionElements.PostalCode:
                    validationHint = PersonalDataSectionDto.InvalidPostcode;
                    break;
                case PersonalDataSectionElements.CountryRegion:
                    validationHint = PersonalDataSectionDto.InvalidCountryCode;
                    break;
                case PersonalDataSectionElements.Email:
                    validationHint = PersonalDataSectionDto.InvalidEmailAddress;
                    break;                
            }
            if (validationHint > 0)
            {
                retval = _validationHints.Exists(delegate(int cur) { return cur == validationHint; });
                if (retval == false)
                    retval = _validationNumberHints.Exists(delegate(int cur) { return cur == validationHint; });

            }
            return retval;
        }
Exemplo n.º 19
0
        private int DoTheSwitch(PersonalDataSectionDto elementDto, PersonalResponseDto response, PersonalDataSectionElements elementToCheck)
        {
            int validationHint = -1;
            switch (elementToCheck)
            {
                case PersonalDataSectionElements.PersonalTitle:
                    if (response == null || elementDto.PersonalTitleChoices == null || elementDto.PersonalTitleChoices.Count == 0)
                        validationHint = PersonalDataSectionDto.InvalidPersonalTitle;
                    else if (!IsValidSelection(elementDto.PersonalTitleChoices, response.PersonalTitle))
                        validationHint = PersonalDataSectionDto.InvalidPersonalTitle;
                    break;
                case PersonalDataSectionElements.FirstName:
                    if (response == null)
                        validationHint = PersonalDataSectionDto.InvalidFirstName;
                    else if (String.IsNullOrEmpty(response.FirstName))
                        validationHint = PersonalDataSectionDto.InvalidFirstName;
                    break;
                case PersonalDataSectionElements.LastName:
                    if (response == null)
                        validationHint = PersonalDataSectionDto.InvalidLastName;
                    else if (String.IsNullOrEmpty(response.LastName))
                        validationHint = PersonalDataSectionDto.InvalidLastName;
                    break;
                case PersonalDataSectionElements.JobSelectName:
                    if (response == null || elementDto.JobChoices == null || elementDto.JobChoices.Count == 0)
                        validationHint = PersonalDataSectionDto.InvalidJobCode;
                    else if (!IsValidSelection(elementDto.JobChoices, response.JobCode))
                        validationHint = PersonalDataSectionDto.InvalidJobCode;
                    break;
                case PersonalDataSectionElements.JobEnterName:
                    if (response == null)
                        validationHint = PersonalDataSectionDto.InvalidJobTitle;
                    else if (String.IsNullOrEmpty(response.JobTitle))
                        validationHint = PersonalDataSectionDto.InvalidJobTitle;
                    break;
                case PersonalDataSectionElements.CompanyName:
                    if (response == null)
                        validationHint = PersonalDataSectionDto.InvalidCompanyName;
                    else if (String.IsNullOrEmpty(response.CompanyName))
                        validationHint = PersonalDataSectionDto.InvalidCompanyName;
                    break;
                case PersonalDataSectionElements.Address:
                    if (response == null)
                        validationHint = PersonalDataSectionDto.InvalidAddress1;
                    else if (String.IsNullOrEmpty(response.Address1))
                        validationHint = PersonalDataSectionDto.InvalidAddress1;
                    break;
                case PersonalDataSectionElements.Address2:
                    if (response == null)
                        validationHint = PersonalDataSectionDto.InvalidAddress2;
                    else if (String.IsNullOrEmpty(response.Address2))
                        validationHint = PersonalDataSectionDto.InvalidAddress2;
                    break;
                case PersonalDataSectionElements.Address3:
                    if (response == null)
                        validationHint = PersonalDataSectionDto.InvalidAddress3;
                    else if (String.IsNullOrEmpty(response.Address3))
                        validationHint = PersonalDataSectionDto.InvalidAddress3;
                    break;
                case PersonalDataSectionElements.Town:
                    if (response == null)
                        validationHint = PersonalDataSectionDto.InvalidTown;
                    else if (String.IsNullOrEmpty(response.Town))
                        validationHint = PersonalDataSectionDto.InvalidTown;
                    break;
                case PersonalDataSectionElements.County:
                    if (response == null)
                        validationHint = PersonalDataSectionDto.InvalidCounty;
                    else if (String.IsNullOrEmpty(response.County))
                        validationHint = PersonalDataSectionDto.InvalidCounty;
                    break;
                case PersonalDataSectionElements.PostalCode:
                    if (response == null)
                        validationHint = PersonalDataSectionDto.InvalidPostcode;
                    else if (String.IsNullOrEmpty(response.Postcode))
                        validationHint = PersonalDataSectionDto.InvalidPostcode;
                    break;
                case PersonalDataSectionElements.CountryRegion:
                    if (response == null || elementDto.CountryRegionChoices == null || elementDto.CountryRegionChoices.Count == 0)
                        validationHint = PersonalDataSectionDto.InvalidCountryCode;
                    else if (!IsValidSelection(elementDto.CountryRegionChoices, response.CountryCode))
                        validationHint = PersonalDataSectionDto.InvalidCountryCode;
                    break;
                case PersonalDataSectionElements.Email:
                    if (response == null)
                        validationHint = PersonalDataSectionDto.InvalidEmailAddress;
                    else if (!DataValidation.ValidateEmail(response.EmailAddress, true))
                        validationHint = PersonalDataSectionDto.InvalidEmailAddress;
                    break;
                case PersonalDataSectionElements.EmailPreferences:
                    if (response == null)
                        validationHint = PersonalDataSectionDto.InvalidEmailPreferences;
                    else if (!response.EmailPreferences.HasValue)
                        validationHint = PersonalDataSectionDto.InvalidEmailPreferences;
                    break;
                case PersonalDataSectionElements.Telephone:
                    if (response == null || !ValidateLongPhone(response.TelephoneCountry, response.TelephoneArea, response.TelephoneNumber, response.TelephoneExt, true))
                    {
                        validationHint = PersonalDataSectionDto.InvalidTelephone;
                    }
                    break;
                case PersonalDataSectionElements.Fax:
                    if (response == null || !ValidateLongPhone(response.FaxCountry, response.FaxArea, response.FaxNumber, response.FaxExt, true))
                    {
                        validationHint = PersonalDataSectionDto.InvalidFax;
                    }
                    break;
                case PersonalDataSectionElements.Mobile:
                    if (response == null || !ValidateShortPhone(response.MobileCountry, response.MobileNumber, true))
                    {
                        validationHint = PersonalDataSectionDto.InvalidMobile;
                    }
                    break;                      
                case PersonalDataSectionElements.PrimaryBusiness:
                    if (response == null || elementDto.BusinessChoices == null || elementDto.BusinessChoices.Count == 0)
                        validationHint = PersonalDataSectionDto.InvalidBusinessCode;
                    else if (!IsValidSelection(elementDto.BusinessChoices, response.BusinessCode))
                        validationHint = PersonalDataSectionDto.InvalidBusinessCode;
                    break;
                case PersonalDataSectionElements.CompanySize:
                    if (response == null || elementDto.CompanySizeChoices == null || elementDto.CompanySizeChoices.Count == 0)
                        validationHint = PersonalDataSectionDto.InvalidWorldSize;
                    else if (!IsValidSelection(elementDto.CompanySizeChoices, response.WorldSize))
                        validationHint = PersonalDataSectionDto.InvalidWorldSize;


                    break;
                case PersonalDataSectionElements.PreferredLanguage:
                    if (response == null || elementDto.PreferredLanguageChoices == null || elementDto.PreferredLanguageChoices.Count == 0)
                        validationHint = PersonalDataSectionDto.InvalidPreferredLanguage;
                    else if (!IsValidSelection(elementDto.PreferredLanguageChoices, response.PreferredLanguage))
                        validationHint = PersonalDataSectionDto.InvalidPreferredLanguage;
                    break;

                    //RFG 2.11 | Added by Raju
                case PersonalDataSectionElements.CompanyWebsite:
                    if (response == null)
                        validationHint = PersonalDataSectionDto.InvalidCompanyWebsite;
                    else if (!IsValidWebsite(response.CompanyWebsite))
                        validationHint = PersonalDataSectionDto.InvalidCompanyWebsite;
                    break;
                case PersonalDataSectionElements.CompanyRevenue:
                    if (response == null)
                        validationHint = PersonalDataSectionDto.InvalidCompanyRevenue;
                    else if (!IsValidSelection(elementDto.CompanyRevenueChoices, response.CompanyRevenue))
                        validationHint = PersonalDataSectionDto.InvalidCompanyRevenue;
                    break;
            }
            return validationHint;
        }