コード例 #1
0
ファイル: QuizEntity.cs プロジェクト: bubber11/JiTU-CS
        public void UpdateQuiz(QuizData theQuiz)
        {
            QuestionEntity temp = new QuestionEntity();

            for (int i = 0; i < theQuiz.Questions.Count; i++)
            {
                QuestionData questionToSave;
                questionToSave = theQuiz.Questions[i];
                if (questionToSave.Id == 0)
                {
                    temp.CreateQuestion(questionToSave);
                    AddQuestion(theQuiz, questionToSave);
                }
                else
                {
                    temp.UpdateQuestion(questionToSave);
                }
            }


            temp.Dispose();

            SQL = "UPDATE `quizzes` q SET q.`name` = \"" + theQuiz.Name + "\", q.`open_date` = \"" + theQuiz.Open.ToString("yyyy-MM-dd") + "\", q.`due_date` = \"" + theQuiz.Due.ToString("yyyy-MM-dd") + "\" WHERE q.`quiz_id` = \"" + theQuiz.Id + "\";";
            InitializeCommand();
            OpenConnection();

            int result = ExecuteStoredProcedure();

            CloseConnection();

            if (result == 0)
            {
                throw new Exception("Unable to update the quiz on the database");
            }
        }
コード例 #2
0
ファイル: QuizEntity.cs プロジェクト: bubber11/JiTU-CS
        public void UpdateQuiz(QuizData theQuiz)
        {
            QuestionEntity temp = new QuestionEntity();

            for (int i = 0; i < theQuiz.Questions.Count; i++)
            {
                QuestionData questionToSave;
                questionToSave = theQuiz.Questions[i];
                if (questionToSave.Id == 0)
                {
                    temp.CreateQuestion(questionToSave);
                    AddQuestion(theQuiz, questionToSave);

                }
                else
                    temp.UpdateQuestion(questionToSave);

            }

            temp.Dispose();

            SQL = "UPDATE `quizzes` q SET q.`name` = \"" + theQuiz.Name + "\", q.`open_date` = \"" + theQuiz.Open.ToString("yyyy-MM-dd") + "\", q.`due_date` = \"" + theQuiz.Due.ToString("yyyy-MM-dd") + "\" WHERE q.`quiz_id` = \"" + theQuiz.Id + "\";";
            InitializeCommand();
            OpenConnection();

            int result = ExecuteStoredProcedure();
            CloseConnection();

            if (result == 0)
                throw new Exception("Unable to update the quiz on the database");
        }