//LOAD QUESTION public void LoadQuestion() { QuestionBL QuestionBL = new QuestionBL(); Catalogue Cat = new Catalogue(); Cat.IDCatalogue = IDCat; List<DO.Question> QuestionList; QuestionList = QuestionBL.GetQuestionByCatalogue(Cat); if (QuestionList != null) dgv_Question1.DataSource = QuestionList; dgv_Question1.Columns["IDCatalogue"].Visible = false; dgv_Question1.Columns["IDQuestion"].Visible = false; dgv_Question1.Columns["AnswerContent"].Visible = false; dgv_Question1.Columns["Catalogue"].Visible = false; dgv_Question1.Columns["Date"].Visible = false; dgv_Question1.Columns["Sequence"].HeaderText = "STT"; dgv_Question1.Columns["QuestionTitle"].HeaderText = "Tên câu Hỏi"; dgv_Question1.Columns["NameQuestion"].HeaderText = "Nội dung câu Hỏi"; dgv_Question1.Columns["TypeQuestion"].HeaderText = "Loại Câu Hỏi"; dgv_Question1.Columns["NameCatalogue"].HeaderText = "Tên Chủ Đề"; dgv_Question1.Columns["Sequence"].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells; dgv_Question1.Columns["NameCatalogue"].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells; dgv_Question1.Columns["TypeQuestion"].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells; dgv_Question1.Columns["QuestionTitle"].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells; }
//SAVE AND CONTINUE TO ADD QUESTION 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 = ""; } } }
//Copy Question public void CopyQuestion() { Question question = new Question(); Answer answer = new Answer(); QuestionBL questionBL = new QuestionBL(); foreach (DataGridViewRow row in dgv_Question.Rows) { if (row.Cells["Check"].Value != null && (bool)row.Cells["Check"].Value == true) { question.QuestionTitle = row.Cells["QuestionTitle"].Value.ToString(); question.NameQuestion = row.Cells["QuestionName"].Value.ToString(); question.TypeQuestion = row.Cells["QuestionType"].Value.ToString(); question.IDCatalogue = IDCat; question.Date = DateTime.Now; if (questionBL.AddQuestion(question)) { question.IDQuestion = Convert.ToInt32(row.Cells["IDQuestion"].Value); List<DO.Answer> AnswerList; AnswerList = questionBL.GetAnswerByQuestionID(question); if (AnswerList != null) { for (int i = 0; i < AnswerList.Count; i++) { answer.ContentAnswer = AnswerList.ElementAt(i).ContentAnswer; if (AnswerList.ElementAt(i).IsCorrect == true) { answer.Check = 1; } else { answer.Check = 0; } answer.IDQuestion = questionBL.MaxIDQuestion(); answer.IDCatalogue = IDCat; questionBL.AddAnswer(answer); } } } } } }
//SAVE QUESTION private void btn_Save_Click(object sender, EventArgs e) { QuestionBL questionBl = new QuestionBL(); Question question = new Question(); Answer answer = new Answer(); if (txt_ContentQuestion.Text.Trim() == "" || txt_ContentAnswer.Text.Trim() == "") { if (txt_ContentQuestion.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 { //Update question question.NameQuestion = txt_ContentQuestion.Text.Trim(); question.IDQuestion = IDQuestion; questionBl.EditQuestionbyID(question); //Update answer answer.IDQuestion = IDQuestion; answer.ContentAnswer = txt_ContentAnswer.Text.Trim(); //answer.IsCorrect = true; answer.Check = 1; questionBl.EditAnswerbyID(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 Form FindForm = this.FindForm(); FindForm.Close(); } }
//SAVE QUESTION AND ANSWER. CONTINUE INPUT private void btn_SaveAndCreateNewQuestion_Click(object sender, EventArgs e) { QuestionBL questionBl = new QuestionBL(); Question question = new Question(); Answer answer = new Answer(); int NumAnswer = flp_addAnswer.Controls.Count; if (txt_ContentQuestion.Text.Trim() == "" || txt_NameQuestion.Text.Trim() == "" || NumAnswer < 2) { if (txt_ContentQuestion.Text.Trim() == "" || txt_NameQuestion.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 { question.QuestionTitle = txt_NameQuestion.Text.Trim(); question.NameQuestion = txt_ContentQuestion.Text.Trim(); question.TypeQuestion = "onechoice"; question.IDCatalogue = IDCat; question.Date = DateTime.Now; if (questionBl.AddQuestion(question)) { foreach (Answer_OnlyOneSelect item in flp_addAnswer.Controls) { answer.ContentAnswer = item.txt_Answercontent.Text.Trim(); if (item.rad_check.Checked == true) { answer.Check = 1; } else { answer.Check = 0; } 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 this.txt_ContentQuestion.Text = ""; flp_addAnswer.Controls.Clear(); //AUTO ADD 4 ANSWER for (int j = 0; j < 4; j++) { Answer_OnlyOneSelect OneChoiceAnswer = new Answer_OnlyOneSelect(); i++; OneChoiceAnswer.Tag = i; OneChoiceAnswer.ID_Answer = i; OneChoiceAnswer.onDelete += OneChoiceAnswer_onDelete; OneChoiceAnswer.onCheck += OneChoiceAnswer_onCheck; OneChoiceAnswer.rad_check.Text = Convert.ToChar(a + j).ToString(); flp_addAnswer.Controls.Add(OneChoiceAnswer); } } } } } }
//SELECT ITEM IN COMMOBOX private void cmb_Catalogue_SelectedIndexChanged(object sender, EventArgs e) { //dgv_Question.Columns.Clear(); Catalogue catalogue = new Catalogue(); CatalogueBL CatBL = new CatalogueBL(); List<DO.Catalogue> CatList; CatList = CatBL.GetCatalogue(); if (CatList != null) for (int i = 0; i < CatList.Count; i++) { if (cmb_Catalogue.SelectedItem.ToString() == CatList.ElementAt(i).NameCatalogue) { catalogue.IDCatalogue = CatList.ElementAt(i).IDCatalogue; } } QuestionBL QuestionBL = new QuestionBL(); List<DO.Question> QuestionList; QuestionList = QuestionBL.GetQuestionByCatalogue(catalogue); if (QuestionList != null) { dgv_Question.DataSource = QuestionList; dgv_Question.Columns["IDCatalogue"].Visible = false; dgv_Question.Columns["IDQuestion"].Visible = false; dgv_Question.Columns["AnswerContent"].Visible = false; dgv_Question.Columns["Catalogue"].Visible = false; dgv_Question.Columns["NameCatalogue"].Visible = false; dgv_Question.Columns["Date"].Visible = false; } chk_CheckAll.Checked = false; }
public void MoveQuestion() { Question question = new Question(); Answer answer = new Answer(); QuestionBL questionBL = new QuestionBL(); foreach (DataGridViewRow row in dgv_Question.Rows) { if (row.Cells["Check"].Value != null && (bool)row.Cells["Check"].Value == true) { question.IDCatalogue = IDCat; question.IDQuestion = Convert.ToInt32(row.Cells["IDQuestion"].Value); questionBL.EditIDCatalogueAnswerByIDQuestion(question); questionBL.EditIDCatalogueQuestionByIDQuestion(question); ////add question //question.QuestionTitle = row.Cells["QuestionTitle"].Value.ToString(); //question.NameQuestion = row.Cells["QuestionName"].Value.ToString(); //question.TypeQuestion = row.Cells["QuestionType"].Value.ToString(); //question.IDCatalogue = IDCat; //question.Date = DateTime.Now; //if (questionBL.AddQuestion(question)) //{ // //add answer // question.IDQuestion = Convert.ToInt32(row.Cells["IDQuestion"].Value); // List<DO.Answer> AnswerList; // AnswerList = questionBL.GetAnswerByQuestionID(question); // if (AnswerList != null) // { // for (int i = 0; i < AnswerList.Count; i++) // { // answer.ContentAnswer = AnswerList.ElementAt(i).ContentAnswer; // if (AnswerList.ElementAt(i).IsCorrect == true) // { // answer.Check = 1; // } // else // { // answer.Check = 0; // } // answer.IDQuestion = questionBL.MaxIDQuestion(); // answer.IDCatalogue = IDCat; // questionBL.AddAnswer(answer); // } // } // //Delete answer and question // questionBL.DeleteAnswerByIDQuestion(question); // questionBL.DeleteQuestionByID(question); //} } } }
private void txt_SearchCatalogue_TextChanged(object sender, EventArgs e) { //QuestionBL questionBL = new QuestionBL(); //List<DO.Question> ListQuestion = questionBL.GetQuestion(); QuestionBL QuestionBL = new QuestionBL(); Catalogue Cat = new Catalogue(); Cat.IDCatalogue = IDCat; List<DO.Question> QuestionList; QuestionList = QuestionBL.GetQuestionByCatalogue(Cat); //if (QuestionList != null) //dgv_Question1.DataSource = QuestionList; //loadQuestion(); ListtoDataTableConverter converter = new ListtoDataTableConverter(); DataTable dt = converter.ToDataTable(QuestionList); dgv_Question1.DataSource = dt; dt.DefaultView.RowFilter = string.Format("NameQuestion LIKE '%{0}%' or TypeQuestion LIKE '%{0}%' or NameCatalogue LIKE '%{0}%' or QuestionTitle LIKE '%{0}%'or Sequence LIKE '%{0}%'", txt_SearchCatalogue.Text); dgv_Question1.Columns["IDCatalogue"].Visible = false; dgv_Question1.Columns["IDQuestion"].Visible = false; dgv_Question1.Columns["IDCatalogue"].Visible = false; dgv_Question1.Columns["AnswerContent"].Visible = false; dgv_Question1.Columns["AnswerList"].Visible = false; dgv_Question1.Columns["Date"].Visible = false; dgv_Question1.Columns["Sequence"].HeaderText = "STT"; dgv_Question1.Columns["NameQuestion"].HeaderText = "Tên Câu Hỏi"; dgv_Question1.Columns["NameCatalogue"].HeaderText = "Tên chủ Đề"; dgv_Question1.Columns["TypeQuestion"].HeaderText = "Loại Câu hỏi"; dgv_Question1.Columns["Sequence"].ReadOnly = true; dgv_Question1.Columns["NameQuestion"].ReadOnly = false; dgv_Question1.Columns["NameCatalogue"].ReadOnly = true; dgv_Question1.Columns["TypeQuestion"].ReadOnly = true; dgv_Question1.Columns["Sequence"].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells; dgv_Question1.Columns["NameCatalogue"].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells; dgv_Question1.Columns["TypeQuestion"].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells; }
//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(); } } } }
//SAVE QUESTION private void btn_SaveImport_Click(object sender, EventArgs e) { try { if (txt_FilePath.Text == "") { MessageBox.Show("Vui lòng chọn đường dẫn đến tập tin trước khi lưu!", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { int count = 0; foreach (DataGridViewRow row in dataGridView1.Rows) { if (row.Cells["Check"].Value != null && (bool)row.Cells["Check"].Value== true) { count++; } } if (count>0) { int CheckQuestion = 0; Question question = new Question(); Answer answer = new Answer(); QuestionBL questionBL = new QuestionBL(); foreach (DataGridViewRow row in dataGridView1.Rows) { if (row.Cells["Check"].Value != null && (bool)row.Cells["Check"].Value == true) { if (row.Cells["TypeQuestion"].Value.ToString().Trim() == "shortanswer") { string[] AnswerContent = row.Cells["AnswerContent"].Value.ToString().Trim().Split(new string[] { "</answer>" }, StringSplitOptions.None); string[] AnswerItem = AnswerContent[0].Split(new string[] { "---" }, StringSplitOptions.None); //question.QuestionTitle = question.QuestionTitle = row.Cells["QuestionTitle"].Value.ToString().Trim(); question.NameQuestion = row.Cells["NameQuestion"].Value.ToString().Trim(); question.TypeQuestion = row.Cells["TypeQuestion"].Value.ToString().Trim(); question.IDCatalogue = IDCat; question.Date = DateTime.Now; questionBL.AddQuestion(question); //answer.IsCorrect = true; answer.Check = 1; answer.ContentAnswer = AnswerItem[1].ToString().Trim(); answer.IDQuestion = questionBL.MaxIDQuestion(); answer.IDCatalogue = IDCat; questionBL.AddAnswer(answer); CheckQuestion++; } else { string[] AnswerContent = row.Cells["AnswerContent"].Value.ToString().Trim().Split(new string[] { "</answer>" }, StringSplitOptions.None); //ADD QUESTION MULTIPLE CHOICE question.QuestionTitle = row.Cells["QuestionTitle"].Value.ToString().Trim(); question.NameQuestion = row.Cells["NameQuestion"].Value.ToString().Trim(); question.TypeQuestion = ""; question.IDCatalogue = IDCat; question.Date = DateTime.Now; questionBL.AddQuestion(question); CheckQuestion++; int countMultipleChoice = 0; for (int i = 0; i < AnswerContent.Length - 1; i++) { string[] AnswerItem = AnswerContent[i].Split(new string[] { "---" }, StringSplitOptions.None); if (Convert.ToInt32(AnswerItem[0].ToString().Trim()) > 0) { //answer.IsCorrect = true; answer.Check = 1; answer.ContentAnswer = AnswerItem[1].ToString().Trim(); answer.IDQuestion = questionBL.MaxIDQuestion(); answer.IDCatalogue = IDCat; questionBL.AddAnswer(answer); countMultipleChoice++; } else { //answer.IsCorrect = false; answer.Check = 0; answer.ContentAnswer = AnswerItem[1].ToString().Trim(); answer.IDQuestion = questionBL.MaxIDQuestion(); answer.IDCatalogue = IDCat; questionBL.AddAnswer(answer); }//end if }//end for //UPDATE QUESTION TYPE if (countMultipleChoice == 1) { question.TypeQuestion = "onechoice"; question.IDQuestion = questionBL.MaxIDQuestion(); questionBL.EditQuestionTypebyID(question); } else { question.TypeQuestion = "multichoice"; question.IDQuestion = questionBL.MaxIDQuestion(); questionBL.EditQuestionTypebyID(question); } } } }//end foreach //CLOSE FORM if (CheckQuestion > 0) { MessageBox.Show("Nhập " + CheckQuestion + " câu hỏi từ file thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); CheckQuestion = 0; Form FindForm = this.FindForm(); FindForm.Close(); } } else { MessageBox.Show("Vui lòng chọn câu hỏi trước khi lưu!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } catch (Exception) { MessageBox.Show("Hệ thống lưu không thành công vì do định dạng file không đúng!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
//LOAD FILE QUESTION private void btn_LoadFile_Click(object sender, EventArgs e) { QuestionBL questionBL = new QuestionBL(); OpenFileDialog OpenFile = new OpenFileDialog(); DialogResult Result = OpenFile.ShowDialog(); if (Result == DialogResult.OK) { if (Path.GetExtension(OpenFile.FileName) == ".txt" || Path.GetExtension(OpenFile.FileName) == ".xml" || Path.GetExtension(OpenFile.FileName) == ".jqz") { if (Path.GetExtension(OpenFile.FileName) == ".txt") { dataGridView1.Columns.Clear(); QuestionBL QuestionBL = new QuestionBL(); List<DO.Question> QuestionList; QuestionList = QuestionBL.GetFileTXT(OpenFile.FileName); txt_FilePath.Text = OpenFile.FileName; if (QuestionList != null) { dataGridView1.DataSource = QuestionList; Showcolumns(); CheckQuestion(); if (WrongQuestion > 0) { MessageBox.Show("Tập tin nhập vào có " + WrongQuestion + " câu hỏi không hợp lệ (câu hỏi bị bôi đỏ). " +"Hệ thống không cho phép chọn các câu hỏi đó. " +"Vui lòng kiểm tra lại nội dung, loại câu hỏi và Phải chọn đáp án cho câu hỏi.", "Cảnh Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { dataGridView1.Columns.Clear(); txt_FilePath.Text = ""; MessageBox.Show("Tải file không thành công. Bạn định dạng file không hợp lý.", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { //xml if (Path.GetExtension(OpenFile.FileName) == ".xml") { dataGridView1.Columns.Clear(); QuestionBL QuestionBL = new QuestionBL(); List<DO.Question> QuestionList; QuestionList = QuestionBL.GetFileXML(OpenFile.FileName); txt_FilePath.Text = OpenFile.FileName; if (QuestionList != null) { dataGridView1.DataSource = QuestionList; Showcolumns(); CheckQuestion(); if (WrongQuestion > 0) { MessageBox.Show("Tập tin nhập vào có " + WrongQuestion + " câu hỏi không hợp lệ (câu hỏi bị bôi đỏ). " + "Hệ thống không cho phép chọn các câu hỏi đó. " + "Vui lòng kiểm tra lại nội dung, loại câu hỏi và Phải chọn đáp án cho câu hỏi.", "Cảnh Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { dataGridView1.Columns.Clear(); txt_FilePath.Text = ""; MessageBox.Show("Tải file không thành công. Bạn định dạng file không hợp lý.", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { //hot potatoes dataGridView1.Columns.Clear(); QuestionBL QuestionBL = new QuestionBL(); List<DO.Question> QuestionList; QuestionList = QuestionBL.GetFileHotPotato(OpenFile.FileName); txt_FilePath.Text = OpenFile.FileName; if (QuestionList != null) { dataGridView1.DataSource = QuestionList; Showcolumns(); CheckQuestion(); if (WrongQuestion > 0) { MessageBox.Show("Tập tin nhập vào có " + WrongQuestion + " câu hỏi không hợp lệ (câu hỏi bị bôi đỏ). " + "Hệ thống không cho phép chọn các câu hỏi đó. " + "Vui lòng kiểm tra lại nội dung, loại câu hỏi và Phải chọn đáp án cho câu hỏi.", "Cảnh Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { dataGridView1.Columns.Clear(); txt_FilePath.Text = ""; MessageBox.Show("Tải file không thành công. Bạn định dạng file không hợp lý.", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } else { dataGridView1.Columns.Clear(); txt_FilePath.Text = ""; MessageBox.Show("Tải file không thành công. Bạn phải chọn File .XML hoặc .TXT.", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } chk_CheckAll.Checked = false; } }
//SAVE QUESTION private void btn_SaveQuestion_Click(object sender, EventArgs e) { if (cmb_Catalogue.SelectedItem != null) { int NumAnswer = flp_addAnswer.Controls.Count; if (txt_ContentQuestion.Text.Trim() == "" || txt_NameQuestion.Text.Trim() == "" || NumAnswer < 2) { if (txt_ContentQuestion.Text.Trim() == "" || txt_NameQuestion.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 { //GET CATALOGUE ID CatalogueBL CatBL = new CatalogueBL(); List<DO.Catalogue> CatList; CatList = CatBL.GetCatalogue(); if (CatList != null) for (int i = 0; i < CatList.Count; i++) { if (CatList.ElementAt(i).NameCatalogue == cmb_Catalogue.SelectedItem.ToString()) { IDCat = Convert.ToInt32(CatList.ElementAt(i).IDCatalogue); } } //SAVE QUESTION QuestionBL questionBl = new QuestionBL(); Question question = new Question(); Answer answer = new Answer(); question.QuestionTitle = txt_NameQuestion.Text.Trim(); question.NameQuestion = txt_ContentQuestion.Text.Trim(); question.TypeQuestion = "multichoice"; question.IDCatalogue = IDCat; question.Date = DateTime.Now; if ( questionBl.AddQuestion(question)) { foreach (Answer_MultiSelect item in flp_addAnswer.Controls) { if (item.txt_AnswerContent.Text.Trim() != "") { answer.ContentAnswer = item.txt_AnswerContent.Text.Trim(); if (item.chk_Check.Checked == true) { answer.Check = 1; } else { answer.Check = 0; } 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); //Close Form Form FindForm = this.FindForm(); FindForm.Close(); } } } } } else { MessageBox.Show("Vui lòng chọn chủ đề cho câu hỏi!", "Cảnh Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
//SAVE QUESTION AND CONTINUE ADD QUESTION private void btn_SaveAndCreateNewQuestion_Click(object sender, EventArgs e) { if (cmb_Catalogue.SelectedItem != null) { //GET CATALOGUE ID this.Dock = DockStyle.Fill; CatalogueBL CatBL = new CatalogueBL(); List<DO.Catalogue> CatList; CatList = CatBL.GetCatalogue(); if (CatList != null) for (int i = 0; i < CatList.Count; i++) { if (CatList.ElementAt(i).NameCatalogue == cmb_Catalogue.SelectedItem.ToString()) { IDCat = Convert.ToInt32(CatList.ElementAt(i).IDCatalogue); } } //SAVE QUESTION 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 = ""; } } } else { MessageBox.Show("Vui lòng chọn chủ đề cho câu hỏi!", "Cảnh Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
//EDIT QUESTION private void btn_EditQuestion_Click(object sender, EventArgs e) { btn_EditQuestion.Visible = false; btn_Save.Visible = true; btn_addAnswer.Visible = true; flp_Answer.Controls.Clear(); txt_ContentQuestion.ReadOnly = false; //GET QUESTION BY ID Question QuestionBL QuestionBL = new QuestionBL(); List<DO.Question> QuestionList; Question question = new Question(); QuestionList = QuestionBL.GetQuestion(); if (QuestionList != null) { for (int i = 0; i < QuestionList.Count; i++) { if (QuestionList.ElementAt(i).IDQuestion == IDQuestion) { txt_Catalogue.Text = QuestionList.ElementAt(i).NameCatalogue; txt_ContentQuestion.Text = QuestionList.ElementAt(i).NameQuestion; txt_QuestionType.Text = QuestionList.ElementAt(i).TypeQuestion; txt_Date.Text = QuestionList.ElementAt(i).Date.ToString("d"); } } //GET ANSWER BY ID QUESTION List<DO.Answer> AnswerList; Answer answer = new Answer(); question.IDQuestion = IDQuestion; AnswerList = QuestionBL.GetAnswerByQuestionID(question); if (AnswerList != null) { for (int j = 0; j < AnswerList.Count; j++) { Answer_OnlyOneSelect OneChoiceAnswer = new Answer_OnlyOneSelect(); i++; OneChoiceAnswer.Tag = i; OneChoiceAnswer.ID_Answer = i; OneChoiceAnswer.onDelete += OneChoiceAnswer_onDelete; OneChoiceAnswer.onCheck += OneChoiceAnswer_onCheck; OneChoiceAnswer.rad_check.Text = Convert.ToChar(a+j).ToString(); OneChoiceAnswer.txt_Answercontent.Text = AnswerList.ElementAt(j).ContentAnswer; OneChoiceAnswer.rad_check.Checked = AnswerList.ElementAt(j).IsCorrect; flp_Answer.Controls.Add(OneChoiceAnswer); } } } }
public void CheckQuestion() { WrongQuestion = 0; //int CheckQuestion = 0; Question question = new Question(); Answer answer = new Answer(); QuestionBL questionBL = new QuestionBL(); foreach (DataGridViewRow row in dataGridView1.Rows) { if ( row.Cells["QuestionTitle"].Value.ToString().Trim() != "" && row.Cells["NameQuestion"].Value.ToString().Trim() != "" && row.Cells["AnswerContent"].Value.ToString().Trim() != "" && row.Cells["TypeQuestion"].Value.ToString().Trim() != "") { if (row.Cells["TypeQuestion"].Value.ToString().Trim() == "shortanswer" || row.Cells["TypeQuestion"].Value.ToString().Trim() == "multichoice") { if (row.Cells["TypeQuestion"].Value.ToString().Trim() == "shortanswer") { string[] AnswerContent = row.Cells["AnswerContent"].Value.ToString().Trim().Split(new string[] { "</answer>" }, StringSplitOptions.None); int NumAnswer = AnswerContent.Length - 1; if (NumAnswer == 1) { string[] AnswerItem = AnswerContent[0].Split(new string[] { "---" }, StringSplitOptions.None); if (AnswerItem[1].ToString().Trim() != "" && AnswerItem[1].ToString().Trim().Contains("</span>")==false && AnswerItem[0].ToString().Trim() != "") { int PointAnswer; bool isNum = int.TryParse(AnswerItem[0].ToString().Trim(), out PointAnswer); if (isNum = true && Convert.ToInt32(AnswerItem[0].ToString().Trim()) > 0) { row.DefaultCellStyle.BackColor = Color.LightSkyBlue ; } else { row.DefaultCellStyle.BackColor = Color.LightCoral; row.ReadOnly = true; WrongQuestion++; } } else { row.DefaultCellStyle.BackColor = Color.LightCoral; row.ReadOnly = true; WrongQuestion++; } } else { row.DefaultCellStyle.BackColor = Color.LightCoral; row.ReadOnly = true; WrongQuestion++; } } else { string[] AnswerContent = row.Cells["AnswerContent"].Value.ToString().Trim().Split(new string[] { "</answer>" }, StringSplitOptions.None); int Numanswer = AnswerContent.Length - 1; if (Numanswer < 2) { row.DefaultCellStyle.BackColor = Color.LightCoral; row.ReadOnly = true; WrongQuestion++; } else { int empty = 0; int CountNumberOfIncorrect = 0; int TotalAnswer = 0; for (int i = 0; i < AnswerContent.Length - 1; i++) { string[] AnswerItem = AnswerContent[i].Split(new string[] { "---" }, StringSplitOptions.None); int PointAnswer; bool isNum = int.TryParse(AnswerItem[0].ToString().Trim(), out PointAnswer); //check null answer or invalid answer if (AnswerItem[1].ToString().Trim() == "" || AnswerItem[1].ToString().Trim().Contains("</span>") == true || AnswerItem[0].ToString().Trim() == "" || isNum == false) { empty++; } //check don't have any correct answer if (int.TryParse(AnswerItem[0].ToString().Trim(), out PointAnswer)) { if (Convert.ToInt32(AnswerItem[0].ToString().Trim()) == 0) { CountNumberOfIncorrect++; } } TotalAnswer++; } if (empty > 0 || TotalAnswer == CountNumberOfIncorrect) { row.DefaultCellStyle.BackColor = Color.LightCoral; row.ReadOnly = true; WrongQuestion++; } else { row.DefaultCellStyle.BackColor = Color.LightSkyBlue ; } } } } else { row.DefaultCellStyle.BackColor = Color.LightCoral; row.ReadOnly = true; WrongQuestion++; } } else { row.DefaultCellStyle.BackColor = Color.LightCoral; row.ReadOnly = true; WrongQuestion++; } }//end foreach }
//Load Form private void ViewQuestionShortAnswer_Load(object sender, EventArgs e) { //GET QUESTION BY ID Question QuestionBL QuestionBL = new QuestionBL(); List<DO.Question> QuestionList; Question question = new Question(); QuestionList = QuestionBL.GetQuestion(); if (QuestionList != null) { for (int i = 0; i < QuestionList.Count; i++) { if (QuestionList.ElementAt(i).IDQuestion == IDQuestion) { txt_Catalogue.Text = QuestionList.ElementAt(i).NameCatalogue; txt_ContentQuestion.Text = QuestionList.ElementAt(i).NameQuestion; txt_QuestionType.Text = QuestionList.ElementAt(i).TypeQuestion; txt_Date.Text = QuestionList.ElementAt(i).Date.ToString("d"); } } //GET ANSWER BY ID QUESTION List<DO.Answer> AnswerList; Answer answer = new Answer(); question.IDQuestion = IDQuestion; AnswerList = QuestionBL.GetAnswerByQuestionID(question); if (AnswerList != null) { for (int j = 0; j < AnswerList.Count; j++) { txt_ContentAnswer.Text = AnswerList.ElementAt(j).ContentAnswer; } } } }
//Select question follow catalogue private void cmb_Catalogue_SelectedIndexChanged(object sender, EventArgs e) { dgv_Question.Columns.Clear(); Catalogue catalogue = new Catalogue(); CatalogueBL CatBL = new CatalogueBL(); List<DO.Catalogue> CatList; CatList = CatBL.GetCatalogue(); if (CatList != null) for (int i = 0; i < CatList.Count; i++) { if (cmb_Catalogue.SelectedItem.ToString() == CatList.ElementAt(i).NameCatalogue) { catalogue.IDCatalogue = CatList.ElementAt(i).IDCatalogue; } } QuestionBL QuestionBL = new QuestionBL(); List<DO.Question> QuestionList; QuestionList = QuestionBL.GetQuestionByCatalogue(catalogue); if (QuestionList != null) { dgv_Question.DataSource = QuestionList; } dgv_Question.Columns["IDCatalogue"].Visible = false; dgv_Question.Columns["IDQuestion"].Visible = false; dgv_Question.Columns["AnswerContent"].Visible = false; dgv_Question.Columns["Date"].Visible = false; dgv_Question.Columns["NameCatalogue"].Visible = false; dgv_Question.Columns["Catalogue"].Visible = false; dgv_Question.Columns["Sequence"].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells; dgv_Question.Columns["TypeQuestion"].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells; dgv_Question.Columns["NameCatalogue"].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells; dgv_Question.Columns["QuestionTitle"].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells; dgv_Question.Columns["Sequence"].HeaderText = "STT"; dgv_Question.Columns["TypeQuestion"].HeaderText = "Loại Câu Hỏi"; dgv_Question.Columns["NameQuestion"].HeaderText = "Nội Dung Câu Hỏi"; dgv_Question.Columns["QuestionTitle"].HeaderText = "Tên Câu Hỏi"; dgv_Question.Columns["Sequence"].ReadOnly = true; dgv_Question.Columns["TypeQuestion"].ReadOnly = true; dgv_Question.Columns["NameQuestion"].ReadOnly = true; dgv_Question.Columns["QuestionTitle"].ReadOnly = true; DataGridViewCheckBoxColumn CheckColumn = new DataGridViewCheckBoxColumn(); CheckColumn.Name = "Check"; dgv_Question.Columns.Add(CheckColumn); dgv_Question.Columns["Check"].HeaderText = "Chọn"; dgv_Question.Columns["Check"].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells; chk_CheckAll.Checked = false; }
//SAVE QUESTION AND ANSWER private void btn_SaveQuestion_Click(object sender, EventArgs e) { QuestionBL questionBl = new QuestionBL(); Question question = new Question(); Answer answer = new Answer(); int NumAnswer = flp_addAnswer.Controls.Count; if (txt_ContentQuestion.Text.Trim() == "" || txt_NameQuestion.Text.Trim() == "" || NumAnswer < 2) { if (txt_ContentQuestion.Text.Trim() == "" || txt_NameQuestion.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 { question.QuestionTitle = txt_NameQuestion.Text.Trim(); question.NameQuestion = txt_ContentQuestion.Text.Trim(); question.TypeQuestion = "multichoice"; question.IDCatalogue = IDCat; question.Date = DateTime.Now; if (questionBl.AddQuestion(question)) { foreach (Answer_MultiSelect item in flp_addAnswer.Controls) { if (item.txt_AnswerContent.Text.Trim() != "") { answer.ContentAnswer = item.txt_AnswerContent.Text.Trim(); if (item.chk_Check.Checked == true) { answer.Check = 1; } else { answer.Check = 0; } 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(1000); MessageBox.Show("Thêm câu hỏi thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); //Close form Form FindForm = this.FindForm(); FindForm.Close(); } } } } }
//LOAD FORM private void EditQuestion_MultiSelect_Load(object sender, EventArgs e) { //GET QUESTION BY ID Question QuestionBL QuestionBL = new QuestionBL(); List<DO.Question> QuestionList; Question question = new Question(); QuestionList = QuestionBL.GetQuestion(); if (QuestionList != null) { for (int i = 0; i < QuestionList.Count; i++) { if (QuestionList.ElementAt(i).IDQuestion == IDQuestion) { txt_ContentQuestion.Text = QuestionList.ElementAt(i).NameQuestion; txt_Date.Text = QuestionList.ElementAt(i).Date.ToString("d"); } } //GET ANSWER BY ID QUESTION List<DO.Answer> AnswerList; Answer answer = new Answer(); question.IDQuestion = IDQuestion; AnswerList = QuestionBL.GetAnswerByQuestionID(question); if (AnswerList != null) { for (int j = 0; j < AnswerList.Count; j++) { Answer_MultiSelect MultiSelectAnswer = new Answer_MultiSelect(); i++; MultiSelectAnswer.Tag = i; MultiSelectAnswer.ID_Answer = i; MultiSelectAnswer.onDelete += MultiSelectAnswer_onDelete; MultiSelectAnswer.chk_Check.Text = Convert.ToChar(a + j).ToString(); //flp_addAnswer.Controls.Add(MultiSelectAnswer); MultiSelectAnswer.txt_AnswerContent.Text = AnswerList.ElementAt(j).ContentAnswer; MultiSelectAnswer.chk_Check.Checked = AnswerList.ElementAt(j).IsCorrect; flp_addAnswer.Controls.Add(MultiSelectAnswer); } } } }
//LOAD FORM private void ViewQuestionMultiple_Load(object sender, EventArgs e) { //GET QUESTION BY ID Question QuestionBL QuestionBL = new QuestionBL(); List<DO.Question> QuestionList; Question question = new Question(); QuestionList = QuestionBL.GetQuestion(); if (QuestionList != null) { for (int i = 0; i < QuestionList.Count; i++) { if (QuestionList.ElementAt(i).IDQuestion == IDQuestion) { txt_Catalogue.Text = QuestionList.ElementAt(i).NameCatalogue; txt_ContentQuestion.Text = QuestionList.ElementAt(i).NameQuestion; txt_QuestionType.Text = QuestionList.ElementAt(i).TypeQuestion; txt_Date.Text = QuestionList.ElementAt(i).Date.ToString("d"); } } //GET ANSWER BY ID QUESTION List<DO.Answer> AnswerList; Answer answer = new Answer(); question.IDQuestion = IDQuestion; AnswerList = QuestionBL.GetAnswerByQuestionID(question); if (AnswerList != null) { for (int j = 0; j < AnswerList.Count; j++) { Answer_MultiSelect MultiChoiceAnswer = new Answer_MultiSelect(); i++; MultiChoiceAnswer.Tag = i; MultiChoiceAnswer.ID_Answer = i; MultiChoiceAnswer.onDelete += OneChoiceAnswer_onDelete; MultiChoiceAnswer.chk_Check.Text = Convert.ToChar(a + j).ToString(); MultiChoiceAnswer.txt_AnswerContent.Text = AnswerList.ElementAt(j).ContentAnswer; MultiChoiceAnswer.chk_Check.Checked = AnswerList.ElementAt(j).IsCorrect; MultiChoiceAnswer.txt_AnswerContent.ReadOnly = true; MultiChoiceAnswer.chk_Check.Enabled = false; MultiChoiceAnswer.btn_DelAnswer.Visible = false; flp_Answer.Controls.Add(MultiChoiceAnswer); } } } }
//SAVE QUESTION private void btn_SaveCopy_Click(object sender, EventArgs e) { if (cmb_Catalogue.SelectedItem != null) { //GET ID CATALOGUE AFTER SELECT COMMOBOX CatalogueBL CatBL = new CatalogueBL(); List<DO.Catalogue> CatList; CatList = CatBL.GetCatalogue(); if (CatList != null) for (int i = 0; i < CatList.Count; i++) { if (CatList.ElementAt(i).NameCatalogue == cmb_Catalogue.SelectedItem.ToString()) { IDCatSelected = Convert.ToInt32(CatList.ElementAt(i).IDCatalogue); } } //ADD QUESTION QuestionBL QuestionBL = new QuestionBL(); List<DO.Question> QuestionList; QuestionList = QuestionBL.GetQuestion(); if (QuestionList != null) { for (int i = 0; i < QuestionList.Count; i++) { int count = 0; for (int j = 0; j < IdQ.Length; j++) { if (QuestionList.ElementAt(i).IDQuestion == Convert.ToInt32(IdQ[j])) { count++; } } if (count > 0) { Question question = new Question(); question.QuestionTitle = QuestionList.ElementAt(i).QuestionTitle; question.NameQuestion = QuestionList.ElementAt(i).NameQuestion; question.TypeQuestion = QuestionList.ElementAt(i).TypeQuestion; question.IDCatalogue = IDCatSelected; IDQuestion = QuestionList.ElementAt(i).IDQuestion; question.Date = DateTime.Now; if (QuestionBL.AddQuestion(question)==true) { //ADD ANSWER Question Question = new Question(); Question.IDQuestion = IDQuestion; List<DO.Answer> AnswerList; AnswerList = QuestionBL.GetAnswerByQuestionID(Question); if (AnswerList != null) for (int ii = 0; ii < AnswerList.Count; ii++) { if (AnswerList.ElementAt(ii).IDQuestion == IDQuestion) { Answer answer = new Answer(); answer.ContentAnswer = AnswerList.ElementAt(ii).ContentAnswer; if (AnswerList.ElementAt(ii).IsCorrect == true) { answer.Check = 1; } else { answer.Check = 0; } answer.IDQuestion = QuestionBL.MaxIDQuestion(); answer.IDCatalogue = IDCatSelected; QuestionBL.AddAnswer(answer); } } } } } //Notify //notifyIcon1.Icon = SystemIcons.Information; //notifyIcon1.BalloonTipText = "Sao Chép câu hỏi sang chủ đề \"" + cmb_Catalogue.SelectedItem.ToString() + "\" thành công."; //notifyIcon1.ShowBalloonTip(2000); MessageBox.Show("Sao Chép câu hỏi sang chủ đề \"" + cmb_Catalogue.SelectedItem.ToString() + "\" thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } } else { MessageBox.Show("Vui lòng chọn chủ đề!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } }