예제 #1
0
        //==================================Additional functions====================================
        //==========================================================================================
        //Load data from sql server
        public void loadData()
        {
            //Load topic
            BOTopic bot = new BOTopic();
            topicList = bot.ListAll();
            cbbTopic.DataSource = topicList;

            //Load questions and answers
            BOQuestion boq = new BOQuestion();
            BOAnswer boa = new BOAnswer();
            answerList = boa.ListAll();
            questionList = boq.ListAll();
            for (int i = 0; i < questionList.Count; i++)
            {
                questionList[i].Answers = new List<Answer>();
                for (int j = 0; j < answerList.Count; j++)
                    if (answerList[j].QCode == questionList[i].Code)
                    {
                        questionList[i].Answers.Add(answerList[j]);
                    }
            }
        }
 //Save data to the sql database
 public void saveData(Question q)
 {
     BOQuestion boq = new BOQuestion();
     BOAnswer boa = new BOAnswer();
     boq.Add(q);
 }