示例#1
0
        private void addQuestionButton_Click(object sender, EventArgs e)
        {
            if (questionTbox.Text != null && questionTbox.Text != "" && replyTBox.Text != "" && replyTBox.Text != null && categoryTypeCombo.SelectedItem != null && replyTBox1.Text != "" && replyTBox1.Text != null && replyTBox2.Text != "" && replyTBox2.Text != null && replyTBox3.Text != "" && replyTBox3.Text != null && replyTBox4.Text != "" && replyTBox4.Text != null && validationReturn())
            {
                questionName = DateTime.Now.ToString().Trim().Replace(" ", string.Empty).Trim().Replace(":", string.Empty).Trim().Replace("/", string.Empty);
                Classes.questionClass ques = new Classes.questionClass();
                if (oldFileLoc != "")
                {
                    File.Copy(oldFileLoc, @"images\\" + questionName + ".jpg");
                }
                questionTbox.SaveFile(@"question\\" + questionName + ".rtf");
                //soru oluşturma

                question newQuest = new question();
                newQuest.questionText = questionTbox.Text;
                newQuest.questionName = questionName;
                newQuest.reply        = replyTBox.Text;
                newQuest.reply1       = replyTBox1.Text;
                newQuest.reply2       = replyTBox2.Text;
                newQuest.reply3       = replyTBox3.Text;
                newQuest.reply4       = replyTBox4.Text;
                newQuest.categoryID   = (int)categoryTypeCombo.SelectedValue;
                bool ret = quizOP.addQuestion(newQuest);
                if (ret)
                {
                    MessageBox.Show("Sorunuz başarılı bir şekilde eklendi.");
                    qListe();
                    clearForms();
                }
            }
            else
            {
                MessageBox.Show("Lütfen bilgileri doğru ve eksiksiz giriniz.");
            }
        }
        public void addQuestion()
        {
            Classes.QuestionOperation quizOp = new Classes.QuestionOperation();
            question quest = new question();

            quest.questionName = "Demo";
            quest.questionText = "Demo Sorusu";
            quest.reply        = "1";
            quest.reply1       = "2";
            quest.reply2       = "3";
            quest.reply3       = "4";
            quest.reply4       = "5";
            quest.categoryID   = 6;

            Assert.AreEqual(true, quizOp.addQuestion(quest));
        }