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);
}
}
}
}
}
}