private void btn_SaveAndCreateNewQuestion_Click(object sender, EventArgs e)
{
QuestionBL questionBl = new QuestionBL();
Question question = new Question();
Answer answer = new Answer();
if (txt_ContentQuestion.Text.Trim() == "" || txt_NameQuestion.Text.Trim() == "" || txt_AnswerContent.Text.Trim() == "")
{
if (txt_ContentQuestion.Text.Trim() == "" || txt_NameQuestion.Text.Trim() == "")
{
MessageBox.Show("Câu hỏi không được rỗng. Vui lòng nhập thông tin câu hỏi trước khi lưu.", "Cảnh Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else
{
MessageBox.Show("Đáp án không được rỗng. Vui lòng nhập thông tin đáp án trước khi lưu.", "Cảnh Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
else
{
question.QuestionTitle = txt_NameQuestion.Text.Trim();
question.NameQuestion = txt_ContentQuestion.Text.Trim();
question.TypeQuestion = "shortanswer";
question.IDCatalogue = IDCat;
question.Date = DateTime.Now;
if (questionBl.AddQuestion(question))
{
answer.ContentAnswer = txt_AnswerContent.Text.Trim();
answer.Check = 1;
answer.IDQuestion = questionBl.MaxIDQuestion();
answer.IDCatalogue = IDCat;
questionBl.AddAnswer(answer);
//Show notify
//notifyIcon1.Icon = SystemIcons.Information;
//notifyIcon1.BalloonTipText = "Thêm câu hỏi thành công.";
//notifyIcon1.ShowBalloonTip(2000);
MessageBox.Show("Thêm câu hỏi thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
//Refesh form
txt_ContentQuestion.Text = "";
txt_AnswerContent.Text = "";
}
}
}