public void FillAnswers(Object sender, EventArgs e)
        {
            QuestionAnswersStruct question_answer = model_edit_question.GetAnswers(iquestionEdit.question_checked);

            iquestionEdit.answerA_new_text = question_answer.answerA;
            iquestionEdit.answerB_new_text = question_answer.answerB;
            iquestionEdit.answerC_new_text = question_answer.answerC;
            iquestionEdit.answerD_new_text = question_answer.answerD;
        }
        public void Edit(Object sender, EventArgs e)
        {
            QuestionAnswersStruct question_answer = new QuestionAnswersStruct();

            question_answer.question_old = iquestionEdit.question_checked;
            question_answer.question_new = iquestionEdit.question_new_text;
            question_answer.answerA      = iquestionEdit.answerA_new_text;
            question_answer.answerB      = iquestionEdit.answerB_new_text;
            question_answer.answerC      = iquestionEdit.answerC_new_text;
            question_answer.answerD      = iquestionEdit.answerD_new_text;
            model_edit_question.Edit(question_answer);
            UpdateView();
        }
 public QuestionAnswersStruct GetAnswers(String question)
 {
     using (var db = new EntityDM.MillionareDBEntities3())
     {
         IQueryable <EntityDM.Answers> answers = db.Answers;
         var answer = answers.Where(x => x.Questions.Question == question).ToList().First();
         QuestionAnswersStruct qa = new QuestionAnswersStruct();
         qa.answerA = answer.Answer_A;
         qa.answerB = answer.Answer_B;
         qa.answerC = answer.Answer_C;
         qa.answerD = answer.Answer_D;
         return(qa);
     }
 }
 public void Edit(QuestionAnswersStruct qa)
 {
     try
     {
         using (var db = new EntityDM.MillionareDBEntities3())
         {
             IQueryable <EntityDM.Questions> q = db.Questions;
             IQueryable <EntityDM.Answers>   a = db.Answers;
             var question = q.Where(x => x.Question.Equals(qa.question_old)).ToList().First();
             var answer   = a.Where(x => x.Questions_FK == question.Id).ToList().First();
             answer.Answer_A   = qa.answerA;
             answer.Answer_B   = qa.answerB;
             answer.Answer_C   = qa.answerC;
             answer.Answer_D   = qa.answerD;
             question.Question = qa.question_new;
             db.SaveChanges();
             Update();
         }
     }
     catch
     { throw; }
 }