Example #1
0
        public static ArrayList List(int qid)
        {
            /*
             AnswerList
             * @qid int
             */

            //[Id],QuestionId, Title, Data, WithInput, Excludes, SkipType, [Skip], SortNum

            ArrayList list = new ArrayList();

            SqlDataReader reader = null;

            try
            {
                reader = Database.ExecuteReader(CommandType.StoredProcedure, "AnswerList",
                            new SqlParameter[] { Database.MakeInParam("@qid", SqlDbType.Int, qid) });
                while (reader.Read())
                {
                    Answer a = new Answer();
                    a.id = reader.GetInt32(0);
                    a.questionId = reader.GetInt32(1);
                    a.title = reader.GetString(2);
                    a.data = reader.GetString(3);
                    a.withInput = reader.GetString(4) == "1";
                    a.excludes = reader.GetString(5);
                    a.skipType = (AnswerSkipType)(reader.GetInt16(6));
                    a.skip = reader.GetString(7);
                    a.sortNum = reader.GetInt16(8);
                    list.Add(a);
                }
                reader.Close();
            }
            catch
            {
                throw;
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }

            return list;
        }
Example #2
0
 private void SaveAnswer()
 {
     Response.Clear();
     if (Request.Form["aId"] != null &&
         Request.Form["qId"] != null &&
         Request.Form["aSort"] != null &&
         Request.Form["aTitle"] != null &&
         Request.Form["aData"] != null &&
         Request.Form["aExcludes"] != null)
     {
         try
         {
             Answer a = new Answer(Convert.ToInt32(Request.Form["qId"]));
             a.SortNum = Convert.ToInt16(Request.Form["aSort"]);
             a.Title = Request.Form["aTitle"].Trim();
             a.Data = Request.Form["aData"].Trim();
             a.Excludes = Request.Form["aExcludes"].Trim();
             a.WithInput = Request.Form["aWithInput"] != null;
             a.SkipType = AnswerSkipType.None;
             if (Request.Form["aSkipType"] != "0" && Request.Form["aSkip"] != null)
             {
                 if (!String.IsNullOrEmpty(Request.Form["aSkip"].Trim()))
                 {
                     a.SkipType = (AnswerSkipType)(Convert.ToInt16(Request.Form["aSkipType"]));
                     a.Skip = Request.Form["aSkip"].Trim();
                 }
             }
             int newId = a.Save(Convert.ToInt32(Request.Form["aId"]));
             Response.Write(newId);
         }
         catch
         {
             //
         }
     }
     Response.End();
 }
Example #3
0
        public static Answer Get(int aid)
        {
            /*
             AnswerGet
            @id int
             */

            //QuestionId, Title, Data, WithInput, Excludes, SkipType, [Skip], SortNum

            Answer a = new Answer();

            SqlDataReader reader = null;

            try
            {
                reader = Database.ExecuteReader(CommandType.StoredProcedure, "AnswerGet",
                            new SqlParameter[] { Database.MakeInParam("@id", SqlDbType.Int, aid) });
                if (reader.Read())
                {
                    a = new Answer();
                    a.id = aid;
                    a.questionId = reader.GetInt32(0);
                    a.title = reader.GetString(1);
                    a.data = reader.GetString(2);
                    a.withInput = reader.GetString(3) == "1";
                    a.excludes = reader.GetString(4);
                    a.skipType=(AnswerSkipType)(reader.GetInt16(5));
                    a.skip = reader.GetString(6);
                    a.sortNum = reader.GetInt16(7);
                }
                reader.Close();
            }
            catch
            {
                //
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }

            return a;
        }