private FlowLayoutPanel binddata_for_review(string SubjectCode) { var query = from p in question_dataset.Tables[0].AsEnumerable() where p.Field<string>(2).Equals(SubjectCode) select new { ExamCode = p.Field<string>(0), TestCode = p.Field<string>(1), SubjectCode = p.Field<string>(2), ExamName = p.Field<string>(3), TestName = p.Field<string>(4), SubjectName = p.Field<string>(5), QuestionNo = p.Field<int>(6), QuestionName = p.Field<string>(7), Answer1 = p.Field<string>(8), Answer2 = p.Field<string>(9), Answer3 = p.Field<string>(10), Answer4 = p.Field<string>(11), Answer5 = p.Field<string>(12), CorrectOption = p.Field<int>(13), Qname_HasImage = p.Field<int>(14), Option1 = p.Field<int>(15), Option2 = p.Field<int>(16), Option3 = p.Field<int>(17), Option4 = p.Field<int>(18), Option5 = p.Field<int>(19), IsAttempted = p.Field<int>(20), Ans1_HasImage = p.Field<int>(21), Ans2_HasImage = p.Field<int>(22), Ans3_HasImage = p.Field<int>(23), Ans4_HasImage = p.Field<int>(24), Ans5_HasImage = p.Field<int>(25) }; FlowLayoutPanel FlPanel = new FlowLayoutPanel(); foreach (var grp in query) { obj_UsrCntrl[count] = new usr_cntrl(); if (grp.Qname_HasImage == 1) { obj_UsrCntrl[count].Picture.Image = Image.FromFile(Application.StartupPath + "\\image_path\\" + grp.QuestionName); obj_UsrCntrl[count].Flpanel.Visible = true; obj_UsrCntrl[count].Question_Label.Visible = false; obj_UsrCntrl[count].Flpanel.Size = new Size(793, 196); obj_UsrCntrl[count].Flpanel.Location = new Point(29, 40); } if (grp.Ans1_HasImage == 1) { obj_UsrCntrl[count].ImageAns1.Image = Image.FromFile(Application.StartupPath + "\\image_path\\" + grp.Answer1); } if (grp.Ans2_HasImage == 1) { obj_UsrCntrl[count].ImageAns2.Image = Image.FromFile(Application.StartupPath + "\\image_path\\" + grp.Answer2); } if (grp.Ans3_HasImage == 1) { obj_UsrCntrl[count].ImageAns3.Image = Image.FromFile(Application.StartupPath + "\\image_path\\" + grp.Answer3); } if (grp.Ans4_HasImage == 1) { obj_UsrCntrl[count].ImageAns4.Image = Image.FromFile(Application.StartupPath + "\\image_path\\" + grp.Answer4); } if (grp.Ans5_HasImage == 1) { obj_UsrCntrl[count].ImageAns5.Image = Image.FromFile(Application.StartupPath + "\\image_path\\" + grp.Answer5); } if (grp.Qname_HasImage == 0) { obj_UsrCntrl[count].Question_Label.Text = grp.QuestionName; obj_UsrCntrl[count].Flpanel.Visible = false; obj_UsrCntrl[count].Question_Label.Visible = true; obj_UsrCntrl[count].Question_Label.Size = new Size(793, 196); obj_UsrCntrl[count].Question_Label.Location = new Point(29, 40); } if (grp.Ans1_HasImage == 0) { obj_UsrCntrl[count].ImageAns1.Text = grp.Answer1; } if (grp.Ans2_HasImage == 0) { obj_UsrCntrl[count].ImageAns2.Text = grp.Answer2; } if (grp.Ans3_HasImage == 0) { obj_UsrCntrl[count].ImageAns3.Text = grp.Answer3; } if (grp.Ans4_HasImage == 0) { obj_UsrCntrl[count].ImageAns4.Text = grp.Answer4; } if (grp.Ans5_HasImage == 0) { obj_UsrCntrl[count].ImageAns5.Text = grp.Answer5; } obj_UsrCntrl[count].RadioButton6.Checked = Convert.ToBoolean(grp.Option1); obj_UsrCntrl[count].RadioButton7.Checked = Convert.ToBoolean(grp.Option2); obj_UsrCntrl[count].RadioButton8.Checked = Convert.ToBoolean(grp.Option3); obj_UsrCntrl[count].RadioButton9.Checked = Convert.ToBoolean(grp.Option4); obj_UsrCntrl[count].RadioButton10.Checked = Convert.ToBoolean(grp.Option5); obj_UsrCntrl[count].RadioButton6.Enabled = false; obj_UsrCntrl[count].RadioButton7.Enabled = false; obj_UsrCntrl[count].RadioButton8.Enabled = false; obj_UsrCntrl[count].RadioButton9.Enabled = false; obj_UsrCntrl[count].RadioButton10.Enabled = false; if (obj_UsrCntrl[count].RadioButton6.Checked) { obj_UsrCntrl[count].WrongImage1.Visible = true; obj_UsrCntrl[count].WrongImage2.Visible = false; obj_UsrCntrl[count].WrongImage3.Visible = false; obj_UsrCntrl[count].WrongImage4.Visible = false; obj_UsrCntrl[count].WrongImage5.Visible = false; } else if (obj_UsrCntrl[count].RadioButton7.Checked) { obj_UsrCntrl[count].WrongImage1.Visible = false; obj_UsrCntrl[count].WrongImage2.Visible = true; obj_UsrCntrl[count].WrongImage3.Visible = false; obj_UsrCntrl[count].WrongImage4.Visible = false; obj_UsrCntrl[count].WrongImage5.Visible = false; } else if (obj_UsrCntrl[count].RadioButton8.Checked) { obj_UsrCntrl[count].WrongImage1.Visible = false; obj_UsrCntrl[count].WrongImage2.Visible = false; obj_UsrCntrl[count].WrongImage3.Visible = true; obj_UsrCntrl[count].WrongImage4.Visible = false; obj_UsrCntrl[count].WrongImage5.Visible = false; } else if (obj_UsrCntrl[count].RadioButton9.Checked) { obj_UsrCntrl[count].WrongImage1.Visible = false; obj_UsrCntrl[count].WrongImage2.Visible = false; obj_UsrCntrl[count].WrongImage3.Visible = false; obj_UsrCntrl[count].WrongImage4.Visible = true; obj_UsrCntrl[count].WrongImage5.Visible = false; } else if (obj_UsrCntrl[count].RadioButton10.Checked) { obj_UsrCntrl[count].WrongImage1.Visible = false; obj_UsrCntrl[count].WrongImage2.Visible = false; obj_UsrCntrl[count].WrongImage3.Visible = false; obj_UsrCntrl[count].WrongImage4.Visible = false; obj_UsrCntrl[count].WrongImage5.Visible = true; } else { obj_UsrCntrl[count].WrongImage1.Visible = false; obj_UsrCntrl[count].WrongImage2.Visible = false; obj_UsrCntrl[count].WrongImage3.Visible = false; obj_UsrCntrl[count].WrongImage4.Visible = false; obj_UsrCntrl[count].WrongImage5.Visible = false; } switch (grp.CorrectOption) { case 1: obj_UsrCntrl[count].CorrectImage1.Visible = true; obj_UsrCntrl[count].CorrectImage2.Visible = false; obj_UsrCntrl[count].CorrectImage3.Visible = false; obj_UsrCntrl[count].CorrectImage4.Visible = false; obj_UsrCntrl[count].CorrectImage5.Visible = false; if (obj_UsrCntrl[count].RadioButton6.Checked) { obj_UsrCntrl[count].WrongImage1.Visible = false; obj_UsrCntrl[count].WrongImage2.Visible = false; obj_UsrCntrl[count].WrongImage3.Visible = false; obj_UsrCntrl[count].WrongImage4.Visible = false; obj_UsrCntrl[count].WrongImage5.Visible = false; } break; case 2: obj_UsrCntrl[count].CorrectImage1.Visible = false; obj_UsrCntrl[count].CorrectImage2.Visible = true; obj_UsrCntrl[count].CorrectImage3.Visible = false; obj_UsrCntrl[count].CorrectImage4.Visible = false; obj_UsrCntrl[count].CorrectImage5.Visible = false; if (obj_UsrCntrl[count].RadioButton7.Checked) { obj_UsrCntrl[count].WrongImage1.Visible = false; obj_UsrCntrl[count].WrongImage2.Visible = false; obj_UsrCntrl[count].WrongImage3.Visible = false; obj_UsrCntrl[count].WrongImage4.Visible = false; obj_UsrCntrl[count].WrongImage5.Visible = false; } break; case 3: obj_UsrCntrl[count].CorrectImage1.Visible = false; obj_UsrCntrl[count].CorrectImage2.Visible = false; obj_UsrCntrl[count].CorrectImage3.Visible = true; obj_UsrCntrl[count].CorrectImage4.Visible = false; obj_UsrCntrl[count].CorrectImage5.Visible = false; if (obj_UsrCntrl[count].RadioButton8.Checked) { obj_UsrCntrl[count].WrongImage1.Visible = false; obj_UsrCntrl[count].WrongImage2.Visible = false; obj_UsrCntrl[count].WrongImage3.Visible = false; obj_UsrCntrl[count].WrongImage4.Visible = false; obj_UsrCntrl[count].WrongImage5.Visible = false; } break; case 4: obj_UsrCntrl[count].CorrectImage1.Visible = false; obj_UsrCntrl[count].CorrectImage2.Visible = false; obj_UsrCntrl[count].CorrectImage3.Visible = false; obj_UsrCntrl[count].CorrectImage4.Visible = true; obj_UsrCntrl[count].CorrectImage5.Visible = false; if (obj_UsrCntrl[count].RadioButton9.Checked) { obj_UsrCntrl[count].WrongImage1.Visible = false; obj_UsrCntrl[count].WrongImage2.Visible = false; obj_UsrCntrl[count].WrongImage3.Visible = false; obj_UsrCntrl[count].WrongImage4.Visible = false; obj_UsrCntrl[count].WrongImage5.Visible = false; } break; case 5: obj_UsrCntrl[count].CorrectImage1.Visible = false; obj_UsrCntrl[count].CorrectImage2.Visible = false; obj_UsrCntrl[count].CorrectImage3.Visible = false; obj_UsrCntrl[count].CorrectImage4.Visible = false; obj_UsrCntrl[count].CorrectImage5.Visible = true; if (obj_UsrCntrl[count].RadioButton10.Checked) { obj_UsrCntrl[count].WrongImage1.Visible = false; obj_UsrCntrl[count].WrongImage2.Visible = false; obj_UsrCntrl[count].WrongImage3.Visible = false; obj_UsrCntrl[count].WrongImage4.Visible = false; obj_UsrCntrl[count].WrongImage5.Visible = false; } break; } obj_UsrCntrl[count].question_number.Text = Convert.ToString(grp.QuestionNo); obj_UsrCntrl[count].CorrectOption.Text = Convert.ToString(grp.CorrectOption); obj_UsrCntrl[count].CorrectOption.Visible = false; obj_UsrCntrl[count].section_code.Text = grp.SubjectCode; obj_UsrCntrl[count].section_code.Visible = false; obj_UsrCntrl[count].Dock = System.Windows.Forms.DockStyle.Top; FlPanel.Controls.Add(obj_UsrCntrl[count]); count++; } FlPanel.AutoScroll = true; FlPanel.Size = new Size(856, 462); return FlPanel; }
private FlowLayoutPanel bind_data(string SubjectCode) { var query = from p in question_dataset.Tables[0].AsEnumerable() where p.Field<string>(2).Equals(SubjectCode) select new { SubjectGroup = p.Field<string>(0), SubjectName = p.Field<string>(1), SubjectCode = p.Field<string>(2), QuestionNo = p.Field<int>(3), QuestionName = p.Field<string>(4), Answer1 = p.Field<string>(5), Answer2 = p.Field<string>(6), Answer3 = p.Field<string>(7), Answer4 = p.Field<string>(8), Answer5 = p.Field<string>(9), CorrectOption = p.Field<int>(10), Qname_HasImage = p.Field<int>(11), Ans1_HasImage = p.Field<int>(12), Ans2_HasImage = p.Field<int>(13), Ans3_HasImage = p.Field<int>(14), Ans4_HasImage = p.Field<int>(15), Ans5_HasImage = p.Field<int>(16) }; FlowLayoutPanel FlPanel = new FlowLayoutPanel(); foreach (var grp in query) { obj_UsrCntrl[count] = new usr_cntrl(); obj_UsrCntrl[count].CorrectImage1.Visible = false; obj_UsrCntrl[count].CorrectImage2.Visible = false; obj_UsrCntrl[count].CorrectImage3.Visible = false; obj_UsrCntrl[count].CorrectImage4.Visible = false; obj_UsrCntrl[count].CorrectImage5.Visible = false; obj_UsrCntrl[count].WrongImage1.Visible = false; obj_UsrCntrl[count].WrongImage2.Visible = false; obj_UsrCntrl[count].WrongImage3.Visible = false; obj_UsrCntrl[count].WrongImage4.Visible = false; obj_UsrCntrl[count].WrongImage5.Visible = false; if (grp.Qname_HasImage == 1) { obj_UsrCntrl[count].Picture.Image = Image.FromFile(Application.StartupPath + "\\image_path\\" + grp.QuestionName); obj_UsrCntrl[count].Flpanel.Visible = true; obj_UsrCntrl[count].Question_Label.Visible = false; obj_UsrCntrl[count].Flpanel.Size = new Size(793, 196); obj_UsrCntrl[count].Flpanel.Location = new Point(29, 40); } if (grp.Ans1_HasImage == 1) { obj_UsrCntrl[count].ImageAns1.Image = Image.FromFile(Application.StartupPath + "\\image_path\\" + grp.Answer1); } if (grp.Ans2_HasImage == 1) { obj_UsrCntrl[count].ImageAns2.Image = Image.FromFile(Application.StartupPath + "\\image_path\\" + grp.Answer2); } if (grp.Ans3_HasImage == 1) { obj_UsrCntrl[count].ImageAns3.Image = Image.FromFile(Application.StartupPath + "\\image_path\\" + grp.Answer3); } if (grp.Ans4_HasImage == 1) { obj_UsrCntrl[count].ImageAns4.Image = Image.FromFile(Application.StartupPath + "\\image_path\\" + grp.Answer4); } if (grp.Ans5_HasImage == 1) { obj_UsrCntrl[count].ImageAns5.Image = Image.FromFile(Application.StartupPath + "\\image_path\\" + grp.Answer5); } if (grp.Qname_HasImage == 0) { obj_UsrCntrl[count].Question_Label.Text = grp.QuestionName; obj_UsrCntrl[count].Flpanel.Visible = false; obj_UsrCntrl[count].Question_Label.Visible = true; obj_UsrCntrl[count].Question_Label.Size = new Size(793, 196); obj_UsrCntrl[count].Question_Label.Location = new Point(29, 40); } if (grp.Ans1_HasImage == 0) { obj_UsrCntrl[count].ImageAns1.Text = grp.Answer1; } if (grp.Ans2_HasImage == 0) { obj_UsrCntrl[count].ImageAns2.Text = grp.Answer2; } if (grp.Ans3_HasImage == 0) { obj_UsrCntrl[count].ImageAns3.Text = grp.Answer3; } if (grp.Ans4_HasImage == 0) { obj_UsrCntrl[count].ImageAns4.Text = grp.Answer4; } if (grp.Ans5_HasImage == 0) { obj_UsrCntrl[count].ImageAns5.Text = grp.Answer5; } obj_UsrCntrl[count].question_number.Text = Convert.ToString(grp.QuestionNo); obj_UsrCntrl[count].CorrectOption.Text = Convert.ToString(grp.CorrectOption); obj_UsrCntrl[count].CorrectOption.Visible = false; obj_UsrCntrl[count].section_code.Text = grp.SubjectCode; obj_UsrCntrl[count].section_code.Visible = false; obj_UsrCntrl[count].Dock = System.Windows.Forms.DockStyle.Top; FlPanel.Controls.Add(obj_UsrCntrl[count]); count++; } FlPanel.AutoScroll = true; FlPanel.Size = new Size(856, 462); return FlPanel; }