//Save Question private void btn_Save_Click(object sender, EventArgs e) { int NumAnswer = flp_Answer.Controls.Count; if (txt_ContentQuestion.Text.Trim() == "" || NumAnswer < 2) { if (txt_ContentQuestion.Text.Trim() == "") { MessageBox.Show("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("Vui lòng nhập hơn một đáp án!", "Cảnh Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { if (checkAnswerEmpty() == true) { MessageBox.Show("Không lưu câu hỏi vì tồn tại đáp án rỗng!", "Cảnh Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { if (checkBlankCorrectAnswer() ==true) { MessageBox.Show("Vui lòng chọn đáp án cho câu hỏi!", "Cảnh Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { QuestionBL questionBl = new QuestionBL(); Question question = new Question(); Answer answer = new Answer(); //Update question question.NameQuestion = txt_ContentQuestion.Text.Trim(); question.IDQuestion = IDQuestion; questionBl.EditQuestionbyID(question); //DELETE ANSWER question.IDQuestion = IDQuestion; questionBl.DeleteAnswerByIDQuestion(question); foreach (Answer_MultiSelect item in flp_Answer.Controls) { if (item.txt_AnswerContent.Text.Trim() != "") { answer.ContentAnswer = item.txt_AnswerContent.Text.Trim(); //answer.IsCorrect = item.chk_Check.Checked; if (item.chk_Check.Checked == true ) { answer.Check = 1; } else { answer.Check = 0; } answer.IDQuestion = IDQuestion; answer.IDCatalogue = IDCatalogue; questionBl.AddAnswer(answer); } } //Show notify //notifyIcon1.Icon = SystemIcons.Information; //notifyIcon1.BalloonTipText = " Chỉnh sửa câu hỏi thành công"; //notifyIcon1.ShowBalloonTip(2000); //Close form this.Close(); } } } }