Exemplo n.º 1
0
        public List <QuestionABC> GetAllQuestionsBySubThemeName(string subThemeName)
        {
            List <QuestionABC> questions = new List <QuestionABC>();
            QuestionABC        quest     = new QuestionABC();
            AnswerDAL          aDAL      = new AnswerDAL();

            base.OpenConnection();

            SqlCommand command = new SqlCommand(string.Format("Select * from Questions inner join Sub_Themes on Questions.ID_SubTheme = Sub_Themes.ID where Sub_Themes.Sub_Theme like '" + "{0}" + "'", subThemeName), base._sqlConnection);

            SqlDataReader reader = command.ExecuteReader();

            using (reader)
            {
                while (reader.Read())
                {
                    quest.Id = (int)reader["ID"];
                    quest.QuestionCurrent = (string)reader["Question"];
                    quest.SubThemeId      = (int)reader["ID_SubTheme"];
                    quest.ListAnswers     = aDAL.GetAllAnswersByQuestion(quest.QuestionCurrent);

                    questions.Add(quest);

                    quest = new QuestionABC();
                }
            }

            base.CloseConnection();

            return(questions);
        }
Exemplo n.º 2
0
        public void InsertQuestionViaStoredProc(QuestionABC quest)
        {
            base.OpenConnection();

            SqlCommand cmd = new SqlCommand("InsertIntoQuestions", base._sqlConnection);

            using (cmd)
            {
                cmd.CommandType = CommandType.StoredProcedure;
                SqlParameter param = new SqlParameter();
                param.ParameterName = "@Question";
                param.SqlDbType     = SqlDbType.VarChar;
                param.Size          = 200;
                param.Value         = quest.QuestionCurrent;

                cmd.Parameters.Add(param);

                param = new SqlParameter();
                param.ParameterName = "@Id_Sub_Theme";
                param.SqlDbType     = SqlDbType.Int;
                param.Value         = quest.SubThemeId;

                cmd.Parameters.Add(param);

                cmd.ExecuteNonQuery();
            }

            base.CloseConnection();
        }
Exemplo n.º 3
0
        public string GetSubThemeByQuestion(QuestionABC quest)
        {
            string subTheme = "";

            base.OpenConnection();

            SqlCommand command = new SqlCommand(string.Format("Select Sub_Themes.Sub_Theme from Sub_Themes inner join Questions on Sub_Themes.ID = Questions.ID_SubTheme where Questions.Question like '" + "{0}" + "'", quest.QuestionCurrent), base._sqlConnection);

            SqlDataReader reader = command.ExecuteReader();

            using (reader)
            {
                while (reader.Read())
                {
                    subTheme = (string)reader["Sub_Theme"];
                }
            }

            base.CloseConnection();

            return(subTheme);
        }