EditIDCatalogueAnswerByIDQuestion() public méthode

public EditIDCatalogueAnswerByIDQuestion ( Question Question ) : bool
Question CapDemo.DO.Question
Résultat bool
 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);
             //}
         }
     }
 }
 //SAVE QUESTION
 private void btn_SaveMove_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)
                 {
                     //QuestionBL questionbl = new QuestionBL();
                     Question question = new Question();
                     question.IDQuestion = QuestionList.ElementAt(i).IDQuestion;
                     question.IDCatalogue = IDCatSelected;
                     QuestionBL.EditIDCatalogueAnswerByIDQuestion(question);
                     QuestionBL.EditIDCatalogueQuestionByIDQuestion(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);
                     //            }
                     //        }
                     //    //DELETE QUESTION
                     //    QuestionBL.DeleteAnswerByIDQuestion(Question);
                     //    QuestionBL.DeleteQuestionByID(Question);
                     //}
                 }
             }
             //Notify
             //notifyIcon1.Icon = SystemIcons.Information;
             //notifyIcon1.BalloonTipText = "Chuyển câu hỏi sang chủ đề \"" + cmb_Catalogue.SelectedItem.ToString() + "\" thành công.";
             //notifyIcon1.ShowBalloonTip(2000);
             MessageBox.Show("Chuyển 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);
     }
 }