Ejemplo n.º 1
0
        private void WriteAnswers(Question qu)
        {
            //foreach (Answer a in qu.Answers)
            //{
            //    wr.WriteStartElement("Answer");

            //    wr.WriteStartAttribute("withInput");
            //    wr.WriteValue(a.WithInput);
            //    wr.WriteEndAttribute();

            //    wr.WriteStartAttribute("excludes");
            //    wr.WriteValue(a.Excludes);
            //    wr.WriteEndAttribute();

            //    wr.WriteStartElement("Title");
            //    wr.WriteCData(a.Title);
            //    wr.WriteEndElement();

            //    wr.WriteStartElement("Data");
            //    wr.WriteCData(a.Data);
            //    wr.WriteEndElement();

            //    wr.WriteEndElement();
            //}
        }
Ejemplo n.º 2
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (IsPost)
            {
                switch (AjaxAction)
                {
                    case "QuestionaryPage.save":
                        SaveQuestionary();
                        return;

                    case "QuestionaryPage.saveQuestion":
                        SaveQuestion();
                        return;

                    case "QuestionaryPage.saveAnswer":
                        SaveAnswer();
                        return;

                    case "QuestionaryPage.getQuestion":
                        GetQuestion();
                        return;

                    case "QuestionaryPage.getAnswer":
                        GetAnswer();
                        return;

                    case "QuestionaryPage.delQuestion":
                        DeleteQuestion();
                        return;

                    case "QuestionaryPage.delAnswer":
                        DeleteAnswer();
                        return;

                }
            }
            else
            {
                if (Request["cateId"] != null)
                {
                    CategoryId = Request["cateId"].Trim();

                    CurrentQuestionary = Questionary.Get(CategoryId);
                }

                if (CurrentQuestionary == null)
                {
                    CurrentQuestionary = new Questionary(CategoryId);
                }

                if (Request["qid"] != null)
                {
                    try
                    {
                        QuestionId = Convert.ToInt32(Request["qid"]);
                        CurrentQuestion = Question.Get(QuestionId);
                    }
                    catch
                    {
                        //
                    }
                }

                if (CurrentQuestion == null)
                {
                    CurrentQuestion = new Question();
                }
            }
        }
Ejemplo n.º 3
0
        private void SaveQuestion()
        {
            Response.Clear();
            if (Request.Form["qCateId"] != null &&
                Request.Form["qSort"] != null &&
                Request.Form["qTitle"] != null &&
                Request.Form["qRequireTitle"] != null &&
                Request.Form["qRemark"] != null &&
                Request.Form["qMode"] != null &&
                Request.Form["qDecoration"] != null)
            {
                try
                {
                    int qid = 0;
                    if (Request.Form["qId"] != null)
                    {
                        qid = Convert.ToInt32(Request.Form["qId"]);
                    }

                    Question q = new Question();
                    q.SortNum = Convert.ToInt16(Request.Form["qSort"]);
                    q.CategoryId = Request.Form["qCateId"].Trim();
                    q.Title = Request.Form["qTitle"].Trim();
                    q.RequestTitle = Request.Form["qRequireTitle"].Trim();
                    q.Remark = Request.Form["qRemark"].Trim();
                    q.VariableName = Request.Form["qName"].Trim();
                    q.Mode = (QuestionMode)(Convert.ToInt16(Request.Form["qMode"].Trim()));
                    q.Required = Request.Form["qIsRequired"] != null;
                    q.AllowSearch = Request.Form["qAllowSrh"] != null;
                    q.Enable = Request.Form["qEnable"] != null;
                    q.Decoration = (QuestionDecoration)(Convert.ToInt16(Request.Form["qDecoration"]));
                    qid = q.Save(qid);
                    Response.Write(qid);
                }
                catch (Exception e)
                {
                    Response.Write(e.ToString());
                }
            }
            Response.End();
        }
Ejemplo n.º 4
0
        public static ArrayList List(string cateId,bool onlyEnabled)
        {
            /*
             QuestionList
             * @cateId varchar(30)
             */

            //[Id],CategoryId, Title, RequestTitle, Mode, VariableName, Required, AllowSearch, SortNum,Enable,Decoration,Remark

            ArrayList list = new ArrayList();

            SqlDataReader reader = null;

            try
            {
                reader = Database.ExecuteReader(CommandType.StoredProcedure, "QuestionList",
                            new SqlParameter[] { Database.MakeInParam("@cateId", SqlDbType.Int, cateId), Database.MakeInParam("@enabled", SqlDbType.Bit, onlyEnabled) });
                while (reader.Read())
                {
                    Question q = new Question();
                    q.id = reader.GetInt32(0);
                    q.categoryId = reader.GetString(1);
                    q.title = reader.GetString(2);
                    q.requestTitle = reader.GetString(3);
                    q.mode = (QuestionMode)(reader.GetInt16(4));
                    q.variableName = reader.GetString(5);
                    q.required = reader.GetString(6) == "1";
                    q.allowSearch = reader.GetString(7) == "1";
                    q.sortNum = reader.GetInt16(8);
                    q.enable = reader.GetString(9) == "1";
                    q.decoration = (QuestionDecoration)(reader.GetInt16(10));
                    q.remark = reader.GetString(11);
                    list.Add(q);
                }
                reader.Close();
            }
            catch
            {
                //throw;
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }

            return list;
        }
Ejemplo n.º 5
0
        public static Question Get(int qid)
        {
            /*
             QuestionGet
             * @id int
             */

            //CategoryId, Title, RequestTitle,Remark, Mode, VariableName, Required, AllowSearch, SortNum,Enable,Decoration

            Question q = null;

            SqlDataReader reader = null;

            try
            {
                reader = Database.ExecuteReader(CommandType.StoredProcedure, "QuestionGet",
                            new SqlParameter[] {Database.MakeInParam("@id",SqlDbType.Int,qid) });
                if (reader.Read())
                {
                    q = new Question();
                    q.id = qid;
                    q.categoryId = reader.GetString(0);
                    q.title = reader.GetString(1);
                    q.requestTitle = reader.GetString(2);
                    q.remark = reader.GetString(3);
                    q.mode = (QuestionMode)(reader.GetInt16(4));
                    q.variableName = reader.GetString(5);
                    q.required = reader.GetString(6) == "1";
                    q.allowSearch = reader.GetString(7) == "1";
                    q.sortNum = reader.GetInt16(8);
                    q.enable = reader.GetString(9) == "1";
                    q.decoration = (QuestionDecoration)(reader.GetInt16(10));
                }
                reader.Close();
            }
            catch
            {
                //
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }

            return q;
        }