/// <summary> /// Parse an MatrixChildCollection, converts the data /// to webcontrols and returns a filled matrix section /// </summary> protected override MatrixSection GetMatrixSection(MatrixChildQuestionData childQuestions, int sectionNumber, int sectionUid) { MatrixSection sectionContainer = new MatrixSection(); sectionContainer.SectionUid = sectionUid; sectionContainer.SectionNumber = sectionNumber; sectionContainer.ChildQuestions = QuestionItemFactory.CreateQuestionChildCollection(childQuestions, sectionContainer, base.LanguageCode, this.UniqueID + GlobalConfig.AnswerSectionName + sectionUid, AnswerSelectionMode.CheckBox, base.AnswerStyle, base.RenderMode, base.VoterAnswersState, base.EnableAnswersDefault); return sectionContainer; }
/// <summary> /// Converts a stronlgy typed MatrixChildQuestionData dataset /// to a webcontrol collection /// </summary> /// <param name="childQuestions">The questions / answers data</param> /// <param name="parentControlUniqueID"> /// Unique ID required to identify global groups /// like radiobutton groups /// </param> /// <returns>a web control collection of MatrixChildQuestion</returns> public static MatrixChildCollection CreateQuestionChildCollection(MatrixChildQuestionData childQuestions, Section sectionContainer, string languageCode, string parentControlUniqueID, AnswerSelectionMode selectionMode, Style answerStyle, ControlRenderMode renderMode, VoterAnswersData.VotersAnswersDataTable voterAnswersState, bool enableAnswersDefault) { MatrixChildCollection childs = new MatrixChildCollection(); foreach (MatrixChildQuestionData.ChildQuestionsRow row in childQuestions.ChildQuestions.Rows) { MatrixChildQuestion question = new MatrixChildQuestion(); question.QuestionId = row.QuestionId; question.Text = new PipeManager().PipeValuesInText(row.QuestionId, row.QuestionText, voterAnswersState, languageCode); AnswerData answers = new AnswerData(); // answers.Merge(row.GetAnswersRows()); MatrixChildQuestionData.AnswersRow[] ar = row.GetAnswersRows(); foreach (MatrixChildQuestionData.AnswersRow r in ar) { r.Table.Namespace = answers.Namespace; } answers.Merge(ar); question.Answers = AnswerItemFactory.CreateAnswerItemCollection(answers, question, sectionContainer, selectionMode, answerStyle, renderMode, languageCode, parentControlUniqueID, false, voterAnswersState, enableAnswersDefault); childs.Add(question); } return childs; }
private void AddRowButton_Click(object sender, System.EventArgs e) { if (NewRowTextBox.Text.Length == 0) { MessageLabel.Visible = true; ((PageBase)Page).ShowErrorMessage(MessageLabel, ((PageBase)Page).GetPageResource("RowMissingQuestiondMessage")); } else { MatrixChildQuestionData childQuestion = new MatrixChildQuestionData(); MatrixChildQuestionData.ChildQuestionsRow updatedChildQuestion = childQuestion.ChildQuestions.NewChildQuestionsRow(); updatedChildQuestion.ParentQuestionId = _parentQuestionId; updatedChildQuestion.QuestionText = NewRowTextBox.Text; childQuestion.ChildQuestions.AddChildQuestionsRow(updatedChildQuestion); new Question().AddChildQuestion(childQuestion); BindChildQuestions(); MessageLabel.Visible = true; ((PageBase)Page).ShowNormalMessage(MessageLabel, ((PageBase)Page).GetPageResource("MatrixRowAddedMessage")); NewRowTextBox.Text = string.Empty; } }
private void RowsDataGrid_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { TextBox updatedChildText = ((TextBox)e.Item.Cells[0].Controls[0]); if (updatedChildText.Text.Length == 0) { MessageLabel.Visible = true; ((PageBase)Page).ShowErrorMessage(MessageLabel, ((PageBase)Page).GetPageResource("RowMissingQuestionMessage")); } else { MatrixChildQuestionData childQuestion = new MatrixChildQuestionData(); MatrixChildQuestionData.ChildQuestionsRow updatedChildQuestion = childQuestion.ChildQuestions.NewChildQuestionsRow(); updatedChildQuestion.QuestionId = int.Parse(RowsDataGrid.DataKeys[e.Item.ItemIndex].ToString()); updatedChildQuestion.QuestionText = updatedChildText.Text; childQuestion.ChildQuestions.AddChildQuestionsRow(updatedChildQuestion); new Question().UpdateChildQuestion(childQuestion, ChildsLanguageDropdownlist.SelectedValue); RowsDataGrid.EditItemIndex = -1; BindChildQuestions(); MessageLabel.Visible = true; ((PageBase)Page).ShowNormalMessage(MessageLabel, ((PageBase)Page).GetPageResource("MatrixRowUpdatedMessage")); } }
private void BindChildQuestions() { MatrixChildQuestionData childQuestions = new MatrixChildQuestionData(); childQuestions = new Questions().GetMatrixChildQuestions(_parentQuestionId, ChildsLanguageDropdownlist.SelectedValue); RowsDataGrid.DataSource = childQuestions; RowsDataGrid.DataMember = "ChildQuestions"; RowsDataGrid.DataKeyField = "QuestionID"; RowsDataGrid.DataBind(); }
/// <summary> /// Adds a new child question to the parent question specified by the parent questio id in the database /// </summary> /// <param name="newChildQuestion">Question object with information about what to add. Only Id must be ommited</param> public void AddChildQuestion(MatrixChildQuestionData newChildQuestion) { QuestionFactory.Create().AddChildQuestion(newChildQuestion); }
/// <summary> /// Update the child question in the database /// </summary> /// <param name="updatedChildQuestion">question to update, must contain the question id</param> public void UpdateChildQuestion(MatrixChildQuestionData updatedChildQuestion, string languageCode) { QuestionFactory.Create().UpdateChildQuestion(updatedChildQuestion, languageCode); }
/// <summary> /// Adds a new child question to the parent question specified by the parent questio id in the database /// </summary> /// <param name="newChildQuestion">Question object with information about what to add. Only Id must be ommited</param> public void AddChildQuestion(MatrixChildQuestionData newChildQuestion) { SqlConnection sqlConnection = new SqlConnection(DbConnection.NewDbConnectionString); DbConnection.db.UpdateDataSet(newChildQuestion, "ChildQuestions", this.GetInsertChildQuestionCommand(sqlConnection, null), new SqlCommand(), new SqlCommand(), UpdateBehavior.Transactional); }
/// <summary> /// Returns all question childs from the question /// </summary> /// <param name="parentQuestionId">Question id from which you want to retrieve the child questions</param> /// <returns>A question object collection</returns> public MatrixChildQuestionData GetMatrixChildQuestions(int parentQuestionId, string languageCode) { //SqlParameter[] commandParameters = new SqlParameter[] //{ new SqlParameter("@ParentQuestionId", parentQuestionId), // new SqlParameter("@LanguageCode", languageCode) //}; ArrayList commandParameters = new ArrayList(); { commandParameters.Add(new SqlParameter("@ParentQuestionId", parentQuestionId).SqlValue); commandParameters.Add(new SqlParameter("@LanguageCode", languageCode).SqlValue); } MatrixChildQuestionData dataSet = new MatrixChildQuestionData(); DbConnection.db.LoadDataSet("vts_spQuestionsGetMatrixChilds", dataSet, new string[] { "ChildQuestions", "Answers" }, commandParameters.ToArray()); return dataSet; }
public void RemoveAnswersRow(MatrixChildQuestionData.AnswersRow row) { base.Rows.Remove(row); }
/// <summary> /// Update the child question in the database /// </summary> /// <param name="updatedChildQuestion">question to update, must contain the question id</param> public void UpdateChildQuestion(MatrixChildQuestionData updatedChildQuestion, string languageCode) { SqlConnection connection = new SqlConnection(DbConnection.NewDbConnectionString); SqlCommand insertCommand = new SqlCommand("vts_spQuestionChildUpdate", connection); insertCommand.CommandType = CommandType.StoredProcedure; insertCommand.Parameters.Add(new SqlParameter("@ChildQuestionId", SqlDbType.Int, 4, "QuestionId")); insertCommand.Parameters.Add(new SqlParameter("@QuestionText", SqlDbType.NVarChar, 0xfa0, "QuestionText")); insertCommand.Parameters.Add(new SqlParameter("@LanguageCode", languageCode)); DbConnection.db.UpdateDataSet(updatedChildQuestion, "ChildQuestions", insertCommand, new SqlCommand(), insertCommand, UpdateBehavior.Transactional); }
public MatrixChildQuestionData.AnswersRow AddAnswersRow(MatrixChildQuestionData.ChildQuestionsRow parentChildQuestionsRowByChildQuestionAnswers, string AnswerText, string ImageUrl, int TypeMode, int FieldWidth, int FieldLength, int FieldHeight, int VoteCount, string XmlDatasource, bool Selected, string DefaultText, bool UserSelected, string UserText, string DataSource, bool Mandatory) { MatrixChildQuestionData.AnswersRow row = (MatrixChildQuestionData.AnswersRow) base.NewRow(); object[] objArray = new object[0x10]; objArray[1] = parentChildQuestionsRowByChildQuestionAnswers[0]; objArray[2] = AnswerText; objArray[3] = ImageUrl; objArray[4] = TypeMode; objArray[5] = FieldWidth; objArray[6] = FieldLength; objArray[7] = FieldHeight; objArray[8] = VoteCount; objArray[9] = XmlDatasource; objArray[10] = Selected; objArray[11] = DefaultText; objArray[12] = UserSelected; objArray[13] = UserText; objArray[14] = DataSource; objArray[15] = Mandatory; row.ItemArray = objArray; base.Rows.Add(row); return row; }
public void AddAnswersRow(MatrixChildQuestionData.AnswersRow row) { base.Rows.Add(row); }
public ChildQuestionsRowChangeEvent(MatrixChildQuestionData.ChildQuestionsRow row, DataRowAction action) { this.eventRow = row; this.eventAction = action; }
public void RemoveChildQuestionsRow(MatrixChildQuestionData.ChildQuestionsRow row) { base.Rows.Remove(row); }
public void AddChildQuestionsRow(MatrixChildQuestionData.ChildQuestionsRow row) { base.Rows.Add(row); }