Ejemplo n.º 1
0
 private void MakeFunnyThingsHappen(PersonalDataSectionDto elementDto, PersonalResponseDto response, List<int> validationHints)
 {
     foreach (KeyValuePair<PersonalDataSectionElements, Triple<int?, bool, bool>> elementToCheck in elementDto.PresentationPosition)
     {
         if (elementToCheck.Value != null)
         {
             if (elementToCheck.Value.Second)//mandatory
             {
                 int validationHint = DoTheSwitch(elementDto, response, elementToCheck.Key);
                 if (validationHint > 0)
                 {
                     validationHints.Add(validationHint);
                 }
             }
             else
             {
                 if (response != null)
                 {
                     switch (elementToCheck.Key)
                     {
                         case PersonalDataSectionElements.Email:
                             if (!DataValidation.ValidateEmail(response.EmailAddress, false))
                             {
                                 validationHints.Add(PersonalDataSectionDto.InvalidEmailAddress); 
                             }
                             break;
                         case PersonalDataSectionElements.Telephone:
                             if (!ValidateLongPhone(response.TelephoneCountry, response.TelephoneArea, response.TelephoneNumber, response.TelephoneExt, false))
                             {
                                 validationHints.Add(PersonalDataSectionDto.InvalidTelephone);
                             }
                             break;
                         case PersonalDataSectionElements.Fax:
                             if (!ValidateLongPhone(response.FaxCountry, response.FaxArea, response.FaxNumber, response.FaxExt, false))
                             {
                                 validationHints.Add(PersonalDataSectionDto.InvalidFax);
                             }
                             break;
                         case PersonalDataSectionElements.Mobile:
                             if (!ValidateShortPhone(response.MobileCountry, response.MobileNumber, false))
                             {
                                 validationHints.Add(PersonalDataSectionDto.InvalidMobile);
                             }
                             break;
                         case PersonalDataSectionElements.CompanyWebsite:
                             if (!string.IsNullOrEmpty(response.CompanyWebsite) && !IsValidWebsite(response.CompanyWebsite))
                             {
                                 validationHints.Add(PersonalDataSectionDto.InvalidCompanyWebsite);
                             }
                             break;
                         default:
                             break;
                     }
                 }
             }
         }
     }
 }
 protected void Page_Init(object sender, EventArgs e)
 {
     _element = PageElement as PersonalDataSectionDto;
     if (_element == null)
     {
         throw new BugException("Personal section received an incompatible page element \"" + PageElement.GetType().Name + "\"");
     }            
     _controls = new List<Triple<PersonalDataSectionElements, WebControl, Label>>();
     countryRegionControl = null;
     if(_questionnaire.QuestionnaireId == 4258)
         QuestionnaireID = "4259";
     else
         QuestionnaireID = _questionnaire.QuestionnaireId.ToString();
         
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Will not return a value as the list would not be filled
 /// </summary>
 /// <param name="dto"></param>
 public void CreateOrUpdate(PersonalDataSectionDto dto)
 {
     DbCommand sp = null;
     DbConnection connection = null;
     IDataReader reader = null;
     try
     {
         connection = _dbLayer.GetConnection();
         sp = connection.CreateCommand();
         sp.CommandText = "update_personalsection";
         sp.CommandType = CommandType.StoredProcedure;
         Write(sp, dto, false);                
         _dbLayer.AddReturnParameter(sp);
         sp.ExecuteNonQuery();                
     }
     catch(Exception ex)
     {
         int err = _dbLayer.GetReturnValue(sp);
         Trace.WriteLine("PersonalDataSectionDao.CreateOrUpdate(" + dto + ") returned " + err);
     }
     finally
     {
         if (reader != null && !reader.IsClosed)
             reader.Close();
         if (sp != null)
             sp.Dispose();
         if (connection != null)
         {
             _dbLayer.ReturnConnection(connection);
         }
         else
         {
             _dbLayer.ReturnConnection(connection, true);
         }
     }
 }   
Ejemplo n.º 4
0
        public static Triple<string, string, string> BuildFieldSets(PersonalDataSectionDto dto)
        {

            StringBuilder mandatoryFields = new StringBuilder("00000000000000000000000000000000000000000000000000");
            StringBuilder prefilledFields = new StringBuilder("00000000000000000000000000000000000000000000000000");
            StringBuilder positionFields = new StringBuilder();

            int counter = 0;
            foreach (PersonalDataSectionElements key in Enum.GetValues(typeof(PersonalDataSectionElements)))
            {
                /// <summary>
                /// Triple.First is position/not shown
                /// Triple.Second is mandatory/required
                /// Triple.Third is prefilled
                /// </summary>
                if (counter != 0)
                {

                    positionFields.Append('|');
                }

                Triple<int?, bool, bool> element;
                if (dto.PresentationPosition.TryGetValue(key, out element))
                {
                    if (element.Second)
                    {
                        mandatoryFields[counter] = '1';
                    }
                    if (element.Third)
                    {
                        prefilledFields[counter] = '1';
                    }
                    if (element.First.HasValue)
                    {

                        positionFields.Append(element.First);
                    }
                    else
                    {
                        positionFields.Append(-1);
                    }
                }
                else
                {
                    positionFields.Append(-1);
                }
                counter++;
            }

            Triple<string, string, string> retval = new Triple<string, string, string>(positionFields.ToString(), mandatoryFields.ToString(), prefilledFields.ToString());
            return retval;
        }
Ejemplo n.º 5
0
 private PersonalDataSectionDto Fill(PersonalDataSectionDto dto, long newId)
 {
     PersonalDataSectionDto retval = new PersonalDataSectionDto((int)newId, dto.PageId, dto.SortSequence, dto.ElementText,
         dto.PersonalQuestion, dto.PersonalTitle, dto.PersonalTitleChoices, dto.FirstName, dto.LastName, dto.JobSelectName,
         dto.JobChoices, dto.JobEnterName, dto.CompanyName, dto.Address, dto.Address2, dto.Address3, dto.Town, dto.County, dto.CountryRegion,
         dto.CountryRegionChoices, dto.PostalCode, dto.Email, dto.EmailPreferences, dto.PreferTextMail, dto.PreferHtmlMail,
         dto.TelephoneCountry, dto.TelephoneArea, dto.TelephoneNumber, dto.TelephoneExt, dto.FaxCountry, dto.FaxArea, dto.FaxNumber, dto.FaxExt, dto.MobileCountry, dto.MobileNumber, dto.Business, dto.BusinessChoices, dto.CompanySize, dto.CompanySizeChoices, dto.PreferredLanguage, dto.PreferredLanguageChoices, dto.CompanyWebsite, dto.CompanyRevenue, dto.CompanyRevenueChoices, dto.PresentationPosition,
         dto.TelephoneValidationMessage, dto.FaxValidationMessage, dto.MobileValidationMessage, dto.IsActive, dto.IsRequired);  //RFG 2.11
     return retval;
 }
Ejemplo n.º 6
0
        private PersonalDataSectionDto Read(IDataReader reader, ref bool alreadyRead)
        {
            int pageElementId = reader.GetInt32(0);
            string address = GetString(reader, 1);
            string business = GetString(reader, 2);
            string companyName = GetString(reader, 3);
            string companySize = GetString(reader, 4);
            string countryRegion = GetString(reader, 5);
            string county = GetString(reader, 6);
            string personalSectionHeader = GetString(reader, 7);
            string email = GetString(reader, 8);
            string emailPreferences = GetString(reader, 9);
            string firstName = GetString(reader, 10);
            string jobEnterName = GetString(reader, 11);
            string jobSelectName = GetString(reader, 12);
            string lastName = GetString(reader, 13);
            int pageId = reader.GetInt32(14);
            string personalQuestion = GetString(reader, 15);
            string personalTitle = GetString(reader, 16);
            string postalCode = GetString(reader, 17);
            string preferHtmlMail = GetString(reader, 18);
            string preferTextMail = GetString(reader, 19);
            int sortSequence = reader.GetInt32(20);
            string telephoneNumber = GetString(reader, 21);


            string town = GetString(reader, 22);
            string positionFields = GetString(reader, 23);
            string mandatoryFields = GetString(reader, 24);
            string prefilledFields = GetString(reader, 25);

            bool isActive = reader.GetBoolean(26);
            bool isRequired = reader.GetBoolean(27);

            string address2 = GetString(reader, 28);
            string address3 = GetString(reader, 29);


            string telephoneCountry = GetString(reader, 30);
            string telephoneArea = GetString(reader, 31);
            string telephoneExt = GetString(reader, 32);

            string faxCountry = GetString(reader, 33);
            string fax2Area = GetString(reader, 34);
            string fax3Number = GetString(reader, 35);
            string fax4Ext = GetString(reader, 36);
            string mobileCountry = GetString(reader, 37);
            string mobile2Number = GetString(reader, 38);
            string preferredLanguage = GetString(reader, 39);
            string companywebsite = GetString(reader, 40); //RFG 2.11 | Added by Raju
            string companyrevenue = GetString(reader, 41);


            List<Pair<string, string>> personalTitleChoices = ReadChoices(reader);
            List<Pair<string, string>> jobChoices = ReadChoices(reader);
            List<Pair<string, string>> countryRegionChoices = ReadChoices(reader);
            List<Pair<string, string>> businessChoices = ReadChoices(reader);
            List<Pair<string, string>> companySizeChoices = ReadChoices(reader);
            List<Pair<string, string>> preferredLanguageChoices = ReadChoices(reader);
            List<Pair<string, string>> companyRevenueChoices = ReadChoices(reader);
            SortedList<PersonalDataSectionElements, Triple<int?, bool, bool>> presentationPosition =
                BuildPositionPresentation(positionFields, mandatoryFields, prefilledFields);            
            PersonalDataSectionDto retval = new PersonalDataSectionDto(pageElementId, pageId,
                sortSequence, personalSectionHeader,
                personalQuestion, personalTitle, personalTitleChoices,
                firstName, lastName, jobSelectName, jobChoices,
                jobEnterName, companyName, address, address2, address3, town, county, countryRegion,
                countryRegionChoices, postalCode, email,
                emailPreferences, preferTextMail, preferHtmlMail, telephoneCountry, telephoneArea, telephoneNumber, telephoneExt, faxCountry, fax2Area, fax3Number, fax4Ext, mobileCountry, mobile2Number,
                business, businessChoices, companySize,
                companySizeChoices, preferredLanguage, preferredLanguageChoices, companywebsite, companyrevenue, companyRevenueChoices, presentationPosition, null, null, null, isActive, isRequired);  //RFG 2.11
            //Madan: Caliber # PR239974 for Rel 2.0.1
            //setting up the country code property for this instance.
            retval.CountryCode = GetCountryCode(reader);
            return retval;
        }
Ejemplo n.º 7
0
 private void Write(DbCommand sp, PersonalDataSectionDto dto, bool includeId)
 {
     Triple<string, string, string> fields = BuildFieldSets(dto);
     if (includeId)
     {
         _dbLayer.AddInParameter(sp, "@elementId", DbType.Int32, dto.ElementId);
     }
     _dbLayer.AddInParameter(sp, "@page_id", DbType.Int32, dto.PageId);
     _dbLayer.AddInParameter(sp, "@sort_sequence", DbType.Int32, dto.SortSequence);
     _dbLayer.AddInParameter(sp, "@personal_header", DbType.String, dto.ElementText);
     _dbLayer.AddInParameter(sp, "@question_text", DbType.String, dto.PersonalQuestion);
     _dbLayer.AddInParameter(sp, "@personaltitle_label", DbType.String, dto.PersonalTitle);
     _dbLayer.AddInParameter(sp, "@firstname_label", DbType.String, dto.FirstName);
     _dbLayer.AddInParameter(sp, "@lastname_label", DbType.String, dto.LastName);
     _dbLayer.AddInParameter(sp, "@jobtitle_label", DbType.String, dto.JobEnterName);
     _dbLayer.AddInParameter(sp, "@jobcode_label", DbType.String, dto.JobSelectName);
     _dbLayer.AddInParameter(sp, "@companyname_label", DbType.String, dto.CompanyName);
     _dbLayer.AddInParameter(sp, "@companywebsite_label", DbType.String, dto.CompanyWebsite); //RFG 2.11 | Added by Raju
     _dbLayer.AddInParameter(sp, "@companyrevenue_label", DbType.String, dto.CompanyRevenue); 
     _dbLayer.AddInParameter(sp, "@address_label", DbType.String, dto.Address);
     _dbLayer.AddInParameter(sp, "@address2_label", DbType.String, dto.Address2);
     _dbLayer.AddInParameter(sp, "@address3_label", DbType.String, dto.Address3);
     _dbLayer.AddInParameter(sp, "@town_label", DbType.String, dto.Town);
     _dbLayer.AddInParameter(sp, "@county_label", DbType.String, dto.County);
     _dbLayer.AddInParameter(sp, "@postcode_label", DbType.String, dto.PostalCode);
     _dbLayer.AddInParameter(sp, "@country_label", DbType.String, dto.CountryRegion);
     _dbLayer.AddInParameter(sp, "@email_label", DbType.String, dto.Email);
     _dbLayer.AddInParameter(sp, "@emailpref_label", DbType.String, dto.EmailPreferences);
     _dbLayer.AddInParameter(sp, "@pd_text_label", DbType.String, dto.PreferTextMail);
     _dbLayer.AddInParameter(sp, "@pd_html_label", DbType.String, dto.PreferHtmlMail);
     _dbLayer.AddInParameter(sp, "@telephone_label", DbType.String, dto.TelephoneNumber);
     _dbLayer.AddInParameter(sp, "@telephone_country_label", DbType.String, dto.TelephoneCountry);
     _dbLayer.AddInParameter(sp, "@telephone_area_label", DbType.String, dto.TelephoneArea);
     _dbLayer.AddInParameter(sp, "@telephone_extn_label", DbType.String, dto.TelephoneExt);
     _dbLayer.AddInParameter(sp, "@telephone_validation_message", DbType.String, dto.TelephoneValidationMessage);
     _dbLayer.AddInParameter(sp, "@business_label", DbType.String, dto.Business);
     _dbLayer.AddInParameter(sp, "@worldsize_label", DbType.String, dto.CompanySize);
     _dbLayer.AddInParameter(sp, "@fax_label", DbType.String, dto.FaxNumber);
     _dbLayer.AddInParameter(sp, "@fax_country_label", DbType.String, dto.FaxCountry);
     _dbLayer.AddInParameter(sp, "@fax_area_label", DbType.String, dto.FaxArea);
     _dbLayer.AddInParameter(sp, "@fax_extn_label", DbType.String, dto.FaxExt);
     _dbLayer.AddInParameter(sp, "@fax_validation_message", DbType.String, dto.FaxValidationMessage);
     _dbLayer.AddInParameter(sp, "@mobile_label", DbType.String, dto.MobileNumber);
     _dbLayer.AddInParameter(sp, "@mobile_country_label", DbType.String, dto.MobileCountry);
     _dbLayer.AddInParameter(sp, "@mobile_validation_message", DbType.String, dto.MobileValidationMessage);
     _dbLayer.AddInParameter(sp, "@mandatory_fields", DbType.String, fields.Second);
     _dbLayer.AddInParameter(sp, "@prefilled_fields", DbType.String, fields.Third);
     _dbLayer.AddInParameter(sp, "@position_fields", DbType.String, fields.First);
     _dbLayer.AddInParameter(sp, "@language_label", DbType.String, dto.PreferredLanguage);
 }
Ejemplo n.º 8
0
        public void TestCreateGetUpdate()
        {
            SortedList<PersonalDataSectionElements, Triple<int?, bool, bool>> presentationPosition = CreateEmptyPresentationPositions();
            PersonalDataSectionDto dto = new PersonalDataSectionDto(_currentPage.PageId, 1, "personalSectionHeader",
                "personal question", "personal title", "first name", "last name", "job select", "job enter",
                "company name", "address", "address2", "address3", "town", "county", "region", "postal", "email", "email pref", "preferText",
                "prefer html", "telephoneCountry", "telephoneArea", "telephoneNumber", "telephoneExt", "faxCountry", "faxArea", "faxNumber", "faxExt", "mobileCountry", "mobileNumber", "business", "company size", "preferred language", "companyWebsiteUrl", "companyRevenue", presentationPosition, null, null, null, true, true);
            FormRegistry.PersonalDao.CreateOrUpdate(dto);
            PersonalDataSectionDto pers = FormRegistry.PersonalDao.GetByPageId(_currentPage.PageId);
            Assert.IsNotNull(pers);
            Assert.AreEqual(dto.Address, pers.Address);
            Assert.AreEqual(dto.Business, pers.Business);
            Assert.AreEqual(dto.CompanyName, pers.CompanyName);
            Assert.AreEqual(dto.CompanyRevenue, pers.CompanyRevenue);
            Assert.AreEqual(dto.CompanySize, pers.CompanySize);
            Assert.AreEqual(dto.CompanyWebsite, pers.CompanyWebsite);
            Assert.AreEqual(dto.CountryRegion, pers.CountryRegion);
            Assert.AreEqual(dto.County, pers.County);
            Assert.AreEqual(dto.ElementText, pers.ElementText);
            Assert.AreEqual(dto.Email, pers.Email);
            Assert.AreEqual(dto.EmailPreferences, pers.EmailPreferences);
            Assert.AreEqual(dto.FirstName, pers.FirstName);
            Assert.AreEqual(dto.IsActive, pers.IsActive);
            Assert.AreEqual(dto.IsRequired, pers.IsRequired);
            Assert.AreEqual(dto.JobEnterName, pers.JobEnterName);
            Assert.AreEqual(dto.JobSelectName, pers.JobSelectName);
            Assert.AreEqual(dto.LastName, pers.LastName);
            Assert.AreEqual(dto.MaxLength, pers.MaxLength);
            Assert.AreEqual(dto.PageId, pers.PageId);
            Assert.AreEqual(dto.PersonalQuestion, pers.PersonalQuestion);
            Assert.AreEqual(dto.PersonalTitle, pers.PersonalTitle);
            Assert.AreEqual(dto.PostalCode, pers.PostalCode);
            Assert.AreEqual(dto.PreferHtmlMail, pers.PreferHtmlMail);
            Assert.AreEqual(dto.PreferTextMail, pers.PreferTextMail);
            Assert.AreEqual(dto.SortSequence, pers.SortSequence);

            Assert.AreEqual(dto.TelephoneCountry, pers.TelephoneCountry);
            Assert.AreEqual(dto.TelephoneArea, pers.TelephoneArea);
            Assert.AreEqual(dto.TelephoneNumber, pers.TelephoneNumber);
            Assert.AreEqual(dto.TelephoneExt, pers.TelephoneExt);

            Assert.AreEqual(dto.FaxCountry, pers.FaxCountry);
            Assert.AreEqual(dto.FaxArea, pers.FaxArea);
            Assert.AreEqual(dto.FaxNumber, pers.FaxNumber);
            Assert.AreEqual(dto.FaxExt, pers.FaxExt);

            Assert.AreEqual(dto.MobileCountry, pers.MobileCountry);
            Assert.AreEqual(dto.MobileNumber, pers.MobileNumber);
            Assert.AreEqual(dto.PreferredLanguage, pers.PreferredLanguage);

            Assert.AreEqual(dto.Town, pers.Town);

            SortedList<PersonalDataSectionElements, Triple<int?, bool, bool>> presentationPosition2 = CreateEmptyPresentationPositions();
            presentationPosition2[PersonalDataSectionElements.Address] = new Triple<int?, bool, bool>(1, true, false);
            presentationPosition2[PersonalDataSectionElements.CompanyName] = new Triple<int?, bool, bool>(7, true, true);
            presentationPosition2[PersonalDataSectionElements.Town] = new Triple<int?, bool, bool>(3, false, false);
            presentationPosition2[PersonalDataSectionElements.PersonalTitle] = new Triple<int?, bool, bool>(5, false, true);
            PersonalDataSectionDto update = new PersonalDataSectionDto(pers.ElementId, _currentPage.PageId, 2, "personalSectionHeader2",
                "personal question2", "personal title2", pers.PersonalTitleChoices, "first name2", "last name2", "job select2", pers.JobChoices, "job enter2",
                "company name2", "address22", "address32", "address42", "town2", "county2", "region2", pers.CountryRegionChoices, "postal2", "email2", "email pref2", "preferText2",
                "prefer html2", "telephone2", "telephone22", "telephone23", "telephone24", "fax2", "fax22", "fax3", "fax4","mobile2","mobile22", "business2", pers.BusinessChoices, "company size2", pers.CompanySizeChoices, "language2", pers.PreferredLanguageChoices, "companyWebsite2", "companyRevenue2", pers.CompanyRevenueChoices, presentationPosition2, null, null, null, true, true);

            FormRegistry.PersonalDao.CreateOrUpdate(update);
            PersonalDataSectionDto sel = FormRegistry.PersonalDao.GetByPageId(_currentPage.PageId);
            Assert.AreEqual(update, sel);
            Assert.AreNotEqual(update, pers);

        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Ux_TheResponse.ID += (PageQuestion == null) ? "_" + PageElement.ElementId : "_P" + PageQuestion.PagePredefinedQuestionId;
            Ux_ElementTitel.AssociatedControlID = Ux_TheResponse.ID;

            Ux_ElementTitel.Text = PageElement.ElementText;
            Ux_TheResponse.CssClass = (this.PageElementType == PageElementType.CheckBoxesLong) ? WebConstants.CssClassLongerChoicesContainer : WebConstants.CssClassShorterChoicesContainer;

             _radioTextIds = new List<Triple<int, string, string>>();
            if (Choices != null)
            {
                foreach (PageElementChoiceDto choice in Choices)
                {
                    Panel p = new Panel();
                    p.ID = "Uxd_Lit_Choice_" + choice.ChoiceId;
                    CheckBox cb = new CheckBox();
                    cb.ID = "Uxd_Lit_CheckBox_" + choice.ChoiceId;
                    //cb.CssClass = WebConstants.CssClassCheckRadio;
                    //cb.Text = choice.ElementText;
                    Label l = new Label();
                    l.Text = choice.ElementText;
                    l.AssociatedControlID = cb.ID;
                    if (Choices.Count < 2)
                    {
                        l.CssClass = WebConstants.CssClassLabelVeryLongNoValidationError;
                    }
                    else
                    {
                        l.CssClass = WebConstants.CssClassLabelNoValidationError;
                    }

                    p.Controls.Add(cb);
                    p.Controls.Add(l);

                    int choiceId = choice.ChoiceId;
                    string radioId = cb.ID;
                    string textId = null;
                    if (Choices.Count < 2)
                    {
                        p.CssClass = WebConstants.CssClassChoiceElementWholeWidth;
                    }
                    else
                    {
                        p.CssClass = WebConstants.CssClassChoiceElement;
                    } 
                    Ux_TheResponse.Controls.Add(p);
                    _radioTextIds.Add(new Triple<int, string, string>(choiceId, radioId, textId));
                }
            }
            

            if (!String.IsNullOrEmpty(_element.ErrorText))
            {
                Panel p = new Panel();
                p.ID = "Uxd_Lit_Ship_" + this.ID;
                CheckBox cb = new CheckBox();
                cb.ID = "Uxd_Lit_CheckBox_" + this.ID;
                //cb.CssClass = WebConstants.CssClassCheckRadio;
                //cb.Text = choice.ElementText;                
                Label l = new Label();
                l.Text = _element.ErrorText;
                l.AssociatedControlID = cb.ID;
                //l.CssClass = WebConstants.CssClassLabelNoValidationError;
                l.CssClass = WebConstants.CssClassLabelVeryLongNoValidationError;
                p.Controls.Add(cb);
                p.Controls.Add(l);

                p.CssClass = WebConstants.CssClassChoiceElementWholeWidth;
                //p.CssClass = WebConstants.CssClassLabelNoValidationError + " " + WebConstants.CssClassFullLine;

                Ux_ShippingAddress.Controls.Add(p);

                //We also have to add shipping data from personal data section and crm data
                RfgExternalPage page = Page as RfgExternalPage;                
                PageElementAssemblyDto pdSection= page.Elements.Find(pe=> pe.Pageelement.PageElementType == PageElementType.PersonalDataSection);
                personalDataSectionDto = pdSection.Pageelement as PersonalDataSectionDto;
                SortedList<int, Triple<bool, bool, PersonalDataSectionElements>> list = new SortedList<int, Triple<bool, bool, PersonalDataSectionElements>>();
                foreach (KeyValuePair<PersonalDataSectionElements, Triple<int?, bool, bool>> entry in personalDataSectionDto.PresentationPosition)
                {
                    if (entry.Value != null)
                    {
                        if (entry.Value.First.HasValue && entry.Value.First.Value != -1)
                        {
                            list.Add(entry.Value.First.Value, new Triple<bool, bool, PersonalDataSectionElements>(entry.Value.Second, entry.Value.Third, entry.Key));
                        }
                    }
                }
                foreach (Triple<bool, bool, PersonalDataSectionElements> control in list.Values)
                {
                    AddControl(control, list);
                }
                if (isCountyControl)
                {
                    AdditionalStateData();
                }
            }
                       
        }
Ejemplo n.º 10
0
 public static void CreateUpdatePersonalDataSection(PersonalDataSectionDto dto)
 {
     FormRegistry.PersonalDao.CreateOrUpdate(dto);
 }
Ejemplo n.º 11
0
        protected void save_personaldatasection_Click(object sender, System.EventArgs e)
        {

            PersonalDataSectionDto personalDataSection = new PersonalDataSectionDto();

            #region (switching the validators on/off )

            foreach (Control c in this.FindControl("Form1").Controls)
            {
                if (c.GetType().ToString().IndexOf("CheckBox") != -1 && c.ID.EndsWith("_field") == true)
                {
                    switch (c.ID)
                    {
                        case "emailpref_field": // emailpref validation
                            #region (validators emailpref)
                            emailpref_field.ForeColor = System.Drawing.Color.Black;
                            pd_text_radio.ForeColor = System.Drawing.Color.Black;
                            pd_html_radio.ForeColor = System.Drawing.Color.Black;
                            if (emailpref_field.Checked == false)
                            {
                                emailpref_label.Text = String.Empty;
                                pd_text_label.Text = String.Empty;
                                pd_html_label.Text = String.Empty;
                            }
                            else
                            {
                                if (IsTextBoxInputWrong(emailpref_label))
                                {
                                    custom_bool_label = false;
                                    emailpref_field.ForeColor = System.Drawing.Color.Red;
                                }
                                if (IsTextBoxInputWrong(pd_text_label))
                                {
                                    custom_bool_label = false;
                                    pd_text_radio.ForeColor = System.Drawing.Color.Red;
                                }
                                if (IsTextBoxInputWrong(pd_html_label))
                                {
                                    custom_bool_label = false;
                                    pd_html_radio.ForeColor = System.Drawing.Color.Red;
                                }
                                custom_bool_min = true;
                            }
                            #endregion
                            break;
                        // madan added for the aditional fields
                        case "telephone_field": // telephone validation
                            #region (validators telephone)
                            telephone_field.ForeColor = System.Drawing.Color.Black;
                            telephone_country_fld.ForeColor = System.Drawing.Color.Black;
                            telephone_area_fld.ForeColor = System.Drawing.Color.Black;
                            telephone_extension_fld.ForeColor = System.Drawing.Color.Black;
                            telephone_validation_msg.ForeColor = System.Drawing.Color.Black;
                            if (telephone_field.Checked == false)
                            {
                                telephone_label.Text = String.Empty;
                                telephone_country_label.Text = String.Empty;
                                telephone_area_label.Text = String.Empty;
                                telephone_extension_label.Text = String.Empty;
                                telephone_validation_messge_label.Text = String.Empty;
                            }
                            else
                            {
                                if (IsTextBoxInputWrong(telephone_label))
                                {
                                    custom_bool_label = false;
                                    telephone_field.ForeColor = System.Drawing.Color.Red;
                                }
                                if (IsTextBoxInputWrong(telephone_country_label))
                                {
                                    custom_bool_label = false;
                                    telephone_country_fld.ForeColor = System.Drawing.Color.Red;
                                }
                                if (IsTextBoxInputWrong(telephone_area_label))
                                {
                                    custom_bool_label = false;
                                    telephone_area_fld.ForeColor = System.Drawing.Color.Red;
                                }
                                if (IsTextBoxInputWrong(telephone_extension_label))
                                {
                                    custom_bool_label = false;
                                    telephone_extension_fld.ForeColor = System.Drawing.Color.Red;
                                }
                                if (IsTextBoxInputWrong(telephone_validation_messge_label))
                                {
                                    custom_bool_label = false;
                                    telephone_validation_msg.ForeColor = System.Drawing.Color.Red;
                                }      
                                custom_bool_min = true;
                            }
                            #endregion
                            break;
                        case "fax_field": // fax validation
                            #region (validators fax)
                            fax_field.ForeColor = System.Drawing.Color.Black;
                            fax_country_fld.ForeColor = System.Drawing.Color.Black;
                            fax_area_fld.ForeColor = System.Drawing.Color.Black;
                            fax_extension_fld.ForeColor = System.Drawing.Color.Black;
                            fax_validation_msg.ForeColor = System.Drawing.Color.Black;
                            if (fax_field.Checked == false)
                            {
                                fax_label.Text = String.Empty;
                                fax_country_label.Text = String.Empty;
                                fax_area_label.Text = String.Empty;
                                fax_extension_label.Text = String.Empty;
                                fax_validation_message_label.Text = String.Empty;
                            }
                            else
                            {
                                if (IsTextBoxInputWrong(fax_label))
                                {
                                    custom_bool_label = false;
                                    fax_field.ForeColor = System.Drawing.Color.Red;
                                }
                                if (IsTextBoxInputWrong(fax_country_label))
                                {
                                    custom_bool_label = false;
                                    fax_country_fld.ForeColor = System.Drawing.Color.Red;
                                }
                                if (IsTextBoxInputWrong(fax_area_label))
                                {
                                    custom_bool_label = false;
                                    fax_area_fld.ForeColor = System.Drawing.Color.Red;
                                }
                                if (IsTextBoxInputWrong(fax_extension_label))
                                {
                                    custom_bool_label = false;
                                    fax_extension_fld.ForeColor = System.Drawing.Color.Red;
                                }
                                if (IsTextBoxInputWrong(fax_validation_message_label))
                                {
                                    custom_bool_label = false;
                                    fax_validation_msg.ForeColor = System.Drawing.Color.Red;
                                }      
                                custom_bool_min = true;
                            }
                            #endregion
                            break;
                        case "mobile_field": // mobile validation
                            #region (validators mobile)
                            mobile_field.ForeColor = System.Drawing.Color.Black;
                            mobile_country_fld.ForeColor = System.Drawing.Color.Black;
                            mobile_validation_message.ForeColor = System.Drawing.Color.Black;

                            if (mobile_field.Checked == false)
                            {
                                mobile_label.Text = String.Empty;
                                mobile_country_label.Text = String.Empty;
                                mobile_validation_message_label.Text = String.Empty;

                            }
                            else
                            {
                                if (IsTextBoxInputWrong(mobile_label))
                                {
                                    custom_bool_label = false;
                                    mobile_field.ForeColor = System.Drawing.Color.Red;
                                }
                                if (IsTextBoxInputWrong(mobile_country_label))
                                {
                                    custom_bool_label = false;
                                    mobile_country_fld.ForeColor = System.Drawing.Color.Red;
                                }
                                if (IsTextBoxInputWrong(mobile_validation_message_label))
                                {
                                    custom_bool_label = false;
                                    mobile_validation_message.ForeColor = System.Drawing.Color.Red;
                                }      

                                custom_bool_min = true;
                            }
                            #endregion
                            break;
                        case "address_field": // address validation
                            #region (validators address)
                            address_field.ForeColor = System.Drawing.Color.Black;
                            address2_field.ForeColor = System.Drawing.Color.Black;
                            address3_field.ForeColor = System.Drawing.Color.Black;
                            if (address_field.Checked == false)
                            {
                                address_label.Text = String.Empty;
                                address2_label.Text = String.Empty;
                                address3_label.Text = String.Empty;
                            }
                            else
                            {
                                if (IsTextBoxInputWrong(address_label))
                                {
                                    custom_bool_label = false;
                                    address_field.ForeColor = System.Drawing.Color.Red;
                                }
                                if (IsTextBoxInputWrong(address2_label) && address2_field.Checked)
                                {
                                    custom_bool_label = false;
                                    address2_field.ForeColor = System.Drawing.Color.Red;
                                }
                                if (IsTextBoxInputWrong(address3_label) && address3_field.Checked)
                                {
                                    custom_bool_label = false;
                                    address3_field.ForeColor = System.Drawing.Color.Red;
                                }
                                custom_bool_min = true;
                            }
                            #endregion
                            break;
                        default:
                            #region (validator for all other fields)
                            ((CheckBox)c).ForeColor = System.Drawing.Color.Black;
                            if (((CheckBox)c).Checked == false)
                            {
                                ((TextBox)this.FindControl(c.ID.ToString().Split('_')[0] + "_label")).Text = String.Empty;
                            }
                            else
                            {
                                if (IsTextBoxInputWrong(FindControl(c.ID.ToString().Split('_')[0] + "_label") as TextBox))
                                {
                                    custom_bool_label = false;
                                    ((CheckBox)c).ForeColor = System.Drawing.Color.Red;
                                }
                                custom_bool_min = true;
                            }
                            #endregion
                            break;
                    }
                }
            }
            #endregion

            #region validate positions
            bool custom_bool_positions = true;
            //position bitmap needs to be two "bits" bigger for address2 and address3 then the number of overall "fields" which is equal to MaxSortSequence;
            int[] position_bitmap = new int[MaxSortSequence+2];
            int max_pos = 0;
            int requiredPositions = 0;
            #region do all checked fields have a position selected?
            //madan added for the aditional 2 fields
            int addressPosition = Int32.MaxValue;
            int add = 0;
            if (address_field.Checked && address2_field.Checked)
            {
                if (Int32.TryParse(pos_address.SelectedValue, out addressPosition))
                {
                    add = 1;
                    if (address3_field.Checked)
                    {
                        add = 2;
                    }
                }

            }
            for (int i = 0; i < MaxSortSequence; i++)
            {
                string pos_name = pos_names[i];

                CheckBox cb = (CheckBox)this.FindControl(pos_name.Split('_')[1] + "_field");
                DropDownList pos_dd = (DropDownList)this.FindControl(pos_name);

                //TODO: RFG 2.5 check if this statement runs correctly for all fields

                int iTemp = i;
                //Because of Address2 and Address3 we should skip them, increase iTemp-index by two as the address fields are on index 18 and 19
                if (i >= BitmapIndexAddress2)
                {
                    iTemp = i+2;                        
                }


                if (cb.Checked)
                {
                    requiredPositions++;
                    int selected_pos = Int32.Parse(pos_dd.SelectedValue);

                    if (selected_pos == -1)
                    {
                        custom_bool_positions = false;
                        position_bitmap[iTemp] = -1;
                    }
                    else
                    {
                        if (selected_pos > addressPosition)
                        {
                            selected_pos += add;
                        }
                        if (selected_pos > max_pos)
                        {
                            max_pos = selected_pos;
                        }
                        position_bitmap[iTemp] = selected_pos;
                    }
                }
                else
                {
                    position_bitmap[iTemp] = -1;
                }
            }
            #endregion

            #region check if all numbers between 1 and max_pos are present
            for (int i = 1; i < requiredPositions; i++)
            {
                if (!reserved_positions.Contains(i.ToString()))
                {
                    custom_bool_positions = custom_bool_positions & false;
                }
            }
            if (max_pos == -1)
            {
                max_pos = 1;
            }
            #endregion

            positions_error.Text = "Please check the position dropdowns!<br>- each checked field has to have a position selected<br>- from 1 through {0} all numbers in between have to be present";
            positions_error.Text = String.Format(positions_error.Text, max_pos);
            #endregion

            validate_table1.Visible = true;
            validate_table2.Visible = true;
            RequiredIntroValdiator.Validate();

            if (String.IsNullOrEmpty(personalsection_header.Text) && String.IsNullOrEmpty(question_text.Text))
            {
                RequiredIntroValdiator.IsValid = false;
            }
            else
            {
                RequiredIntroValdiator.IsValid = true;
            }


            if (this.IsValid && custom_bool_min && custom_bool_label && custom_bool_positions)
            {                
                personalDataSection.PageId = int.Parse(page_id);
                int selected_sort_sequence = Int32.Parse(sort_sequence.SelectedValue);
                personalDataSection.SortSequence = selected_sort_sequence;                
                if (!String.IsNullOrEmpty(personalsection_header.Text))
                {
                    personalDataSection.ElementText = personalsection_header.Text;                    
                }
                personalDataSection.PersonalQuestion = question_text.Text;
                
                int[] mandatory_bitmap = new int[50];
                int[] prefilled_bitmap = new int[50];

                int i = 0;

                foreach (Control c in this.FindControl("Form1").Controls)
                {
                    //this.FindControl("Form1").Controls does not contain address2 and address3 checkbox-controls (and others) directly as they are encapsulated by a <tr id=.. runat=server>...
                    if (c.GetType().ToString().IndexOf("CheckBox") != -1 && c.ID.EndsWith("_field") == true)
                    {
                        //TODO: RFG 2.5 check if this statement runs correctly for all fields
                        //Because of Address2 and Address3 we should skip them, increase iTemp-index by two as the address fields are on index 18 and 19
                        if (i == BitmapIndexAddress2)
                        {
                            i += 2;
                        }

                        switch (c.ID)
                        {
                            case "emailpref_field":
                                #region (save emailpref)
                                if (emailpref_field.Checked == true)
                                {
                                    personalDataSection.EmailPreferences = emailpref_label.Text;
                                    personalDataSection.PreferTextMail = pd_text_label.Text;
                                    personalDataSection.PreferHtmlMail = pd_html_label.Text;                                                                        
                                    if (emailpref_mandatory.Checked == true)
                                    {
                                        mandatory_bitmap[i] = 1;
                                    }
                                }
                              #endregion
                                break;
                            //madan added for the additioanl fields
                            case "telephone_field":
                                #region (save telephone)
                                if (telephone_field.Checked == true)
                                {
                                    personalDataSection.TelephoneNumber = telephone_label.Text;
                                    personalDataSection.TelephoneCountry = telephone_country_label.Text;
                                    personalDataSection.TelephoneArea = telephone_area_label.Text;
                                    personalDataSection.TelephoneExt = telephone_extension_label.Text;
                                    personalDataSection.TelephoneValidationMessage = telephone_validation_messge_label.Text;                                    
                                    if (telephone_mandatory.Checked == true)
                                    {
                                        mandatory_bitmap[i] = 1;
                                    }
                                    if (telephone_prefilled.Checked)
                                        prefilled_bitmap[i] = 1;
                                }
                                #endregion
                                break;
                            case "fax_field":
                                #region (save fax)
                                if (fax_field.Checked == true)
                                {
                                    personalDataSection.FaxNumber = fax_label.Text;
                                    personalDataSection.FaxCountry = fax_country_label.Text;
                                    personalDataSection.FaxArea = fax_area_label.Text;
                                    personalDataSection.FaxExt = fax_extension_label.Text;
                                    personalDataSection.FaxValidationMessage = fax_validation_message_label.Text;                                    
                                    
                                    if (fax_mandatory.Checked == true)
                                    {
                                        mandatory_bitmap[i] = 1;
                                    }

                                    if (fax_prefilled.Checked)
                                        prefilled_bitmap[i] = 1;
                                }
                                #endregion
                                break;
                            case "mobile_field":
                                #region (save mobile)
                                if (mobile_field.Checked == true)
                                {
                                    personalDataSection.MobileNumber = mobile_label.Text;
                                    personalDataSection.MobileCountry = mobile_country_label.Text;
                                    personalDataSection.MobileValidationMessage = mobile_validation_message_label.Text;                                    

                                    if (mobile_mandatory.Checked == true)
                                    {
                                        mandatory_bitmap[i] = 1;
                                    }

                                    if (mobile_prefilled.Checked)
                                        prefilled_bitmap[i] = 1;
                                }
                                #endregion
                                break;
                            case "address_field":
                                #region (save address)
                                if (address_field.Checked == true)
                                {
                                    personalDataSection.Address = address_label.Text;                                    

                                    if (address_mandatory.Checked == true)
                                    {
                                        mandatory_bitmap[i] = 1;
                                    }

                                    if (address_prefilled.Checked)
                                        prefilled_bitmap[i] = 1;
                                }
                                #endregion
                                #region (save address2)
                                if (address2_field.Checked == true)
                                {
                                    address2_label.Text = address2_field.Checked ? address2_label.Text : String.Empty;
                                    personalDataSection.Address2 = address2_label.Text;                                    

                                    if (address2_mandatory.Checked == true)
                                    {
                                        mandatory_bitmap[BitmapIndexAddress2] = 1;
                                    }
                                    position_bitmap[BitmapIndexAddress2] = position_bitmap[i] + 1;
                                    if (address2_prefilled.Checked)
                                        prefilled_bitmap[BitmapIndexAddress2] = 1;
                                }
                                else
                                {
                                    position_bitmap[BitmapIndexAddress2] = -1;
                                }
                                #endregion
                                #region (save address3)
                                if (address3_field.Checked == true)
                                {
                                    address3_label.Text = address3_field.Checked ? address3_label.Text : String.Empty;
                                    personalDataSection.Address3 = address3_label.Text;                                    


                                    if (address3_mandatory.Checked == true)
                                    {
                                        mandatory_bitmap[BitmapIndexAddress3] = 1;
                                    }
                                    position_bitmap[BitmapIndexAddress3] = position_bitmap[i] + 2;
                                    if (address3_prefilled.Checked)
                                        prefilled_bitmap[BitmapIndexAddress3] = 1;
                                }
                                else
                                {
                                    position_bitmap[BitmapIndexAddress3] = -1;
                                }
                                #endregion
                                break;
                            default:
                                #region (save all other fields)
                                if (((CheckBox)c).Checked == true)
                                {
                                    string name = c.ID.ToString().Split('_')[0];
                                    DropDownList name_position = (DropDownList)this.FindControl("pos_" + name);
                                    TextBox name_label = (TextBox)this.FindControl(name + "_label");
                                    CheckBox name_mandatory = (CheckBox)this.FindControl(name + "_mandatory");
                                    CheckBox name_prefilled = (CheckBox)this.FindControl(name + "_prefilled");

                                    switch (name_label.ID)
                                    { 
                                        case "language_label":
                                            personalDataSection.PreferredLanguage = name_label.Text;
                                            break;
                                        case "personaltitle_label":
                                            personalDataSection.PersonalTitle = name_label.Text;
                                            break;
                                        case "firstname_label":
                                            personalDataSection.FirstName = name_label.Text;
                                            break;
                                        case "lastname_label":
                                            personalDataSection.LastName = name_label.Text;
                                            break;
                                        case "jobcode_label":
                                            personalDataSection.JobSelectName = name_label.Text;
                                            break;
                                        case "jobtitle_label":
                                            personalDataSection.JobEnterName = name_label.Text;
                                            break;
                                        case "companyname_label":
                                            personalDataSection.CompanyName = name_label.Text;
                                            break;
                                        case "town_label":
                                            personalDataSection.Town = name_label.Text;
                                            break;
                                        case "county_label":
                                            personalDataSection.County = name_label.Text;
                                            break;
                                        case "postcode_label":
                                            personalDataSection.PostalCode = name_label.Text;
                                            break;
                                        case "country_label":
                                            personalDataSection.CountryRegion = name_label.Text;
                                            break;
                                        case "email_label":
                                            personalDataSection.Email = name_label.Text;
                                            break;
                                        case "business_label":
                                            personalDataSection.Business = name_label.Text;
                                            break;
                                        case "worldsize_label":
                                            personalDataSection.CompanySize = name_label.Text;
                                            break;

                                        //RFG 2.11 | Added by Raju
                                        case "companywebsite_label":
                                            personalDataSection.CompanyWebsite = name_label.Text;
                                            break;  
                                        case "companyrevenue_label":
                                            personalDataSection.CompanyRevenue = name_label.Text;
                                            break;  
                                    }

                                    if (name_mandatory != null)
                                    {
                                        if (name_mandatory.Checked == true)
                                        {                                            
                                            mandatory_bitmap[i] = 1;
                                        }
                                    }

                                    if (name_prefilled != null)
                                    {
                                        if (name_prefilled.Checked == true)
                                        {
                                            prefilled_bitmap[i] = 1;
                                        }
                                    }
                                }
                                #endregion
                                break;
                        }
                        i++;
                    }
                }

                string mandatory_bits = "";

                foreach (int bit in mandatory_bitmap)
                {
                    mandatory_bits = String.Format("{0}{1}", mandatory_bits, bit.ToString());
                }

                string prefilled_bits = "";

                foreach (int bit in prefilled_bitmap)
                {
                    prefilled_bits = String.Format("{0}{1}", prefilled_bits, bit.ToString());
                }

                string position_bits = "";

                foreach (int bit in position_bitmap)
                {
                    if (position_bits.Length > 0)
                    {
                        position_bits = String.Format("{0}|", position_bits);
                    }
                    position_bits = String.Format("{0}{1}", position_bits, bit.ToString());
                }

                personalDataSection.PresentationPosition = FormRegistry.PersonalDao.BuildPositionPresentation(position_bits, mandatory_bits, prefilled_bits);                                                                    
                QuestionnaireFacade.CreateUpdatePersonalDataSection(personalDataSection);
                Response.Redirect("edit_formpage.aspx", true);
            }
            else
            {
                if (!custom_bool_min)
                {
                    personaldata_min.Visible = true;
                    validate_table3.Visible = true;
                }
                if (!custom_bool_label)
                {
                    label_required.Visible = true;
                    validate_table2.Visible = true;
                }
                else
                {
                    label_required.Visible = false;
                    validate_table2.Visible = false;
                }
                if (!custom_bool_positions)
                {
                    positions_error.Visible = true;
                }

                if (RequiredIntroValdiator.IsValid == false)
                {
                    validate_table1.Visible = true;
                }
                else
                {
                    validate_table1.Visible = false;
                }
            }
        }
Ejemplo n.º 12
0
 private void ValidateShippingAddress(ShippingAddressResponseDto shAddress, IResponseElementProvider elementToValidate, List<int> validationHints, PersonalDataSectionDto personalDataSectionDto)
 {
     PageElementWithErrorDto element = elementToValidate.PageElement as PageElementWithErrorDto;
     PersonalDataSectionDto personalDataSection =  FormRegistry.PersonalDao.GetByPageId(element.PageId);
     foreach (KeyValuePair<PersonalDataSectionElements, Triple<int?, bool, bool>> elementToCheck in personalDataSection.PresentationPosition)
     {
         if (elementToCheck.Value != null)
         {
             if (elementToCheck.Value.Second)//mandatory
             {
                 int validationHint = DoTheSwitch(elementToCheck.Key, shAddress, personalDataSection);
                 if (validationHint > 0)
                 {
                     validationHints.Add(validationHint);
                 }
             }
             else
             {                        
                 switch (elementToCheck.Key)
                 {
                     case PersonalDataSectionElements.Email:
                         if (!DataValidation.ValidateEmail(shAddress.EmailAddress, false))
                         {
                             validationHints.Add(PersonalDataSectionDto.InvalidEmailAddress);
                         }
                         break;
                     default:
                         break;
                 }                        
             }
         }
     }                
 }
Ejemplo n.º 13
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;
 }
        //protected void pos_personaltitle_SelectedIndexChanged(object sender, System.EventArgs e)
        //{
        //    pos_dd_SelectedIndexChanged(pos_personaltitle);
        //}

        //protected void pos_firstname_SelectedIndexChanged(object sender, System.EventArgs e)
        //{
        //    pos_dd_SelectedIndexChanged(pos_firstname);
        //}

        //protected void pos_lastname_SelectedIndexChanged(object sender, System.EventArgs e)
        //{
        //    pos_dd_SelectedIndexChanged(pos_lastname);
        //}

        //protected void pos_jobcode_SelectedIndexChanged(object sender, System.EventArgs e)
        //{
        //    pos_dd_SelectedIndexChanged(pos_jobcode);
        //}

        //protected void pos_jobtitle_SelectedIndexChanged(object sender, System.EventArgs e)
        //{
        //    pos_dd_SelectedIndexChanged(pos_jobtitle);
        //}

        //protected void pos_companyname_SelectedIndexChanged(object sender, System.EventArgs e)
        //{
        //    pos_dd_SelectedIndexChanged(pos_companyname);
        //}
        //protected void pos_address_SelectedIndexChanged(object sender, System.EventArgs e)
        //{
        //    pos_dd_SelectedIndexChanged(pos_address);
        //}

        //protected void pos_town_SelectedIndexChanged(object sender, System.EventArgs e)
        //{
        //    pos_dd_SelectedIndexChanged(pos_town);
        //}

        //protected void pos_county_SelectedIndexChanged(object sender, System.EventArgs e)
        //{
        //    pos_dd_SelectedIndexChanged(pos_county);
        //}

        //protected void pos_postcode_SelectedIndexChanged(object sender, System.EventArgs e)
        //{
        //    pos_dd_SelectedIndexChanged(pos_postcode);
        //}

        //protected void pos_country_SelectedIndexChanged(object sender, System.EventArgs e)
        //{
        //    pos_dd_SelectedIndexChanged(pos_country);
        //}

        //protected void pos_email_SelectedIndexChanged(object sender, System.EventArgs e)
        //{
        //    pos_dd_SelectedIndexChanged(pos_email);
        //}

        //protected void pos_emailpref_SelectedIndexChanged(object sender, System.EventArgs e)
        //{
        //    pos_dd_SelectedIndexChanged(pos_emailpref);
        //}

        //protected void pos_telephone_SelectedIndexChanged(object sender, System.EventArgs e)
        //{
        //    pos_dd_SelectedIndexChanged(pos_telephone);
        //}

        //protected void pos_business_SelectedIndexChanged(object sender, System.EventArgs e)
        //{
        //    pos_dd_SelectedIndexChanged(pos_business);
        //}

        //protected void pos_worldsize_SelectedIndexChanged(object sender, System.EventArgs e)
        //{
        //    pos_dd_SelectedIndexChanged(pos_worldsize);
        //}
		

        //private void pos_dd_SelectedIndexChanged(DropDownList pos_dd)
        //{
        //    int selected_pos = Int32.Parse(pos_dd.SelectedValue);

        //    int old_pos = (int)ViewState[pos_dd.ID];

        //    #region important for test of intervall
        //    if (old_pos == -1)
        //    {
        //        old_pos = 16;
        //    }
        //    #endregion
			
        //    #region change other positions accordingly to new selected position
        //    if (selected_pos != -1)
        //    {
        //        if (reserved_positions.Contains(selected_pos.ToString()))
        //        {
        //            //position is forgiven, other positions have to be changed
        //            //clear reserved_positions
        //            reserved_positions.Clear();

        //            foreach(string pos_name in pos_names)
        //            {
        //                if (pos_name != pos_dd.ID)
        //                {
        //                    DropDownList other_pos_dd = (DropDownList)this.FindControl(pos_name);

        //                    int other_pos = Int32.Parse(other_pos_dd.SelectedValue);
        //                    if (other_pos != -1)
        //                    {
        //                        #region test whether pos_dd is in relevant Intervall
        //                        if (selected_pos <= old_pos)
        //                        {
        //                            if (other_pos >= selected_pos && other_pos < old_pos)
        //                            {
        //                                other_pos += 1;
        //                            }
        //                        }
        //                        else
        //                        {
        //                            if (other_pos > old_pos && other_pos <= selected_pos)
        //                            {
        //                                other_pos -= 1;
        //                            }
        //                        }
        //                        #endregion
        //                        other_pos_dd.SelectedValue = other_pos.ToString();
        //                        ViewState[pos_name] = other_pos;
        //                        reserved_positions.Add(other_pos.ToString());
        //                    }
        //                }
        //            }
        //        }
        //        else
        //        {
        //            reserved_positions.Remove(old_pos.ToString());
        //        }
        //        ViewState[pos_dd.ID] = selected_pos;
        //        reserved_positions.Add(selected_pos.ToString());
        //    }
        //    else
        //    {
        //        reserved_positions.Clear();
				
        //        foreach(string pos_name in pos_names)
        //        {
        //            if (pos_name != pos_dd.ID)
        //            {
        //                DropDownList other_pos_dd = (DropDownList)this.FindControl(pos_name);

        //                int other_pos = Int32.Parse(other_pos_dd.SelectedValue);
        //                if (other_pos != -1)
        //                {
        //                    if (other_pos > old_pos)
        //                    {
        //                        other_pos -= 1;
        //                    }
        //                    other_pos_dd.SelectedValue = other_pos.ToString();
        //                    ViewState[pos_name] = other_pos;
        //                    reserved_positions.Add(other_pos.ToString());
        //                }
        //            }
        //        }
        //        ViewState[pos_dd.ID] = selected_pos;
        //    }
        //    #endregion

        //    positions_error.Visible = false;
        //}

		
		protected void save_personaldatasection_Click(object sender, System.EventArgs e)
		{
            PersonalDataSectionDto personalDataSection = new PersonalDataSectionDto();
			#region (switching the validators on/off )
			
			foreach (Control c in this.FindControl("Form1").Controls)
			{
				if (c.GetType().ToString().IndexOf("CheckBox") != -1 && c.ID.EndsWith("_field") == true)
				{
					switch(c.ID)
					{
						case "emailpref_field": // emailpref validation
							#region (validators emailpref)
                            //emailpref_field.ForeColor = System.Drawing.Color.Black;
                            //pd_text_radio.ForeColor = System.Drawing.Color.Black;
                            //pd_html_radio.ForeColor = System.Drawing.Color.Black;
                            //if (emailpref_field.Checked == false)
                            if (emailpref_field.Checked)
							{
                                //emailpref_label.Text = "";
                                //pd_text_label.Text = "";
                                //pd_html_label.Text = "";
                                custom_bool_min = true;
                            }
                            //else
                            //{
                            //    if (emailpref_label.Text == "")
                            //    {
                            //        custom_bool_label = false;
                            //        emailpref_field.ForeColor = System.Drawing.Color.Red;
                            //    }
                            //    if (pd_text_label.Text == "")
                            //    {
                            //        custom_bool_label = false;
                            //        pd_text_radio.ForeColor = System.Drawing.Color.Red;
                            //    }
                            //    if (pd_html_label.Text == "")
                            //    {
                            //        custom_bool_label = false;
                            //        pd_html_radio.ForeColor = System.Drawing.Color.Red;
                            //    }
                            //    custom_bool_min = true;
                            //}
							#endregion
							break;
						default:
							#region (validator for all other fields)
							((CheckBox)c).ForeColor = System.Drawing.Color.Black;
                            //if (((CheckBox)c).Checked == false)
                            if (((CheckBox)c).Checked)
							{
                                //((TextBox)this.FindControl(c.ID.ToString().Split('_')[0]+"_label")).Text = "";
                                custom_bool_min = true;
                            }
                            //else
                            //{
                            //    if (((TextBox)this.FindControl(c.ID.ToString().Split('_')[0]+"_label")).Text == "")
                            //    {
                            //        custom_bool_label = false;
                            //        ((CheckBox)c).ForeColor = System.Drawing.Color.Red;
                            //    }
                            //    custom_bool_min = true;
                            //}
							#endregion
							break;
					}
				}
			}
			#endregion

			#region validate positions
            //bool custom_bool_positions = true;
            //int[] position_bitmap = new int[16];
            //int max_pos = -1;
			
			#region store position for all checked fields
            //for (int i = 0; i < 16; i++)
            //{
            //    string pos_name = pos_names[i];

            //    CheckBox cb = (CheckBox)this.FindControl(pos_name.Split('_')[1] + "_field");
            //    DropDownList pos_dd = (DropDownList)this.FindControl(pos_name);

            //    if (cb.Checked)
            //    {
            //        int selected_pos = Int32.Parse(pos_dd.SelectedValue);

            //        if (selected_pos == -1)
            //        {
            //            //custom_bool_positions = false;
            //            position_bitmap[i] = -1;
            //        }
            //        else
            //        {
            //            if (selected_pos > max_pos)
            //            {
            //                max_pos = selected_pos;
            //            }
            //            position_bitmap[i] = selected_pos;
            //        }
            //    }
            //    else
            //    {
            //        position_bitmap[i] = -1;
            //    }
            //}
			#endregion

			#region check if all numbers between 1 and max_pos are present
            //for (int i = 1; i < max_pos; i++)
            //{
            //    if (!reserved_positions.Contains(i.ToString()))
            //    {
            //        custom_bool_positions = custom_bool_positions & false;
            //    }
            //}
            //if (max_pos == -1)
            //{
            //    max_pos = 1;
            //}
			#endregion

            //positions_error.Text = "Please check the position dropdowns!<br>- each checked field has to have a position selected<br>- from 1 through {0} all numbers in between have to be present";
            //positions_error.Text = String.Format(positions_error.Text, max_pos);
			#endregion

            //validate_table1.Visible = true;
            //validate_table2.Visible = true;
            //RequiredIntroValdiator.Validate();

            //if (personalsection_header.Text == "" && question_text.Text == "")
            //{
            //    RequiredIntroValdiator.IsValid = false;
            //}
            //else
            //{
            //    RequiredIntroValdiator.IsValid = true;
            //}


            //if (this.IsValid && custom_bool_min && custom_bool_label && custom_bool_positions)
            if (this.IsValid && custom_bool_min && custom_bool_label)
			{
                personalDataSection.PageId = int.Parse(page_id);
				int selected_sort_sequence = Int32.Parse(sort_sequence.SelectedValue);
                personalDataSection.SortSequence = selected_sort_sequence;                

				if (personalsection_header.Text != "")
				{
                    personalDataSection.ElementText = personalsection_header.Text;                    
				}
                personalDataSection.PersonalQuestion = string.Empty;
				
				
				int[] mandatory_bitmap = new int[50];
				int[] prefilled_bitmap = new int[50];
                int[] position_bitmap = new int[NumberOfFields];

				int i = 0;

				foreach (Control c in this.FindControl("Form1").Controls)
				{
                    //this.FindControl("Form1").Controls does not contain address2 and address3 checkbox-controls (and others) directly as they are encapsulated by a <tr id=.. runat=server>...
					if (c.GetType().ToString().IndexOf("CheckBox") != -1 && c.ID.EndsWith("_field") == true)
					{
                        //TODO: RFG 2.5 check if this statement runs correctly for all fields
                        //Because of Address2 and Address3 we should skip them, increase iTemp-index by two as the address fields are on index 18 and 19
                        if (i == BitmapIndexAddress2)
                        {
                            i += 2;
                        }

						switch(c.ID)
						{
							case "emailpref_field":
								#region (save emailpref)
								if (emailpref_field.Checked == true)
								{
                                    personalDataSection.EmailPreferences = emailpref_label.Text;
                                    personalDataSection.PreferTextMail = pd_text_label.Text;
                                    personalDataSection.PreferHtmlMail = pd_html_label.Text;                                                                        									
									if(emailpref_mandatory.Checked == true)
									{
										mandatory_bitmap[i] = 1;  
									}
                                    //position_bitmap[i] = Int32.Parse(pos_emailpref.SelectedValue);
                                    position_bitmap[i] = 1;
                                }
								else
								{
                                    position_bitmap[i] = -1;
								}
								#endregion
								break;
                            //added new fields for 1.9.6
                            case "telephone_field":
                                #region (save telephone)
                                if (telephone_field.Checked == true)
                                {
                                    personalDataSection.TelephoneNumber = telephone_label.Text;
                                    personalDataSection.TelephoneCountry = telephone_country_label.Text;
                                    personalDataSection.TelephoneArea = telephone_area_label.Text;
                                    personalDataSection.TelephoneExt = telephone_extension_label.Text;                                    
                                    if (telephone_mandatory.Checked == true)
                                    {
                                        mandatory_bitmap[i] = 1;
                                    }
                                    position_bitmap[i] = 1;
                                }
								else
								{
                                    position_bitmap[i] = -1;
								}
                                #endregion
                                break;
                            case "fax_field":
                                #region (save fax)
                                if (fax_field.Checked == true)
                                {
                                    personalDataSection.FaxNumber = fax_label.Text;
                                    personalDataSection.FaxCountry = fax_country_label.Text;
                                    personalDataSection.FaxArea = fax_area_label.Text;
                                    personalDataSection.FaxExt = fax_extension_label.Text;                                    
                                    if (fax_mandatory.Checked == true)
                                    {
                                        mandatory_bitmap[i] = 1;
                                    }
                                    position_bitmap[i] = 1;
                                }
                                else
                                {
                                    position_bitmap[i] = -1;
                                }
                                #endregion
                                break;
                            case "mobile_field":
                                #region (save mobile)
                                if (mobile_field.Checked == true)
                                {
                                    personalDataSection.MobileNumber = mobile_label.Text;
                                    personalDataSection.MobileCountry = mobile_country_label.Text;
                                    
                                    if (mobile_mandatory.Checked == true)
                                    {
                                        mandatory_bitmap[i] = 1;
                                    }
                                    position_bitmap[i] = 1;
                                }
                                else
                                {
                                    position_bitmap[i] = -1;
                                }
                                #endregion
                                break;
                            case "address_field":
                                #region (save address)
                                if (address_field.Checked == true)
                                {
                                    personalDataSection.Address = address_label.Text;                                    

                                    if (address_mandatory.Checked == true)
                                    {
                                        mandatory_bitmap[i] = 1;
                                    }
                                    position_bitmap[i] = 1;
                                }
                                else
                                {
                                    position_bitmap[i] = -1;
                                }
                                #endregion
                                #region (save address2)
                                if (address2_field.Checked == true)
                                {
                                    address2_label.Text = address2_field.Checked ? address2_label.Text : String.Empty;
                                    personalDataSection.Address2 = address2_label.Text;                                    

                                    if (address2_mandatory.Checked == true)
                                    {
                                        mandatory_bitmap[BitmapIndexAddress2] = 1;
                                    }
                                    position_bitmap[BitmapIndexAddress2] = position_bitmap[i] + 1;
                                }
                                else
                                {
                                    position_bitmap[BitmapIndexAddress2] = -1;
                                }
                                #endregion
                                #region (save address3)
                                if (address3_field.Checked == true)
                                {
                                    address3_label.Text = address3_field.Checked ? address3_label.Text : String.Empty;
                                    personalDataSection.Address3 = address3_label.Text;                                    

                                    if (address3_mandatory.Checked == true)
                                    {
                                        mandatory_bitmap[BitmapIndexAddress3] = 1;
                                    }
                                    position_bitmap[BitmapIndexAddress3] = position_bitmap[i] + 2;
                                }
                                else
                                {
                                    position_bitmap[BitmapIndexAddress3] = -1;
                                }
                                #endregion
                                break;

							default:
								#region (save all other fields)
								if (((CheckBox)c).Checked == true)
								{
									string name = c.ID.ToString().Split('_')[0];
                                    //DropDownList name_position = (DropDownList)this.FindControl("pos_" + name);
									TextBox name_label = (TextBox)this.FindControl(name+"_label");
									CheckBox name_mandatory = (CheckBox)this.FindControl(name+"_mandatory");
                                    //CheckBox name_prefilled = (CheckBox)this.FindControl(name+"_prefilled");

                                    switch (name_label.ID)
                                    {
                                        case "language_label":
                                            personalDataSection.PreferredLanguage = name_label.Text;
                                            break;
                                        case "personaltitle_label":
                                            personalDataSection.PersonalTitle = name_label.Text;
                                            break;
                                        case "firstname_label":
                                            personalDataSection.FirstName = name_label.Text;
                                            break;
                                        case "lastname_label":
                                            personalDataSection.LastName = name_label.Text;
                                            break;
                                        case "jobcode_label":
                                            personalDataSection.JobSelectName = name_label.Text;
                                            break;
                                        case "jobtitle_label":
                                            personalDataSection.JobEnterName = name_label.Text;
                                            break;
                                        case "companyname_label":
                                            personalDataSection.CompanyName = name_label.Text;
                                            break;
                                        //RFG 2.11 | Added by Raju
                                        case "companywebsite_label":
                                            personalDataSection.CompanyWebsite = name_label.Text;
                                            break;
                                        case "companyrevenue_label":
                                            personalDataSection.CompanyRevenue = name_label.Text;
                                            break;
                                        case "town_label":
                                            personalDataSection.Town = name_label.Text;
                                            break;
                                        case "county_label":
                                            personalDataSection.County = name_label.Text;
                                            break;
                                        case "postcode_label":
                                            personalDataSection.PostalCode = name_label.Text;
                                            break;
                                        case "country_label":
                                            personalDataSection.CountryRegion = name_label.Text;
                                            break;
                                        case "email_label":
                                            personalDataSection.Email = name_label.Text;
                                            break;
                                        case "business_label":
                                            personalDataSection.Business = name_label.Text;
                                            break;
                                        case "worldsize_label":
                                            personalDataSection.CompanySize = name_label.Text;
                                            break;
                                    }


									if(name_mandatory != null)
									{
										if (name_mandatory.Checked == true)
										{
											mandatory_bitmap[i] = 1;  
										}
									}

                                    //if(name_prefilled != null)
                                    //{
                                    //    if (name_prefilled.Checked == true)
                                    //    {
                                    //        prefilled_bitmap[i] = 1;  
                                    //    }
                                    //}

                                    //if (name_position != null)
                                    //{
                                        //position_bitmap[i] = Int32.Parse(name_position.SelectedValue);
                                        position_bitmap[i] = 1;
                                    //}
								}
                                else
                                {
                                    position_bitmap[i] = -1;
                                }
								#endregion
								break;
						}
						i++;
					}
				}

				string mandatory_bits = "";

				foreach (int bit in mandatory_bitmap)
				{
					mandatory_bits = String.Format("{0}{1}", mandatory_bits, bit.ToString());
				}

				string prefilled_bits = "";

				foreach (int bit in prefilled_bitmap)
				{
					prefilled_bits = String.Format("{0}{1}", prefilled_bits, bit.ToString());
				}

				string position_bits = "";

				foreach (int bit in position_bitmap)
				{
					if (position_bits.Length > 0)
					{
						position_bits = String.Format("{0}|", position_bits);
					}
					position_bits = String.Format("{0}{1}", position_bits, bit.ToString());
				}

                personalDataSection.PresentationPosition = FormRegistry.PersonalDao.BuildPositionPresentation(position_bits, mandatory_bits, prefilled_bits);
                QuestionnaireFacade.CreateUpdatePersonalDataSection(personalDataSection);
                Response.Redirect("edit_processorpage.aspx", true);
			}
			else
			{
				if (!custom_bool_min)
				{
					personaldata_min.Visible = true;
					validate_table3.Visible = true;
				}
                //if (!custom_bool_label)
                //{
                //    label_required.Visible = true;
                //    validate_table2.Visible = true;
                //}
                //else
                //{
                //    label_required.Visible = false;
                //    validate_table2.Visible = false;
                //}
                //if (!custom_bool_positions)
                //{
                //    positions_error.Visible = true;
                //}

                //if (RequiredIntroValdiator.IsValid == false)
                //{
                //    validate_table1.Visible = true;
                //}
                //else
                //{
                //    validate_table1.Visible = false;
                //}
			}
		}
Ejemplo n.º 15
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;
        }
Ejemplo n.º 16
0
        private void PhoneValidationStatus(PersonalDataSectionDto elementDto, PersonalResponseDto response, List<int> validationHints)
        {
            foreach (KeyValuePair<PersonalDataSectionElements, Triple<int?, bool, bool>> elementToCheck in elementDto.PresentationPosition)
            {
                if (elementToCheck.Value != null)
                {
             //       if (!(elementToCheck.Value.Second))//mandatory
            //        {
                        //int validationHint = DoTheSwitch(elementDto, response, elementToCheck.Key);
                        //if (validationHint > 0)
                        //{
                        //    validationHints.Add(validationHint);
                        //}

                        if (response != null)
                        {
                            switch (elementToCheck.Key)
                            {
                                case PersonalDataSectionElements.Telephone:
                                    if (!ValidateLongPhone(response.TelephoneCountry, response.TelephoneArea, response.TelephoneNumber, response.TelephoneExt, false))
                                    {
                                        validationHints.Add(PersonalDataSectionDto.InvalidTelephone);
                                    }
                                    break;
                                default:
                                    break;
                            }
                        }
                //    }
                }
            }
        }