private void take_exam(object sender, RoutedEventArgs e) { if (selectedExamId > 0) { rel_exam_student ess = (from es in contect3.rel_exam_student where es.ExamCode == selectedExamId && es.StuId == userID select es).First(); ess.Taken = true; contect3.SaveChanges(); getQuestionsOfExam = (from Q in contect3.questions join E in contect3.exam_qusetion on Q.QustCode equals E.Question_Id where E.Exam_Id == selectedExamId select Q).ToList(); QCounter = getQuestionsOfExam.Count(); // getting the first question question questionIndex = getQuestionsOfExam.ElementAt(i); string QuestionContent = ""; if (questionIndex.type == "text") { var Question = (from qs in contect3.textquestions where qs.QustCode == questionIndex.QustCode select qs).FirstOrDefault(); QuestionContent = Question.question; CurrentQuestion = "text"; Canvas.SetZIndex(textAnswer, ++z); } if (questionIndex.type == "MSQ") { QuestionContent = (from qs in contect3.multichoices where qs.QustCode == questionIndex.QustCode select qs.question).FirstOrDefault(); List <string> choise = (from choisse in contect3.msqmultivalues where choisse.MCQCode == (from qs in contect3.multichoices where qs.QustCode == questionIndex.QustCode select qs.MCQCode).FirstOrDefault() select choisse.ModelAnswer).ToList(); A.Content = choise.ElementAt(0); B.Content = choise.ElementAt(1); C.Content = choise.ElementAt(2); D.Content = choise.ElementAt(3); CurrentQuestion = "mcq"; Canvas.SetZIndex(msqAnswer, ++z); } if (questionIndex.type == "true&false") { QuestionContent = (from qs in contect3.qtruefalses where qs.QustCode == questionIndex.QustCode select qs.question).FirstOrDefault(); CurrentQuestion = "tf"; Canvas.SetZIndex(tfAnswer, ++z); } question.Content = QuestionContent; Canvas.SetZIndex(stuQuestion, ++z); } else { MessageBox.Show("Get Out"); } }
private void Button_Click_6(object sender, RoutedEventArgs e) { try { examListView exa = avaialableExams.SelectedItem as examListView; rel_exam_student t = (from y in context2.rel_exam_student where y.ExamCode == exa.ExamCode select y).FirstOrDefault(); context2.rel_exam_student.Remove(t); context2.SaveChanges(); MessageBox.Show("done"); } catch (Exception dds) { } }