Beispiel #1
0
        public override DataSet Clone()
        {
            AnswerTypeData data = (AnswerTypeData)base.Clone();

            data.InitVars();
            return(data);
        }
        /// <summary>
        /// Return an answer type object that reflects the database answer type
        /// </summary>
        /// <param name="answerTypeId">Id of the answer type you need</param>
        /// <returns>An answer type object with the current database values</returns>
        public AnswerTypeData GetAnswerTypeById(int answerTypeId)
        {
            AnswerTypeData dataSet = new AnswerTypeData();

            ArrayList commandParameters = new ArrayList();
            {
                commandParameters.Add(new SqlParameter("@AnswerTypeId", answerTypeId).SqlValue);
            }

            DbConnection.db.LoadDataSet("vts_spAnswerTypeGetDetails", dataSet, new string[] { "AnswerTypes" }, commandParameters.ToArray());
            return dataSet;
        }
 /// <summary>
 /// Returns a list of answer types list
 /// </summary>
 public AnswerTypeData GetAnswerTypesList()
 {
     AnswerTypeData dataSet = new AnswerTypeData();
     DbConnection.db.LoadDataSet("vts_spAnswerTypeGetList", dataSet, new string[] { "AnswerTypes" });
     return dataSet;
 }
 /// <summary>
 /// Adds a new answer type in the database
 /// </summary>
 /// <param name="newAnswerType">Answer type object with information about what to add. Only Id must be ommited</param>
 public void AddAnswerType(AnswerTypeData newAnswerType, int userId)
 {
     SqlConnection sqlConnection = new SqlConnection(DbConnection.NewDbConnectionString);
     DbConnection.db.UpdateDataSet(newAnswerType, "AnswerTypes", this.GetInsertAnswerTypeCommand(sqlConnection, null, userId), new SqlCommand(), new SqlCommand(), UpdateBehavior.Transactional);
 }
 /// <summary>
 /// Update the answer type in the database
 /// </summary>
 /// <param name="updatedAnswerType">Answer type to update, must specify the answer type id</param>
 public void UpdateAnswerType(AnswerTypeData updatedAnswerType)
 {
     SqlConnection connection = new SqlConnection(DbConnection.NewDbConnectionString);
     SqlCommand insertCommand = new SqlCommand("vts_spAnswerTypeUpdate", connection);
     insertCommand.CommandType = CommandType.StoredProcedure;
     insertCommand.Parameters.Add(new SqlParameter("@AnswerTypeID", SqlDbType.Int, 4, "AnswerTypeID"));
     insertCommand.Parameters.Add(new SqlParameter("@Description", SqlDbType.VarChar, 200, "Description"));
     insertCommand.Parameters.Add(new SqlParameter("@XmlDataSource", SqlDbType.VarChar, 200, "XmlDataSource"));
     insertCommand.Parameters.Add(new SqlParameter("@DataSource", SqlDbType.NVarChar, 0xfa0, "DataSource"));
     insertCommand.Parameters.Add(new SqlParameter("@TypeMode", SqlDbType.Int, 4, "TypeMode"));
     insertCommand.Parameters.Add(new SqlParameter("@FieldWidth", SqlDbType.Int, 4, "FieldWidth"));
     insertCommand.Parameters.Add(new SqlParameter("@FieldHeight", SqlDbType.Int, 4, "FieldHeight"));
     insertCommand.Parameters.Add(new SqlParameter("@FieldLength", SqlDbType.Int, 4, "FieldLength"));
     insertCommand.Parameters.Add(new SqlParameter("@PublicFieldResults", SqlDbType.Bit, 1, "PublicFieldResults"));
     insertCommand.Parameters.Add(new SqlParameter("@JavascriptFunctionName", SqlDbType.VarChar, 0x3e8, "JavascriptFunctionName"));
     insertCommand.Parameters.Add(new SqlParameter("@JavascriptErrorMessage", SqlDbType.VarChar, 0x3e8, "JavascriptErrorMessage"));
     insertCommand.Parameters.Add(new SqlParameter("@JavascriptCode", SqlDbType.VarChar, 0x1f40, "JavascriptCode"));
     insertCommand.Parameters.Add(new SqlParameter("@TypeAssembly", SqlDbType.VarChar, 200, "TypeAssembly"));
     insertCommand.Parameters.Add(new SqlParameter("@TypeNameSpace", SqlDbType.VarChar, 200, "TypeNameSpace"));
     DbConnection.db.UpdateDataSet(updatedAnswerType, "AnswerTypes", insertCommand, new SqlCommand(), insertCommand, UpdateBehavior.Transactional);
 }
        /// <summary>
        /// Returns a list of answer types available to the user and that can 
        /// be edited from the admin interface
        /// </summary>
        public AnswerTypeData GetEditableAssignedAnswerTypesList(int userId)
        {
            AnswerTypeData dataSet = new AnswerTypeData();

            ArrayList commandParameters = new ArrayList();
            {
                commandParameters.Add(new SqlParameter("@UserId", userId).SqlValue);
            }

            DbConnection.db.LoadDataSet("vts_spAnswerTypeGetEditableListForUser", dataSet, new string[] { "AnswerTypes" }, commandParameters.ToArray());
            return dataSet;
        }
        /// <summary>
        /// Returns a list of answer types available to the user
        /// </summary>
        public AnswerTypeData GetAssignedAnswerTypesList(int userId, int surveyId)
        {
            //SqlParameter[] commandParameters = new SqlParameter[] 
            //{ new SqlParameter("@UserId", userId), 
            //    new SqlParameter("@SurveyId", surveyId) };

            ArrayList commandParameters = new ArrayList();
            {
                commandParameters.Add(new SqlParameter("@UserId", userId).SqlValue);
                commandParameters.Add(new SqlParameter("@SurveyId", surveyId).SqlValue);
            }

            AnswerTypeData dataSet = new AnswerTypeData();
            DbConnection.db.LoadDataSet("vts_spAnswerTypeGetListForUser", dataSet, new string[] { "AnswerTypes" }, commandParameters.ToArray());
            return dataSet;
        }
 /// <summary>
 /// Update the answer type in the database
 /// </summary>
 /// <param name="updatedAnswerType">Answer type to update, must specify the answer type id</param>
 public void UpdateAnswerType(AnswerTypeData updatedAnswerType)
 {
     AnswerTypeFactory.Create().UpdateAnswerType(updatedAnswerType);
 }
 /// <summary>
 /// Adds a new answer type in the database
 /// </summary>
 /// <param name="newAnswerType">Answer type object with information about what to add. Only Id must be ommited</param>
 public void AddAnswerType(AnswerTypeData newAnswerType, int userId)
 {
     AnswerTypeFactory.Create().AddAnswerType(newAnswerType, userId);
 }
 public AnswerTypesRowChangeEvent(AnswerTypeData.AnswerTypesRow row, DataRowAction action)
 {
     this.eventRow = row;
     this.eventAction = action;
 }
 public void RemoveAnswerTypesRow(AnswerTypeData.AnswerTypesRow row)
 {
     base.Rows.Remove(row);
 }
 public void AddAnswerTypesRow(AnswerTypeData.AnswerTypesRow row)
 {
     base.Rows.Add(row);
 }
        private AnswerTypeData CreateSqlTypeFromForm()
        {
            AnswerTypeData answerTypeData = null;
            if (SqlQueryTextbox.Text.Length == 0)
            {
                MessageLabel.Visible = true;
                ((PageBase)Page).ShowErrorMessage(MessageLabel, ((PageBase)Page).GetPageResource("MissingQueryDataSourceMessage"));
            }
            else if (SqlQueryTextbox.Text.IndexOf("update") > -1 ||
                SqlQueryTextbox.Text.IndexOf("delete") > -1 || SqlQueryTextbox.Text.IndexOf("create") > -1 ||
                SqlQueryTextbox.Text.IndexOf("truncate") > -1 || SqlQueryTextbox.Text.IndexOf("fetch") > -1 ||
                SqlQueryTextbox.Text.IndexOf("grant") > -1 || SqlQueryTextbox.Text.IndexOf("insert") > -1 ||
                SqlQueryTextbox.Text.IndexOf("revoke") > -1 || SqlQueryTextbox.Text.IndexOf("open") > -1 ||
                SqlQueryTextbox.Text.IndexOf("alter") > -1)
            {
                MessageLabel.Visible = true;
                ((PageBase)Page).ShowErrorMessage(MessageLabel, ((PageBase)Page).GetPageResource("OnlySelectQueryAllowedMessage"));
            }
            else
            {
                answerTypeData = new AnswerTypeData();
                AnswerTypeData.AnswerTypesRow newAnswerType = answerTypeData.AnswerTypes.NewAnswerTypesRow();
                newAnswerType.Description = TitleTextBox.Text;
                newAnswerType.TypeMode = (int)AnswerTypeMode.DataSource;
                newAnswerType.TypeMode += (int)AnswerTypeMode.Publisher;
                newAnswerType.TypeMode += (int)AnswerTypeMode.Mandatory;
                SqlQueryTextbox.Text.Replace("delete ", "");
                SqlQueryTextbox.Text.Replace("update ", "");
                SqlQueryTextbox.Text.Replace("truncate ", "");

                newAnswerType.DataSource = SqlQueryTextbox.Text;
                newAnswerType.TypeAssembly = "Votations.NSurvey.WebControls";
                newAnswerType.TypeNameSpace = "Votations.NSurvey.WebControls.UI.AnswerSqlListItem";

                answerTypeData.AnswerTypes.AddAnswerTypesRow(newAnswerType);
            }

            return answerTypeData;
        }
        private AnswerTypeData CreateXmlTypeFromForm()
        {
            AnswerTypeData answerTypeData = null;
            if (XmlFileNameTextbox.Text.Length == 0)
            {
                MessageLabel.Visible = true;
                ((PageBase)Page).ShowErrorMessage(MessageLabel, ((PageBase)Page).GetPageResource("MissingXmlDataSourceMessage"));
            }
            else
            {
                answerTypeData = new AnswerTypeData();
                AnswerTypeData.AnswerTypesRow newAnswerType = answerTypeData.AnswerTypes.NewAnswerTypesRow();
                newAnswerType.Description = TitleTextBox.Text;
                newAnswerType.TypeMode = (int)AnswerTypeMode.DataSource;
                newAnswerType.TypeMode += (int)AnswerTypeMode.Publisher;
                newAnswerType.TypeMode += (int)AnswerTypeMode.Mandatory;

                newAnswerType.XmlDataSource = XmlFileNameTextbox.Text;
                newAnswerType.TypeAssembly = "Votations.NSurvey.WebControls";
                newAnswerType.TypeNameSpace = "Votations.NSurvey.WebControls.UI.AnswerXmlListItem";

                answerTypeData.AnswerTypes.AddAnswerTypesRow(newAnswerType);
            }

            return answerTypeData;
        }
        private AnswerTypeData CreateTypeFromForm()
        {
            int TypeMode = 0;
            AnswerTypeData answerTypeData = new AnswerTypeData();
            AnswerTypeData.AnswerTypesRow newAnswerType = answerTypeData.AnswerTypes.NewAnswerTypesRow();

            newAnswerType.Description = TitleTextBox.Text;
            if (SelectionTypeCheckBox.Checked)
            {
                TypeMode += (int)AnswerTypeMode.Selection;
                newAnswerType.TypeAssembly = "Votations.NSurvey.WebControls";
                newAnswerType.TypeNameSpace = "Votations.NSurvey.WebControls.UI.AnswerSelectionItem";
            }

            if (FieldTypeCheckBox.Checked)
            {
                if (!ValidateFieldOptions())
                {
                    return null;
                }

                TypeMode += (int)AnswerTypeMode.Field;
                TypeMode += (int)AnswerTypeMode.Publisher;
                TypeMode += (int)AnswerTypeMode.RegExValidator;
                TypeMode += (int)AnswerTypeMode.Mandatory;
                if (SelectionTypeCheckBox.Checked)
                {
                    newAnswerType.TypeAssembly = "Votations.NSurvey.WebControls";
                    newAnswerType.TypeNameSpace = "Votations.NSurvey.WebControls.UI.AnswerOtherFieldItem";
                }
                else if (RichFieldCheckBox.Checked)
                {
                    TypeMode += (int)AnswerTypeMode.ExtendedType;
                    newAnswerType.TypeAssembly = "Votations.NSurvey.WebControls";
                    newAnswerType.TypeNameSpace = "Votations.NSurvey.WebControls.ThirdPartyItems.FreeTextBoxAnswerItem";
                }
                else
                {
                    newAnswerType.TypeAssembly = "Votations.NSurvey.WebControls";
                    newAnswerType.TypeNameSpace = "Votations.NSurvey.WebControls.UI.AnswerFieldItem";
                }
            }

            newAnswerType.TypeMode = TypeMode;
            newAnswerType.FieldHeight = int.Parse(FieldHeightTextBox.Text);
            newAnswerType.FieldWidth = int.Parse(FieldWidthTextBox.Text);
            newAnswerType.FieldLength = int.Parse(FieldMaxLengthTextBox.Text);
            newAnswerType.PublicFieldResults = FieldShownInResultsCheckBox.Checked;
            newAnswerType.JavascriptFunctionName = JavascriptFunctionNameTextBox.Text;
            newAnswerType.JavascriptErrorMessage = JavascriptErrorMessageTextBox.Text;
            newAnswerType.JavascriptCode = JavascriptTextBox.Text;
            answerTypeData.AnswerTypes.AddAnswerTypesRow(newAnswerType);
            return answerTypeData;

        }