private void frm_QuestionAddEdit_Load(object sender, EventArgs e)
        {   s = null;
            ob = new class_Application();
            
            s = "SELECT Exam_Master.Exam_Code, Test_Master.Test_code, Subject_Master.Sub_code, Exam_Master.Exam_Name, " +
                "Test_Master.Test_Name, Subject_Master.Sub_Name FROM (Exam_Master INNER JOIN Test_Master ON " +
                "Exam_Master.Exam_Code = Test_Master.Exam_code) INNER JOIN Subject_Master ON Exam_Master.Exam_Code = " +
                "Subject_Master.Exam_code;";

            dt = new DataTable();
            dt = ob.fill_data_table(s);

            var query = from p in dt.AsEnumerable()
                        group p by new
                        {   ExamCode = p.Field<string>("Exam_Code"),
                            ExamName = p.Field<string>("Exam_Name")
                        } into grp
                        select new
                        {   ExamCode = grp.Key.ExamCode,
                            ExamName = grp.Key.ExamName
                        };

            DataTable ExamTable = new DataTable("Exam_Master");
            ExamTable.Columns.Add("ExamCode", typeof(string));
            ExamTable.Columns.Add("ExamName", typeof(string));

            foreach (var grp in query)
            {   DataRow dr = ExamTable.NewRow();
                dr["ExamCode"] = grp.ExamCode;
                dr["ExamName"] = grp.ExamName;
                ExamTable.Rows.Add(dr);
            }

           
            comboBox1.DataSource = ExamTable;
            comboBox1.DisplayMember = "ExamName";
             
        }
        //--form load event---->
        private void frm_exam_Load(object sender, EventArgs e)
        {

            
            count = 0;
            ob = new class_Application();

            if (class_Application.REVIEW == 0)
            {
                timer1.Enabled = true;
                lbl_timer.Visible = true;

                string s = "SELECT Exam_Master.Exam_Code, Subject_Master.Sub_code, Test_Master.Test_code, Exam_Master.Exam_Name," +
               " Subject_Master.Sub_Name, Test_Master.Test_Name, Questions_Master.Q_No, Questions_Master.Q_Name, " +
               "Questions_Master.Answer1, Questions_Master.Answer2, Questions_Master.Answer3, Questions_Master.Answer4, " +
               "Questions_Master.Answer5, Questions_Master.Answer6, Questions_Master.Answer7, Questions_Master.Answer8, " +
               "Questions_Master.Answer9, Questions_Master.Answer10, Questions_Master.Answer11, Questions_Master.Answer12, " +
               "Questions_Master.Answer13, Questions_Master.Answer14, Questions_Master.Answer15, Questions_Master.Answer16," +
               " Questions_Master.Answer17, Questions_Master.Answer18, Questions_Master.Qname_HasImage,"+
               "Questions_Master.Q_type,Exam_Master.Can_Skip,sub_duration FROM ((Exam_Master INNER JOIN Subject_Master ON " +
               "Exam_Master.Exam_Code = Subject_Master.Exam_code) INNER JOIN Test_Master ON Exam_Master.Exam_Code = " +
               "Test_Master.Exam_code) INNER JOIN Questions_Master ON (Exam_Master.Exam_Code = Questions_Master.Exam_code) AND " +
               "(Test_Master.Test_code = Questions_Master.Test_code) AND (Test_Master.Exam_code = Questions_Master.Exam_code)" +
               " AND (Subject_Master.Exam_code = Questions_Master.Exam_code) AND (Subject_Master.Sub_code = Questions_Master.Sub_code) " +
               "WHERE (((Exam_Master.Exam_Code)='" + ExamCode + "') AND ((Test_Master.Test_code)='" + TestCode + "'));";
                init_datatable = ob.fill_data_table(s);
                collection = new DataTable();
                collection = init_datatable.Clone();
                collection.Columns.Add("option1", typeof(int));
                collection.Columns.Add("option2", typeof(int));
                collection.Columns.Add("option3", typeof(int));
                collection.Columns.Add("option4", typeof(int));
                collection.Columns.Add("option5", typeof(int));
                collection.Columns.Add("option6", typeof(int));
                collection.Columns.Add("option7", typeof(int));
                collection.Columns.Add("option8", typeof(int));
                collection.Columns.Add("option9", typeof(int));
                collection.Columns.Add("option10", typeof(int));
                collection.Columns.Add("option11", typeof(int));
                collection.Columns.Add("option12", typeof(int));
                collection.Columns.Add("option13", typeof(int));
                collection.Columns.Add("option14", typeof(int));
                collection.Columns.Add("option15", typeof(int));
                collection.Columns.Add("option16", typeof(int));
                collection.Columns.Add("option17", typeof(int));
                collection.Columns.Add("option18", typeof(int));
                collection.Columns.Add("essay_answer", typeof(string));



                var query = from p in init_datatable.AsEnumerable()
                            group p by new
                            {
                                SubjectCode = p.Field<string>("Sub_code"),
                                SubjectName = p.Field<string>("Sub_Name"),
                                time = p.Field<int>("sub_duration"),
                                CanSkip = p.Field<int>("Can_Skip")
                            } into grp
                            select new
                            {
                                SubjectCode = grp.Key.SubjectCode,
                                SubjectName = grp.Key.SubjectName,
                                time = grp.Key.time,
                                CanSkip = grp.Key.CanSkip
                            };

                Subject = new DataTable("Subject");
                Subject.Columns.Add("SubjectCode", typeof(string));
                Subject.Columns.Add("SubjectName", typeof(string));
                Subject.Columns.Add("time", typeof(int));
                Subject.Columns.Add("CanSkip", typeof(int));
                foreach (var grp in query)
                {
                    DataRow dr = Subject.NewRow();
                    dr["SubjectCode"] = grp.SubjectCode;
                    dr["SubjectName"] = grp.SubjectName;
                    dr["time"] = grp.time;
                    dr["CanSkip"] = grp.CanSkip;
                    Subject.Rows.Add(dr);
                }

                lbl_exam.Text = ExamName;
                lbl_test.Text = TestName;
                string sub_code = Convert.ToString(Subject.Rows[count]["SubjectCode"]);
                time = Convert.ToInt32(Subject.Rows[count]["time"]) * 60;
                bind_data(sub_code);


               }
            else
            {
                timer1.Enabled = false;
                lbl_timer.Visible = false;

                string s = "SELECT Exam_Master.Exam_Code, Subject_Master.Sub_code, Test_Master.Test_code, Exam_Master.Exam_Name, "+
                           "Subject_Master.Sub_Name, Test_Master.Test_Name, Questions_Master.Q_No, Questions_Master.Q_Name, Questions_Master.Answer1, "+
                           "Questions_Master.Answer2, Questions_Master.Answer3, Questions_Master.Answer4, Questions_Master.Answer5, "+
                           "Questions_Master.Answer6, Questions_Master.Answer7, Questions_Master.Answer8, Questions_Master.Answer9, "+
                           "Questions_Master.Answer10, Questions_Master.Answer11, Questions_Master.Answer12, Questions_Master.Answer13, "+
                           "Questions_Master.Answer14, Questions_Master.Answer15, Questions_Master.Answer16, Questions_Master.Answer17, "+
                           "Questions_Master.Answer18, Questions_Master.Qname_HasImage, Questions_Master.Correct_Option, Questions_Master.Q_type, "+
                           "User_Exam_Dtl.Option1, User_Exam_Dtl.Option2, User_Exam_Dtl.Option3, User_Exam_Dtl.Option4, User_Exam_Dtl.Option5, "+
                           "User_Exam_Dtl.Option6, User_Exam_Dtl.Option7, User_Exam_Dtl.Option8, User_Exam_Dtl.Option9, User_Exam_Dtl.Option10, "+
                           "User_Exam_Dtl.Option11, User_Exam_Dtl.Option12, User_Exam_Dtl.Option13, User_Exam_Dtl.Option14, User_Exam_Dtl.Option15, "+
                           "User_Exam_Dtl.Option16, User_Exam_Dtl.Option17, User_Exam_Dtl.Option18, User_Exam_Dtl.Essay_Answer FROM (((Exam_Master INNER "+
                           "JOIN Test_Master ON Exam_Master.Exam_Code = Test_Master.Exam_code) INNER JOIN Subject_Master ON Exam_Master.Exam_Code = "+
                           "Subject_Master.Exam_code) INNER JOIN Questions_Master ON (Exam_Master.Exam_Code = Questions_Master.Exam_code) AND "+
                           "(Test_Master.Test_code = Questions_Master.Test_code) AND (Test_Master.Exam_code = Questions_Master.Exam_code) AND "+
                           "(Subject_Master.Exam_code = Questions_Master.Exam_code) AND (Subject_Master.Sub_code = Questions_Master.Sub_code)) "+
                           "INNER JOIN User_Exam_Dtl ON (Exam_Master.Exam_Code = User_Exam_Dtl.Exam_code) AND (Questions_Master.Q_No = User_Exam_Dtl.Q_No) "+
                           "AND (Questions_Master.Test_code = User_Exam_Dtl.Test_code) AND (Questions_Master.Sub_code = User_Exam_Dtl.Sub_code) AND "+
                           "(Questions_Master.Exam_code = User_Exam_Dtl.Exam_code) WHERE (((Exam_Master.Exam_Code)='"+ ExamCode +"') AND "+
                           "((Test_Master.Test_code)='"+ TestCode +"') AND ((User_Exam_Dtl.User_ID)='"+ class_Application.user_id +"'));";

                init_datatable = ob.fill_data_table(s);


                var query = from p in init_datatable.AsEnumerable()
                            group p by new
                            {
                                SubjectCode = p.Field<string>("Sub_code"),
                                SubjectName = p.Field<string>("Sub_Name"),
                            } into grp
                            select new
                            {
                                SubjectCode = grp.Key.SubjectCode,
                                SubjectName = grp.Key.SubjectName,
                             
                            };

                Subject = new DataTable("Subject");
                Subject.Columns.Add("SubjectCode", typeof(string));
                Subject.Columns.Add("SubjectName", typeof(string));
                foreach (var grp in query)
                {
                    DataRow dr = Subject.NewRow();
                    dr["SubjectCode"] = grp.SubjectCode;
                    dr["SubjectName"] = grp.SubjectName;
                    Subject.Rows.Add(dr);
                }

                lbl_exam.Text = ExamName;
                lbl_test.Text = TestName;
                string sub_code = Convert.ToString(Subject.Rows[count]["SubjectCode"]);
                bind_data_for_review(sub_code);

            }
        }