public utility.return_information validate_control()
		{
			#region validate content and length of field
			bool valid = true;
			bool maxlength = true;

			string tb_text = tb.Text.Trim();
			
			if (required)
			{
				if (tb_text == "")
				{
					valid = valid & false;
				}
			}

			if (tb_text.Length > 4000)
			{
				valid = valid & false;
				maxlength = false;
			}
			#endregion

			#region highlight label if not valid
			if (!valid)
			{
				//mark labels
				textbox_label.Text = String.Format("<font color=red>{0}</font>", textbox_label.Text);
			}
			else
			{
				//demark labels
				textbox_label.Text = textbox_label.Text.Replace("<font color=red>", "").Replace("</font>", "");
			}
			#endregion

			#region display error message if maxlength is reached
			if (!maxlength)
			{
				error_table.Visible = true;
			}
			else
			{
				error_table.Visible = false;
			}
			#endregion

			utility.return_information retvalue = new utility.return_information();

			retvalue.isValid = valid;
			retvalue.choice_id = tb.ID;
			retvalue.field_label = textbox_label.Text;
			retvalue.field_text = tb_text;

			return retvalue;
		}
Example #2
0
		public utility.return_information validate_control()
		{
			#region validate upload and file_type
			bool valid = true;
			bool file_type = true;
			
			if (required)
			{
				if (upload.Value == "")
				{
					valid = valid & false;
				}
			}

            //if .PostedFile is null it is most likely that the file-upload field is disabled because of 
            //   browser/user-agent specialities (iPad-, iPhone-Devices do not support file-upload hence fields are disabled)
			if (upload.Value != "" && upload.PostedFile != null)
			{
				string filetype = upload.PostedFile.ContentType;
                //EA-REQ041
                string regex_pattern = utility.getParameter("regex_allowed_file_types"); //"^(text/.*)|(image/.*)|(application/x-zip-compressed)|(application/pdf)$";

				file_type = Regex.IsMatch(filetype, regex_pattern);

				valid = valid & file_type;
			}
			#endregion

			#region highlight label if not valid
			//label has always to be highlighted in Page_Load (if required = true) as the field is empty when a Post_back occurs
			#endregion

			#region highlight label and display error message if filetype is forbidden
			if (!file_type)
			{
				//mark labels
				upload_label.Text = String.Format("<font color=red>{0}</font>", upload_label.Text);

				error_table.Visible = true;
			}
			else
			{
				//demark labels
				//upload_label.Text = upload_label.Text.Replace("<font color=red>", "").Replace("</font>", "");

				error_table.Visible = false;
			}
			#endregion

			string field_text = "";

            //if .PostedFile is null it is most likely that the file-upload field is disabled because of 
            //   browser/user-agent specialities (iPad-, iPhone-Devices do not support file-upload hence fields are disabled)
            if (upload.Value != "" && upload.PostedFile != null)
            {
                field_text = System.IO.Path.GetFileName(upload.PostedFile.FileName);
            }
			
			utility.return_information retvalue = new utility.return_information();

			retvalue.isValid = valid;
			retvalue.field_label = upload_label.Text;
			retvalue.field_text = field_text;
            //if .PostedFile is null it is most likely that the file-upload field is disabled because of 
            //   browser/user-agent specialities (iPad-, iPhone-Devices do not support file-upload hence fields are disabled)
            if (valid && upload.Value != "" && upload.PostedFile != null)
			{
				retvalue.file_stream = upload.PostedFile.InputStream;
			}

			return retvalue;
		}
		override public utility.return_information[] validate_control()
		{
			#region validate content and input of fields
			bool valid = true;

			string subunsub_choice_id = "-1";
			//default if question is not mandatory no choice has been made
			string subunsub_text = "";

			#region validate subunsub
			if (cb_subunsub_table.Visible)
			{
                if (cb_subunsub.Checked)
                {
                    subunsub_choice_id = cb_subunsub.ID;
                    subunsub_text = cb_subunsub_label.Text;
                }
                else
                {
                    if (required)
                    {
                        valid = false;
                    }
                }
			}
			else
			{
				if (rbl_subunsub.SelectedItem == null)
				{
					if (required)
					{
						valid = false;
					}
				}
				else
				{
					subunsub_choice_id = rbl_subunsub.SelectedItem.Value;
					subunsub_text = rbl_subunsub.SelectedItem.Text;
				}
			}
			#endregion
			
			#region commented
			/*
			if (required)
			{
				#region validate subunsub
				if (cb_subunsub_table.Visible)
				{
					valid = cb_subunsub.Checked;

					subunsub_choice_id = cb_subunsub.ID;
					subunsub_text = cb_subunsub_label.Text;
				}
				else
				{
					if (rbl_subunsub.SelectedItem == null)
					{
						valid = false;
					}
					else
					{
						subunsub_choice_id = rbl_subunsub.SelectedItem.Value;
						subunsub_text = rbl_subunsub.SelectedItem.Text;
					}
				}
				#endregion
			}
			*/
			#endregion

			#endregion

			#region highlight label if not valid
			if (!valid)
			{
				//mark labels
					content.Text = String.Format("<font color=red>{0}</font>", content.Text);
			}
			else
			{
				//demark labels
				content.Text = content.Text.Replace("<font color=red>", "").Replace("</font>", "");
			}
			#endregion

			#region display error message if maxlength is reached
//			if (!maxlength)
//			{
//				error_table.Visible = true;
//			}
//			else
//			{
//				error_table.Visible = false;
//			}
			#endregion

			#region build willingness choice infos
			utility.return_information retvalue = new utility.return_information();

			retvalue.isValid = valid;
			retvalue.question_type = element_row.element_type_FK;
			retvalue.choice_id = subunsub_choice_id;
			retvalue.field_label = content.Text;
			retvalue.field_text_to_DB = false;
			retvalue.field_text = subunsub_text;
			#endregion
	
			utility.return_information[] retvalues = new utility.return_information[1]{retvalue};

			return retvalues;
		}
		override public utility.return_information[] validate_control()
		{
			#region validate content and input of fields
			bool valid = true;
			
			string tb_text = "";
			string choice_id = "-1";
			//default if question is not mandatory no choice has been made
			string label_to_add = "";

			#region validate required fields 
			if (cb_row.Visible)
			{
				#region validate checkbox and checkbox_textbox
				tb_text = cbtb.Text.Trim();
				label_to_add = textcb.Text;

				if (required)
				{
					valid = valid & cb.Checked;
				}

				if (cb.Checked)
				{
					choice_id = cb.ID;
					
					if (tb_text == "")
					{
						valid = valid & false;
					}
					else
					{
						if (validcrm_vemail.ValidationExpression == constants.REGEX_EMAIL)
						{
							validcrm_vemail.Enabled = true;
						}
						if (validcrm_vfax.ValidationExpression == constants.REGEX_PHONE)
						{
							validcrm_vfax.Enabled = true;
						}
					}
				}
				#endregion
			}
			else
			{
				#region radiobuttons are visible
				if (required)
				{
					valid = valid & (rb1.Checked | rb2.Checked);
				}

				if (rb1.Checked)
				{
					tb_text = rbtb1.Text.Trim();
					choice_id = rb1.ID;
					label_to_add = textrb1.Text;
				
					if (tb_text == "")
					{
						valid = valid & false;
					}

					if (validcrm_vemail.ControlToValidate == rbtb1.ID)
					{
						validcrm_vemail.Enabled = true;
					}
					if (validcrm_vfax.ControlToValidate == rbtb1.ID)
					{
						validcrm_vfax.Enabled = true;
					}
				}

				if (rb2.Checked)
				{
					tb_text = rbtb2.Text.Trim();
					choice_id = rb2.ID;
					label_to_add = textrb2.Text;
				
					if (tb_text == "")
					{
						valid = valid & false;
					}

					if (validcrm_vemail.ControlToValidate == rbtb2.ID)
					{
						validcrm_vemail.Enabled = true;
					}
					if (validcrm_vfax.ControlToValidate == rbtb2.ID)
					{
						validcrm_vfax.Enabled = true;
					}
				}
				#endregion
			}
			#endregion

			#region validate input as email-address/fax if email-address/fax is asked
			if (validcrm_vemail.Enabled)
			{
				validcrm_vemail.Validate();

				valid = valid & validcrm_vemail.IsValid;
			}
			if (validcrm_vfax.Enabled)
			{
				validcrm_vfax.Validate();

				valid = valid & validcrm_vfax.IsValid;
			}
			#endregion

			#endregion

			#region highlight label if not valid
			if (!valid)
			{
				//mark labels
				moreinfo_label.Text = String.Format("<font color=red>{0}</font>", moreinfo_label.Text);
			}
			else
			{
				//demark labels
				moreinfo_label.Text = moreinfo_label.Text.Replace("<font color=red>", "").Replace("</font>", "");
			}
			#endregion

			#region display error message if maxlength is reached
//			if (!maxlength)
//			{
//				error_table.Visible = true;
//			}
//			else
//			{
//				error_table.Visible = false;
//			}
			#endregion

			utility.return_information retvalue = new utility.return_information();

			retvalue.isValid = valid;
			retvalue.question_type = element_row.element_type_FK;
			retvalue.choice_id = choice_id;
			retvalue.field_label = String.Format("{0} - {1}", moreinfo_label.Text, label_to_add);
			retvalue.field_text = tb_text;

			utility.return_information[] retvalues = new utility.return_information[1]{retvalue};

			return retvalues;
		}
		override public utility.return_information[] validate_control()
		{
			#region validate content and input of fields
			bool valid = true;
			bool valid_willing = true;
			bool valid_timeframe = true;

			string willing_text = "";
			string willing_choice_id = "-1";
			//default if question is not mandatory and no choice has been made
			string time_text = "";
			string time_choice_id = "-1";
			//default if question is not mandatory and no choice has been made
			
			#region validate willingness
			if (rbl_willingness.SelectedItem == null)
			{
				if (required)
				{
					valid_willing = false;
				}
				willing_choice_id = "-1";
			}
			else
			{
				willing_choice_id = rbl_willingness.SelectedItem.Value;
				willing_text = rbl_willingness.SelectedItem.Text;
			}
			#endregion

			#region validate timeframe
			//timeframe is only mandatory if rbl_willingness = yes
			if (rbl_willingness.Items[yes_sort].Selected)
			{
				if (timeframe_dd.SelectedIndex == 0)
				{
					valid_timeframe = false;
				}
			}

			if (willing_choice_id != "-1")
			{
				//if no willingness choice is made -> timeframe is of no interest
				time_text = timeframe_dd.SelectedItem.Text;
				time_choice_id = timeframe_dd.ID;
			}
			#endregion

			valid = valid & valid_willing & valid_timeframe;
			#endregion

			#region highlight label if not valid
			if (!valid)
			{
				//mark labels
				if (!valid_willing)
				{
					content.Text = String.Format("<font color=red>{0}</font>", content.Text);
				}
				if (!valid_timeframe)
				{
					timeframe_label.Text = String.Format("<font color=red>{0}</font>", timeframe_label.Text);
				}
			}
			else
			{
				//demark labels
				content.Text = content.Text.Replace("<font color=red>", "").Replace("</font>", "");
				timeframe_label.Text = timeframe_label.Text.Replace("<font color=red>", "").Replace("</font>", "");
			}
			#endregion

			#region display error message if maxlength is reached
//			if (!maxlength)
//			{
//				error_table.Visible = true;
//			}
//			else
//			{
//				error_table.Visible = false;
//			}
			#endregion

			#region build willingness choice infos
			utility.return_information retvalue1 = new utility.return_information();

			retvalue1.isValid = valid;
			retvalue1.question_type = element_row.element_type_FK;
			retvalue1.choice_id = willing_choice_id;
			retvalue1.field_label = content.Text;
			retvalue1.field_text_to_DB = false;
			retvalue1.field_text = willing_text;

			#endregion
			
			utility.return_information[] retvalues = new utility.return_information[1]{retvalue1};

			if (no_sort != rbl_willingness.SelectedIndex)
			{
				#region build timeframe choice infos
				utility.return_information retvalue2 = new utility.return_information();

				retvalue2.isValid = valid;
				retvalue2.question_type = element_row.element_type_FK;
				retvalue2.choice_id = time_choice_id;
				retvalue2.field_label = String.Format("{0} - {1}", retvalue1.field_label, timeframe_label.Text);
				retvalue2.field_text_to_DB = false;
				retvalue2.field_text = time_text;
				retvalue2.field_lov_FK = timeframe_dd.SelectedValue;
				#endregion
	
				retvalues = new utility.return_information[2]{retvalue1, retvalue2};
			}
			
			return retvalues;
		}
Example #6
0
        private void submit_page()
        {
            string notification_recipients = "";

            #region (triggering of validators)

            Hashtable control_answers = new Hashtable();

            //foreach (BaseValidator valid in this.Validators)
            //{
            //    valid.Validate();

            #region (in case of textboxes)
            //if (valid.ID.ToString().StartsWith("validtbc_") == true)
            //{
            //    string element_id = valid.ID.ToString().Split('_')[1];

            //    live.question_textbox found_control = (live.question_textbox)this.FindControl("tbc_" + element_id);

            //    utility.return_information ret_values = found_control.validate_control();

            //    valid.IsValid = ret_values.isValid;

            //    control_answers[element_id] = ret_values;
            //}
            #endregion

            #region (in case of dd_mailto's)
            //if (valid.ID.ToString().StartsWith("validdmc_") == true)
            //{
            //    string element_id = valid.ID.ToString().Split('_')[1];

            //    live.question_dd_mailto found_control = (live.question_dd_mailto)this.FindControl("dd_mailto_" + element_id);

            //    utility.return_information ret_values = found_control.validate_control();

            //    valid.IsValid = ret_values.isValid;

            //    #region remember the mailto recipient...
            //    string separator = "";
            //    if (notification_recipients.Length > 0)
            //    {
            //        separator = ";";
            //    }
            //    notification_recipients = String.Format("{0}{1}{2}", notification_recipients, separator, ret_values.mailto_recipient);
            //    #endregion

            //    control_answers[element_id] = ret_values;
            //}
            #endregion

            #region (in case of crm_controls)
            //if (valid.ID.StartsWith("validcrm_") && !valid.ID.StartsWith("validcrm_v"))
            //{
            //    string element_id = valid.ID.ToString().Split('_')[1];

            //    live.question_crm_c_control found_control = (live.question_crm_c_control)this.FindControl("crm_" + element_id);

            //    utility.return_information[] ret_values = found_control.validate_control();

            //    valid.IsValid = ret_values[0].isValid;

            //    control_answers[element_id] = ret_values;
            //}
            //if (valid.ID.StartsWith("validcrm_v"))
            //{
            //    //validators were handled inside control
            //    valid.IsValid = true;
            //}
            #endregion

            #region (setting all invalid field labels to red colour and in case of email_address)
            //if (valid.ID != "optin_valid" && !valid.ID.StartsWith("validtb") && !valid.ID.StartsWith("valid_email") && !valid.ID.StartsWith("validps") && !valid.ID.StartsWith("validdmc_") && !valid.ID.StartsWith("validupc_") && !valid.ID.StartsWith("validcrm_") && !valid.ID.StartsWith("validc1c_") && !valid.ID.StartsWith("validc2c_") && !valid.ID.StartsWith("validc3c_") && !valid.ID.StartsWith("validc4c_") && !valid.ID.StartsWith("validc5c_"))
            //{
            //    //optin_valid and validtb.. are already highlighted, valid_email is handled in ELSE
            //    if (!valid.IsValid)
            //    {
            //        string name_of_questioncell = valid.ID.ToString().Split('_')[1];

            //        Literal question_cell = (Literal)this.FindControl("literal_question_" + name_of_questioncell);

            //        question_cell.Text = "<font color=red>" + question_cell.Text + "</font>";
            //    }
            //    else
            //    {
            //        string name_of_questioncell = valid.ID.ToString().Split('_')[1];
            //        Literal question_cell = (Literal)this.FindControl("literal_question_" + name_of_questioncell);
            //        question_cell.Text = question_cell.Text.Replace("<font color=red>", "");
            //        question_cell.Text = question_cell.Text.Replace("</font>", "");
            //        //						HtmlTableCell question_cell = (HtmlTableCell)this.FindControl("question_" + name_of_questioncell);
            //        //						question_cell.InnerText = question_cell.InnerText.Replace("<font color=red>", "");
            //        //						question_cell.InnerText = question_cell.InnerText.Replace("</font>", "");
            //    }
            //}
            //else
            //{
            #region validators 'valid_email...'
            ////check always the input of this field - regular expression
            //if (valid.ID.StartsWith("valid_email_2") == true)
            //{
            //bool required_passed = true;

            //BaseValidator valid2 = (BaseValidator)this.FindControl("valid_email_2");
            //valid2.Validate();

            #region validate reuired_field_validator if present
            //BaseValidator valid1 = (BaseValidator)this.FindControl("valid_email_1");

            //if (valid1 != null)
            //{
            //    valid1.Validate();

            //    if (!valid1.IsValid)
            //    {
            //        string name_of_questioncell = valid.ID.ToString().Split('_')[1];
            //        Literal question_cell = (Literal)this.FindControl("literal_question_" + name_of_questioncell);
            //        question_cell.Text = "<font color=red>" + question_cell.Text.ToString() + "</font>";
            //        //							HtmlTableCell question_cell = (HtmlTableCell)this.FindControl("question_" + name_of_questioncell);
            //        //							question_cell.InnerHtml = "<font color=red>" + question_cell.InnerText.ToString() + "</font>";
            //    }
            //    else
            //    {
            //        string name_of_questioncell = valid.ID.ToString().Split('_')[1];
            //        Literal question_cell = (Literal)this.FindControl("literal_question_" + name_of_questioncell);
            //        question_cell.Text = question_cell.Text.Replace("<font color=red>", "");
            //        question_cell.Text = question_cell.Text.Replace("</font>", "");
            //        //							HtmlTableCell question_cell = (HtmlTableCell)this.FindControl("question_" + name_of_questioncell);
            //        //							question_cell.InnerText = question_cell.InnerText.Replace("<font color=red>", "");
            //        //							question_cell.InnerText = question_cell.InnerText.Replace("</font>", "");
            //    }

            //    required_passed = valid1.IsValid;
            //}
            #endregion

            ////only execute the highlightening if required_validator is valid otherwise 
            ////the label is already highlighted and this execution may change it into black
            //if (required_passed)
            //{
            //    if (!valid2.IsValid)
            //    {
            //        string name_of_questioncell = valid.ID.ToString().Split('_')[1];
            //        Literal question_cell = (Literal)this.FindControl("literal_question_" + name_of_questioncell);
            //        question_cell.Text = "<font color=red>" + question_cell.Text.ToString() + "</font>";
            //        //							HtmlTableCell question_cell = (HtmlTableCell)this.FindControl("question_" + name_of_questioncell);
            //        //							question_cell.InnerHtml = "<font color=red>" + question_cell.InnerText.ToString() + "</font>";
            //    }
            //    else
            //    {
            //        string name_of_questioncell = valid.ID.ToString().Split('_')[1];
            //        Literal question_cell = (Literal)this.FindControl("literal_question_" + name_of_questioncell);
            //        question_cell.Text = question_cell.Text.Replace("<font color=red>", "");
            //        question_cell.Text = question_cell.Text.Replace("</font>", "");
            //        //							HtmlTableCell question_cell = (HtmlTableCell)this.FindControl("question_" + name_of_questioncell);
            //        //							question_cell.InnerText = question_cell.InnerText.Replace("<font color=red>", "");
            //        //							question_cell.InnerText = question_cell.InnerText.Replace("</font>", "");
            //    }
            //}
            //}
            #endregion
            //}
            #endregion
            //}

            #region validate passwordfields if there are some

            Control c = (Control)this.FindControl("passwordfields");

            bool pwd_fields_valid = true;

            utility.return_information pwd_fields_retvalue = new utility.return_information();

            if (c != null)
            {
                liveclassic.question_password pwd_fields = (liveclassic.question_password)c;
                pwd_fields_retvalue = pwd_fields.validate_passwords();

                pwd_fields_valid = pwd_fields_retvalue.isValid;
            }
            #endregion

            #region validate personalsection if there is one
            Control c2 = (Control)this.FindControl("personalsection");

            bool personalsection_valid = true;
            ArrayList personal_retvalues = new ArrayList();

            if (c2 != null)
            {
                liveclassic.question_personal_data_section personalsection = (liveclassic.question_personal_data_section)c2;

                personalsection_valid = personalsection.validate_fields(ref personal_retvalues);
            }
            #endregion

            #endregion

            #region load and save cid/rid
            customer_id = Constants.UnknownCustomer;

            #endregion

            DataTable post_params = new DataTable();
            post_params.Columns.Add("question_text");
            post_params.Columns.Add("question_id");
            post_params.Columns.Add("question_answers");
            //interim column needed for building customquestionssummary                
            post_params.Columns.Add("question_crm_flag");

            //if (this.IsValid & pwd_fields_valid & personalsection_valid)
            //{

            Hashtable h_params = new Hashtable();

            h_params.Add("flag", "response");
            h_params.Add("customer_id", customer_id);
            h_params.Add("questionnaire_id", processor_id);
            h_params.Add("source_type", Migration.ViewTypeToString(ViewType.Processor));
            h_params.Add("http_referrer", Request.UrlReferrer.ToString());   //RFG 2.8|Raju|CaliberRM PR652387 

            string response_id = (DB.execProc("insert_response_time", h_params)).Rows[0][0].ToString();

            h_params.Clear();

            DataTable answers_for_ne = new DataTable();
            answers_for_ne.Columns.Add("question_text");
            answers_for_ne.Columns.Add("question_id");
            answers_for_ne.Columns.Add("question_answers");
            answers_for_ne.PrimaryKey = new DataColumn[] { answers_for_ne.Columns["question_id"] };
            //flag to indicate whether question is a crm question (those don't need to be contained in customquestionssummary
            //question_crm_flag = "crm" for crm-questions or empty if normal question
            answers_for_ne.Columns.Add("question_crm_flag");

            string desc_format = String.Format("Response to RFG web form - {0}live/processor.aspx?qid={1}", utility.getParameter("UrlToForms"), "{0}");

            //myParams = Request.Params;

            hParamsPrivacy = new Hashtable();
            hParamsPersonal = new Hashtable();
            emailprefPersonal = String.Empty;
            emailprefPrivacy = String.Empty;
            emailaddress = String.Empty;
            hParamsSiebel = new Hashtable();

            #region process all parameters which are provided
            foreach (string key in myParams.AllKeys)
            {
                if (key.StartsWith("aid_"))
                {
                    DataRow[] acceptableParameterPairs = idset.Select(String.Format("parameter_key = '{0}'", key));

                    //bool valueAccepted = false;
                    DataRow drValueAccepted = idset.NewRow();

                    foreach (string singleValue in myParams.GetValues(key))
                    {
                        DataRow single_answer = answers_for_ne.NewRow();

                        h_params.Clear();
                        h_params.Add("response_id", response_id);

                        foreach (DataRow singleRow in acceptableParameterPairs)
                        {
                            #region check if value rule is present
                            if (singleRow["parameter_value"].ToString() != "")
                            {
                                #region check for valid entry against accepted values
                                //if (myParams[key] == singleRow["parameter_value"].ToString())
                                if (singleValue == singleRow["parameter_value"].ToString())
                                {
                                    drValueAccepted = singleRow;
                                    //valueAccepted = true;

                                    bool[] retval = save_value_in_DB(key, singleValue, ref single_answer, ref answers_for_ne, ref h_params, drValueAccepted, ref notification_recipients);
                                    if (retval[0] & retval[1])
                                    {
                                        answers_for_ne.Rows.Add(single_answer);
                                    }

                                }
                                #endregion
                            }
                            else
                            {
                                drValueAccepted = singleRow;
                                //valueAccepted = true;
                                bool[] retval = save_value_in_DB(key, singleValue, ref single_answer, ref answers_for_ne, ref h_params, drValueAccepted, ref notification_recipients);
                                if (retval[0] & retval[1])
                                {
                                    answers_for_ne.Rows.Add(single_answer);
                                }

                            }
                            #endregion
                        }
                    }
                }
                else if(key.StartsWith("flexfield")) // if flexfield
                {
                    for (int i = 1; i < 16; i++)
                    {
                        string flexfieldname = "flexfield" + i.ToString();

                        if (key.ToLower().Equals(flexfieldname))
                        {
                            hParamsPersonal.Add(flexfieldname, myParams[key]);
                        }
                    }
                }
            }
            #endregion

            #region execute personal section insert as collected by processing parameters

            //try to translate into CRM english value... for the namevalue passed and from state_locals where in_country_fk and in_language_Fk = questionnaire settings?
            //if possible overwrite value from county otherwise leave it as it was
            if (hParamsPersonal.Contains("county"))
            {
                //try to translate into CRM english value... for the namevalue passed and from state_locals where in_country_fk and in_language_Fk = questionnaire settings?
                //if possible overwrite value from county otherwise leave it as it was
                string countyHparams = hParamsPersonal["county"].ToString();
                string selectedCountry = pid_country;
                if (hParamsPersonal.Contains("country_FK"))
                {
                    string countryHparams = hParamsPersonal["country_FK"].ToString();
                    if (!String.IsNullOrEmpty(countyHparams))
                    {
                        selectedCountry = countyHparams;
                    }
                }
                if (!String.IsNullOrEmpty(countyHparams))
                {
                    StandardCountyDto sCounty = FormRegistry.ResponseDao.GetStandardCountyByLocalName(countyHparams, pid_country, pid_language, selectedCountry);
                    if (sCounty != null)
                    {
                        countyHparams = sCounty.CountyName;
                    }
                }
                hParamsPersonal["county"] = countyHparams;
                //TODO notification email will contain the untranslated county name while report and crm_record will contain the translated name if possible
            }


            hParamsPersonal.Add("customer_id", customer_id);
            hParamsPersonal.Add("response_id", response_id);

            if (hParamsPersonal.Count > 2)
            {
                DB.execProc("insert_response_personal", hParamsPersonal);
            }
            #endregion

            #region execute privacy section insert as collected by processing parameters

            //hParamsPrivacy.Clear();

            hParamsPrivacy.Add("response_id", response_id);

            #region (add emailpreference from personalsection)
            if (emailprefPersonal != "")
            {
                hParamsPrivacy["email_pref"] = emailprefPersonal;
            }
            #endregion

            #region (add emailpreference from privacy)
            if (emailprefPrivacy != "")
            {
                hParamsPrivacy["email_pref"] = emailprefPrivacy;
            }
            #endregion

            if (hParamsPrivacy.Count > 1)
            {
                DB.execProc("insert_response_privacy", hParamsPrivacy);

                hParamsPrivacy.Clear();
                hParamsPrivacy.Add("response_id", response_id);
                hParamsPrivacy.Add("questionnaire_id", processor_id);
                hParamsPrivacy.Add("page_id", page_id);

                // RFG 2.18 | DMS-update response type to "Complted Survey" if no sibel question submitted in the response and  privacy section not exists
                if (pass_responses_to_crm && sibelQuestionsSubmittedCounter > 0)
                {
                    hParamsPrivacy.Add("element_type_FK", "--");  //Requested Opt-in/Opt-out
                }
                else if (pass_responses_to_crm)
                {
                    hParamsPrivacy.Add("element_type_FK", "##");//Completed Survey
                }
                else
                {
                    hParamsPrivacy.Add("element_type_FK", "--");//Requested Opt-in/Opt-out
                }
                
                hParamsPrivacy.Add("resp_desc", String.Format(desc_format, processor_id));

                if (!pass_responses_to_crm)
                {
                    hParamsPrivacy.Add("crm_submit", 0);
                }
                hParamsPrivacy.Add("cid_submit", 1);
                pass_responses_to_cid = true;
                DB.execProc("insert_response_crm_record", hParamsPrivacy);
            }

            #endregion

            #region execute siebel answers update as collected by processing parameters

            foreach (string key in hParamsSiebel.Keys)
            {
                #region insert crm_record if applicable and when all choices are inserted
                if (pass_responses_to_crm)
                {
                    h_params.Clear();
                    h_params.Add("response_id", response_id);
                    h_params.Add("questionnaire_id", processor_id);
                    h_params.Add("page_id", page_id);
                    h_params.Add("question_id", key);
                    h_params.Add("element_type_FK", hParamsSiebel[key].ToString());
                    h_params.Add("resp_desc", String.Format(desc_format, processor_id));

                    DB.execProc("insert_response_crm_record", h_params);
                }
                #endregion

            }
            #endregion
            
            #region (load customer profile - only completely updated from this point)

            h_params.Clear();

            h_params.Add("response_id", response_id);

            if (customer_id != Constants.UnknownCustomer)
            {
                h_params.Add("customer_id", customer_id);
            }

            DataTable customer_data = DB.execProc("select_customerinfo", h_params);

            customer_data.Columns.Add("url_to_processor");
            customer_data.Rows[0]["url_to_processor"] = String.Format("{0}live/processor.aspx?pid={1}", utility.getParameter("UrlToForms"), processor_id);

            //add column containing the wavecode which has been passed through the URL (?wcd=...)
            customer_data.Columns.Add("wavecode");
            if (myParams["wcd"] != null)
            {                
                customer_data.Rows[0]["wavecode"] = myParams["wcd"].ToString();
            }
            customer_data.Columns.Add("flexfield_jumpid");
            if (myParams["jumpid"] != null)
            {                
                customer_data.Rows[0]["flexfield_jumpid"] = myParams["jumpid"].ToString();
            }            
            if (myParams["flexfield10"] != null)
            {                
                customer_data.Rows[0]["flexfield10"] = myParams["flexfield10"].ToString();
            }            
            if (myParams["flexfield11"] != null)
            {             
                customer_data.Rows[0]["flexfield11"] = myParams["flexfield11"].ToString();
            }

            if (myParams["flexfield12"] != null)
            {
                customer_data.Rows[0]["flexfield12"] = myParams["flexfield12"].ToString();//††† 20120410 Parthasarathy | RFG 2.6  Support Sub_bu capture †††
            }

            //RFG 2.11 | for watch list | added by Raju
            if (myParams["flexfield14"] != null)
            {
                customer_data.Rows[0]["flexfield14"] = myParams["flexfield14"].ToString(); 
            }

            #endregion

            #region build post_params datatable and params for "update_crm_records"
            h_params.Clear();

            #region define which columns should be passed to "update_crm_records"
            StringCollection columns_for_crm_records = new StringCollection();
            columns_for_crm_records.Add("company_id");
            columns_for_crm_records.Add("company_name");
            columns_for_crm_records.Add("company_website");
            columns_for_crm_records.Add("company_revenue");
            columns_for_crm_records.Add("country_FK");
            columns_for_crm_records.Add("address1");
            columns_for_crm_records.Add("address2");
            columns_for_crm_records.Add("address3");
            columns_for_crm_records.Add("town");
            columns_for_crm_records.Add("postcode");
            columns_for_crm_records.Add("county");
            columns_for_crm_records.Add("number_of_employees");
            columns_for_crm_records.Add("siebel_con_id");
            columns_for_crm_records.Add("first_name");
            columns_for_crm_records.Add("last_name");
            columns_for_crm_records.Add("jobtitle");
            columns_for_crm_records.Add("personal_title");
            columns_for_crm_records.Add("language_FK");
            //columns_for_crm_records.Add("language_name"); not needed here, will be automatically added by below condition if (column_name.StartsWith("language_FK"))

            columns_for_crm_records.Add("telephone_country");   //††† 2010071026 Fix for PR291531- RI files do not contain the inserted values of all four telephone †††
            columns_for_crm_records.Add("telephone_area");  //††† 2010071026 Fix for PR291531- RI files do not contain the inserted values of all four telephone †††
            columns_for_crm_records.Add("telephone");
            columns_for_crm_records.Add("telephone_extn");


            columns_for_crm_records.Add("mobile_country");
            columns_for_crm_records.Add("mobile");

            columns_for_crm_records.Add("fax_country");   //††† 2010071026 Fix for PR291531- RI files do not contain the inserted values of all four telephone †††
            columns_for_crm_records.Add("fax_area");  //††† 2010071026 Fix for PR291531- RI files do not contain the inserted values of all four telephone †††
            columns_for_crm_records.Add("fax");

            columns_for_crm_records.Add("fax_extn");
  
            columns_for_crm_records.Add("email_address");
            columns_for_crm_records.Add("email_pref");
            columns_for_crm_records.Add("siebel_prosp_id");
            columns_for_crm_records.Add("wavecode");
            columns_for_crm_records.Add("flexfield_jumpid");
            columns_for_crm_records.Add("flexfield10");
            columns_for_crm_records.Add("flexfield11");
            columns_for_crm_records.Add("flexfield12");//††† 20120410 Parthasarathy | RFG 2.6  Support Sub_bu capture †††
             
            //RFG 2.11 | for watch list |added by Raju
            columns_for_crm_records.Add("flexfield14"); 

            #endregion

            string strPhonenumber = string.Empty;
            string strMobilenumber = string.Empty;
            string strFaxnumber = string.Empty;

            foreach (DataColumn column in customer_data.Columns)
            {
                string column_name = column.ColumnName;
                string column_text = customer_data.Rows[0][column].ToString();

                DataRow adding_row = post_params.NewRow();
                adding_row["question_text"] = column_name;
                adding_row["question_id"] = column_name.ToLower();
                adding_row["question_answers"] = column_text;

                post_params.Rows.Add(adding_row);

                #region add parameter to h_params if it should be passed
                if (columns_for_crm_records.Contains(column_name))
                {
                    if (column_name.StartsWith("language_FK"))
                    {
                        SiebelLanguageDto lang = FormRegistry.ResponseDao.GetSiebelLanguage(column_text);
                        if (lang != null)
                        {
                            h_params.Add("language_FK", lang.LanguageFK);
                            h_params.Add("language_name", lang.LanguageName);
                        }
                    }
                    else if (column_name.StartsWith("telephone") && column_name != "telephone_extn")
                    {
                        //††† 2010071026 Fix for PR291531- RI files do not contain the inserted values of all four telephone Start †††

                        strPhonenumber = strPhonenumber + column_text;


                        if (column_name == "telephone")
                        {
                            if (strPhonenumber.Trim().Length > 0)
                                h_params.Add(column_name, strPhonenumber);
                        }
                    }
                    else if (column_name.StartsWith("mobile"))
                    {

                        strMobilenumber = strMobilenumber + column_text;


                        if (column_name == "mobile")
                        {
                            if (strMobilenumber.Trim().Length > 0)
                                h_params.Add(column_name, strMobilenumber);
                        }
                    }
                    else if (column_name.StartsWith("fax"))
                    {
                        //††† 2010071026 Fix for PR291531- RI files do not contain the inserted values of all four telephone Start †††

                        strFaxnumber = strFaxnumber + column_text;

                        if (column_name == "fax_extn")
                        {
                            if (strFaxnumber.Trim().Length > 0)
                                h_params.Add("fax", strFaxnumber);
                        }
                    }

                    else
                    {
                        if (column_text.Trim().Length > 0)
                        {
                            if (column_name == "telephone_extn")
                            {
                                h_params.Add("telephone_extension", column_text);
                            }
                            else
                            {
                                h_params.Add(column_name, column_text);
                            }
                        }
                    }
                }
                #endregion
            }

            #region complete post_params and build/add customquestionssummary
            StringBuilder customquestionssummary = new StringBuilder(utility.getParameter("crm_summary_delimiter_before_customquestions"));
            string newline_substitute = utility.getParameter("newline_substitute");   
            //fill post_params and customquestionssummary
            foreach (DataRow single_answer in answers_for_ne.Rows)
            {
                post_params.Rows.Add(single_answer.ItemArray);

                #region fill customquestionssummary
                if (single_answer["question_crm_flag"].ToString() != question_crm_flag_value)
                {
                    //add question text and delimiter for separating question text from customer answer (web.config)
                    customquestionssummary.Append(utility.parse_string(single_answer["question_text"].ToString(), utility.newline, newline_substitute));
                    customquestionssummary.Append(utility.getParameter("crm_summary_delimiter_before_answer"));
                    //add answer and delimiter for separating answer from next question
                    customquestionssummary.Append(utility.parse_string(single_answer["question_answers"].ToString(), utility.newline, newline_substitute));
                    customquestionssummary.Append(utility.getParameter("crm_summary_delimiter_before_question"));
                }
                #endregion
            }          
            
            h_params.Add("flexfield_customquestions", customquestionssummary.ToString());
            #endregion

            //update all inserted crm records with profile information and mark them as "ready for submit"
            h_params.Add("mode", 1);
            h_params.Add("response_id", response_id);
            h_params.Add("company", Company_Code);  // RFG 2.20

            //Conditional check (if crm to transfer is checked) for Update Crm Records
            if (pass_responses_to_crm || pass_responses_to_cid)
                DB.execProc("update_crm_records", h_params);

            //remove interim column which is no longer needed
            post_params.Columns.Remove("question_crm_flag");

            #endregion

            #region (send thankyou_email)
            if (processor_general.Rows[0]["thankyou_email"].ToString().ToLower() == "true"
                &&
                emailaddress != "")
            {

                h_params.Clear();
                h_params.Add("questionnaire_id", processor_id);
                h_params.Add("email_type", "te");

                DataTable te_email = DB.execProc("select_email", h_params);
                string email_id;

                if (te_email.Rows.Count != 0 && processorpage.Rows[0]["email_label"].ToString() != "")
                {
                    email_id = te_email.Rows[0]["email_id"].ToString();
                }
                else
                {
                    email_id = "-1";
                }

                email.send_email(response_id, customer_data, email_id, null, post_params, processor_id, "", null, new StringCollection());
            }
            #endregion

            #region (send notification_email)
            if (processor_general.Rows[0]["notification_email"].ToString().ToLower() == "true")
                //&&
                //notification_recipients.Length != 0)
            {
                if (notification_recipients.Length != 0)
                {
                    notification_recipients = String.Format("{1}{0}", notification_recipients, email.EmailSeparator);
                }

                h_params.Clear();
                h_params.Add("questionnaire_id", processor_id);
                h_params.Add("email_type", "ne");

                DataTable ne_email = DB.execProc("select_email", h_params);
                string email_id;

                if (ne_email.Rows.Count != 0)
                {
                    email_id = ne_email.Rows[0]["email_id"].ToString();
                }
                else
                {
                    email_id = "-2";
                }

                email.send_email(response_id, customer_data, email_id, answers_for_ne, post_params, processor_id, notification_recipients, null, new StringCollection());
            }
            #endregion

            #region (send ASTRO2 notification_email)
            if (processor_general.Rows[0]["notification_email_astro2"].ToString().ToLower() == "true")
            //&&
            //notification_recipients.Length != 0)
            {
                if (notification_recipients.Length != 0)
                {
                    notification_recipients = String.Format("{1}{0}", notification_recipients, email.EmailSeparator);
                }

                h_params.Clear();
                h_params.Add("questionnaire_id", processor_id);
                h_params.Add("email_type", "an");

                DataTable ne_email = DB.execProc("select_email", h_params);
                string email_id;

                if (ne_email.Rows.Count != 0)
                {
                    email_id = ne_email.Rows[0]["email_id"].ToString();
                }
                else
                {
                    email_id = "-2";
                }

                email.send_email(response_id, customer_data, email_id, answers_for_ne, post_params, processor_id, notification_recipients, null, new StringCollection());
            }
            #endregion


            #region (redirect to nextpage (URL taken from posted Params))
            string nextPage = string.Empty;
            // RFG 2.20
            if(Company_Code== int.Parse(ConfigurationManager.AppSettings["Company_HPI"].ToString()))
             nextPage = String.Format("404.aspx?cc={0}&ll={1}", pid_country, pid_language);
            else
                nextPage = String.Format("404_e.aspx?cc={0}&ll={1}", pid_country, pid_language);

            if (myParams["aid_nextpage"] != null && myParams["aid_nextpage"] != "")
            {
                //Response.Redirect(myParams["aid_nextpage"], true);
                nextPage = myParams["aid_nextpage"];
            }
            string sCode = "302";
            if (myParams["RequiredHTTPStatus"] != null && myParams["RequiredHTTPStatus"] != "")
            {
               // Response.Redirect(String.Format("404.aspx?cc={0}&ll={1}", pid_country, pid_language), true);
                
                sCode=myParams["RequiredHTTPStatus"];                
            }

            CallRedirect(sCode, nextPage);

            #endregion

            //}

        }
		public utility.return_information validate_passwords()
		{
			#region validate content of fields
			bool valid = true;
			bool equal = true;

			string pwd_text = password_text.Trim();
			string pwdcfm_text = password_cfm_text.Trim();

			if (required.Text == "*")
			{
				if (pwd_text == "")
				{
					valid = valid & false;
				}
				if (pwdcfm_text == "")
				{
					valid = valid & false;
				}
				if (pwd_text != pwdcfm_text)
				{
					valid = valid & false;
					equal = false;
				}
			}
			else
			{
				if (pwd_text != pwdcfm_text)
				{
					valid = false;
					equal = false;
				}
			}
			#endregion

			#region highlight labels if not valid
			if (!valid)
			{
				//mark labels
				pwd_label.ForeColor = System.Drawing.Color.Red;
				pwdcf_label.ForeColor = System.Drawing.Color.Red;
				//first_row_cell.InnerHtml = "<font color=red>" + first_row_cell.InnerText.Replace("<font color=red>", "").Replace("</font>", "") + "</font>";
				//third_row_cell.InnerHtml = "<font color=red>" + third_row_cell.InnerText.Replace("<font color=red>", "").Replace("</font>", "") + "</font>";						
			}
			else
			{
				//demark labels
				pwd_label.ForeColor = System.Drawing.Color.Black;
				pwdcf_label.ForeColor = System.Drawing.Color.Black;
				//first_row_cell.InnerText = first_row_cell.InnerText.Replace("<font color=red>", "").Replace("</font>", "");
				//third_row_cell.InnerText = third_row_cell.InnerText.Replace("<font color=red>", "").Replace("</font>", "");
			}
			#endregion

			#region display error message if unequal
			if (!equal)
			{
				error_table.Visible = true;
			}
			else
			{
				error_table.Visible = false;
			}
			#endregion

			utility.return_information retvalue = new utility.return_information();

			retvalue.isValid = valid;
			retvalue.choice_id = password_field_cell.ID.Split('_')[2];
			retvalue.field_label = pwd_label.Text;
			//retvalue.field_label = first_row_cell.InnerText;
			retvalue.field_text = this.password_text;

			return retvalue;
		}
		virtual public utility.return_information[] validate_control()
		{
			utility.return_information[] retvalues = new utility.return_information[0];

			return retvalues;
		}
		public utility.return_information validate_control()
		{
			#region validate dd_mailto dropdown or literal
			bool valid = true;

            DataRow[] drOtherCoices = null;

            bool OtherChoiceValid = true;
			
			if (choices.Rows.Count != 1)
			{
				if (required)
				{
					if (dd_mailto.SelectedIndex == 0)
					{
						valid = valid & false;
					}
				}


                if (dd_mailto.SelectedIndex != 0)
                {
                    drOtherCoices = choices.Select("choice_id = '" + dd_mailto.SelectedValue + "' AND extra_textfield <>  ''");

                    if (drOtherCoices != null)
                    {
                        if (drOtherCoices.Length > 0)
                        {
                            if (tb_mailto != null)
                            {
                                if (tb_mailto.Visible.Equals(true))
                                {
                                    if (String.IsNullOrEmpty(tb_mailto.Text.Trim()))
                                    {
                                        OtherChoiceValid = false;
                                    }
                                    //††† 20110504 Biju Pattathil | RFG 2.3.2-MailTo Dropdown Others Receipent  Start†††
                                    //else
                                    //{
                                    //    if (!(Check_email_entries(tb_mailto.Text)))
                                    //            OtherChoiceValid = false;
                                    //}
                                    //††† 20110504 Biju Pattathil | RFG 2.3.2-MailTo Dropdown Others Receipent  End†††
                                }
                            }
                        }
                    }
                }

			}
			#endregion

			#region highlight label if not valid
			if (!valid)
			{
				//mark labels
				mailto_label.Text = String.Format("<font color=red>{0}</font>", mailto_label.Text);
			}
			else
			{
				//demark labels
				mailto_label.Text = mailto_label.Text.Replace("<font color=red>", "").Replace("</font>", "");
			}
			#endregion    

            #region highlight label if not valid
            if (!OtherChoiceValid)
            {
                //mark labels
                OtherChoice_label.Text = String.Format("<font color=red>{0}</font>", OtherChoice_label.Text);
            }
            else
            {
                //demark labels
                OtherChoice_label.Text = OtherChoice_label.Text.Replace("<font color=red>", "").Replace("</font>", "");
            }
            #endregion

			choices.PrimaryKey = new DataColumn[]{choices.Columns["choice_id"]};
			string choice_id = "";
			string mailto_recipient = "";
			string field_text = "";
            string OtherText = string.Empty;

			if (choices.Rows.Count == 1)
			{
				choice_id = hidden_mailto.Value;
				field_text = lt_mailto.Text;

                //TODO: ADD105 check impact?
                mailto_recipient = choices.Rows.Find(choice_id)["mailto_recipient"].ToString();
			}
			else
			{
                //TODO: ADD105 check impact?
                if (dd_mailto.SelectedIndex != 0)
                {
                    choice_id = dd_mailto.SelectedValue;
                    field_text = dd_mailto.SelectedItem.Text;
                    
                    mailto_recipient = choices.Rows.Find(choice_id)["mailto_recipient"].ToString();
                    
                    if(bOthertextExists)
                    {
                        if (tb_mailto.Visible.Equals(true))
                               OtherText = tb_mailto.Text;
                    }
                }
			}

            //TODO: ADD105 check impact?
			//mailto_recipient = choices.Rows.Find(choice_id)["mailto_recipient"].ToString();

			utility.return_information retvalue = new utility.return_information();

            if (!(OtherChoiceValid))
            {
                valid = OtherChoiceValid;
            }

            retvalue.isValid = valid;
			retvalue.choice_id = choice_id;
            retvalue.field_lov_FK = OtherText;
			retvalue.field_label = mailto_label.Text;
			retvalue.field_text = field_text;
            retvalue.mailto_recipient  = mailto_recipient;  

			return retvalue;
		}