/// <summary>
 /// Deserialize the properties from the datastore and 
 /// populate the local properties
 /// </summary>
 /// <param name="answerId">answer owner of the properties</param>
 protected virtual object Deserialize(int answerId)
 {
     byte[] buffer = new Answers().RestoreAnswerProperties(answerId);
     object obj2 = null;
     if (buffer != null)
     {
         MemoryStream serializationStream = null;
         try
         {
             serializationStream = new MemoryStream(buffer);
             obj2 = new BinaryFormatter().Deserialize(serializationStream);
         }
         catch (SerializationException)
         {
             obj2 = new Hashtable();
         }
         finally
         {
             if (serializationStream != null)
             {
                 serializationStream.Close();
             }
         }
     }
     return obj2;
 }
Exemple #2
0
        private Table GenerateFileList(string groupGuid, Style tableStyle)
        {
            Table table = Votations.NSurvey.BE.Votations.NSurvey.Constants.Commons.GetCentPercentTable();//JJ;

            table.ControlStyle.CopyFrom(tableStyle);
            table.Rows.Clear();
            FileData guidFiles = new Votations.NSurvey.DataAccess.Answers().GetGuidFiles(groupGuid);

            if (guidFiles.Files.Rows.Count > 0)
            {
                foreach (FileData.FilesRow row in guidFiles.Files)
                {
                    table.Rows.Add(this.GetFileRow(row.FileId, row.GroupGuid, row.FileSize, row.FileName, row.FileType));
                }
                return(table);
            }
            TableRow  row2 = new TableRow();
            TableCell cell = new TableCell();

            cell.Text = ResourceManager.GetString("NoFileUploadedMessage", base.LanguageCode);
            row2.Cells.Add(cell);
            table.Rows.Add(row2);
            return(table);
        }
		/// <summary>
		/// Generates the answers list for the question
		/// </summary>
		/// <param name="questionId"></param>
		/// <param name="onlyAnswered">show only answers that have been answered</param>
		string GenerateAnswersReport(int questionId, bool onlyAnswered, int sectionNumber)
		{
			StringBuilder answersReport = new StringBuilder();

			AnswerData questionAnswers = new Answers().GetAnswers(questionId, null);
			int longestTextLength = GetLongestAnswerLength(questionAnswers);

			foreach (AnswerData.AnswersRow answer in questionAnswers.Answers.Rows)
			{
				AnswerTypeMode typeMode = (AnswerTypeMode) answer.TypeMode;

				VoterAnswersData.VotersAnswersRow voterAnswer = _voterAnswers.VotersAnswers.FindByVoterIdAnswerIdSectionNumber(_voterAnswers.Voters[0].VoterId , answer.AnswerId, sectionNumber);
				string answerText = new PipeManager().PipeValuesInText(questionId, answer.AnswerText, _voterAnswers.VotersAnswers, null);

				if (voterAnswer != null)
				{

					// Check answer type
					if ((((typeMode & AnswerTypeMode.Field) > 0) || 
						((typeMode & AnswerTypeMode.Custom) > 0) ||
						((typeMode & AnswerTypeMode.DataSource) > 0)) &&
						((typeMode & AnswerTypeMode.Selection) == 0))
					{
						if (voterAnswer.AnswerText.Length > 0)
						{
							answersReport.Append(" " + answerText + GenerateMissingSpaces(answerText.Length, longestTextLength) + " " + voterAnswer.AnswerText + Environment.NewLine + "<br />");
						}
						else if (!onlyAnswered)
						{
							answersReport.Append(" " + answerText + GenerateMissingSpaces(answerText.Length, longestTextLength) + " " + ResourceManager.GetString("AnswerNotAnsweredMessage") + Environment.NewLine + "<br />");
						}
					}
					else if (((AnswerTypeMode)answer.TypeMode & AnswerTypeMode.Field) > 0 &&
							((AnswerTypeMode)answer.TypeMode & AnswerTypeMode.Selection) > 0)
					{
						answersReport.Append( " " + answerText + GenerateMissingSpaces(answerText.Length, longestTextLength) + " [x] " +voterAnswer.AnswerText+ Environment.NewLine + "<br />");
						_questionScore += answer.ScorePoint;
					}
					else if(((AnswerTypeMode)typeMode & AnswerTypeMode.Upload) > 0)
					{
						answersReport.Append( " " + answerText + GenerateMissingSpaces(answerText.Length, longestTextLength) + " " +GenerateFileList(voterAnswer.AnswerText)+ Environment.NewLine + "<br />");
					}

					else
					{
						answersReport.Append( " " + answerText + GenerateMissingSpaces(answerText.Length, longestTextLength) + " [x]" + Environment.NewLine + "<br />");
						_questionScore += answer.ScorePoint;
					}
				}
				else if (!onlyAnswered)
				{
					// Check answer type
					if ((((typeMode & AnswerTypeMode.Field) > 0) || 
						((typeMode & AnswerTypeMode.Custom) > 0) ||
						((typeMode & AnswerTypeMode.DataSource) > 0)) &&
						((typeMode & AnswerTypeMode.Selection) == 0))
					{
						answersReport.Append(" " + answerText + GenerateMissingSpaces(answerText.Length, longestTextLength) + " " + ResourceManager.GetString("AnswerNotAnsweredMessage")+ Environment.NewLine + "<br />");
					}
					else if ( ((AnswerTypeMode)answer.TypeMode & AnswerTypeMode.Field) > 0 &&
							((AnswerTypeMode)answer.TypeMode & AnswerTypeMode.Selection) > 0)
					{
						answersReport.Append( " " + answerText + GenerateMissingSpaces(answerText.Length, longestTextLength) + " [] " +ResourceManager.GetString("AnswerNotAnsweredMessage")+ Environment.NewLine + "<br />");
					}
					else
					{
						answersReport.Append( " " + answerText + GenerateMissingSpaces(answerText.Length, longestTextLength) + " []" + Environment.NewLine + "<br />");
					}

				}
			}

			return answersReport.ToString();
		}
		/// <summary>
		/// Bind the list and mark field answer 
		/// with a negative answer id value
		/// </summary>
		private void BindAnswerDropDownList()
		{
			AnswerData answers = new Answers().GetAnswersList(int.Parse(QuestionFilterDropdownlist.SelectedValue));
			AnswerFilterDropdownlist.Items.Clear();
			AnswerFilterDropdownlist.Items.Add(new ListItem(GetPageResource("AnyAnswerMessage"), "0"));

			foreach (AnswerData.AnswersRow answerRow in answers.Answers)
			{
				if ((((AnswerTypeMode)answerRow.TypeMode & AnswerTypeMode.Field) > 0) ||
					(((AnswerTypeMode)answerRow.TypeMode & AnswerTypeMode.Custom) > 0) ||
					(((AnswerTypeMode)answerRow.TypeMode & AnswerTypeMode.DataSource) > 0))
				{
					// Mark field answer with a negative answerid
					AnswerFilterDropdownlist.Items.Add(new ListItem(answerRow.AnswerText +" "+ GetPageResource("TextEntryInfo"), (-answerRow.AnswerId).ToString()));
				}
				else
				{
					AnswerFilterDropdownlist.Items.Add(new ListItem(answerRow.AnswerText +" "+ GetPageResource("SelectionInfo"), answerRow.AnswerId.ToString()));
				}
			}
		}
 /// <summary>
 /// Export the files of the survey to the directory and 
 /// returns the total of bytes exported
 /// </summary>
 public int ExportAnswerFilesToDirectory(int surveyId, string path, FileExportMode exportMode)
 {
     int num;
     int num2 = 0;
     Hashtable savedFiles = new Hashtable();
     foreach (FileData.FilesRow row in new Answers().GetValidatedFileAnswers(surveyId, 1, 10, out num).Files)
     {
         string str = path;
         if (exportMode == FileExportMode.VoterFileGroup)
         {
             if (!Directory.Exists(path + row.VoterId))
             {
                 Directory.CreateDirectory(path + row.VoterId);
             }
             str = path + row.VoterId + '/';
         }
         else if (exportMode == FileExportMode.GuidFileGroup)
         {
             if (!Directory.Exists(path + row.GroupGuid))
             {
                 Directory.CreateDirectory(path + row.GroupGuid);
             }
             str = path + row.GroupGuid + '/';
         }
         byte[] answerFileData = new Answers().GetAnswerFileData(row.FileId, row.GroupGuid);
         this.SaveFileToDisk(str, row.FileName, answerFileData, savedFiles);
         num2 += answerFileData.Length;
     }
     return num2;
 }
 protected virtual void GenerateFileList()
 {
    // return;
     //JJ Return so the File is not displayed in other surveys ad 
     this._fileTable.ControlStyle.Font.CopyFrom(base.AnswerStyle.Font);
     this._fileTable.ControlStyle.CssClass = "lddl"; 
     this._fileTable.Rows.Clear();
     FileData guidFiles = new Answers().GetGuidFiles(this.GroupGuid);
     if (guidFiles.Files.Rows.Count > 0)
     {
         foreach (FileData.FilesRow row in guidFiles.Files)
         {
             this._fileTable.Rows.Add(this.GetFileRow(row.FileId, row.GroupGuid, row.FileSize, row.FileName, row.FileType));
         }
     }
 }
        private Table GenerateFileList(string groupGuid)
        {
            Table fileTable = new Table();
            fileTable.CssClass = "smallText";
            fileTable.Rows.Clear();

            // Retrieve all files that are available for this group
            FileData answerFiles = new Answers().GetGuidFiles(groupGuid);

            if (answerFiles.Files.Rows.Count > 0)
            {
                foreach (FileData.FilesRow file in answerFiles.Files)
                {
                    fileTable.Rows.Add(GetFileRow(file.FileId, file.GroupGuid, file.FileSize, file.FileName, file.FileType));
                }
            }
            else
            {
                TableRow fileRow = new TableRow();
                TableCell fileCell = new TableCell();
                fileCell.Text = GetPageResource("NoFileUploadedMessage");
                fileRow.Cells.Add(fileCell);
                fileTable.Rows.Add(fileRow);
            }

            return fileTable;
        }
        private void BindMatrix(DataView childQuestions, PlaceHolder container, int sectionNumber)
        {
            Table selectionTable = new Table();
            TableRow	selectionRow = new TableRow(),
                        matrixHeaderRow = new TableRow();
            TableCell	selectionCell;	// Selection cell for the answer item
            bool generateHeader = true;	// Header generation in progress
            System.Web.UI.WebControls.Image spotImage = new System.Web.UI.WebControls.Image();

            selectionTable.CssClass = (sectionNumber%2) == 0 ?
                "innerText" : "alternatingSection" ;

            // Creates header's first empty cell
            TableCell answerHeaderCell = new TableCell();
            matrixHeaderRow.Cells.Add(answerHeaderCell);

            // Get all answer items available for this
            // question
            foreach (DataRowView questionRow in childQuestions)
            {
                selectionRow = new TableRow();
                TableCell questionCell = new TableCell();
                questionCell.VerticalAlign = VerticalAlign.Top;
                questionCell.Text = new PipeManager().PipeValuesInText(
                    int.Parse(questionRow["QuestionId"].ToString()),questionRow["QuestionText"].ToString(), _voterAnswers.VotersAnswers, null);

                selectionRow.Cells.Add(questionCell);

                // Parse the child question's answers
                AnswerData questionAnswers = new Answers().GetAnswers(int.Parse(questionRow["QuestionId"].ToString()), null);
                foreach (AnswerData.AnswersRow answer in questionAnswers.Answers)
                {
                    // New spot image
                    spotImage = new System.Web.UI.WebControls.Image();

                    // Creates a new answer text in the matrix header
                    if (generateHeader)
                    {
                        answerHeaderCell = new TableCell();
                        answerHeaderCell.VerticalAlign = VerticalAlign.Top;
                        answerHeaderCell.HorizontalAlign = HorizontalAlign.Center;
                        answerHeaderCell.Wrap = false;
                        answerHeaderCell.Text =
                            new PipeManager().PipeValuesInText(answer.QuestionId, answer.AnswerText, _voterAnswers.VotersAnswers, null);
                        matrixHeaderRow.Cells.Add(answerHeaderCell);
                    }

                    // Add a new selection to the matrix's child question
                    selectionCell = new TableCell();
                    selectionCell.VerticalAlign = VerticalAlign.Top;
                    selectionCell.HorizontalAlign = HorizontalAlign.Center;
                    selectionCell.Wrap = false;

                    // Check if the voter has answered this answer
                    VoterAnswersData.VotersAnswersRow voterAnswer = _voterAnswers.VotersAnswers.FindByVoterIdAnswerIdSectionNumber(_voterId, answer.AnswerId, sectionNumber);
                    if (voterAnswer != null)
                    {
                        // Check answer type
                        if ((((AnswerTypeMode)answer.TypeMode & AnswerTypeMode.Field) > 0) ||
                            (((AnswerTypeMode)answer.TypeMode & AnswerTypeMode.Custom) > 0) ||
                            (((AnswerTypeMode)answer.TypeMode & AnswerTypeMode.DataSource) > 0))
                        {
                            selectionCell.Text = FormatVoterAnswer(null, voterAnswer.AnswerText,true);
                        }
                        else if(((AnswerTypeMode)answer.TypeMode & AnswerTypeMode.Upload) > 0)
                        {
                            selectionCell.Controls.Add(GenerateFileList(voterAnswer.AnswerText));
                        }
                        else
                        {
                            spotImage.ImageUrl = "images/spot_on.gif";
                            selectionCell.Controls.Add(spotImage);
                        }
                    }
                    else
                    {
                        // Check answer type
                        if ((((AnswerTypeMode)answer.TypeMode & AnswerTypeMode.Field) > 0)  ||
                            (((AnswerTypeMode)answer.TypeMode & AnswerTypeMode.Custom) > 0) ||
                            (((AnswerTypeMode)answer.TypeMode & AnswerTypeMode.DataSource) > 0))
                        {
                            selectionCell.Text = FormatVoterAnswer(null,null,false);
                        }
                        else if(((AnswerTypeMode)answer.TypeMode & AnswerTypeMode.Upload) > 0)
                        {
                            selectionCell.Text = GetPageResource("NoFileUploadedMessage");
                        }
                        else
                        {
                            spotImage.ImageUrl = "images/spot_off.gif";
                            selectionCell.Controls.Add(spotImage);
                        }
                    }

                    selectionRow.Cells.Add(selectionCell);
                }

                // Generates the answer text header
                if (generateHeader)
                {
                    selectionTable.Rows.Add(matrixHeaderRow);
                    generateHeader = false;
                }

                selectionTable.Rows.Add(selectionRow);
            }

            selectionTable.Width = Unit.Percentage(100);

            container.Controls.Add(selectionTable);
        }
		/// <summary>
		/// Get the current DB data and fill 
		/// the fields with them
		/// </summary>
		private void BindFields()
		{
			AnswerData answer = new Answers().GetAnswerById(AnswerId, LanguageCode);
			AnswerTextTextBox.Text = answer.Answers[0].AnswerText;
			AnswerImageURLTextBox.Text = answer.Answers[0].ImageURL;
			DefaultTextTextBox.Text = answer.Answers[0].DefaultText;
			AnswerPipeAliasTextBox.Text = answer.Answers[0].AnswerPipeAlias;
			SelectionCheckBox.Checked = answer.Answers[0].Selected;
			if (AnswerTypeDropDownList.Items.FindByValue(answer.Answers[0].AnswerTypeId.ToString()) != null)
			{
				AnswerTypeDropDownList.SelectedValue = answer.Answers[0].AnswerTypeId.ToString();
			}
			RatingPartCheckbox.Checked = answer.Answers[0].RatePart;
			RatingPartCheckbox.Visible = RatingEnabled;
			AnswerRatingLabel.Visible = RatingEnabled;
			ScoreTextBox.Text = answer.Answers[0].ScorePoint.ToString();
			ScoreTextBox.Visible = ScoreEnabled;
			ScoreLabel.Visible = ScoreEnabled;
			MandatoryCheckBox.Checked = answer.Answers[0].Mandatory;
			if (!answer.Answers[0].IsRegularExpressionIdNull())
			{
				RegExDropDownList.SelectedValue = answer.Answers[0].RegularExpressionId.ToString();
			}
            txtAnswerAlias.Text = answer.Answers[0].AnswerAlias;
            txtAnswerID.Text = answer.Answers[0].AnswerIDText;

            SliderRangeDDL.SelectedValue = answer.Answers[0].SliderRange;

            SliderValueTextBox.Text = Convert.ToString(answer.Answers[0].SliderValue);
            SliderMinTextBox.Text = Convert.ToString(answer.Answers[0].SliderMin);
            SliderMaxTextBox.Text = Convert.ToString(answer.Answers[0].SliderMax);
            SliderAnimateCheckbox.Checked = answer.Answers[0].SliderAnimate;
            SliderStepTextBox.Text = Convert.ToString(answer.Answers[0].SliderStep);
            
			SetUIState(answer.Answers[0].TypeMode, false);
		}
		void BuildCrossTabTabe()
		{
			AnswerData 
				baseAnswers = new Answers().GetSelectableAnswers(int.Parse(BaseQuestionDropDownList.SelectedValue)),
				compareAnswers = new Answers().GetSelectableAnswers(int.Parse(CompareQuestionDropDownList.SelectedValue));

			int compareQuestionId = int.Parse(CompareQuestionDropDownList.SelectedValue),
				baseQuestionId = int.Parse(BaseQuestionDropDownList.SelectedValue);

			DataSet totalCountData = new Questions().GetTotalCrossTabResults(compareQuestionId, baseQuestionId);


			Table crossTable = new Table();
			crossTable.CssClass = "crossTabTable";

			crossTable.Rows.Add(GenerateTableHeader(compareAnswers));

			crossTable.Rows.Add(GenerateNotAnsweredRow(compareQuestionId, baseQuestionId, totalCountData));

			foreach (AnswerData.AnswersRow answer in baseAnswers.Answers.Rows)
			{
				crossTable.Rows.Add(GenerateBaseRow(answer, compareQuestionId, totalCountData));
			}

			if (totalCountData.Tables.Count > 0)
			{
				TableRow breakRow= new TableRow();
				TableCell breakCell = new TableCell();
				breakCell.ColumnSpan = totalCountData.Tables[0].Rows.Count + 1;
                breakCell.Text = "&nbsp;";
				breakRow.Cells.Add(breakCell);
				crossTable.Rows.Add(breakRow);
			}

			crossTable.Rows.Add(GenerateTotalRow(totalCountData));
				
			CrossTabResultsPlaceHolder.Controls.Add(crossTable);
		}
        protected override void CreateChildControls()
        {
            // add original jquery .js slider script:

            AnswerData answer = new Answers().GetAnswerById(AnswerId, LanguageCode);

            string SliderScript = ""; 
            SliderScript = 
                "<script type='text/javascript'>"+
                "$(function () { $('#slider-range-min-"+Convert.ToString(answer.Answers[0].AnswerId)
                +"').slider({ orientation: 'horizontal', " 
                + "animate:"+ Convert.ToString(answer.Answers[0].SliderAnimate).ToLower() 
                + ", range:'" +answer.Answers[0].SliderRange+ "', value:"
                + Convert.ToString(answer.Answers[0].SliderValue)
                + ", min:"+Convert.ToString(answer.Answers[0].SliderMin) 
                + ", max:"+Convert.ToString(answer.Answers[0].SliderMax) 
                + ", step:"+Convert.ToString(answer.Answers[0].SliderStep)
                + ", slide: function (event, ui) { $('#amount"+Convert.ToString(answer.Answers[0].AnswerId)
                + "').val('' + ui.value); }  });  $('#amount"+Convert.ToString(answer.Answers[0].AnswerId)
                +"').val('' + $('#slider-range-min-"+Convert.ToString(answer.Answers[0].AnswerId)
                + "').slider('value')); });"
                + "</script>";

            // second version of jquery .js slider script to correct override "default value" field and keep state:

            string SliderScriptState = "";
            SliderScriptState =
                "<script type='text/javascript'>" +
                "$(function () { $('#slider-range-min-" + Convert.ToString(answer.Answers[0].AnswerId)
                + "').slider({ orientation: 'horizontal', "
                + "animate:" + Convert.ToString(answer.Answers[0].SliderAnimate).ToLower()
                + ", range:'" + answer.Answers[0].SliderRange + "', value:"
                + this.DefaultText
                + ", min:" + Convert.ToString(answer.Answers[0].SliderMin)
                + ", max:" + Convert.ToString(answer.Answers[0].SliderMax)
                + ", step:" + Convert.ToString(answer.Answers[0].SliderStep)
                + ", slide: function (event, ui) { $('#amount" + Convert.ToString(answer.Answers[0].AnswerId)
                + "').val('' + ui.value); }  });  $('#amount" + Convert.ToString(answer.Answers[0].AnswerId)
                + "').val('' + $('#slider-range-min-" + Convert.ToString(answer.Answers[0].AnswerId)
                + "').slider('value')); });"
                + "</script>";
            
            // add secundary jquery scripts:
           this.Page.ClientScript.RegisterClientScriptInclude(this.GetType(), "jquery.ui.core.js", ResolveUrl("~/Scripts/Javascript/ui/jquery.ui.core.js") );
           this.Page.ClientScript.RegisterClientScriptInclude(this.GetType(), "jquery.ui.widget.js", ResolveUrl("~/Scripts/Javascript/ui/jquery.ui.widget.js"));
           this.Page.ClientScript.RegisterClientScriptInclude(this.GetType(), "jquery.ui.mouse.js", ResolveUrl("~/Scripts/Javascript/ui/jquery.ui.mouse.js"));


            // add .css files:
           this.Page.Header.Controls.Add(new LiteralControl(Environment.NewLine));

           HtmlGenericControl css = new HtmlGenericControl("link");
           css.Attributes.Add("rel", "stylesheet");
           css.Attributes.Add("type", "text/css");
           css.Attributes.Add("href", ResolveUrl("~/Scripts/css/ui-core-base/jquery.ui.all.css"));
           Page.Header.Controls.Add(css);

           css = new HtmlGenericControl("link");
           css.Attributes.Add("rel", "stylesheet");
           css.Attributes.Add("type", "text/css");
           //css.Attributes.Add("href", ResolveUrl("~/Scripts/css/custom-theme/jquery-ui-1.8.12.custom.css"));
           css.Attributes.Add("href", ResolveUrl("~/Scripts/css/base/jquery.ui.all.css"));
           Page.Header.Controls.Add(css);

           css = new HtmlGenericControl("link");
           css.Attributes.Add("rel", "stylesheet");
           css.Attributes.Add("type", "text/css");
           css.Attributes.Add("href", ResolveUrl("~/Scripts/javascript/slider/slider.css"));
           Page.Header.Controls.Add(css);


            // add .js scripts if survey not taken inside SP tool:
           if (this.Page.Request.Path.Contains("survey.aspx"))
            {
           Page.Header.Controls.Add(new LiteralControl(Environment.NewLine));

           HtmlGenericControl javascriptControl = new HtmlGenericControl("script");
           javascriptControl.Attributes.Add("type", "text/Javascript");
           javascriptControl.Attributes.Add("src", ResolveUrl("~/Scripts/JavaScript/01_jquery/jquery-1.11.1.js"));
           Page.Header.Controls.Add(javascriptControl);

           Page.Header.Controls.Add(new LiteralControl(Environment.NewLine));

           javascriptControl = new HtmlGenericControl("script");
           javascriptControl.Attributes.Add("type", "text/Javascript");
           javascriptControl.Attributes.Add("src", ResolveUrl("~/Scripts/JavaScript/ui/jquery-ui-1.10.4.js"));
           Page.Header.Controls.Add(javascriptControl);

           Page.Header.Controls.Add(new LiteralControl(Environment.NewLine));
            }

           //if (this.Page.Request.Path.Contains("surveymobile.aspx"))
           //{
           //    Page.Header.Controls.Add(new LiteralControl(Environment.NewLine));

           //    HtmlGenericControl javascriptControl = new HtmlGenericControl("script");
           //    javascriptControl.Attributes.Add("type", "text/Javascript");
           //    javascriptControl.Attributes.Add("src", ResolveUrl("~/Scripts/JavaScript/ui/jquery-ui-1.10.4.js"));
           //    Page.Header.Controls.Add(javascriptControl);

           //    Page.Header.Controls.Add(new LiteralControl(Environment.NewLine));
           //}


            // choose scriptversion depending on state and default value:
            if(this.DefaultText == answer.Answers[0].DefaultText )
            {
            this.Controls.Add(new LiteralControl(SliderScript));
            }
            else if (this.DefaultText == null)
            {
                this.Controls.Add(new LiteralControl(SliderScript));
            }
            else
            {
                this.Controls.Add(new LiteralControl(SliderScriptState));
            }

            // add html to add slideranswer to webpage:
            this.Controls.Add(new LiteralControl("<br /><div class='demo'>"));

            base.CreateChildControls();
            base._fieldTextBox.TextMode = TextBoxMode.SingleLine;
            base._fieldTextBox.Attributes.Add("value", this.DefaultText);
            base._fieldTextBox.Attributes.Add("id", "amount"+Convert.ToString(answer.Answers[0].AnswerId));
            base._fieldTextBox.Attributes.Add("style", "border:0; color:#f6931f; font-weight:bold;");

            //this.Controls.Add(new LiteralControl("<div id=\"slider-range-min\"></div></div><br />"));                 
            this.Controls.Add(new LiteralControl("<div id=\"slider-range-min-"));
            this.Controls.Add(new LiteralControl(Convert.ToString(answer.Answers[0].AnswerId)));
            this.Controls.Add(new LiteralControl("\"></div></div><br />"));

        }
        private void BindAnswerOptions()
        {
            _answerTypes = new AnswerTypes().GetAnswerTypes();
            _answers = new Answers().GetAnswers(_questionId, LanguagesDropdownlist.SelectedValue);
            if (_answers.Answers.Rows.Count > 0)
            {
                AnswersDataGrid.Visible = true;
                AnswersDataGrid.DataSource = _answers;
                AnswersDataGrid.DataMember = "Answers";
                AnswersDataGrid.DataKeyField = "AnswerId";
                AnswersDataGrid.DataBind();
            }
            else
            {
                AnswersDataGrid.Visible = false;
            }

        }
        /// <summary>
        /// Returns the check box status to the event subscribers 
        /// once the survey's page get posted
        /// </summary>
        protected override PostedAnswerDataCollection GetPostedAnswerData()
        {
            int answerFileCount = new Answers().GetAnswerFileCount(this.GroupGuid);
            if (this.Mandatory && (answerFileCount == 0))
            {
                this.OnInvalidAnswer(new AnswerItemInvalidEventArgs(string.Format(ResourceManager.GetString("UploadFileRequiredMessage", base.LanguageCode), this.Text)));
            }
            PostedAnswerDataCollection datas = new PostedAnswerDataCollection();
            datas.Add(new PostedAnswerData(this, this.AnswerId, base.SectionContainer.SectionNumber, this.GroupGuid, AnswerTypeMode.ExtendedType | AnswerTypeMode.Upload | AnswerTypeMode.Mandatory));

            return datas;
        }
		private string GenerateFileList(string groupGuid)
		{
			StringBuilder fileList = new StringBuilder();
			
			// Retrieve all files that are available for this group
			FileData answerFiles = new Answers().GetGuidFiles(groupGuid);

			if (answerFiles.Files.Rows.Count > 0)
			{
				for (int i=0; i<answerFiles.Files.Count;i++)
				{
					fileList.Append(answerFiles.Files[i].FileName + " (" + (Math.Round((double)answerFiles.Files[i].FileSize/1048576*100000)/100000).ToString("0.##") + ResourceManager.GetString("UploadFileSizeFormat") + ")");

					if (i+1<answerFiles.Files.Count)
					{
						fileList.Append(", ");
					}
				}
			}

			return fileList.ToString();
		}
		private void SetExtendedProperties()
		{		
			AnswerData answers = new Answers().GetAnswerById(AnswerId, null);
			ExtendedPropertiesPlaceholder.Controls.Clear();

			if (((AnswerTypeMode)answers.Answers[0].TypeMode & AnswerTypeMode.ExtendedType) > 0)
			{

				ExtendedPlaceholder.Visible = true;
				ExtendedPropertiesPlaceholder.Visible = true;
				AnswerItem answerItem = 
					AnswerItemFactory.Create(answers.Answers[0], null, null, AnswerSelectionMode.None, null,
					ControlRenderMode.Edit, null, UniqueID, true, null, true);

				ExtendedAnswerItem extendedItem = answerItem as ExtendedAnswerItem; 

				if (extendedItem != null)
				{
					extendedItem.RestoreProperties();
					ExtendedPropertiesPlaceholder.Controls.Add(extendedItem.GeneratePropertiesUI());
				}
			}
			else
			{
				ExtendedPropertiesPlaceholder.Controls.Clear();
				ExtendedPropertiesPlaceholder.Visible = false;
				ExtendedPlaceholder.Visible = false;
			}
		}
        private void BindAnswerOptions()
        {
            if (NSurveyUser.Identity.IsAdmin ||
                NSurveyUser.Identity.HasAllSurveyAccess)
            {
                _answerTypes = new AnswerTypes().GetAnswerTypesList();
            }
            else
            {
                _answerTypes =
                    new AnswerTypes().GetAssignedAnswerTypesList(NSurveyUser.Identity.UserId, getSurveyId());
            }

            AnswerTypeDropDownList.DataSource = _answerTypes;
            AnswerTypeDropDownList.DataMember = "AnswerTypes";
            AnswerTypeDropDownList.DataTextField = "Description";
            AnswerTypeDropDownList.DataValueField = "AnswerTypeID";
            AnswerTypeDropDownList.DataBind();
            TranslateListControl(AnswerTypeDropDownList);
            AnswerTypeDropDownList.Items.Insert(0,
                new ListItem(GetPageResource("SelectTypeMessage"), "-1"));
            AnswerTypeDropDownList.SelectedValue = "1";
            _answers = new Answers().GetAnswers(_parentQuestionId, ChildsLanguageDropdownlist.SelectedValue);
            ColsDataGrid.Columns[2].Visible = RatingCheckbox.Checked;
            ColsDataGrid.DataSource = _answers;
            ColsDataGrid.DataMember = "Answers";
            ColsDataGrid.DataKeyField = "AnswerId";
            ColsDataGrid.DataBind();
        }
		private void UpdateAnswerButton_Click(object sender, System.EventArgs e)
		{
			int oldTypeMode = new Answers().GetAnswerTypeMode(AnswerId);
			
			// Create the updated BE
			AnswerData answer = new AnswerData();
			AnswerData.AnswersRow updatedAnswer = answer.Answers.NewAnswersRow();

			updatedAnswer.AnswerText = AnswerTextTextBox.Text;
			updatedAnswer.ImageURL = AnswerImageURLTextBox.Text;
			updatedAnswer.AnswerTypeId = 
				int.Parse(AnswerTypeDropDownList.SelectedValue);
			updatedAnswer.RatePart = RatingPartCheckbox.Checked;
			updatedAnswer.AnswerId = AnswerId;
            updatedAnswer.AnswerIDText = txtAnswerID.Text;
            updatedAnswer.AnswerAlias = txtAnswerAlias.Text;

            updatedAnswer.SliderRange = SliderRangeDDL.SelectedValue.ToString();
            updatedAnswer.SliderValue = int.Parse(SliderValueTextBox.Text);
            updatedAnswer.SliderMin = int.Parse(SliderMinTextBox.Text);
            updatedAnswer.SliderMax = int.Parse(SliderMaxTextBox.Text);
            updatedAnswer.SliderAnimate = SliderAnimateCheckbox.Checked;
            updatedAnswer.SliderStep = int.Parse(SliderStepTextBox.Text);

			if (DefaultTextTextBox.Text.Length>0)
			{
				updatedAnswer.DefaultText = DefaultTextTextBox.Text;
			}
			else
			{
				updatedAnswer.SetDefaultTextNull();
			}
			updatedAnswer.Selected = SelectionCheckBox.Checked;
			updatedAnswer.ScorePoint = Information.IsNumeric(ScoreTextBox.Text) ?
				int.Parse(ScoreTextBox.Text) : 0;
			updatedAnswer.AnswerPipeAlias = AnswerPipeAliasTextBox.Text;
			updatedAnswer.Mandatory = MandatoryCheckBox.Checked;
			if (RegExDropDownList.SelectedIndex > 0)
			{
				updatedAnswer.RegularExpressionId = int.Parse(RegExDropDownList.SelectedValue);
			}
			answer.Answers.AddAnswersRow(updatedAnswer);
			new Answer().UpdateAnswer(answer, LanguageCode);
			
			int newTypeMode = new Answers().GetAnswerTypeMode(AnswerId);
			
			// Check if need to delete persisted properties if it was
			// previously an extended item
			if (oldTypeMode != newTypeMode && ((AnswerTypeMode)oldTypeMode & AnswerTypeMode.ExtendedType)>0)
			{
				new Answer().DeleteAnswerProperties(AnswerId);
			}

			MessageLabel.Visible = true;
            ((PageBase)Page).ShowNormalMessage(MessageLabel,((PageBase)Page).GetPageResource("SelectionUpdatedMessage"));

			SetUIState(newTypeMode, false);

			// Let the subscribers know that something changed
			OnOptionChanged();

		}
        private void BindQuestions(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                int questionId = int.Parse(QuestionsDataGrid.DataKeys[e.Item.ItemIndex].ToString());

                // Check if the question has childs
                string filter = string.Format("ParentQuestionID = {0}", questionId);
                DataView childQuestions =
                    new DataView(_questionData.Questions,filter,"DisplayOrder", DataViewRowState.CurrentRows);
                if (childQuestions.Count == 0)
                {
                    DataGrid answerDataGrid = (DataGrid)e.Item.Cells[0].FindControl("QuestionAnswersDataGrid");
                    AnswerData questionAnswers = new Answers().GetAnswers(questionId, null);
                    for (int sectionNumber=0;sectionNumber<=GetQuestionSectionCount(questionId);sectionNumber++)
                    {
                        BindAnswerTable(questionAnswers,(PlaceHolder)e.Item.Cells[0].FindControl("QuestionAnswerPlaceHolder")
                            , sectionNumber);

                        Label scoreTotalLabel = (Label)e.Item.Cells[0].FindControl("QuestionScoreLabel");
                        if (isScored)
                        {
                            scoreTotalLabel.Text = string.Format("<br />" +GetPageResource("QuestionScoreLabel")+ _questionScore);
                        }
                        _totalScore += _questionScore;
                        _questionScore = 0;
                    }
                }
                else
                {
                    for (int sectionNumber=0;sectionNumber<=GetMatrixSectionCount(childQuestions);sectionNumber++)
                    {
                        BindMatrix(childQuestions,
                            (PlaceHolder)e.Item.Cells[0].FindControl("MatrixPlaceHolder"), sectionNumber);
                    }
                }
            }
        }
 private Table GenerateFileList(string groupGuid, Style tableStyle)
 {
     Table table = Votations.NSurvey.BE.Votations.NSurvey.Constants.Commons.GetCentPercentTable();//JJ;
     table.ControlStyle.CopyFrom(tableStyle);
     table.Rows.Clear();
     FileData guidFiles = new Votations.NSurvey.DataAccess.Answers().GetGuidFiles(groupGuid);
     if (guidFiles.Files.Rows.Count > 0)
     {
         foreach (FileData.FilesRow row in guidFiles.Files)
         {
             table.Rows.Add(this.GetFileRow(row.FileId, row.GroupGuid, row.FileSize, row.FileName, row.FileType));
         }
         return table;
     }
     TableRow row2 = new TableRow();
     TableCell cell = new TableCell();
     cell.Text = ResourceManager.GetString("NoFileUploadedMessage", base.LanguageCode);
     row2.Cells.Add(cell);
     table.Rows.Add(row2);
     return table;
 }
        /// <summary>
        /// Sends the file to the client
        /// </summary>
        private void SendFile(int fileId, string groupGuid, string fileName, string fileType)
        {
            Byte[] fileData = new Answers().GetAnswerFileData(fileId, groupGuid);

            // Clear buffer and send the file
            Context.Response.Clear();
            Context.Response.ContentType = fileType != null && fileType.Length > 0 ?
                fileType : "application/octet-stream";
            Context.Response.AddHeader("Content-Disposition", "attachment; filename=\""+fileName+"\"");
            Context.Response.BinaryWrite(fileData);
            Context.Response.End();
        }
 /// <summary>
 /// Sends the file to the client
 /// </summary>
 protected virtual void downloadButton_Command(object sender, CommandEventArgs e)
 {
     string[] strArray = e.CommandArgument.ToString().Split(new char[] { ',' });
     byte[] answerFileData = new Answers().GetAnswerFileData(int.Parse(strArray[0]), strArray[1]);
     this.Context.Response.Clear();
     this.Context.Response.ContentType = ((strArray[3] != null) && (strArray[3].Length > 0)) ? strArray[3] : "application/octet-stream";
     this.Context.Response.AddHeader("Content-Disposition", "attachment; filename=\"" + strArray[2] + "\"");
     this.Context.Response.BinaryWrite(answerFileData);
     this.Context.Response.End();
 }