Example #1
0
        public override DataSet Clone()
        {
            MessageConditionData data = (MessageConditionData)base.Clone();

            data.InitVars();
            return(data);
        }
 /// <summary>
 /// Updates a message condition
 /// </summary>
 public void UpdateMessageCondition(MessageConditionData updatedMessageCondition)
 {
     SurveyFactory.Create().UpdateMessageCondition(updatedMessageCondition);
 }
 /// <summary>
 /// Add a new condition to show a given thank you message
 /// </summary>
 /// <param name="newBranchingRule"></param>
 public void AddMessageCondition(MessageConditionData newMessageCondition)
 {
     SurveyFactory.Create().AddMessageCondition(newMessageCondition);
 }
 /// <summary>
 /// returns the thank you message contions for the given survey
 /// </summary>
 public MessageConditionData GetSurveyMessageConditions(int surveyId)
 {
     MessageConditionData messageCondition = new MessageConditionData();
    DbConnection.db.LoadDataSet("vts_spSurveyMessageConditionsGetAll", messageCondition, new string[] { "MessageConditions" }, new SqlParameter("@SurveyID", surveyId).SqlValue);
     return messageCondition;
 }
		private void AddUpdateMessageCondition(bool updateMode)
		{
			MessageConditionData messageConditionData = new MessageConditionData();
			MessageConditionData .MessageConditionsRow messageCondition = messageConditionData .MessageConditions.NewMessageConditionsRow();

			if ((MessageConditionDropdownlist.SelectedValue == "2" ||
				MessageConditionDropdownlist.SelectedValue == "3" ||
				MessageConditionDropdownlist.SelectedValue == "4") &&
				Information.IsNumeric(ScoreTextbox.Text))
			{
				messageCondition.Score = int.Parse(ScoreTextbox.Text);

			}
			else if (MessageConditionDropdownlist.SelectedValue == "5" &&
				Information.IsNumeric(ScoreTextbox.Text) &&
				Information.IsNumeric(ScoreMaxTextbox.Text))
			{
				messageCondition.Score = int.Parse(ScoreTextbox.Text);
				messageCondition.ScoreMax = int.Parse(ScoreMaxTextbox.Text);
			}
			else if (MessageConditionDropdownlist.SelectedValue == "2" ||
				MessageConditionDropdownlist.SelectedValue == "3" ||
				MessageConditionDropdownlist.SelectedValue == "4" ||
				MessageConditionDropdownlist.SelectedValue == "5")
			
			{
((PageBase)Page).ShowErrorMessage(MessageLabel,((PageBase)Page).GetPageResource("ScoreNotNumericMessage"));
				MessageLabel.Visible = true;
				return;
			}
			// Condition created from a selected question
			else if (MessageConditionDropdownlist.SelectedValue == "1")
			{
				if ((LogicDropDownList.SelectedValue == "3" ||
					LogicDropDownList.SelectedValue == "4" ||
					LogicDropDownList.SelectedValue == "5") &&
					Information.IsNumeric(ScoreTextbox.Text))
				{
					messageCondition.Score = int.Parse(ScoreTextbox.Text);
				}
				else if (LogicDropDownList.SelectedValue == "6" &&
					Information.IsNumeric(ScoreTextbox.Text) &&
					Information.IsNumeric(ScoreMaxTextbox.Text))
				{
					messageCondition.Score = int.Parse(ScoreTextbox.Text);
					messageCondition.ScoreMax = int.Parse(ScoreMaxTextbox.Text);
				}
				else if (LogicDropDownList.SelectedValue == "3" ||
					LogicDropDownList.SelectedValue == "4" ||
					LogicDropDownList.SelectedValue == "5" ||
					LogicDropDownList.SelectedValue == "6")
				{
((PageBase)Page).ShowErrorMessage(MessageLabel,((PageBase)Page).GetPageResource("ScoreNotNumericMessage"));
					MessageLabel.Visible = true;
					return;
				}
				else
				{
					int answerId = int.Parse(AnswerFilterDropdownlist.SelectedValue);
					if (answerId == 0)
					{
						messageCondition.SetAnswerIdNull();
					}
					else if ( answerId < 0)
					{
						messageCondition.AnswerId  = -answerId;
					}
					else
					{
						messageCondition.AnswerId = answerId;
					}

					if (TextFilterTextbox.Visible)
					{
						messageCondition.ExpressionOperator = 
							int.Parse(ExpressionLogicDropdownlist.SelectedValue);
						messageCondition.TextFilter = TextFilterTextbox.Text;
					}

				}

				messageCondition.QuestionId = int.Parse(QuestionFilterDropdownlist.SelectedValue);
				messageCondition.ConditionalOperator = int.Parse(LogicDropDownList.SelectedValue);
			}

            messageCondition.ThankYouMessage = ConditionCKeditor.Text.Length > 3900 ?
                ConditionCKeditor.Text.Substring(0, 3900) : ConditionCKeditor.Text;
			messageCondition.MessageConditionalOperator = int.Parse(MessageConditionDropdownlist.SelectedValue);
			messageConditionData.MessageConditions.AddMessageConditionsRow(messageCondition);
			
			if (updateMode)
			{
				messageCondition.MessageConditionId = _messageConditionId;
				new Survey().UpdateMessageCondition(messageConditionData);
			}
			else
			{
				messageCondition.SurveyId = SurveyId;
				new Survey().AddMessageCondition(messageConditionData);
			}
		}
        /// <summary>
        /// Updates a message condition
        /// </summary>
        public void UpdateMessageCondition(MessageConditionData updatedMessageCondition)
        {
            SqlConnection dbConnection = new SqlConnection(DbConnection.NewDbConnectionString);
            SqlCommand updateCondition = new SqlCommand("vts_spSurveyMessageConditionUpdate", dbConnection);
            updateCondition.CommandType = CommandType.StoredProcedure;
            updateCondition.Parameters.Add(new SqlParameter("@MessageConditionID", SqlDbType.Int, 4, "MessageConditionId"));
            updateCondition.Parameters.Add(new SqlParameter("@MessageConditionalOperator", SqlDbType.Int, 4, "MessageConditionalOperator"));
            updateCondition.Parameters.Add(new SqlParameter("@QuestionID", SqlDbType.Int, 4, "QuestionID"));
            updateCondition.Parameters.Add(new SqlParameter("@AnswerID", SqlDbType.Int, 4, "AnswerID"));
            updateCondition.Parameters.Add(new SqlParameter("@TextFilter", SqlDbType.NVarChar, 4000, "TextFilter"));
            updateCondition.Parameters.Add(new SqlParameter("@ThankYoumessage", SqlDbType.NVarChar, 4000, "ThankYoumessage"));
            updateCondition.Parameters.Add(new SqlParameter("@ConditionalOperator", SqlDbType.Int, 4, "ConditionalOperator"));
            updateCondition.Parameters.Add(new SqlParameter("@ExpressionOperator", SqlDbType.Int, 4, "ExpressionOperator"));
            updateCondition.Parameters.Add(new SqlParameter("@Score", SqlDbType.Int, 4, "Score"));
            updateCondition.Parameters.Add(new SqlParameter("@ScoreMax", SqlDbType.Int, 4, "ScoreMax"));

           DbConnection.db.UpdateDataSet(updatedMessageCondition, "MessageConditions", updateCondition, new SqlCommand(), updateCondition, UpdateBehavior.Transactional);
        }
 /// <summary>
 /// returns the thank you message conditions for the given survey
 /// </summary>
 public MessageConditionData GetSurveyMessageCondition(int messageConditionId)
 {
     MessageConditionData messageCondition = new MessageConditionData();
    DbConnection.db.LoadDataSet("vts_spSurveyMessageConditionsGetDetails", messageCondition, new string[] { "MessageConditions" }, new SqlParameter("@MessageConditionId", messageConditionId).SqlValue);
     return messageCondition;
 }
 public MessageConditionsRowChangeEvent(MessageConditionData.MessageConditionsRow row, DataRowAction action)
 {
     this.eventRow = row;
     this.eventAction = action;
 }
 public void RemoveMessageConditionsRow(MessageConditionData.MessageConditionsRow row)
 {
     base.Rows.Remove(row);
 }
 public void AddMessageConditionsRow(MessageConditionData.MessageConditionsRow row)
 {
     base.Rows.Add(row);
 }